Forum Discussion
PreviousMonth not returning any data
Hi.
I'm trying to setup a simple table using the PreviousMonth function.
The two measures are setup as follows:
- Risk Score Calc = average(Defender[Risk Score - %Total])
- Risk Score Calc Prev = calculate([Risk Score Calc],PREVIOUSMONTH(Defender[Extract Month]))
Power BI is built so that it best functions when models are in a star schema. Time intelligence functions require this, specifically a date dimension table. You need to create a date dimension table, establish a relationship to your fact table, and adjust your DAX measure to utilize the date table.
4 Replies
- CoreyPSolution Sage
Power BI is built so that it best functions when models are in a star schema. Time intelligence functions require this, specifically a date dimension table. You need to create a date dimension table, establish a relationship to your fact table, and adjust your DAX measure to utilize the date table.
- marktaitHelper I
Hi Corey - thank you for the suggestion.
I created a date table, which lists all days (monthly), including all dates in my "Defender (facts)" table:
I linked them as follows:
..and I changed the calculation to:
Risk Score Calc Prev = calculate([Risk Score Calc],PREVIOUSMONTH(DateListTable[Dates]))However, the table still remains the same, with the Prev column unpopulated.Thanks again for any help,Mark- CoreyPSolution Sage
Date tables need to have a contiguous series of dates. ( Each row is a day, not a month. ) Use the function CALENDAR with FIRSTDATE and LAST DATE to create a dynamic date table with a contiguous set of dates.
- marktaitHelper I
Thank you very much - that solved the issue.