Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
HassanAshas
Helper V
Helper V

How can I create one slicer to filter a column containing upto three values separated by delimeter

I have a dataset like following, 

 

Emp CodeNameSkill
1MattAWS, Python, Django
2AveryAWS
3AryubAWS, Python, JavaScript
4JacobAzure, NodeJS
5ZaraNodeJS, React
6AliAzure, Python, PySpark
7JohnPySpark
8Alisha 
9NovakPython
10AlexDjango
11EmmaJavaScript, React, NodeJS

 

I want to create one slicer which will have distinct values for the "Skill" Column. I have a Table which simply shows the same table, like this, 

 

HassanAshas_0-1680077154532.png

I want to select the Distinct value from the Slicer and then filter whereever that Skill is present. For example, if I filter by "Python", then it should show me the Employees with Emp ID: 1, 3, 6, and 9. 

Similarly, if I filter by Django, then it should show Emp ID: 1 and 10. 

 

How can I achieve this? 

I know one possible way is to duplicate the rows and create as many rows as the number of skills are for each employee (by unpivotting table). So, for example, for Emp ID 1, I will have three different rows, but this approach will badly increase the data model size. 

Is there any other way to solve this? Thank you. 

 

You can download the Sample Power BI File from here: https://drive.google.com/file/d/1AFCPRLmGrNLAHjgsFL-dEqesAoNdLUQ5/view?usp=sharing

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @HassanAshas ,

 

Please try:

First create a new table with Skill column:

vjianbolimsft_0-1680228868177.png

Then split columns:

vjianbolimsft_1-1680228895896.png

Then create slicer with the new table:

vjianbolimsft_2-1680229739500.png

Note: These two tables do not have any relationship.

 

vjianbolimsft_3-1680229798356.png

Then apply the measure to the visual level filter:

Flag =
VAR _a =
    ADDCOLUMNS (
        VALUES ( 'For slicer'[Skill] ),
        "flag",
            SWITCH (
                TRUE (),
                [Skill] = BLANK ()
                    && SELECTEDVALUE ( Data[Skill] ) = BLANK (), 1,
                [Skill] <> BLANK ()
                    && CONTAINSSTRING ( SELECTEDVALUE ( Data[Skill] ), [Skill] ), 1,
                0
            )
    )
VAR _b =
    SUMX ( _a, [flag] )
VAR _c =
    DISTINCTCOUNT ( 'For slicer'[Skill] )
RETURN
    SWITCH (
        TRUE (),
        NOT ( ISFILTERED ( 'For slicer'[Skill] ) ), 1,
        ISFILTERED ( 'For slicer'[Skill] )
            && _b = _c, 1
    )

vjianbolimsft_4-1680230054097.png

Final output:

vjianbolimsft_5-1680230075011.png

vjianbolimsft_6-1680230087288.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
grazitti_sapna
Resolver I
Resolver I

Hey try using the below steps

Duplicate the table and split the column at the row level in the power query editor

grazitti_sapna_0-1683099604999.png

 

 

Name the duplicate table as skill slicer and change the cross-filter direction to both.

 

grazitti_sapna_1-1683099605003.png

 

Use the skill from the skill slicer table in the slicer to filter the data in the skill table.

Hi @grazitti_sapna 

Don't you think bidirectional filtering is a bad practice? Is there any alternative approach than using the bidirectional filtering? 

Hi @grazitti_sapna 

Don't you think bidirectional filtering is a bad practice? Is there any alternative approach than using the bidirectional filtering? 

v-jianboli-msft
Community Support
Community Support

Hi @HassanAshas ,

 

Please try:

First create a new table with Skill column:

vjianbolimsft_0-1680228868177.png

Then split columns:

vjianbolimsft_1-1680228895896.png

Then create slicer with the new table:

vjianbolimsft_2-1680229739500.png

Note: These two tables do not have any relationship.

 

vjianbolimsft_3-1680229798356.png

Then apply the measure to the visual level filter:

Flag =
VAR _a =
    ADDCOLUMNS (
        VALUES ( 'For slicer'[Skill] ),
        "flag",
            SWITCH (
                TRUE (),
                [Skill] = BLANK ()
                    && SELECTEDVALUE ( Data[Skill] ) = BLANK (), 1,
                [Skill] <> BLANK ()
                    && CONTAINSSTRING ( SELECTEDVALUE ( Data[Skill] ), [Skill] ), 1,
                0
            )
    )
VAR _b =
    SUMX ( _a, [flag] )
VAR _c =
    DISTINCTCOUNT ( 'For slicer'[Skill] )
RETURN
    SWITCH (
        TRUE (),
        NOT ( ISFILTERED ( 'For slicer'[Skill] ) ), 1,
        ISFILTERED ( 'For slicer'[Skill] )
            && _b = _c, 1
    )

vjianbolimsft_4-1680230054097.png

Final output:

vjianbolimsft_5-1680230075011.png

vjianbolimsft_6-1680230087288.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jianbo this is brilliantly clear answer to a very complex issue that I've been trying to resolve for some time, thank you. 

Hi@v-jianboli-msft

Could you help me? I'm trying to put this measure into the card visual, but I can't filter flag=1, can you tell me how to solve this problem? Thank you so much

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.