on 04-07-2015 7:06 AM
Hi,
I have two seperate dimensions for year and month. I'm calculating a measure through a prompt for the current month.
I've used the where clause part for the current month like:
Count(Measure)
*where clause*
Table.Year = @Select(Filters\Year) AND
Table.Month = @Select(Filters\Month)
My question is, how can I derive the previous month in a second measure?
Thanks!
Steve,
I wouldn't recommend using where clauses - they will cancel each other out as they both get added to the SQL so your pseudo will end up as something like:
SELECT this, that, theother, count measures
FROM table1, table2
WHERE
transactionmonth = current month
AND
transactionmonth = previous month
The best practice is to use CASE statements to create your two objects as:
count(CASE when month = previous month THEN countitem END)
count(CASE when month = current month THEN countitem END)
Obviously using whatever logic you need to identify the months.
Does that make sense?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Put this is your where clause
Previous Month :
to_char(ADD_MONTHS (TO_DATE (concat( to_char(( current_date ),'YYYYMM') ,'01'), 'YYYYMMDD'), -1),'MMYYYY')
This for current date it will give you 032015 as current month is april 2015 , Replace current date with your date object if you want it for some other date.
Thanks,
Haseeb
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Steve,
You can simple use add_months(variable,-1) for getting previous year.
Thanks,
Swapnil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.