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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
FR14
Helper I
Helper I

LY YTD (total)

Hi Everyone,
 
Using following formula below, i am able to get the LY YTD for the exact month and day amount BUT when i fliter all the months the total LY YTD doesn't show correct amount, do you guys know what condition should be added to this DAX to also have the total LY YTD correct when we filter all the months?
 
LY YTD Bookings =
VAR _MaxDate = MAX(OrderLine[Open_Date])
VAR _PreviousYear = YEAR(_MaxDate) - 1
RETURN
CALCULATE(
    SUM(OrderLine[Booking USD]),
    YEAR(OrderLine[Open_Date]) = _PreviousYear,
    MONTH(OrderLine[Open_Date]) <= MONTH(_MaxDate),
    DAY(OrderLine[Open_Date]) <= DAY(_MaxDate)
)
 
 
Thank you all so much for your support.
1 ACCEPTED SOLUTION
StrategicSavvy
Resolver II
Resolver II

hi @FR14 

 

I belive you can use DATESYTD function based on your calendar table.  Make sure you have properly built di calendar table as @Jihwan_Kim  mentioned before you go.

 

First create measure that will make you are not showing values for future dates in your calendar table:

ShowValueForDates :=
VAR LastDateWithData =
    CALCULATE (
        MAX ( OrderLine[Open_Date] ),
        REMOVEFILTERS ()
    )
VAR FirstDateVisible =
    MIN ( 'Date'[Date] )
VAR Result =
    FirstDateVisible <= LastDateWithData
RETURN
    Result

 

Secondly create this measure:

 

LY YTD Bookings = 
IF(
    [ShowValueForDates],
    CALCULATE(
        SUM ( OrderLine[Booking USD] ),
        DATESYTD('Date'[Date])
    )
)

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: www.linkedin.com/in/lukasz-kozdron 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @FR14 ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

StrategicSavvy
Resolver II
Resolver II

hi @FR14 

 

I belive you can use DATESYTD function based on your calendar table.  Make sure you have properly built di calendar table as @Jihwan_Kim  mentioned before you go.

 

First create measure that will make you are not showing values for future dates in your calendar table:

ShowValueForDates :=
VAR LastDateWithData =
    CALCULATE (
        MAX ( OrderLine[Open_Date] ),
        REMOVEFILTERS ()
    )
VAR FirstDateVisible =
    MIN ( 'Date'[Date] )
VAR Result =
    FirstDateVisible <= LastDateWithData
RETURN
    Result

 

Secondly create this measure:

 

LY YTD Bookings = 
IF(
    [ShowValueForDates],
    CALCULATE(
        SUM ( OrderLine[Booking USD] ),
        DATESYTD('Date'[Date])
    )
)

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: www.linkedin.com/in/lukasz-kozdron 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I suggest using Calendar Dimension table to alter filter context.

But, by using only the situation shown here, please try something like below whether it produces the expected result.

 

LY YTD Bookings =
VAR _MaxDate =
    MAX ( OrderLine[Open_Date] )
VAR _PreviousYear =
    YEAR ( _MaxDate ) - 1
RETURN
    CALCULATE (
        SUM ( OrderLine[Booking USD] ),
        REMOVEFILTERS ( OrderLine[Open_Date] ),
        YEAR ( OrderLine[Open_Date] ) = _PreviousYear,
        MONTH ( OrderLine[Open_Date] ) <= MONTH ( _MaxDate ),
        DAY ( OrderLine[Open_Date] ) <= DAY ( _MaxDate )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Thank you but it didn't solve my problem unfotunately still the amount for the LY YTD to this day of the month is showing correct but then whe select JAN,FEB & March last year the total is not corrrect 😞

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.