Adding values to a Report when there is no Data in query SSRS

随声附和 提交于 2019-12-02 02:00:29

I think you can achieve this smoothly using T-SQL at query level. I don't know why you don't use the simplest way to apply this kind of logic since in T-SQL you can use almost every logic.

However I like this kind of challenges so I come with this possible solution.

This is my sample dataset:

In SSRS dataset (not in T-SQL) I've added a calculated field called Another

Another field is set to the below expression:

=Fields!SalesRep.Value & "-" & Fields!Category.Value

I've added a tablix with the following data arrangement

As I mentioned before category field is hardcoded, the right column with Sales is set to this expression:

=iif(IsNothing(lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7")),0,
lookup(Fields!SalesRep.Value & "-" & ReportItems!Textbox62.Value,
Fields!Another.Value,Fields!Sales.Value,"DataSet7"))

Note: ReportItems!Textbox62.Value corresponds to textbox where G1 was hardcoded. You have to replace the textbox reference for the corresponding in your tablix for every category.

It will preview the below tablix.

Let me know if this was helpful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!