Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Compare last year vs current year (months) on same visual

Hey everyone! I could use some guidance on how to create a visual that is able to show each month (last year vs current year) side by side on a stacked or clusterted bar chart.    Desired Result: ...
  • V-lianl-msft's avatar
    6 years ago

    Hi Anonymous ,

     

    Use if statement to make conditional judgment and calculate data of each month.

    Measure =
    IF (
        (
            YEAR ( MAX ( 'Table'[Date] ) ) = YEAR ( TODAY () )
                || YEAR ( MAX ( 'Table'[Date] ) )
                    = YEAR ( TODAY () ) - 1
        )
            && MONTH ( MAX ( 'Table'[Date] ) ) <= MONTH ( TODAY () )
            && MONTH ( MAX ( 'Table'[Date] ) ) >= 3,
        SUM ( 'Table'[Sales] )
    )

    Sample .pbix

     

    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.