Visual studio Case Statement in Expression Builder

Dom 751 Reputation points
2023-05-25T20:09:25.7233333+00:00

Have an rdl where I filter the report based on a parameter selection. I filter the data in the report in the Tablix. I also have a placeholder in the report header where I display a calculation. However, I want to also filter this calculation based on the parameter selection. I'm trying to use a case statement, but can't get the syntax right in expression builder. Advice?

have 
=Sum(Fields!CodeInstances.Value, "CodeReport")
want
=case when [@selection] = [datavalue] then 
Sum(Fields!CodeInstances.Value, "CodeReport") else NULL end
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,796 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AniyaTang-MSFT 12,311 Reputation points Microsoft Vendor
    2023-05-26T02:05:21.9033333+00:00

    Hi @Dom

    I did a simple test, just using Sum(Fields!xxx.Value, "DataSet") can filter out unselected data based on parameters.

    But if your report is not possible, you can combine Sum with the IIF function. I set the Month as a parameter in the test and then use an expression like below. The expression means that when the parameter Month is the same as the value of the field Month, the value will be recorded in Sum, otherwise it will be counted as 0.

    1

    Preview:

    2

    Best regards,

    Aniya