Forum Discussion
Year over year % change without date column
- Anonymous1 year ago
Hi Anonymous ,
Please modify the measure syntax as shown below:
event_distinctcount_PY = VAR _currentYear = VALUE ( MID ( SELECTEDVALUE ( 'Table'[year_month] ), 2, 2 ) ) VAR _currentMonth = VALUE ( MID ( SELECTEDVALUE ( 'Table'[year_month] ), 5, 2 ) ) var _Slicer_Country = VALUES('Table'[country]) RETURN CALCULATE ( DISTINCTCOUNT ( 'Table'[event] ), FILTER ( ALL ( 'Table' ), VALUE ( MID ( 'Table'[year_month], 2, 2 ) ) = _currentYear - 1 && VALUE ( MID ( 'Table'[year_month], 5, 2 ) ) = _currentMonth &&'Table'[country] IN _Slicer_Country ) )If you have any other questions please feel free to contact me.
Best Regards,
Yang
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!
Anonymous , ryan_mayu
Thank you very much for your quick responses!
In the data I am working with, the year, quarter, and month numbers are not following the normal calendar. For example, 2024/04/01 is Y24M04 but 2023/04/01 might belong to Y23M03.
So I was hoping for a solution when the year_month slicer is selected for one or more values, Y24M04 and Y24M06 for example, then eventcount measure would calculate for Y24M04 & Y24M06, and eventcount_PY would calculate for Y23M04 & Y23M06, and the YoY is the %difference of those two.
I was thinking of creating a lookup table with 2 columns, year_month, and year_month_PY like:
| year_month | year_month_PY |
| Y24M04 | Y23M04 |
| Y24M05 | Y23M05 |
| Y24M06 | Y23M06 |
| Y24M07 | Y23M07 |
| Y24M08 | Y23M08 |
| Y24M09 | Y23M09 |
but I am not sure how to go from there or if that's the right direction.
Thank you!