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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
ngocnguyen94
New Member

Problems when calculating Cumulative value by DATESYTD

Hi,

I just started to learn PBI and I got some problems when calculating cumulative with DATESYTD, hope sb can help plz.

I got the Actuals data (from Jan-2020 to July-2020), main fields are Date column (1-Jan, 1-Feb, 1-Mar, and so on), and Actual number.

I created a Calendar table by Calendarauto. I got the table with dates from 1-Jan-2020 to 31-Dec-2020, and I created some measures as below:

  1. YTD Actual 1 = CALCULATE(SUM(Actuals[Actual]), DATESYTD(Actuals[Date]))
  2. YTD Actual 2 = CALCULATE(SUM(Actuals[Actual]), DATESYTD(CalendarTable[Date].[Date]))
  3. YTD Actual 3 = CALCULATE(SUM(Actuals[Actual]), FILTER(ALLSELECTED(CalendarTable[Date]),ISONORAFTER(CalendarTable[Date],MAX(Actuals[Date]), DESC)))
     

The Table 1 and 2 were created to calculate cumulative values

The measure 3 is still good in both, but measure 1 are not working in two tables (only show data of the month, not cumulative), and measure 2 got same problems in table 1.

I only changed one column of two tables, from Date -> Date hierachy (Month).

 

Can someone help me to explain why the differences occur?

Why this happen when I change the field Date in DATESYTD and the Date/Date Hierarchy column?

Thank you so much

elaine9894_1-1686927642032.png

xelaine9894_3-1686927785390.png

 

 

 

1 REPLY 1
some_bih
Super User
Super User

Hi @ngocnguyen94 function DATESYTD is one of the time intelligence functions in DAX. The best usage of this / these function/s is to be used on Calendar / Date table as other usage is hard to explain. In your example use just Measure 2 for YTD amounts as best practice. Hope this help





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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