Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I am trying to build a slicer that allows multiple selections from dropdown which then filters out the dataset based on the selections.
getting a single selection was quite easy by using:
Solved! Go to Solution.
Hi @Anonymous ,
In this case you need to do a different setup use the following measure:
Product selected exists =
VAR SplitByCharacter = ","
VAR ProductTableSelection =
SELECTCOLUMNS (
ADDCOLUMNS (
GENERATE (
SELECTCOLUMNS (
Solution_Products;
"Find_Text"; Solution_Products[SolutionProducts]
);
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ) )
RETURN
GENERATESERIES ( 1; TokenCount )
);
"Product_selection"; PATHITEM ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ); [Value] )
);
"Products_Selected"; [Product_selection]
)
RETURN
IF (
COUNTROWS (
FILTER (
ALLSELECTED ( Products );
FORMAT ( Products[Product]; "#" ) IN ProductTableSelection
)
)
= COUNT ( Products[Product] );
"Yes";
"No"
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Anonymous ,
One option can be to use the following code:
Product selected exists = IF(
SUMX(Products;
FIND(
UPPER(Products[Product]);
UPPER(SELECTEDVALUE(Solution_Products[SolutionProducts]))
;;0
)
) > 0;
"Yes";
"No"
)
Has you can see below the values are filtered out:
You can now use the measure has a filter on your visualizations you can also replace the No by blank.
PBIX file attach.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi Miguel,
Thank you for this. This is definitely a lot closer.
thre is 1 thing that I need to change on here. Your code filters based on 'OR' so that if I select 4 and 6, rows 2,3,and 4 appear. However, I need the filter to be an 'AND' so that only row 3 should say "Yes"
Many thanks,
Marc
Hi @Anonymous ,
In this case you need to do a different setup use the following measure:
Product selected exists =
VAR SplitByCharacter = ","
VAR ProductTableSelection =
SELECTCOLUMNS (
ADDCOLUMNS (
GENERATE (
SELECTCOLUMNS (
Solution_Products;
"Find_Text"; Solution_Products[SolutionProducts]
);
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ) )
RETURN
GENERATESERIES ( 1; TokenCount )
);
"Product_selection"; PATHITEM ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ); [Value] )
);
"Products_Selected"; [Product_selection]
)
RETURN
IF (
COUNTROWS (
FILTER (
ALLSELECTED ( Products );
FORMAT ( Products[Product]; "#" ) IN ProductTableSelection
)
)
= COUNT ( Products[Product] );
"Yes";
"No"
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi Miguel,
That is perfect thank you.
Marking as solved.
Can have default showing by adding another if to allow for show all when nothing selected.
To do that, I added another coutrows section but instead of having
= COUNT ( Products[Product] );
I added
> 1;
Hi @Anonymous ,
you can ue isfiltered syntax see formula adjusted below:
Product selected exists =
VAR SplitByCharacter = ","
VAR ProductTableSelection =
SELECTCOLUMNS (
ADDCOLUMNS (
GENERATE (
SELECTCOLUMNS (
Solution_Products;
"Find_Text"; Solution_Products[SolutionProducts]
);
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ) )
RETURN
GENERATESERIES ( 1; TokenCount )
);
"Product_selection"; PATHITEM ( SUBSTITUTE ( [Find_Text]; SplitByCharacter; "|" ); [Value] )
);
"Products_Selected"; [Product_selection]
)
RETURN
IF(
ISFILTERED(Products[Product]);
IF (
COUNTROWS (
FILTER (
ALLSELECTED ( Products );
FORMAT ( Products[Product]; "#" ) IN ProductTableSelection
)
)
= COUNT ( Products[Product] );
"Yes";
"No"
);
"Yes"
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsCovering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
152 | |
120 | |
102 | |
87 | |
68 |