Question

I am trying to write an expression to count the number of requests within a specific month from a year's worth of data.

I have tried:

=sum(iif((datepart("M",Fields!RequestDate.Value)) = (datepart("m",Now(-1))),1,0)) 

and many more different versions. Can someone point me in the right direction?

Was it helpful?

Solution

It seems in your example you're counting events from last month? I'm not sure what Now(-1) is trying to calculate in your example.

Anyway, this example worked for me in identifying counts from last month:

=Sum(IIf(DatePart("m", Fields!RequestDate.Value) = DatePart("m", DateAdd("m", -1, Now()))
    , 1
    , 0))

You can update the DateAdd("m", -1, Now()) part of the expression to set the month you want to update against.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top