Forum Discussion
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 it is showing total of all upto december where i wanted to show only this year ytd upto july. i have created date table and connect with order date.
how can i write the dax for ytd?
Thanks in advance.
- Anonymous4 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 _totalThe PBIX file is attached for reference.
Best Regards,
Gao
Community Support TeamIf 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
4 Replies
- AnonymousNot applicable
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 _totalThe PBIX file is attached for reference.
Best Regards,
Gao
Community Support TeamIf 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