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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
el_sa
New Member

YTD Measure Carries Data Over to Next Year

Hi there, 

 

I am facing an issue with my YTD calculation in Power BI Desktop. I have YTD measures for calculating sales for every year, 2022, 2023, 2024 and the current year. Currently, all previous year measures are carrying the data of the whole year when I apply them.

I have tried to apply filters for the given year inside my calculation, and outside, but it did not help. If you faced a similar issue, would love to learn how you solved it.

Thank you

5 REPLIES 5
hnguy71
Super User
Super User

Hi @el_sa 
Can you share your measure and a sample with expected results?



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Hello

Here is my current DAX Measure, DateDimension table is a date dimension. Expected output is the number of YTD users in a given year. 

YTD_2024 =
VAR MaxDate = MAX(DateDimension[Date])
RETURN
CALCULATE(
    SUM('Sales'[TypeA]),
    FILTER(
        ALL(DateDimension),
        DateDimension[Date] <= MaxDate &&        
        DateDimension[Date] >= DATE(2024, 1, 1) &&
        DateDimension[Date] <= DATE(2024, 12, 31))

 

Hi @el_sa 
are you attempting to do a rolling total for the year 2024?



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

That's right

Hi @el_sa 
In that case, this should work for you:

RollingTotal_2024 = 

VAR _CurrDate = MAX(DateDimension[Date])
VAR _Year = 2024

RETURN

/*
    Find current date and use less than or equal to to get rolling total.
    Then using DatesYTD to only keep evaluation for dates within the same year
    Finally, return only year in context
*/

CALCULATE( SUM(Sales[TypeA]), DateDimension[Date] <= _CurrDate, DATESYTD(DateDimension[Date]), DateDimension[Year] = _Year )



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.