Do you know how to use Multiple Disconnected Slicers in Power BI?
I had previously blogged Power BI – Using a Slicer to show different measures
where I showed the steps on to have a different measure based on a slicer selection. I got a few comments from that blog post, where people were asking if it was possible to have multiple Slicers which could be used.
If you are reading this blog post, I would recommend reading my previous blog post Power BI – Using a Slicer to show different measures, this is a follow-on blog post.
Example
In this working example I am going to add in an additional disconnected slicer for Currency.
This will allow me to click on my existing measure, which is for Sales or Cost, and have the ability to then show it in different currencies.
Below is what my Fact table looks like.
As shown above I have got my different columns for my sales and costs, as well as the other values in the different currencies.
Creating the 2nd Disconnected Table
The reason that it is called a disconnected slicer is that it is not connected to anything. And it is used for the slicer, as well as for my measure to control which measure to show.
-
I clicked on Enter Data and put in the following as shown below.
- I gave it the name of Currency
-
You will also see above I put in an Order column, this is so that I can control the order of the measures shown in the slicer.
- Once the table has loaded, I clicked on the Currency column, then in the Ribbon I went to Modeling and then clicked on the Sort By Column and selected Order
Creating the Base Measures
I like to call these measures base measures, because this is the base measure which I am going to build my additional measures on top of these base measures.
Currently have got two values for my Measure Table which are “Sales” and “Costs”
I then need to create 2 measures one for “Sales” and one for “Costs” as shown below.
Sales = VAR SelectedCurrency = SELECTEDVALUE ( 'Currency'[Currency], "AUD" ) RETURN SWITCH ( TRUE (), SelectedCurrency = "AUD", SUM ( Sales[Sales Amount] ), SelectedCurrency = "USD", SUM ( Sales[Sales Amount USD] ), SelectedCurrency = "EUR", SUM ( Sales[Sales Amount EUR] ), 0 )
- I am using the same pattern as I did in the previous blog post.
-
Lines 2 – 3
- Here I am getting the value that has been selected on the Currency Slicer (Which I will create in a future step below)
-
Lines 4 – 11
- I am then taking my variable “SelectedCurrency” and where it matches, then using the related measure
I now do a very similar thing with the Costs, and this time I am using the Cost Amount. The same pattern is used so please refer to the details in the step above.
Costs = VAR SelectedCurrency = SELECTEDVALUE ( 'Currency'[Currency], "AUD" ) RETURN SWITCH ( TRUE (), SelectedCurrency = "AUD", SUM ( Sales[Cost Amount] ), SelectedCurrency = "USD", SUM ( Sales[Cost Amount USD] ), SelectedCurrency = "EUR", SUM ( Sales[Cost Amount EUR] ), 0 )
The final measure that I now need to create is based on what is selected in the Measure slicer. This will allow me to then dynamically change between “Sales” or “Costs
Dynamic Measure = VAR MySelection = SELECTEDVALUE ( 'Measure'[Measure Name], "Sales" ) RETURN SWITCH ( TRUE (), MySelection = "Sales", [Sales], MySelection = "Costs", [Costs], [Sales] )
- Once again, I am using the same pattern as above.
-
Lines 2 – 3
- I am getting the value from my Measure Slicer
-
Line 7
- If the selection = “Sales” then I am going to use the [Sales] measure which I created earlier
-
Line 8
- If the selection = “Costs” then I am going to use the [Costs] measure which I created earlier
Multiple Disconnected Slicers in Action
Below you can see how this works with multiple disconnected slicers.
I have put below the entire table, which will enable you to see that the Dynamic measure is working as expected.
GIF HERE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
And finally, here is a link to the PBIX Multiple Disconnected Slicers
if you are looking for more details
Conclusion
I do hope that you have found this useful and if you do have any questions or comments, I encourage you to please leave them in the section below.
Thanks for reading!
Thanks, It’s very informative.
I have a scenario, there are 4 different reports on one page from different tables/sources. There is not any join between them but I want to filter data on basis of Calendar table also I can’t join calendar table with others.
Hi there
Thanks for the kind words, you can have a look at this article by SQL BI where they talk about using TREATAS to create a relationship between the tables.
https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/
Great post.
Just a little syntax sugar for the expression:
SWITCH (
TRUE (),
SelectedCurrency = “AUD”, SUM ( Sales[Cost Amount] ),
SelectedCurrency = “USD”, SUM ( Sales[Cost Amount USD] ),
SelectedCurrency = “EUR”, SUM ( Sales[Cost Amount EUR] ),
0
)
it is equivalent to:
SWITCH (
SelectedCurrency,
“AUD”, SUM ( Sales[Cost Amount] ),
“USD”, SUM ( Sales[Cost Amount USD] ),
“EUR”, SUM ( Sales[Cost Amount EUR] ),
0
)
Yes that could work too.
If you are interested in how the SWITCH actually works with the syntax sugar here is an interesting article by SQLBI.COM
http://sqlblog.com/blogs/marco_russo/archive/2014/08/18/possible-switch-optimization-in-dax-powerpivot-dax-tabular.aspx
[…] Read More […]
Great post! This is really helpful.
Awesome, thanks for letting me know.
I want to create a measure slicer where i can select multiple measures and can display them on selection in matrix with there measure names.Is this possible?
Hi there
This blog post should be of assistance on how to get multiple measures
No there are two measure fields here which acts based on the other.I need to have one measure slicer which can select multiple KPI’s from the list.
For eg : Measures
Select All
Unit Price
Avg Price
Sales
% Chg in LY
user can select all the KPI or multiselect the one’s needed
Can you please help to achieve the same
Great Guys, excellent tip.
Glad to assist!
Is it possible to allow multi-select to work in the second slicer? For example, after I have selected Sales, I want to show both USD and EUR for Sales at the same time.
Hi there
This might be possible, the question I have is would you want it with more than 2 selections?
how can u show just USD columns when USD slicer is selected and AUS columns when AUS is selected
Hi there
Currently you cannot dynamically change the column names.
What you could do is to put the measure the table, and display which measure has been selected?
Actually, it may be possible to change the column name if you use a matrix visual and put the slicer value in the Column field of the matrix and put the calculated measure in the Value field, with the date being on the Row field. When you click ‘USD’, the column heading for the measure should change to ‘USD’ and if you click ‘EUR’, the column heading should change to ‘EUR’.
I recently did something similar to this to display a measure based on a selected date period. My slicer displayed Week, Month, Quarter, Year and based on the selection, my measure was calculated on either a weekly, monthly, quarterly, or yearly basis. On my bar charts and line charts connected to this slicer, the dates were on the x-axis and the axis labels dynamically changed based on the selection. On my matrix, the column headings would dynamically change accordingly, displaying the week date, month, quarter, or year.
Hi there
Yes that should certainly work too. I know at the time it did not work and that is why I had this workaround.
Thanks for the comment and hopefully this can assist others.
Hi, great article, but I am doing something wrong because when I apply the first slicer in the second slicer I see only one option.
I want to combine the measure (Sales, Units, ….) and time selection (M,3RM, YTD, MAT)
Each separate measure works with the time selection just fine.
Sales =
VAR Selection = SELECTEDVALUE(‘Value Selection'[Time])
RETURN
Switch(Selection,
“M”,Data_Sales[Sales_M_LC],
“3RM”,Data_Sales[Sales_3RM_LC],
“YTD”,Data_Sales[Sales_YTD_LC],
“MAT”,Data_Sales[Sales_MAT_LC],
0)
But when I combine the all measures and time selection using:
Dynamic measure =
VAR Dynamic_measure = SELECTEDVALUE(‘Value Selection'[Measure])
RETURN
Switch(Dynamic_measure,
“Units”,[Units],
“Sales”,[Sales],
“Weighted distr”,[Weighted distribution],
“Numeric distr”,[Numeric distribution],
[Units])
It starts to show only for each timeline different measure.
M = Units
3RM = Sales
YTD = xy
MAT = xz
How to fix it? what I am doing wrong?
Thank you for help
Lenka
Hi there
What you need to do is to change the reference in your Dynamic measure to use the values from your measure. Which from my understanding of the above should be the disconnected table?
Thank you! This helped a lot. However, after downloading the example file I’m totally confused as to how you are making it work with multiple selected countries. I really can’t follow it and I can’t see where if anywhere you are using the SELECTEDVALUE and SWITCH technique. Can you explain that a bit?
Hi Hugo,
In the code the first thing that I do is to create the base measures for Sales and Costs in which there is a Switch statement for the different currencies.
Then the final measure is where I am switching between the Sales and Cost measure using another SWITCH measure.
Does that make sense?
Oh sorry! I posted on the wrong page. My confusion is actually with the file for download here:https://www.fourmoo.com/2019/02/19/do-you-know-how-to-use-multiple-disconnected-slicers-in-power-bi/
The article on that page seems to follow a similar example, but the file is different. The file relates to hours worked in different countries. It seems like a great example though and I would like to understand it.
Hi there
When looking at the measures, you have to look at both of the measures in the PBIX. The first measure for [Sales] and [Cost] is where it looks at what currency to use.
The second measure [Dynamic Measure] then looks at the selected value for the measure to know which measure to use ([Sales] or [Cost]). Both these measures can be used when clicked on.
Does that make sense?
My apologies, it is this post: https://www.fourmoo.com/2017/11/21/power-bi-using-a-slicer-to-show-different-measures/
Your example file there downloads as ‘Disconnected Slicers.pbix’. Its a report for comparing avg working hours across countries. I commented on that post too (but now I’m just sorry for making such a mess). Thanks for your replies.
Did you manage to get it all working?
If not let me know and I will see where I can help!
Oh sorry! I posted on the wrong page. My confusion is actually with the file for download here:https://www.fourmoo.com/2019/02/19/do-you-know-how-to-use-multiple-disconnected-slicers-in-power-bi/
The article on that page seems to follow a similar example, but the file is different. It seems like a great example though and I would like to understand it.
Hi! Great Post. I’ve followed the guide but for some reason when I select one of the slicers it limits my options in the other slicer and vice versa, so that I can only select one option in whichever slicer I click on second. Do you know what the cause of this could be? I have 3 slicers in each, don’t know if that matters.
Hi there,
Yes that would happen if the data in the slicers is directly related. Because the slicer WILL filter the data.
If you have the slicers they would need to have disconnected slicers so that they are not related to any data in the dataset. They only being used when the slicer is clicked.
I currently do have them set up as disconnected slicers, so I’m having trouble pinpointing the issue. I have a disconnected table for Market Segment (“Individual”, “Small Group”, and “Large Group”) and a disconnected table for Place of Service (“POS 19,21,22, or 51”, “POS 23”, and “POS 24″)
Here are the formulas for my 3 created measures and my dynamic measure. Any ideas what is wrong? Thanks again for the help!
Individual Plan = VAR SelectedPOS = SELECTEDVALUE(‘Place of Service'[Place of Service Code],”POS 19, 21, 22, or 51”) RETURN SWITCH(TRUE(), SelectedPOS = “POS 19, 21, 22, or 51”, SUM (Medians[Individual Facility Median]),SelectedPOS = “POS 23”, SUM(Medians[Individual Facility Median (ER)]), SelectedPOS = “POS 24″, SUM(Medians[Individual Non-Facility Median]),0)
Small Group = VAR SelectedPOS = SELECTEDVALUE(‘Place of Service'[Place of Service Code],”POS 19, 21, 22, or 51”) RETURN SWITCH(TRUE(), SelectedPOS = “POS 19, 21, 22, or 51”, SUM (Medians[Small Group Facility Median]),SelectedPOS = “POS 23”, SUM(Medians[Small Group Facility Median (ER)]), SelectedPOS = “POS 24″, SUM(Medians[Small Group Non-Facility Median]),0)
Large Group = VAR SelectedPOS = SELECTEDVALUE(‘Place of Service'[Place of Service Code],”POS 19, 21, 22, or 51”) RETURN SWITCH(TRUE(), SelectedPOS = “POS 19, 21, 22, or 51”, SUM (Medians[Large Group Facility Median]),SelectedPOS = “POS 23”, SUM(Medians[Large Group Facility Median (ER)]), SelectedPOS = “POS 24”, SUM(Medians[Large Group Non-Facility Median]),0)
Dynamic Measure = VAR MySelection = SELECTEDVALUE ( ‘Market Segment'[Market Segment], “Individual Plan”) RETURN SWITCH ( TRUE(), MySelection = “Individual Plan”, [Individual Plan], MySelection = “Small Group”, [Small Group], MySelection = “Large Group”, [Large Group], [Individual Plan] )