I have a dataset called 'dsAllStuTargetData' - i'm trying to count the number of the 'A' values that appear in the column 'Target'.
I'm doing this using a textbox with an expression, I can count the total number of values using the following:
=Count(Fields!Target.Value, "dsAllStuTargetData")
However when I try to count where the value equals 'A' it doesn't work.
=Count(IIF(Fields!Target.Value, "dsAllStuTargetData")="A",1,0)
Using IIF Function in SSRS We are going to add a new field to the report data set to determine if the Order Year is the Max or Current Year. As shown below, the dataset properties window is opened, and the Fields tab is selected. After clicking Add, at the bottom of the list a new field is added.
Add Total and Subtotal to SSRS Report: Approach 2 Next, we will add the Total at the Education level. For this, goto Yearly Income Total Column (Details Total Row -> Yearly Income Column) and right-click on it and select Add Total option. Let me open the Preview tab to check the Totals at the Education level.
Count Function in SSRS falls under Report Builder Functions which basically returns a count of non-null values specified by the expression in the given scope. If statement in SSRS allows a developer to control the program flow and it's outputs. It is a decision function that can be reached through expression.
In the tablix data region body area, right-click the cell where you want to add the total. The cell must contain a numeric field. Point to Add Total, and then click Row or Column. A new row or column outside the current group is added to the data region, with a default total for the field in the cell you clicked.
For this case you need a Sum
, not a Count
, i.e. something like:
=Sum(IIf(Fields!Target.Value = "A", 1, 0), "dsAllStuTargetData")
Count
will just count the number of rows; the IIf
doesn't do anything there - something like CountDistinct
can be affected in certain cases but this will not work here.
However, Sum
will take the total of all rows which meet the IIf
condition, i.e. the total of all 1
values in the DataSet, which is what you're after.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With