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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top