Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Year over year % change without date column

Hello friends, I am new to Power BI and I was wondering how to get a YoY% for the below data.  My data table: year_month event country Y24M04 A US Y24M04 A CA Y24M04 B CA Y2...
  • Anonymous's avatar
    Anonymous
    1 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 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!