Search code examples
reporting-servicesssrs-tablixreportbuilder3.0

SSRS How to change grouping and columns by using parameter


My goul would be to implement a parameter @Grouping with two possibilities: Vendor / Product
With the parameter I need to change the grouping of my data, not only in calculateing the data but also in the sorting of the columns:
enter image description here

Do I need to use executable SQL and calculate everything outside the report and use dynamic columns like
"Column1=Vendor, Column2=Product if Parameter=Vendor" to place them in the Tablix?

Or is it possible to manage all this in the report using grouping properties? If so, unfortunately I am not very familiar with the grouping expressins and would thank you for detailed answers.


Solution

  • I was able to use the parameter :)
    With Vendor beeing my default first Group, I made a Right-Click on the Group in the GroupingBox. In the General section I added an Expression on the "Group on":

    =IIf(Parameters!Grouping.Value = "Vendor", Fields!Vendor.Value, Fields!Product.Value)
    


    On the child group Product I did the opposit:

    =IIf(Parameters!Grouping.Value = "Vendor", Fields!Product.Value, Fields!Vendor.Value)
    


    The same expressions I used in the Sorting section. And also in the fields on the Tablix.
    Thank you.