Forum Discussion
Nesquick91
6 years agoNew Member
Last month calculation
Hello,
I'm have being learning Power BI for last the week using online platforms. I'm on the practising stage doing models and visualisations.
I'm on my third report but stuck on the following and cannot move on.
I have several tables similar to this one:
First I calculate the total value by doing a sum of all values of all columns in all tables and this went well.
(Total Expenses = Sum(table1[value]) + sum(table2[value])...).
Second, I tried to get the last month total value and didn´t work so well.
Last Month total € spent = CALCULATE([Total Expenses],PREVIOUSMONTH('Calendar'[Date]))
I tried also with the Filter() function or PARALLELPERIOD() and DATEADD() in different ways and forms. Here some other functions I used:
Last Month total € spent = IF(MAX('Calendar'[Start of Month].[Month])<TODAY(),CALCULATE([T
otal Expenses]),DATEADD('Calendar'[Start of Month].[Month],-1,MONTH))
otal Expenses]),DATEADD('Calendar'[Start of Month].[Month],-1,MONTH))
Last Month total € spent = IF(MAX('Calendar'[Date])<TODAY(),CALCULATE([Total Expenses]),DATEADD('Calendar'[Date],-1,MONTH)).
This is the table I get using the Total Expenses function:
This is the table I get using the Last Month total € spent function:
This is the result that I want:
Can anybody help? Sorry if didn't use the correct terms or reported on the correct terms.
Thanks.
2 Replies
- AnonymousNot applicable
https://dax.guide/previousmonth/
Please create the correct relationships between your tables. Especially from Calendar and your fact tables. By the way, your Calendar table must be marked as the Date table in the model for time-intel functions to work correctly.
Best
D
- stevedep
Memorable Member
Can you share your data model?