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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JemmaD
Helper V
Helper V

Help on a measure for counting distinct values

Hi there,

I have two categories say [Food Group] and [Food Type] and I need to highlight Food Groups which have more than one Food Type. 
So I have done a Distinct Count of Food Type and put it next to Food Group in a table then filtered the measure to >=2.

Works fine, it tells me that Fruit has 5 Food Types. But I want to expose the Food Types next to the Food Groups. As soon as I put Food Type in the table, it makes each value 1 so the data disappears and if I remove the filter, it simply pulls in the first found Food Type per Group. 

 

Can you help me with a way to show the following, but only Groups with more than one Food Type?

 

Food GroupFood Type
FruitApple
 Orange
 Banana
 Tomato
 Kiwi
VegetableBrocolli
 Kale
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Num food type =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Food Type] ),
    REMOVEFILTERS ( 'Table' ),
    VALUES ( 'Table'[Food Group] )
)

View solution in original post

3 REPLIES 3
mickey64
Super User
Super User

For your refeence.

 

Step 0: I use your data.

mickey64_0-1733844035884.png

 

Step 1: I make a measure and a matrix.

    Count = CALCULATE(COUNT(DATA[Food Type]),ALLEXCEPT('DATA','DATA'[Food Group]))

mickey64_1-1733844069043.png

 

johnt75
Super User
Super User

Try

Num food type =
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Food Type] ),
    REMOVEFILTERS ( 'Table' ),
    VALUES ( 'Table'[Food Group] )
)

Thank yiou @johnt75 this works perfectly! 

 

Actually- now I want it to do something else. It's repeating the total of 5 against every row of Food Type. Is there a way to show the value only once like in the sub total field? 
I've tried playing around with the sub-total field and formatting to make values white but it's not working. 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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