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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
jam17
Helper I
Helper I

Evaluate number of unique values in a column

I'm trying to write a measure that returns a true/false if all the values in a filtered table column are the same or not.

Example:

IDSale
123$50
123$60
456$20


I don't want to do any aggregating of the Sale value, but I want to give a visual indicator (changing the color of the the text) that the table has been filtered down to a single ID (assume there are other columns giving details about the individual sales, and the stakeholder would be interested in seeing the line items for a single ID at a time).

I am looking for a measure I can use to evaluate if the ID filter has been applied, such that only IDs of the same value appear in the table.  I tried doing COUNT and DISTINCTCOUNT, such that I could write the rule to be if the number of uniques = 1 then apply, but it's only evaluating on a row basis:

IDSalesUnique
123$502
123$602
456$201


What I would be expecting though is the UNIQUE column would show 2 for all rows, because there are 2 unique ID values, instead of telling me how many rows there are for each ID.

DAX is new to me, and if I were trying to do this in R in would be a simple: measure <- IF(length(unique(Table[ID])=1, #000000, #CCCCCC)   -- but I can't figure out how to translate that to DAX

1 ACCEPTED SOLUTION
Selva-Salimi
Super User
Super User

Hi @jam17 

 

It's not that much clear for me. are you looking for count of ID's?? if so, then you can write a measure as follows:

 

measure _count := calculate(DISTINCTCOUNT('your_Table'[ID]) , ALLSELECTED('your_table'))
 
If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
jam17
Helper I
Helper I

I am pulling in a Table Vis onto the report to display line items of sales (among other summary cards).

With no filtering, it will show all line items.  I have a slicer on my report to select a particular ID (customer), which filters the Table Vis to just those sales with that ID.  I want something to indicate that the Table Vis is only displaying a single ID's worth of information.

Table Vis (unfiltered)

IDs
123
123
456
789
456

Here there is more than one unique ID in the list.  Text should be grey.
>> APPLY SLICER: ID = 123 <<
Table Vis Filter

ID
123
123

Here this is only one unique ID.  Text should be black.

@jam17 

 

you can use the measure in previous post in setting, cell elements, font color , and define rule.

 

If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly. 

Selva-Salimi
Super User
Super User

Hi @jam17 

 

It's not that much clear for me. are you looking for count of ID's?? if so, then you can write a measure as follows:

 

measure _count := calculate(DISTINCTCOUNT('your_Table'[ID]) , ALLSELECTED('your_table'))
 
If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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