Forum Discussion
Creating a Prior Month Column in Power BI
- 7 years ago
Hi,
I'm sure there are a few solutions to this.
If we use DATEADD in a measure like
Prev Month Sale = CALCULATE(SUM(Table1[Value]), DATEADD(Table1[Month],-1,MONTH))The measure will return some correct values but some blanks.DATEADD won't always work in this example because the dates it works out have to exist in the table. Let's take one case from the table - '30 sept 2018', subtract 1 month from this and we get '30 Aug 2018' (and that date doesn't exist in the table)
What we need is a measure like this :
Prev Month Sale 2 = CALCULATE(SUM(Table1[Value]), PREVIOUSMONTH(Table1[Month]))
Hello BobiRussell
Thanks for the response. I have both of the values in same table. And "Value" is not a measure I calculated. It is part of the original table.
Oka V-Power,
So this is what I've used
- v-power7 years agoFrequent Visitor
Thank you. I tried to search for the "value" field on my table1 using the calculate but it only lists the calculated measures I had created. Existing fields in the table dont show up for some reason.
- HotChilli7 years agoCommunity Champion
Hi,
I'm sure there are a few solutions to this.
If we use DATEADD in a measure like
Prev Month Sale = CALCULATE(SUM(Table1[Value]), DATEADD(Table1[Month],-1,MONTH))The measure will return some correct values but some blanks.DATEADD won't always work in this example because the dates it works out have to exist in the table. Let's take one case from the table - '30 sept 2018', subtract 1 month from this and we get '30 Aug 2018' (and that date doesn't exist in the table)
What we need is a measure like this :
Prev Month Sale 2 = CALCULATE(SUM(Table1[Value]), PREVIOUSMONTH(Table1[Month]))- v-power7 years agoFrequent Visitor
Thank you so much. This worked.