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
Begbie
Helper I
Helper I

Filter data in table based on silcer

Hi All,

 

I'm hoping someone can point me in the right direction here, as my PBI isn't the best. 

 

Currently, I have a report that has a slicer in it, with options of:

 

Secure API

Secure Code

Secure Infrastructure

etc...

 

When a user choose one of those slicer options, it changes the data displayed on the table within the report, usual PBI stuff 😊 but what I'm trying to figure out is to filter the data in the table based on the slicer option choosen.

 

For example:

 

If they choose Secure API, I would like the table to only show results that have 'Devops' & 'CD' in it. 

If they choose Secure Code, I would like the table to only show results that have 'Devops', 'CD' & 'Classic' in it.

If they choose Secure Infrastructure, I would like the table to only show results that have 'Classic' in it.

etc..

 

I think it is possible, but seems my Google-Fo skills isn't quite pointing me in the right direction to help me get to what I'm trying to achieve.

 

Any helps or pointers are greatly appreciated.

 

Many thanks 👍

2 ACCEPTED SOLUTIONS

Try creating a measure to use as a filter for the visual. You will need an independent table for the slicer selection

Let the independent table values be DSlicer[Value], the fact table be FactTable and the selection column be FactTable[Selection])

 

Filter measure =
SWITCH (
    SELECTEDVALUE ( DSlicer[Value] ),
    "Secure API",
        COUNTROWS (
            CALCULATETABLE ( FactTable, FactTable[Selection] IN { "Devops", "CD" } )
        ),
    "Secure Code",
        COUNTROWS (
            CALCULATETABLE (
                FactTable,
                FactTable[Selection] IN { "Devops", "CD", "Classic" }
            )
        ),
    "Secure Infrastructure",
        COUNTROWS (
            CALCULATETABLE ( FactTable, FactTable[Selection] IN { "Classic" } )
        )
)

 

Select the visual and add this measure as a filter, setting the value to greater or equal to 1





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

@PaulDBrown 

 

Just wanted to say thank you for the above and this seems to have resolved my issue 😀

 

No idea how you guys do it and have all this knowledge, but the above solution with the measure helped achieve what I wanted, so a big thank you from me!!

View solution in original post

6 REPLIES 6
BA_Pete
Super User
Super User

Hi @Begbie ,

 

Define a dimension table (dimSlicer) like this:

 

|  slicerValue  |  codeToInclude  |
-----------------------------------
|  Secure API   |  Devops         |
|  Secure API   |  CD             |
|  Secure Code  |  Devops         |
|  Secure Code  |  CD             |
|  Secure Code  |  Classic        |
|  ...

 

 

Define a bridge table (codeBridge) that is just a unique list of codes to include:

 

|  codeToInclude  |
-------------------
|  Devops         |
|  CD             |
|  Classic        |
|  ...

 

 

In your data model, relate as follows:

 

- dimSlicer[codeToInclude] MANY : ONE codeBridge[codeToInclude] (filter direction BOTH)

- codeBridge[codeToInclude] ONE : MANY factTable[Code]

 

Use dimSlicer[slicerValue] in your page slicer.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi Pete,

 

Thank you for the pointers and that has seemed to help with the solution, but seems I now have double / triple entries in my table 😣
This is what is being shown when I use the dimSlicer suggestion you gave above:

Begbie_0-1645613355044.png

Whereas before it would show:

Begbie_1-1645613397428.png

 

I'm sure it's probably down to something silly.

 

Thanks.

Hi @Begbie ,

 

Where did you get this column from?

BA_Pete_0-1645624209462.png

It appears to be what is causing the row duplication.

I don't think this column should come from either of the tables that we added before, but rather from the [code] column in your fact table.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi @BA_Pete 

 

Thank you for coming back to me. Yes, it did seem I did choose the wrong column initially, but then I had other things happen where the data didn't filter quite correctly, but PaulDBrown solution seems to have helped me for what I needed to do.

 

Thanks again 😊

Try creating a measure to use as a filter for the visual. You will need an independent table for the slicer selection

Let the independent table values be DSlicer[Value], the fact table be FactTable and the selection column be FactTable[Selection])

 

Filter measure =
SWITCH (
    SELECTEDVALUE ( DSlicer[Value] ),
    "Secure API",
        COUNTROWS (
            CALCULATETABLE ( FactTable, FactTable[Selection] IN { "Devops", "CD" } )
        ),
    "Secure Code",
        COUNTROWS (
            CALCULATETABLE (
                FactTable,
                FactTable[Selection] IN { "Devops", "CD", "Classic" }
            )
        ),
    "Secure Infrastructure",
        COUNTROWS (
            CALCULATETABLE ( FactTable, FactTable[Selection] IN { "Classic" } )
        )
)

 

Select the visual and add this measure as a filter, setting the value to greater or equal to 1





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown 

 

Just wanted to say thank you for the above and this seems to have resolved my issue 😀

 

No idea how you guys do it and have all this knowledge, but the above solution with the measure helped achieve what I wanted, so a big thank you from me!!

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.