Johann
Johann

Reputation: 1

Count function for two variables in SQL Report Builder 2.0

I would like to display a simple COUNT for a variable but with a conditon that another variable is filtered. This is how I could imagine the function, but I can't make it work in Report Builder. I am not using a graph/table which is why I can't use for example the Tablix filter function. I simply want to display the value in a textbox, so I only can only define the function. Should look somehow like this:

= COUNT(Fields!<var1>) IF (Fields!<var2> = "xyz")

Thankful for any suggestions!!

Upvotes: 0

Views: 383

Answers (2)

Matt Jones MSFT
Matt Jones MSFT

Reputation: 59

Have you tried:

    =COUNT( IIF( Fields!VarA.Value=5, IIF(Fields!VarB.Value=6, 1, 0), 0)

This will check if VarA = 5, then if VarB = 6, will count 1, else 0.

Upvotes: 0

M.Ali
M.Ali

Reputation: 69554

You would need to use Iif function along with count something like this...

=COUNT(IIF(Fields!FieldName.Value="xyz",1,0))

or

=COUNT(IIF(Fields!FieldName.Value="xyz",1,Nothing))

Upvotes: 1

Related Questions