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
mashek
New Member

YTD 2023 2019

Hi All,

 

We selected following filter on "Years" ( 2023, 2021 ) Comparing data of 2023, 2021 and looking only YTD data only.

Current year 2023 Date: 24-JAN-2023
Comparing Year  2021 : 24-JAN-2021

We would like to display QTY result on visual only YTD meaning 2021 QTY data only up to 24-Jan-2021 and 2023 QTy Data upto 24-Jan-2023. 

 

At present for yer 2021 it display complete 2021 years data.

 

mashek_0-1674576367186.png

 

 

Can any one please suggest DAX formula to get data of 2021 and 2023 between 01-JAN and 24-JAN.

 

Thanks,

MS

2 REPLIES 2
johnt75
Super User
Super User

Try

YTD QTY =
VAR SelectedYear =
    SELECTEDVALUE ( 'Date'[Year] )
VAR YearsToSubtract =
    SelectedYear - YEAR ( TODAY () )
RETURN
    CALCULATE (
        SUM ( 'Table'[Quantity] ),
        DATEADD ( DATESYTD ( 'Date'[Date] ), YearsToSubtract, YEAR )
    )

Hi,

 

I tried and getting only result of 2023 year and not for year 2021.

If I select year 2021 and 2022 it should calculate result of full year of ( 2021 and 2022).

In my selection (2021 and 2023) getting in correct result.

By selecting year 2023 and 2021 it should calculate only YTD, ( Period JAN and day between 01 and day 24 ) for year ( 2021, 2023).

mashek_2-1674590636518.png

 

Thanks

MS

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.