Forum Discussion

mith_tina's avatar
mith_tina
Frequent Visitor
4 years ago
Solved

Total YTD

hi, in my data set Order date is upto December 2022. i wanted to show last year YTD and this year YTD upto july . but when i try to create dax , it is showing correctly last year data but this year ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi mith_tina ,

     

    Try this measure and use [Year] as the axis, this should return the correct result.

    Total YTD =
    VAR _date =
        EOMONTH ( TODAY (), -1 )
    VAR _year =
        MAX ( 'Calendar'[Year] )
    VAR _month =
        MONTH ( _date )
    VAR _day =
        DAY ( _date )
    VAR _total =
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                'Calendar',
                'Calendar'[Date] >= DATE ( _year, 1, 1 )
                    && 'Calendar'[Date] <= DATE ( _year, _month, _day )
            )
        )
    RETURN
        _total

    The PBIX file is attached for reference.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data