Forum Discussion
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 for the two months selected. See screenshot below.
For example, Group number 1 has values of 1.94 for May and 1.44 for April. I want the math of 1.94 - 1.44 = 0.54 to be calculated. I would like the difference of 0.54 to be shown on the visual instead of the 1.94 for the first group.
Data can be found here: https://www.dropbox.com/s/n3rzu68aolp8azo/05.16%20Forum%20Question.pbix?dl=0
The desired outcome is two slicers affecting one visual where a user can pick two months to see the variance among groups.
Can this be done? How can this be done? I am a fairly new Power BI user, so I might need a more elaborate explanation/demonstration. I plan on using the visual for all 12 calendar months, but with only 2 slicers to enable users to see the variance between 2 months of data.
I tried something like this, but it sums all the groups' data together. I need each group's variance to be displayed individually on the visual, instead of one summation.
sumtable1 = CALCULATE(SUM(Table1[take]),ALLSELECTED(Table1[Month1]))
sumTable2 = CALCULATE(SUM(Table2[Take]),ALLSELECTED(Table2[Month2]))
look up the values = [sumtable1]-[sumTable2]
- 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.
4 Replies
- lbendlinSuper User
As long as you use disconnected tables for your slicers and measures for your result this will be straightforward.
Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. Avoid posting screenshots of your source data if possible.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523- CoreyLearnsBIFrequent Visitor
I've added a link to the dataset: https://www.dropbox.com/s/n3rzu68aolp8azo/05.16%20Forum%20Question.pbix?dl=0
- AnonymousNot applicable
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.
- CoreyLearnsBIFrequent 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?