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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
UditJ
Helper III
Helper III

Previous Year Value with respect to current year dates

So i have data from 1st jan 2021 to 1st June 2023. I am able to calcuate the Total YTD for current year that is 1st jan 2023 to 1st june 2023. Now i want previous years values but not for the entire year but for the time period 1st jan to 1st jun 2022 (The same period which is of my current year).

Any suggestions ?


1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @UditJ,

You can extract the current date and use date function to get the previous date value as condition to calculate.

LYTD =
VAR currDate =
    MAX ( Table1[Date] )
VAR prevDate =
    DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
RETURN
    CALCULATE (
        SUM ( Table1[Sales] ),
        FILTER (
            ALLSELECTED ( Table1 ),
            YEAR ( [Date] ) = YEAR ( prevDate )
                && [Date] <= prevDate
        ),
        VALUE ( Table1[Category] )
    )

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

HI @UditJ,

You can extract the current date and use date function to get the previous date value as condition to calculate.

LYTD =
VAR currDate =
    MAX ( Table1[Date] )
VAR prevDate =
    DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
RETURN
    CALCULATE (
        SUM ( Table1[Sales] ),
        FILTER (
            ALLSELECTED ( Table1 ),
            YEAR ( [Date] ) = YEAR ( prevDate )
                && [Date] <= prevDate
        ),
        VALUE ( Table1[Category] )
    )

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.