Forum Discussion
Get Value for Previous Month
Hi there,
Im trying to calculate a MOM%, but I can't get the measure to calculate the Current Month or the Previous Month Value.
I've tried:
=Calculate(sum(sales),PreviousMonth(Date))
=Calculate(sum(sales),DateAdd(date,-1,Month))
=Var MaxMonth = Max(Date[Month])
Var MaxYear = Max(Date[Year])
Return
Calculate(sum(sales),Month(date)=MaxMonth-1,Year(date)=MaxYear))
I built this measure on top of an already working one with the formula =Calculate(sum(sales),PreviousMonth(Date))
but when I try it with these values, the result I get is the Total of all period.
*Edit* - I had to remove the printscreen due to NDA.
- Anonymous5 years ago
That didn't work.
However, what worked was, adding to each of my variables a filter for the previous month and same year and then sum them all
2 Replies
- amitchandak
Super User
Anonymous , Previous month give complete last month data,
So the options you have
Calculate(sum(Sales[sales]),DateAdd(date,-1,Month))
or
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
And you have use date and related field only from date table.
Date table should be marked as date table
refer if needed
Why Time Intelligence Fails - Power bi 5 Savior Steps for TI: https://youtu.be/OBf0rjpp5Hw
- AnonymousNot applicable
That didn't work.
However, what worked was, adding to each of my variables a filter for the previous month and same year and then sum them all