cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Roym
Helper III
Helper III

Filter to only show unique values

I have a table in the following format as shown in the table below. Now I want to make a table in my report that only show unique 'items' that don't have a medium classifiction. So based on the below example I only want to see 'Item 2' as that one does not have a medium classification. Anyone an idea on how I could achieve this?

 

Item 1

Low

Item 1Medium
Item 2Low
Item 2Low
Item 2Low
1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @Roym ,

 

you can create a mesure that is checking if the item in each row contains a "Medium" value. Then you can filter the visual by that measure.

I created the following measure:

ItemsWitoutMedium = 
VAR vFilteredTable =
    FILTER (
        ADDCOLUMNS (
            -- Get unique values from [Item]
            VALUES ( myTable[Item] ),
            -- Count for each item the number of rows that contain "Medium"
            "@HasMediumVAlue", CALCULATE ( COUNTROWS ( myTable ), myTable[Classification] = "Medium" )
        ),
        -- Filter for [Items] without "Medium" values
        [@HasMediumVAlue] = BLANK ()
    )
RETURN
    -- return a 1 if the item has no "Medium"
    COUNTX ( vFilteredTable, IF ( [@HasMediumVAlue] = BLANK (), 1) )

 

And then you can filter the visual:

selimovd_0-1660047959527.png

 

I uploaded my example file to this post.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

 

View solution in original post

2 REPLIES 2
selimovd
Super User
Super User

Hey @Roym ,

 

you can create a mesure that is checking if the item in each row contains a "Medium" value. Then you can filter the visual by that measure.

I created the following measure:

ItemsWitoutMedium = 
VAR vFilteredTable =
    FILTER (
        ADDCOLUMNS (
            -- Get unique values from [Item]
            VALUES ( myTable[Item] ),
            -- Count for each item the number of rows that contain "Medium"
            "@HasMediumVAlue", CALCULATE ( COUNTROWS ( myTable ), myTable[Classification] = "Medium" )
        ),
        -- Filter for [Items] without "Medium" values
        [@HasMediumVAlue] = BLANK ()
    )
RETURN
    -- return a 1 if the item has no "Medium"
    COUNTX ( vFilteredTable, IF ( [@HasMediumVAlue] = BLANK (), 1) )

 

And then you can filter the visual:

selimovd_0-1660047959527.png

 

I uploaded my example file to this post.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

 

Great! this works perfectly, thanks!!

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors