I would create a filter in the universe using a prompt and a case statement. You'll also need to add some data dimensions to your universe to get this to work.
I add class called "Date" with a set of Date dimensions to all of our universes with things like Today, Yesterday, This Month, This Year, First Day of This Month, Last Month, Last Year etc. The "select" for these measures needs to use the date handling routines from the database. We use Oracle, so I use stuff like this:
Yesterday = sysdate
This Month = To_Number(To_Char(sysdate, 'MM'))
Last Month = decode(@Select(Dates\This Month), 1, 12, (@Select(Dates\This Month) - 1))
I know that the syntax in SQL Server is different, but I'm not sure exactly what it is.
You'll also want to create a measure for the prompt. Something like this:
@Prompt('Select Report Type', 'A',
('Today', 'This Week', 'This Month', 'Custom Period'), Mono, Constarined)
For the filter, you'll do something like this (here again, I'm not absolutely certain of the syntax for a Case statement in SQL Server, so I'm using Oracle...):
Code:
Case @Select(Class\Report Type Prompt)
when 'Today' then
@Select(Class\Date Measure) = @Select(Dates\Today)
when 'This Month' then
To_Number(To_char(@Select(Class\Date Measure), 'MM)) = @Select(Dates\This Month) and To_Number(To_Char(@Select(Class\Date Measure), 'yyyy')) = @Select(Dates\This Year)
when 'This Week' then
<...I'll leave this one for you to determine...>
Else
@Select(Class\Date Measure) between @Prompt('Enter Start Date', 'D', 'Class\Date Measure', Mono, Free) and @Prompt('Enter End Date', 'D', 'Class\Date Measure', Mono, Free)
end
You'll have to tweak all of this for your specific situation, but hopefully it points you in the right direction.
-Dell
A computer only does what you actually told it to do - not what you
thought you told it to do.