Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dax - YTD

Hello all,

Please help me to calculate YTD-2021 and YTD 2022. I have posted the result.Please find the attached images.Thank You

RaptorFox Hariharan_R Tahreem24 

 

 

  • Refer the attached PBIX file.

    2021 YTD = CALCULATE(TOTALYTD(SUM('Table'[Qty]),'Date'[Date]),'Table'[Year]=2021)
     

    Download

    Thanks

    Hari

    Did I answer your question? Then please mark my post as the solution.
    If I helped you, click on the Thumbs Up to give Kudos.

2 Replies

  • Barthel's avatar
    Barthel
    Icon for Solution Sage rankSolution Sage

    Hey,

     

    You can use these DAX codes to add calculated columns:

    YTD-2022 = 
    VAR CurrentMonth =
        DATEVALUE ( "1 " & 'Table'[Month] & " 2022" )
    RETURN
        CALCULATE (
            SUM ( 'Table'[2022] ),
            DATEVALUE ( "1 " & 'Table'[Month] & " 2022" ) <= CurrentMonth,
            ALLEXCEPT ( 'Table', 'Table'[Business Area] )
        )

     

    YTD-2021 = 
    VAR CurrentMonth =
        DATEVALUE ( "1 " & 'Table'[Month] & " 2021" )
    RETURN
        CALCULATE (
            SUM ( 'Table'[2021] ),
            DATEVALUE ( "1 " & 'Table'[Month] & " 2021" ) <= CurrentMonth,
            ALLEXCEPT ( 'Table', 'Table'[Business Area] )
        )

     

  • Refer the attached PBIX file.

    2021 YTD = CALCULATE(TOTALYTD(SUM('Table'[Qty]),'Date'[Date]),'Table'[Year]=2021)
     

    Download

    Thanks

    Hari

    Did I answer your question? Then please mark my post as the solution.
    If I helped you, click on the Thumbs Up to give Kudos.