Sum column values if parameter is entered

  • Hi, everyone, I'm also new to Reporting Services, and have a question.

    My report user wants to be able to choose between two options in the report.

    First one should show "elementary" result, for example:

    SELECT SalesAmt, UnitName

    FROM TableName

    which returns following result:

    100 A1

    200 A1

    300 B1

    400 B1

    Second one should be like this - showing sum per unit:

    SELECT SUM(SalesAmt), UnitName

    FROM TableName

    GROUP BY UnitName

    which returns:

    300 A1

    700 B1

    I would like to ask you is there another way to do this besides using stored procedure in the report?

    Thank you!

  • Your post's been cut off but I'll take a guess anyways.

    What you can do is create the column and put the sum in there.

    Then in the visibility of the column, put an IIF expression =iif(parameters!paramname.value = "whatever", TRUE, FALSE)

    You can guess the wizard to type the exact parameter syntax by going through the list of candidates in the GUI.

  • You do 2 reports.

    That's why in the end of the project it's not rare to see 100 different sales reports.

  • Thank you!

    Sorry for cut off post, I suppose I was editing the post itself in the same time you tried to see it.

    I'll try with the visibility option.

    Since my user does not want to see anything but sum and one unit to be shown - if he chooses the second (sum) option, I'll include visibility for initial results also >> If Parameter = "something" - show unit and sum, and don't show all SalesAmt per UnitName. And, accordingly, If Parameter <> "something" - show all SalesAmt per Unit, and don't show calculated sum field.

    Best,

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply