Forum Discussion

CoreyLearnsBI's avatar
CoreyLearnsBI
Frequent Visitor
4 years ago
Solved

Using 2 Slicers to Calculate/Display Variance

Hello,   I have a single visual where I would like users to be able to select two months via two separate slicers in order to calculate the difference in performance for each group's performance fo...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi CoreyLearnsBI ,

     

    I download your pbix file and check it. I think you create two slicers by same [Month/Year] column. We couldn't get two different values from one column. It is better for you to create an unrelated Month/Year table for slicer2.

    Month/Year = 
    VALUES('Data for SQL (MY22)'[Month/Year])

    Then create a measure to achieve your goal.

    Display Variance = 
    VAR _sumtable1 =
        CALCULATE ( SUM ( 'Data for SQL (MY22)'[Metric 1] ) )
    VAR _selectmonth =
        SELECTEDVALUE ( 'Month/Year'[Month/Year] )
    VAR _sumtable2 =
        CALCULATE (
            SUM ( 'Data for SQL (MY22)'[Metric 1] ),
            FILTER (
                ALLEXCEPT (
                    'Data for SQL (MY22)',
                    'Data for SQL (MY22)'[Group],
                    'Data for SQL (MY22)'[Market]
                ),
                'Data for SQL (MY22)'[Month/Year] = _selectmonth
            )
        )
    RETURN
        _sumtable1 - _sumtable2

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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