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

Nickso

I have a query that returns Sales representatives number, Category, Sales.

The result is something like this:

enter image description here

There are 4 categories called G1,G2,G3,G4.

As you can see the Sales representative 11 sold 10 each category (Yellow rows). But Representative 12 sold only for category G3 and G4.

The idea is to show in the report all the categories and populate with 0 all those who did not sell on that particular category.

It must be grouped by Sales Representative so if you make a tablix grouping by Sales Representatives you will have something like this:

enter image description here

But you want something like this:

enter image description here

Is there any expression I could use to add these?

What I did so far is to create a group, that group of course are my Sales representatives and combine the cells for that Column and created a Row group for each category, is something like this:

enter image description here

But if you execute that report it will repeat all categories G1,G2... For each time that category exists for that particular Sales Representative.

Another problem is, how can you evaluate The hardcoded category in your report if it does not exist in your datasource you cant make Iif("G1" = Fields!Category.Value,Fields!Sales.Value,"0") as you are not comparing G1 with Null or IsNothing, you are comparing what it exists.

alejandro zuleta

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:

enter image description here

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

enter image description here

Another field is set to the below expression:

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

I've added a tablix with the following data arrangement

enter image description here

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.

enter image description here

Let me know if this was helpful.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SSRS Report Data Source for Query with Multiple Databases

From Dev

SSRS - Calendar Report Query

From Dev

Adding subtotals to SSRS report tablix

From Dev

adding date columns in SSRS Report

From Dev

From C# when calling SSRS report only main report shows data sub report giving error

From Dev

SSRS: Using temp tables in the SSRS report query

From Dev

MDX left in SSRS report query

From Dev

SSRS report parameters not part of query

From Dev

Displaying Dataset Query and Report Expressions in SSRS Report

From Dev

SSRS Adding a Table to Header/Footer of Report

From Dev

SSRS report with multiple data sources

From Dev

SSRS not displaying data but displays data when query runned in tsql

From Dev

Jaspersoft Studio adding uuid when data adapter is changed for report

From Dev

SSRS Report/SQL Server: Display distinct column values even if there is no data on particular dates

From Dev

For an SSRS report with multi select parameters, when I 'select all' for a parameter having a long list of values, report throws a javascript error

From Dev

Pass query string parameter to SSRS report

From Dev

SSRS: Set report parameters as part of query

From Dev

Pass query string parameter to SSRS report

From Dev

SSRS Report Query - BETWEEN within WHERE clause

From Dev

SSRS Pull Variables Or Values From Sub Report Into Main Report

From Dev

JasperReports - JSON Data Report Shows Null Values when run in Java

From Dev

Linq Query for Adding Values

From Dev

Tablix border inconsistent when zooming into ssrs report

From Dev

trigger SSRS report when finishing a SSIS job

From Dev

SSRS Report Works when the Parameter uses the "=" Operator but not "IN"

From Dev

SSRS When uploading report owner name is wrong

From Dev

Show message "NO DATA FOUND" in SSRS report

From Dev

Display ssrs report data vertically in columns

From Dev

prevention of data truncation or growth in SSRS report

Related Related

  1. 1

    SSRS Report Data Source for Query with Multiple Databases

  2. 2

    SSRS - Calendar Report Query

  3. 3

    Adding subtotals to SSRS report tablix

  4. 4

    adding date columns in SSRS Report

  5. 5

    From C# when calling SSRS report only main report shows data sub report giving error

  6. 6

    SSRS: Using temp tables in the SSRS report query

  7. 7

    MDX left in SSRS report query

  8. 8

    SSRS report parameters not part of query

  9. 9

    Displaying Dataset Query and Report Expressions in SSRS Report

  10. 10

    SSRS Adding a Table to Header/Footer of Report

  11. 11

    SSRS report with multiple data sources

  12. 12

    SSRS not displaying data but displays data when query runned in tsql

  13. 13

    Jaspersoft Studio adding uuid when data adapter is changed for report

  14. 14

    SSRS Report/SQL Server: Display distinct column values even if there is no data on particular dates

  15. 15

    For an SSRS report with multi select parameters, when I 'select all' for a parameter having a long list of values, report throws a javascript error

  16. 16

    Pass query string parameter to SSRS report

  17. 17

    SSRS: Set report parameters as part of query

  18. 18

    Pass query string parameter to SSRS report

  19. 19

    SSRS Report Query - BETWEEN within WHERE clause

  20. 20

    SSRS Pull Variables Or Values From Sub Report Into Main Report

  21. 21

    JasperReports - JSON Data Report Shows Null Values when run in Java

  22. 22

    Linq Query for Adding Values

  23. 23

    Tablix border inconsistent when zooming into ssrs report

  24. 24

    trigger SSRS report when finishing a SSIS job

  25. 25

    SSRS Report Works when the Parameter uses the "=" Operator but not "IN"

  26. 26

    SSRS When uploading report owner name is wrong

  27. 27

    Show message "NO DATA FOUND" in SSRS report

  28. 28

    Display ssrs report data vertically in columns

  29. 29

    prevention of data truncation or growth in SSRS report

HotTag

Archive