Search code examples
reporting-servicesssrs-2008ssrs-2008-r2

How to assign a value dynamically for a group filter in ssrs 2008


I have a table on SSRS 2008 like:

         [QuarterCount]
GROUP    Volume
[Group]  [sum(Volume)]

QuarterCount is a syntax like: -Q, where is 1 if the current month is January to March, 2 if the current month is April to July and so on.

The "Volume" column has a group, by QuarterCount, and this column group has a filter like:

enter image description here

So basically this column will show the info belonging to this quarter and the same quarter last year. This table is working well like that, but what I need to do is to make the values here dynamic. I mean, I should not enter the values manually, the report should understand it based on today's date. So I need something like that:

=YEAR(Now()) & "-Q" & IF(MONTH(Now())>0 and MONTH(Now()) <= 3 then "1")
                      IF(MONTH(Now())>3 and MONTH(Now()) <= 6 then "2")
                      IF(MONTH(Now())>6 and MONTH(Now()) <= 9 then "3")
                      IF(MONTH(Now())>9 and MONTH(Now()) <= 12 then "4")

I could not find the correct way to provide it. Any help I would really appreciate. Thanks!


Solution

  • Try using this expression:

    =Split(YEAR(Now()) & "-Q" & 
    Switch(MONTH(Now())<=3,1,
    MONTH(Now())<=6,2,
    MONTH(Now())<=9,3,
    MONTH(Now())<=12,4
    ) & "," &
    YEAR(Now())-1 & "-Q" & 
    Switch(MONTH(Now())<=3,1,
    MONTH(Now())<=6,2,
    MONTH(Now())<=9,3,
    MONTH(Now())<=12,4
    ),",")
    

    Let me know if this helps.