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
LisaB
Helper III
Helper III

MTD and LYMTD - does not show correct values

Hi,

 

Have been searching the forum for a while but without finding any answers to my questions:

 

1. I have created a MTD measure but this won't show any values if I don't have a date filter (= this month). 

    TotalMTD = TOTALMTD(SUM(PostedSalesInvoices[Amount]);dCalendar[Date])
 
2. I also want a LY MTD but this shows me the sales for the whole month previous year, not MTD.
   Totalt LMTD = CALCULATE ( [TotalMTD]; SAMEPERIODLASTYEAR( dCalendar[Date] ) )
 
 
Thanks!
 
Lisa
 
UPDATE: It might be worth to mention that YTD works fine.
1 ACCEPTED SOLUTION

Technically you are getting the correct results but I think what you are seeing is the date over run problem.  Jan 2019 is only a few days old, so MTD is showing the correct answer, but your calendar table has dates through to the end of Jan 2019 (technically it is correct to load your calendar table with the full year).  When MTD LY is calculated, it takes the current month (Jan 2019, which includes all days in Jan) and gives you the result for the same month prior year (Jan 2018).  So you get the full month this year (but it is only a few days) and you get the full month last year.

 

OK, so how to "fix" it.

One way is to add a calculated column to your calendar table that you can use in your page filter. Something like this

 

DateHasPassed = 'Calendar'[Date] < TODAY()
 
then filter on TRUE on your page

This should fix it.


* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

7 REPLIES 7
v-yuezhe-msft
Employee
Employee

@LisaB,

How do you create the visual using the above measures. Your DAX works as expected in my Desktop.
1.PNGCapture.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yuezhe-msft,

 

Thank you for your reply. 

 

I would like it as in Picture 1, but with correct values. 🙂 I have a page filter on this month which gives me the correct value for January 2019.

 

Image 1.png

 

Picture 2 shows how it looks like without any filters (unfortunately it's in Swedish).

 

 Image 2.png

 

 

Thanks.

 

Technically you are getting the correct results but I think what you are seeing is the date over run problem.  Jan 2019 is only a few days old, so MTD is showing the correct answer, but your calendar table has dates through to the end of Jan 2019 (technically it is correct to load your calendar table with the full year).  When MTD LY is calculated, it takes the current month (Jan 2019, which includes all days in Jan) and gives you the result for the same month prior year (Jan 2018).  So you get the full month this year (but it is only a few days) and you get the full month last year.

 

OK, so how to "fix" it.

One way is to add a calculated column to your calendar table that you can use in your page filter. Something like this

 

DateHasPassed = 'Calendar'[Date] < TODAY()
 
then filter on TRUE on your page

This should fix it.


* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

@MattAllington  Bravo man, i spent 2 hours finding a solution to this !!!!

Thank you Matt!

Greg_Deckler
Super User
Super User

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ 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...

Hi @Greg_Deckler,

 

Thank you your reply. Actually, I have dates on my transactions and a separate date table. Worth to mention is that the YTD works perfectly fine, it's only the MTD that messes things up.

 

Lisa

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.