Search code examples
visual-studio-2010reporting-servicesssrs-tablix

Rdlc - calculate sum of columns and display total in a single cell conditionally


Here is the scenario, I have a dataset with fields Category, Country and NUM_SCHOOLS. i created a column to populate the country names as columns. I created a row group to calculate the row column. In my current report Column headers(Country) Country1, Country2....so on are displayed and row headers(Category) A, B, C and D are displayed. Values is [Sum(Fields!NUM_SCHOOLS.Value)]. Everything is correctly displayed I used pipe(|) symbol as the separator between the cells, i am not allowed to post images, i tried my best to explain. Please let me know if you need any information to help me.

Current Report:

      Country1     Country2

A 10 | 12
B 5 | 6
C 5 | 7
D 11 | 15

Required report:

      Country1     Country2

A 10 | 12
B 5 | 6
C 5 | 7
D 26

Only for D column, i want to add the numbers and display the value as a single value. (11+15=26), for other categories it should display in different country buckets.

Please help me out. Thanks in Advance!


Solution

  • Sorry to be the bearer of bad news, but I don't think that you can merge columns across column groups.

    I think that the best option is to remove your column grouping and manually add in 7 columns for your receipt frequencies. You'd have to use a Sum with an Iif to get your values correctly, for instance in the far left column, something like:

    =Sum(iif(fields!RECIEPT_FREQUENCY.Value="ANNUAL" ,Fields!val.Value,0))
    

    then you could add a merged cell underneath and add the following expression

    =Sum(iif(Fields!PART_COUNT.Value="D", Fields!val.Value,0),"DataSetName")
    

    Alternatively, you could leave it as it is and enter the following expression in a total row at the bottom of your matrix. But you would have to do something expression based for the cell borders to give the illusion of it being merged..

    =Sum(iif(Fields!PART_COUNT.Value="D" 
    And fields!RECIEPT_FREQUENCY.Value="BI-WEEKLY" 
    ,Fields!val.Value,0),"DataSetName")