Forum Discussion
Anonymous
7 years agoNot applicable
How to get previous month sales using dax
I have multiple years and months data in this how to get recent previous month total sales .How system identify previous month on multiple years .
My requirment is once open dashboard I want Previous month total sales in card visualization . I will not select perticular date , automatically sytem will undersatand what is current month and current year based on it will give current previous month total sales .
- Anonymous7 years ago
Hi Anonymous
Please check
Cheers
CheenuSing
3 Replies
- AnonymousNot applicable
Hi Anonymous
Please check
Cheers
CheenuSing
- AnonymousNot applicable
Thanks it's useful based on that implemented getting correct result .
- Reddy5833
Helper II
Previous Month Sales =
VarMonthNumber = IF( MONTH(TODAY())-1 = 0, 12,MONTH(TODAY())-1 )VarYearNumber = IF(MonthNumber = 12, YEAR(TODAY()) -1, YEAR(TODAY()))ReturnIF(ISBLANK(CALCULATE(Sum(Table[sales]), FILTER (ALL('Date'), 'Date'[cal_year] = YearNumber && 'Date'[cal_month] = MonthNumber))),0,CALCULATE(Sum(Table[sales]), FILTER (ALL('Date'),'Date'[cal_year] = YearNumber && 'Date'[cal_month] = MonthNumber)))