Forum Discussion
YTD
I have put this dax together.
- Anonymous1 year ago
Hi Anonymous ,
I created a sample pbix file(see the attachment), please check if that is what you want.
YTD AC = CALCULATE ( SUM ( 'Append'[Value] ), FILTER ( 'Append', 'Append'[view] = "actuals" && YEAR ( 'Append'[Date] ) = YEAR ( TODAY () ) && 'Append'[Date] <= TODAY () ) )Best Regards
10 Replies
- Poojara_D12Super User
Hi Anonymous
The issue arises because the TOTALYTD function isn't dynamically filtering the dates based on the year-to-date (YTD) range due to the way you structured your DAX formula. Specifically, the FILTER function within SUMX evaluates the entire table, effectively ignoring the TOTALYTD filter context.
Hereβs what is missing and how to fix it:
Revised DAX for Dynamic YTD Calculation
You need to make sure that the filtering for YTD is applied correctly. Replace your measure with the following:
YTD AC = CALCULATE( SUMX( 'Append', IF('Append'[view] = "actuals", [Value], 0) ), DATESYTD('FinDate'[Date], "31/12") )Testing the Measure
- Verify that your date column ('FinDate'[Date]) contains valid and continuous date values (i.e., no gaps or missing dates).
- Ensure that the column 'Append'[view] accurately classifies rows as "actuals" or other categories.
Optional: Debugging Helper Measure
To see which rows are contributing to your calculation, you can create a debugging table:
EVALUATE CALCULATETABLE( FILTER('Append', 'Append'[view] = "actuals"), DATESYTD('FinDate'[Date], "31/12") )This will show the filtered rows for YTD, helping you verify that the filters are applied correctly.
Let me know if you encounter any issues!
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" π
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
YouTube: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS - Kedar_PandeSuper User
Anonymous
Corrected DAX Measure:
YTD AC =
CALCULATE(
SUM('Append'[Value]),
'Append'[view] = "actuals",
DATESYTD('FinDate'[Date])
)π If this helped, a Kudos π or Solution mark would be great! π
Cheers,
Kedar
Connect on LinkedIn- AnonymousNot applicable
Sorry I tried this, but I still get the whole year, rather than until the current month.
- AnonymousNot applicable
Sorry I tried this, but I still get the whole year, rather than until the current month.
- Dangar332Resident Rockstar
Hi, Anonymous
try below measureMEASURE = CALCULATE ( [value], 'Append'[view] = "actuals", keepfilter ( 'FinDate'[Date] < TODAY () ) )Best Regards,
DangarIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Hi Anonymous ,
Please update the formula of measure as below and check if it can return the expected result...
YTD AC = TOTALYTD ( SUM ( 'Append'[Value] ), 'Append'[Date], FILTER ( ALLSELECTED ( 'Append' ), 'Append'[view] = "actuals" && 'Append'[Date] < TODAY () ) )Best Regards
- AnonymousNot applicable
Sorry, let me clarify.
My table has dates in the future. That's why I keep getting the values in the future. I realised that I need a measure that calculated the YTD to a point in time.
- AnonymousNot applicable
Hi Anonymous ,
I created a sample pbix file(see the attachment), please check if that is what you want.
YTD AC = CALCULATE ( SUM ( 'Append'[Value] ), FILTER ( 'Append', 'Append'[view] = "actuals" && YEAR ( 'Append'[Date] ) = YEAR ( TODAY () ) && 'Append'[Date] <= TODAY () ) )Best Regards
- LaxmanjatothResolver I
Anonymous , use the below measure
the reason why iam choosing this measure , if it is more 1 filters then you have to use datesytd function forperfamnace . please check the below one
YTD =
CALCULATE(
SUM('Append'[Value]),
'Append'[view] = "actuals",
DATESYTD('FinDate'[Date])
)
or use below one
YTD AC =
CALCULATE(
SUM('Append'[Value]),
'Append'[view] = "actuals",
DATESYTD('FinDate'[Date])
)
please accept if my measure will works - Mahesh0016Super UserAnonymous Please try below one
YTD AC =
CALCULATE(TOTALYTD( [Total View], 'FinDate'[Date], 'FinDate'[Date]<TODAY() ), 'Append'[view]="actuals")
Anonymous Thank You!