Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
Need help working with Time Intelligence Functions, I'm working with Sales data and trying to compare period over period sales, so to compare to previous month I tried creating a column using the following :
PriorPeriodSales$ = CALCULATE(sum('Sales'[SalesAmount]),PARALLELPERIOD('Sales'[Date],-1,MONTH))
OR
PriorPeriodSales$ = CALCULATE(sum('Sales'[SalesAmount]),PREVIOUSMONTH('Calendar'[Date]))
in both cases I get a column with no values(no error, just blank), I'm not sure what am I missing. The information on my original table is at a daily level, not sure if that should be a problem?? Please help!
Thanks!
My solution.
Had the same problem - previousmonth returned blanks. Formula syntax was correct but it didnt work. My data was linked to created in Excel calendar ( I'm sure it was perfect, without missing days) but "previousmonth" still didnt work.
Solved it by creating new calendar table inside Power Bi using "Calendar" formula. To make it shorter I've cut it at min and max days in my sales table.
Calendar = CALENDAR( date(YEAR( Min(Sales[Date]) );1;1); date(YEAR( MAX(Sales[Date]) );12;31))
Despite that this formula gives 100% the same calendar I created in Excel "previousmonth" started to work perfectly once I linked my data to this new calendar.
Special thx to the guy who published this video of how to create this Calendar table in Power BI!
Hi @aavilap,
Works good for me.
Make sure :
- your date attribute type is "date" or "datetime"
- all relationships on your date table are marked as single direction
I assume you are filtering on the date/month in 'Calendar'[Date] table in which case you need to include ALL('Calendar') as a filter in your calculation.
E.g.
PriorPeriodSales$ = CALCULATE(SUM('Sales'[SalesAmount]), PREVIOUSMONTH('Calendar'[Date]), ALL('Calendar'))
I am guessing that your issue has to do with the comment from the documentation:
"Returns a table that contains a column of all dates from the previous month, based on the first date in the dates column, in the current context."
It is relatively likely that the first date in your current context is not what you desire it to be.
User | Count |
---|---|
125 | |
106 | |
99 | |
63 | |
60 |
User | Count |
---|---|
135 | |
116 | |
101 | |
71 | |
61 |