Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I need help...
I want to calculate current month and previous month. Eg. Suppose all data is selected then values show current month(May) data and previous month(April) data, and if user click on April month filter then variable need to show current month as April and previous month as March. Hope you understand the requirement.
Regards, Abhijit
Max(month) respectively Max(month) - 1 will return the current and the prevoius month regarding to the selections.
- Marcus
Use two expression one is for current month and previous month.
example: expression for current month: =sum({<Month={"=$(=Max(Month))"}>}Sales)
expression for previous month: =sum({<Month={"=$(=Max(Month)-1)"}>}Sales)
For previous month you can use:
Sum({$<date={'=MonthsEnd(1,(date),-1)'}, Sales)
You can create variables
Curr: vCurrMon
Prev : vPrevMon
vCurrMon = =month(date(Month,'MMM'))
vPrevMon = date(AddMonths((date(Month,'MMM')),-1,MMM'),'MMM')
thanks
Thanks Marcus,
previous month formula is not working properly when we select January month.
what should i do if i want to show current month when we are showing all data (there is nothing filtered).
Regards,
Abhijit
Yes this is right by turn of the year it won't work (so simply). For this you could use a MonthCounter within the Master-Calendar: Re: Howto make a variable to calculate quarters regarding year changes?
Another possibility is the use of addmonths() maybe in this way:
month(max(Date)) // current month
month(addmonths(max(Date), - 1)) // previous month
- Marcus
Current month :sum({<Month={"=$(=Max(Month))"}>}Sales)
Previous month :sum({$<Month={"=$(=Max(Month)-1)"}>}Sales)
Try this.
Current Year = Year(Max(Date))
Current Month = month(Max(Date))
Previous Year = =Year(addmonths(max(Date) ,- 1))
Previous Month = Month(addmonths(max(Date) ,- 1))
Current_Month={"$(=DATE(FLOOR(MonthStart(max(Date))),'MMM'))"}
Last_Month={"$(=DATE(FLOOR(MonthStart(AddMonths(max(Date),-1))),'MMM'))"}