Power BI – How Disconnected Slicers can enrich & transform your analytics data
I have been using disconnected slicers for quite some time. What I love about them is that you can use them so that a user does not have to go to individual pages to view different measures or values, but can easily click on the disconnected
slicer, which will then change the measure or values for them.
I find this to be valuable because it allows the user to stay on the report page, and can quickly switch between measures or values. Which in turn empowers the user to make decisions quickly and efficiently.
I have seen people use Disconnected Slicers for quite a while in different iterations, so I thought it would be best to blog about this, so that I have it for my own future reference, as well as for other people to be able to see it in action.
In this example I am going to use my Strava data using the Custom Data Connector from my previous blog post (Power BI – Using the Custom Data Connector to Connect to Strava) and the ability to change the entire page between Bike, Run and Swim measures or values.
Creating the Disconnected Slicer
The first step is to create the Disconnected Slicer with the values that you want to enable the user to switch between.
-
As with the example I clicked on Enter Data and put in the following.
- And then clicked Load
-
Next I created my Disconnected Slicer onto my report and I used the Chiclet Slicer so that I could format it so that it complimented my report.
Creating my Distance Measure to use the Disconnected Slicer
The next thing that I did was to create a new measure which would use the disconnected slicer details.
So the way that it works is when a value is selected from the disconnected slicer above, it then passes that value to the measure. I wanted it to dynamically change my measure based on the selection.
-
Below is my measure with an explanation afterwards.
Distance (Selected) = // This Variable is looking for the selected value from the Disconnected Slicer // If nothing is selected then display "No Activity Selected" VAR ActivitySelected = SELECTEDVALUE(Activity[Activity],"No Activity Selected") // Now using an IF statement, we can then pass through the required values. RETURN // If nothing has been selected then return the entire distance IF(ActivitySelected = "No Activity Selected", [Distance], // Else if a value is selected the pass that value to the calculate below CALCULATE( [Distance], Activities[Activity Type] = ActivitySelected ) )
- The first section are comments so that when I go back to this DAX measure later I know what I was doing. Great for documenting what I was doing at the time.
-
Next is where I created my variable called ActivitySelected in BLUE
- I am using the new DAX funcation called SELECTEDVALUE, which will return your selected value. Much easier than the older “IF(HASONEVALUE”
- I am then looking for a value from my disconnected slicer that I created earlier from the table named Activity.
- If nothing is selected on my slicer it will then return the text of “No Activity Selected”
- When I use a DAX Variable and I want to start with my measures I have to use RETURN. This then allows the DAX parser that I am completed with the definition and propagation of my variables.
- Next what I did was to use the standard IF DAX function, and in here what I am evaluating at first is that if my variable returns “No Activity Selected” meaning that nothing has been selected on the slicer, then return the [Distance] measure. Highlighted in Purple above.
-
Next if a value is selected then pass that value within my CALCULATE DAX function highlighted in Orange
- In my CALCULATE syntax I am using a column called Activity Type in my Strava data.
Disconnected Slicer in Action
Now as you can see below if I click on Ride, I will only see my data related to the Rides
And if I had to select Ride and Run then I would see both values on my charts due to the way I designed it
Conclusion
As you can see above I have shown how using a disconnected slicer you can have your data slice by using a simple slicer, but it interacts with one measure, instead of creating multiple measures.
Hi,
Thanks for a great article.
I am trying to replicate this but i am having trouble getting two measures to show on a visual.
I have a table split by date, type and value.
I have created two measure as instructed:
Test = SUMX(‘KPI Data (2)’,’KPI Data (2)'[Value])
Test 2 = VAR ActivitySelected = SELECTEDVALUE(‘Measures Selection'[Measure],”No Activity Selected”)
RETURN
IF(ActivitySelected = “No Activity Selected”,
[Test],
CALCULATE([Test],’KPI Data (2)'[Attribute] = ActivitySelected))
However when selected two measures or more, the sum of each measure is added together am i missing something?
Hi Andy,
It would appear that it is correct, because when you are selecting two measures, it is passing both of those measures to your CALCULATE statement. So the filter context for the ‘KPI Data (2)'[Attribute] is filtering on both measures.
Does that make sense?