Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a variable for the previous month that works every other month but for this month it's returning 202300 and I want it to return 202212.
My current variable is:
=max((Cal.YearMonth)-1)
Is there a better way to do this?
Assuming you have a standard calendar with dates try
=Date(addmonths(max(Date) ,- 1)),'YYYYMM')
Assuming you have a standard calendar with dates try
=Date(addmonths(max(Date) ,- 1)),'YYYYMM')
HI, maybe try this.
//Create some data :
SET DateFormat='D/M/YYYY';
Cal.YearMonth:
Load * INLINE [
Cal.YearMonth
202211
202212
202301
];
Load
Cal.YearMonth,
monthname(MAKEDATE(LEFT(Cal.YearMonth,4), RIGHT(Cal.YearMonth,2))) as Date
Resident Cal.YearMonth;
DROP TABLE Cal.YearMonth;
exit script;
// Then in the variable editor create my variable
vPreviousYearMonth = monthname(addmonths(Date, -1))
// and then use it, selecting a period.
This worked! Thank you