Forum Discussion

BUSH781's avatar
BUSH781
New Member
2 years ago
Solved

Calculating Variance based on the year selection in slicer

I have to create a dashboard calculating variance between three different values which are Amount, Fee and count. DB needs to have a slicer enabling user to select current year and any prvious year e.g, 2024 verses 2023 and so on. Dasboard should show the variance percentage based on user selection. Can anyone please help. TIA

  • Anonymous's avatar
    Anonymous
    2 years ago

    lbendlin Thanks for your contribution on this thread.

    Hi BUSH781 ,

    You can create a measure as below to get it, please find the details in the attachment.

    Variance = 
    VAR _curyear =
        YEAR ( TODAY () )
    VAR _selyear =
        SELECTEDVALUE ( 'Table'[year] )
    VAR _cyamount =
        CALCULATE (
            SUM ( 'Table'[Amount] ),
            FILTER ( ALL ( 'Table' ), 'Table'[year] = _curyear )
        )
    VAR _syamount =
        CALCULATE (
            SUM ( 'Table'[Amount] ),
            FILTER ( 'Table', 'Table'[year] = _selyear )
        )
    RETURN
        _cyamount - _syamount

     

    Best Regards

3 Replies