Forum Discussion
Using 2 Slicers to Calculate/Display Variance
- Anonymous4 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 - _sumtable2Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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.
- CoreyLearnsBI4 years agoFrequent Visitor
Hey Rico,
Thanks for taking the time to walk through this example with me!
Do you mind me asking if there is a textbook/course you recommend for mastering DAX?