Forum Discussion
parallelperiod vs previousmonth vs adddate
Hi All,
I found a solution to this already but am confused about why it is so.
I need to find a simple previous month lookup.
Prev. Month Sales = CALCULATE(SUM([Total Sales]),DATEADD([Date]),-1,MONTH))
Prev. Month Sales = CALCULATE(SUM([Total Sales]),PREVIOUSMONTH([Date]))
Prev. Month Sales = CALCULATE(SUM([Total Sales]),PARALLELPERIOD([Date],-1,MONTH))
The first 2 measures return null. The last one gives me the right answer. Why? Aren't these all the same?
Thanks for your thoughts.
Hi SHDJason,
In DAX, PARALLELPERIOD always returns full periods at the given granularity level instead of the partial periods that DATEADD returns. So please check if the dates in date column are continuous. If the dates in the current context do not form a contiguous interval, the function returns an error.
Reference:
PARALLELPERIOD Function (DAX)Regards,
14 Replies
- SeanCommunity Champion
All 3 should be working. Do you have a Calendar Table though?
EDIT: Use Matt's link to create if you don't have - explains step by step - how to create
http://www.powerpivotpro.com/2015/02/create-a-custom-calendar-in-power-query/
- SHDJasonAdvocate II
Yes i do have a calendar table. I tried using that and the date column in the data table. Both worked, but only for parallelperiod.
Is it possible that PowerBI caches the data and then does not always refresh? Sometimes, if I create a formula incorrectly then correct it, the new calculated values do not load. But if I refresh the dataset, they do load. I'm wondering if it is a cache issue.
- v-sihou-msftMicrosoft Employee
Hi SHDJason,
In DAX, PARALLELPERIOD always returns full periods at the given granularity level instead of the partial periods that DATEADD returns. So please check if the dates in date column are continuous. If the dates in the current context do not form a contiguous interval, the function returns an error.
Reference:
PARALLELPERIOD Function (DAX)Regards,
- SamiTiFrequent Visitor
Hi
All measures above are working well.
However am getting BLANK when i try to view this by stores/product/category.
Measure --> PPREVMONTH = CALCULATE([Volume],PREVIOUSMONTH('dim MS Cal'[Date]))
Thanks for your help or advise.
Thanks
Sami