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
FR14
Helper I
Helper I

How to get Last Year YTD

Hi Everyone,

 

Could you please help me modify this formula to get Last Year YTD? Thank you very much in advnace!

 

VAR __MaxDate = MAX('Dates'[Date])
RETURN
Calculate(SUM(OrderLine[Booking USD]), YEAR('OrderLine'[Open_Date]) = YEAR(__MaxDate), MONTH('OrderLine'[Open_Date]) <= MONTH(__MaxDate ))

 

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @FR14 ,

 

You can update your measure.

Measure=
VAR __MaxDate = MAX('Dates'[Date])
RETURN
CALCULATE(
    SUM(OrderLine[Booking USD]),
    DATESYTD(DATEADD(__MaxDate, -1, YEAR))
)

Or:

VAR __MaxDate = MAX('Dates'[Date])
VAR __StartOfLastYear = DATE(YEAR(__MaxDate) - 1, 1, 1)

RETURN
CALCULATE(
    SUM(OrderLine[Booking USD]),
    OrderLine[Open_Date] >= __StartOfLastYear,
    OrderLine[Open_Date] <= __MaxDate
)

You can refer to the following posts that may be helpful to you:

YTD last year DAX - Microsoft Fabric Community

How to Calculate Year to Date and Prior YTD in Power BI (popautomation.com)

Get the YTD of the same period last year - Kasper On BI

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

1 REPLY 1
v-tangjie-msft
Community Support
Community Support

Hi @FR14 ,

 

You can update your measure.

Measure=
VAR __MaxDate = MAX('Dates'[Date])
RETURN
CALCULATE(
    SUM(OrderLine[Booking USD]),
    DATESYTD(DATEADD(__MaxDate, -1, YEAR))
)

Or:

VAR __MaxDate = MAX('Dates'[Date])
VAR __StartOfLastYear = DATE(YEAR(__MaxDate) - 1, 1, 1)

RETURN
CALCULATE(
    SUM(OrderLine[Booking USD]),
    OrderLine[Open_Date] >= __StartOfLastYear,
    OrderLine[Open_Date] <= __MaxDate
)

You can refer to the following posts that may be helpful to you:

YTD last year DAX - Microsoft Fabric Community

How to Calculate Year to Date and Prior YTD in Power BI (popautomation.com)

Get the YTD of the same period last year - Kasper On BI

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

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!

December 2024

A Year in Review - December 2024

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