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
DonWong
New Member

YTD calculation (TOTALYTD and DATESYTD) gives incorrect amount?

Hi folks,

 

May I pick your brain on this issue I have encountered? Sorry, I cannot provide a sample file at this stage. but I will try explaining it clearly. Btw, I am having this issue in Power Pivot in Excel. But I think it is technically the same as Power BI when it comes to DAX commands.

 

My situation is actually quite straightforward:

 

1. I have a dynamic prior year measure that gives result as expected. There is a condition in this measure to switch between two different measures when the condition is met (in this example, when <= Feb 24, use green shade, otherwise, use yellow shade when > Feb 24). As you can see from the attached photo, green shades and yellow shades are matching. All good in this dynamic measure.

 

2. I have another measure utilising TOTALYTD to calculate the YTD total with year-end date being 31/5. In the attached photo, it is the red font area. YTD up to Feb-24 is all good but becomes incorrect from Mar-24. There is nothing complicated in this measure, I just wrapped the dynamic measure mentioned in Point 1 above inside of TOTALYTD. I even tried using a different DAX to caculate such as DATESYTD, but it still behaves the same as TOTALYTD. Strangely also, if you add the numbers for Apr-24 and May-24 under the yellow shade to the incorrect YTD of 437,893,334 (Mar-24), the aggregation is actually equal to the May-24 YTD number of 525,844,960. So it appears only the monthly number for Mar-24 is incorrect ? (not = 44,600,533). Then I used DATESBETWEEN (from 1/3/2023 to 31/03/2023) to test the dynamic measure (Point 1 above), and the result is actually 44,600,533 (the correct one). So it seems the issue only happens when doing a YTD calculation?

 

And I also further tested the YTD calculation using DATESBETWEEN again, using period of 1/6/2023 - 31/05/2024. Again, it gave the incorrect result, same as using TOTALYTD.

 

Any thoughts folks?

 

Many thanks

 

Don


Screenshot 2023-03-23 010304.png

3 REPLIES 3
lbendlin
Super User
Super User

Confirm that you have a covering and contiguous date table in your data model.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Hi there,

 

Confirming there is no gap in my date table. The date table (Calendar) is generated by Power Query.

 

I have made up some data and attached the sample file here. I have indicated the issue and expected outcome in the attached file.

 

https://www.dropbox.com/s/8r36j8f3ap4qms3/Issue%20Test.xlsx?dl=0

 

thanks!

Sorry, your Excel file still has the external links - please sanitize. It is also missing the dates table.

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