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.12345678910111213141516<strong>Distance (Selected) =</strong><span style="color: #70ad47;"><strong>// This Variable is looking for the selected value from the Disconnected Slicer</strong></span><span style="color: #70ad47;"><strong>// If nothing is selected then display "No Activity Selected"</strong></span><span style="color: #00b0f0;"><strong>VAR ActivitySelected = SELECTEDVALUE(Activity[Activity],"No Activity Selected")</strong></span><span style="color: #70ad47;"><strong>// Now using an IF statement, we can then pass through the required values.</strong></span>RETURN<strong><span style="color: #70ad47;">// If nothing has been selected then return the entire distance</span></strong><span style="color: #7030a0;"><strong>IF(ActivitySelected = "No Activity Selected",</strong></span><span style="color: #7030a0;"><strong> [Distance],</strong></span>// Else if a value is selected the pass that value to the calculate below<span style="color: #ed7d31;"><strong>CALCULATE(</strong></span><span style="color: #ed7d31;"><strong> [Distance],</strong></span><span style="color: #ed7d31;"><strong> Activities[Activity Type] =</strong><span style="color: #00b0f0;"><strong>ActivitySelected</strong></span></span><strong><span style="color: #ed7d31;"> )</span></strong><strong><span style="color: #7030a0;">)</span></strong>
- 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
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.