Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi,
Looking for a measure to resolve this.
I have a table with multiple columns. 2 of those are Team, and Team_Category.
There are some teams that happen to fall in 2 categories: Category X, Category Y.
If I put Team Category in slicer, when user selects Category X, those specific teams in the table should represent Category X under Team Category Column, and if Category Y is selected, those specific in the table should represent Category Y under Team Category Column.
If nothing is selected for the slicer, the default values for those teams should be "Category X & Category Y".
I want to create a slicer that can not only does the above but also have ability to filter the table based on slicer selection.
I assume it maybe a combination of selectedvalue, switch, and userelationship/crossfilter but I can't really arrive at a cohesive solution.
This is the DAX i could get to but this prevents the slicer from being able to filter table based on slicer selection. This is the measure being fed to the table instead of the original Team Category column, and a dummy column is created which is acting as slicer with values : Category A, Category B, Category X, Category Y.
Value Type =
VAR selected_value =
SELECTEDVALUE('Type Slicers'[Column1],"Category A")
RETURN
SWITCH(
selected_value,
"Category A",MAX(Teams[Team_Category]),
"Category X",MAX(Teams[Team_Category_CATXModified]),
"Category Y",MAX(Teams[Team_Category_CATYModified]),
"Category B",MAX(Teams[Team_Category]),
BLANK()
)
Below are the calculated columns along with original column.
Solved! Go to Solution.
Hi @Judy101 ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a measure.
Flag = IF(OR([Value Type] in VALUES('Slicer Table'[Column1]),ISFILTERED('Slicer Table'[Column1])=FALSE()),1,0)
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Judy101 ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2)Click "transform data" to enter the power query, copy the source table to delete the rest of the columns and keep only the [Category] column and then split according to "&" and then transpose. Open "Advanced Editor", copy and paste the following code. You can check the steps in the right hand side step bar.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wck4sSU3PL6pUcFTSUTJUitVBEnICChmhCkUoxJQaGBiZKcBFIoGKjJViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Category", type text}, {"Value", type number}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Value"}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns", "Category", Splitter.SplitTextByDelimiter("&", QuoteStyle.Csv), {"Category.1", "Category.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Category.1", type text}, {"Category.2", type text}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {}, "Attribute", "Value"),
#"Removed Columns1" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
#"Replaced Value" = Table.ReplaceValue(#"Removed Columns1"," ","",Replacer.ReplaceText,{"Value"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","Category","Category ",Replacer.ReplaceText,{"Value"}),
#"Renamed Columns" = Table.RenameColumns(#"Replaced Value1",{{"Value", "Slicer Team_Category"}})
in
#"Renamed Columns"
(3) We can create calculated columns.
Team_Category_CATXModified = TRIM( LEFT([Team_Category],IF(FIND ( "&", [Team_Category],1,BLANK())-1<=0,0,FIND ( "&", [Team_Category],1,BLANK())-1)))
Team_Category_CATYModified = TRIM(RIGHT([Team_Category],IF(FIND ( "&", [Team_Category],1,BLANK())-1<=0,0,FIND ( "&", [Team_Category],1,BLANK())-1)))
(4)We can create a measure.
Flag =
SWITCH(TRUE(),
ISFILTERED('Table (2)'[Slicer Team_Category])=FALSE(),1,
SELECTEDVALUE('Table (2)'[Slicer Team_Category])=MAX('Teams'[Team_Category]),1,
SELECTEDVALUE('Table (2)'[Slicer Team_Category])=MAX('Teams'[Team_Category_CATXModified]),1,
SELECTEDVALUE('Table (2)'[Slicer Team_Category])=MAX('Teams'[Team_Category_CATYModified]),1,0)
(5) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I am somehow unable to add the pbix. Adding snaps for your ref.
State in which nothing is selected from the dummy slicer:
What happens if I selected Category X , Category Y - Team E & F will appear under Category X, and Category Y accordinly.
This part is great, but I want it to have the ability to work like a slicer. Only rows that correspond to that category should remain in the table. That is where I am struggling.
To achieve the above, I created a Slicer Table within Powerbi which has a Column containing categories:
and has a measure called Value Type (that you see in the above Table visual screenshots) -
Hi @Judy101 ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a measure.
Flag = IF(OR([Value Type] in VALUES('Slicer Table'[Column1]),ISFILTERED('Slicer Table'[Column1])=FALSE()),1,0)
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This was super helpful thank you 🙂
I may have more questions wrt this slicer interacting with other visuals & slicers on the dashboard. I will get back on this chain 🙂
Hi @Judy101 ,
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please feel free to let me know.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Neeko,
I have rephrased my query. Hopefully the question makes more sense now.
Unfortunately, I am looking for DAX solution for this. So I cannot say it's resolved at this stage.
Go to Query editor ---->Split the category column Based on "&" ----> Unpivot all the splitted column and then save it.
now use your value column as slicer and in matrix to get desired result.
Hi Rupak,
I changed my query to make more sense. I do not think the original ask was clear.
I am looking for DAX to help here 🙂
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
26 | |
20 | |
19 | |
14 | |
13 |
User | Count |
---|---|
44 | |
36 | |
24 | |
24 | |
22 |