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
dw700d
Post Patron
Post Patron

Calculate YTD prior month numbers

I am trying to calculate YTD Prior month spend but something is off

This is the dax measure I am using

---YTD Spend PM = CALCULATE([YTD SPEND],DATEADD('Calendar'[Date],-1,MONTH))---

 

When I break it down by month the grand total shows the correct prior month spend which is 1580500 but it deletes the month of January and attributes the wrong YTD spend number for July. When I exclude the month then it appears that YTD spend is = YTD prior month spend which is not true.

 

YTD Prior month spend should be 1580500. What Dax measure can I write to show this?

 

The chart on the left shows correct YTD numbers, the chart on the right was my attempt to calculate the YTD prior month numbers

 

Capture.PNG

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @dw700d ,

Create a relationship between your date table and fact table to use time-intelligence-function , create measures like this to get the expected result:

date relationship.png

YTD Spend PM =
CALCULATE ( [YTD Speed], DATEADD ( 'Table'[Date], -1, MONTH ) )

res.png

 

Attached sample file that you can refer: Calculate YTD prior month numbers.pbix

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yingjl
Community Support
Community Support

Hi @dw700d ,

Create a relationship between your date table and fact table to use time-intelligence-function , create measures like this to get the expected result:

date relationship.png

YTD Spend PM =
CALCULATE ( [YTD Speed], DATEADD ( 'Table'[Date], -1, MONTH ) )

res.png

 

Attached sample file that you can refer: Calculate YTD prior month numbers.pbix

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@dw700d  - I just recently wrote something that might help: 

https://community.powerbi.com/t5/Quick-Measures-Gallery/To-bleep-With-TOTALMTD/td-p/1250110

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
harshnathani
Community Champion
Community Champion

Hi @dw700d ,

 

Add a year Column in your visual.

 

Regards,

HN

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.