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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
tgjones43
Helper IV
Helper IV

Measure to identity values in one column which have multiple values in another column

Hi all

 

I need a measure to return True if there is more than one unique value for each unique value in another column. So in the below example, it should return False for value 1 in ID1 (as there is only 1 unique value in ID2) but True for value 2 in ID1 (because there are 2 unique values in ID2).

 

ID1ID2Value
1A1
1A2
1A3
2

A

1
2A2
2A3
2B1
2B2
2B3

 

Thank you!



1 ACCEPTED SOLUTION
rsbin
Super User
Super User

@tgjones43 ,

Hope this Measure works for you:

Unique = IF( CALCULATE( DISTINCTCOUNT( 'Table'[ID2] ),
                 ALLEXCEPT( 'Table','Table'[ID1] )) = 1, 
                 "False", "True" )

rsbin_1-1719328988407.png

Regards,

View solution in original post

4 REPLIES 4
rsbin
Super User
Super User

@tgjones43 ,

Hope this Measure works for you:

Unique = IF( CALCULATE( DISTINCTCOUNT( 'Table'[ID2] ),
                 ALLEXCEPT( 'Table','Table'[ID1] )) = 1, 
                 "False", "True" )

rsbin_1-1719328988407.png

Regards,

UPDATE: I forgot that my file was a csv, which was preventing me from adding measures. 😅

However, I'm not sure that it's working right now that I was able to create it. What is the way that this could be created as a calculated column, @tgjones43 ?

----

Hello. I think this solution is just what I need for my own data except I don't understand where to put this function. I'm sure this is very basic information but can you please demonstrate where I put this? My data is a table loaded from a power query query.

When I try to put it in as a step in my query I get an error "Expression.Error: The name 'IF' wasn't recognized. Make sure it's spelled correctly." If I change "IF" to "if" I get an error saying then is expected, then else is expected then "Token Eof expected". If I then remove the ) at the end it says "CALCULATE" isn't recognized.
I get the same when I try to make this a function. 

If this is supposed to be a pivot table measure, I can't figure out how to get a measure in (the options under power pivot are always all greyed out, even when I add a pivot table). 

Any help would be apprectiated.

@petrawiggin ,

This was originally created as a DAX Measure.

What you are doing above is trying to use DAX as an M Query in PQ.

Once you have loaded all of your data, go to your Power BI report  and create a "New Measure.

rsbin_0-1723553884708.png

Hope this helps.

Regards,

@rsbin it does, thank you! As a calculated column, rather than a measure, but that's fine.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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