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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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