1

I am trying to use parameters within my expression because I won't be able to use the parameters in the dataset, I am trying to do a simple expression but I am struggling to figure out what I am doing wrong, here is what I want to achieve:

I want to count the rows when the Month(Date) = @Month.

What I have so far:

=IIf(Month(Fields!Date_Logged_SQL.Value) = Parameters!rpMonth.Value,CountRows(),Nothing)

My results return no values which I am assuming must be something to do with my false return.

1 Answer 1

1

You need to use the IIf expression as part of a larger aggregation expression, something like:

=Sum(IIf(Month(Fields!Date_Logged_SQL.Value) = Parameters!rpMonth.Value,1,0))

For each row in Scope, this will either add 1 or 0 to the running total of rows that fulfill your check, the end result being the total of rows that match the month.

Depending on where you're adding the expression, you may need to add a Scope parameter to get the correct result, e.g. something like:

=Sum(IIf(Month(Fields!Date_Logged_SQL.Value) = Parameters!rpMonth.Value,1,0), "DataSet1")
3
  • Thanks a lot!, I had a feeling it was something small but you just saved me a lot of time :)
    – Jack Ocean
    Aug 20, 2014 at 9:53
  • If I wanted to add another parameter to my expression would I just do something like this: =Sum(IIf(Month(Fields!Date_Logged_SQL.Value) = Parameters!rpMonth.Value & Year(Fields!Date_Logged_SQL.Value) = Parameters!rpYear.Value,1,0)) When I do this it just returns all values of 0, sorry if this is obvious, I'm pretty new to SSRS.
    – Jack Ocean
    Aug 20, 2014 at 9:58
  • 1
    Yep, it's just an expression so you can add as many conditions as you like as long as SSRS can parse it. The only thing to note is that SSRS uses And as a boolean operator, not &. Aug 20, 2014 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.