Forum Discussion
How to filter table where a column has multiple comma delimited values
- 2 years ago
Thanks but this didn't work as expected. When selecting all options it showed all rows when it should only show rows if all options were assigned in the Fruits column (comma seperated) to the row.
However, I have managed to work it out.
TABLES
Measure =
MEASUREVAR selValues = CONCATENATEX(VALUES(Slicer[Fruit]),Slicer[Fruit],", ",Slicer[Fruit],ASC)VAR selCount = COUNTROWS(ALLSELECTED(Slicer[Fruit]))VAR sTableselCount = CALCULATE(COUNTROWS(Table),Table[AssignedCount]=selCount)VAR sTableselValues = CALCULATE(COUNTROWS(Table),Table[Fruits]= selValues)VAR sResults = IF(sTableselCount>0 && sTableselValues >0,1)RETURNIF(NOT ISFILTERED(Slicer[Fruit]),0,sResults)
Add the measure to the table filter as below
Hi DTPBI ,
Please try this measure:
Measure =
VAR __cur_fruit = SELECTEDVALUE('Table1'[FRUITS])
VAR __fruits = VALUES('Table2'[FRUITS])
VAR __slicer_count = COUNTROWS(ALLSELECTED('Slicer'[SLICER]))
VAR __table_count = CALCULATE(COUNTROWS('Table2'),'Table2'[FRUITS] IN __fruits && 'Table2'[FRUITS]=__cur_fruit)
VAR __table_count_2 = CALCULATE(COUNTROWS('Table2'),'Table2'[FRUITS]=__cur_fruit,ALLEXCEPT('Table2','Table2'[FRUITS]))
VAR __result = IF(__cur_fruit IN __fruits && __slicer_count = __table_count && __slicer_count = __table_count_2, 1)
RETURN
__result
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group
Thanks again for your assistance. I managed to get it working based on my original post and modifying some of your logic using this measure:
Note: Fruits[AssignedCount] is a calculated column in the Fruits table to count number of assigend fruits per row.
I then add the above measure to the table as a filter and select show items where Is Not Blank.
I still have one issue, while this works perfectly when there are slections in the slicer, it does not display any rows in the table where no selections have been made in the slicer. I would like the table to display all rows in that sceanrio.
- Ashish_Mathur2 years ago
Super User
Hi,
PBI file attached.
- DTPBI2 years agoFrequent Visitor
Thanks but this didn't work as expected. When selecting all options it showed all rows when it should only show rows if all options were assigned in the Fruits column (comma seperated) to the row.
However, I have managed to work it out.
TABLES
Measure =
MEASUREVAR selValues = CONCATENATEX(VALUES(Slicer[Fruit]),Slicer[Fruit],", ",Slicer[Fruit],ASC)VAR selCount = COUNTROWS(ALLSELECTED(Slicer[Fruit]))VAR sTableselCount = CALCULATE(COUNTROWS(Table),Table[AssignedCount]=selCount)VAR sTableselValues = CALCULATE(COUNTROWS(Table),Table[Fruits]= selValues)VAR sResults = IF(sTableselCount>0 && sTableselValues >0,1)RETURNIF(NOT ISFILTERED(Slicer[Fruit]),0,sResults)
Add the measure to the table filter as below