Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nesquick91
New 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:
9joevyr1zx251.png

 

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))
 
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:
908sm5v30y251.png

 

 
This is the table I get using the Last Month total € spent function:
 ux9oej9d0y251.png

 

 
This is the result that I want:
ql26tabn0y251.png

 

 
 
Can anybody help? Sorry if didn't use the correct terms or reported on the correct terms.
Thanks.
2 REPLIES 2
stevedep
Memorable Member
Memorable Member

Anonymous
Not 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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors