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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
cosmicyes
Helper II
Helper II

Rolling YTD for previous year

Dear Power BI friends,

 

I am trying to write a measure that gives me the YTD value of my revenue relative to the previous year. Today is November 20, 2024, and I have the revenue in the measure "Umsatz". What I want is the revenue for the period from January 1, 2023, to November 20, 2023.

The measure should roll dynamically, meaning it should respond to changes in the calendar slicers.

I have managed to get it working halfway, but this way, the measure does not respond to changes in the calendar:

 

 

 

Umsatz YTD Vorjahr # =
CALCULATE (
    CALCULATE (
        [Umsatz],
        DATESYTD ( Kalender[Datum] )
    ),
    Kalender[Datum]
        = (
            DATE ( YEAR ( TODAY () ) - 1, MONTH (
                TODAY ()
            ), DAY (
                TODAY ()
            ) )
        ) - 1
)

 

Thank you for your help.
 

1 ACCEPTED SOLUTION

@cosmicyes I think this will work 

 

Umsatz YTD Vorjahr = 
CALCULATE(
    [Umsatz],
    DATESBETWEEN(
        Kalender[Datum],
        DATE(YEAR(MAX(Kalender[Datum])) - 1, 1, 1), -- Start of the previous year
        DATE(YEAR(MAX(Kalender[Datum])) - 1, MONTH(MAX(Kalender[Datum])), DAY(MAX(Kalender[Datum]))) -- End date in the prior year
    )
)

But if above formula is not filtering with changes in calendar. 
Try below code

Umsatz YTD Vorjahr =
CALCULATE (
    [Umsatz],
    DATESYTD ( DATEADD ( Kalender[Datum], -1, YEAR ), "12/31" )
)

 

View solution in original post

6 REPLIES 6
saurabhtd
Resolver II
Resolver II

@cosmicyes This DAX will give you result

Umsatz YTD Vorjahr = 
CALCULATE(
    [Umsatz],
    SAMEPERIODLASTYEAR(
        DATESYTD(Kalender[Datum])
    )
)

Dear @bhanu_gautam 
this looks really good and I hoped it worked.
But it seems the measure delivers the revenue for the *whole* year 2023.
Am I missing something?

@cosmicyes I think this will work 

 

Umsatz YTD Vorjahr = 
CALCULATE(
    [Umsatz],
    DATESBETWEEN(
        Kalender[Datum],
        DATE(YEAR(MAX(Kalender[Datum])) - 1, 1, 1), -- Start of the previous year
        DATE(YEAR(MAX(Kalender[Datum])) - 1, MONTH(MAX(Kalender[Datum])), DAY(MAX(Kalender[Datum]))) -- End date in the prior year
    )
)

But if above formula is not filtering with changes in calendar. 
Try below code

Umsatz YTD Vorjahr =
CALCULATE (
    [Umsatz],
    DATESYTD ( DATEADD ( Kalender[Datum], -1, YEAR ), "12/31" )
)

 

@bhanu_gautam 
Thank you very much.
It still does not work 100% but this is something I can work with!

bhanu_gautam
Super User
Super User

@cosmicyes , Try using dax


Umsatz YTD Vorjahr =
CALCULATE (
[Umsatz],
DATESYTD (
SAMEPERIODLASTYEAR ( Kalender[Datum] ),
"11/20"
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam 

thank you very much - but 11/20 ist not flexible and rolling.
What I mean is: it should also work if I select June 2024 in calender and should show the result by June 23 2023 and so on...
Is this possible?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (4,463)