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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
joostvanham
Frequent Visitor

Check whether an ID has two specific values in another column

Hi,

 

Hopefully someone can help me with the following. I have a column with ID's that can have multiple values for another column. I'd like to count/filter all ID's that have a specific value for that other column. Small example:

 

Column with IDClassification
AX
BY
C<other>
AX
B<other>
CY

 

I would like to get all ID's that have value X AND Y in column "Classification". How can I do that?

 

Looking forward to your suggestions!

 

KR,

Joost

1 ACCEPTED SOLUTION
joostvanham
Frequent Visitor

Couldn't quite make the above solutions work. It has something to do with the fact that ID's reoccur a lot. I had to pivot the table and then count for X and Y if they were > 0 for the ID's in the table. If I created a X AND Y > 0 I could get the cross section I need. Thanks all for the support!

View solution in original post

9 REPLIES 9
joostvanham
Frequent Visitor

Couldn't quite make the above solutions work. It has something to do with the fact that ID's reoccur a lot. I had to pivot the table and then count for X and Y if they were > 0 for the ID's in the table. If I created a X AND Y > 0 I could get the cross section I need. Thanks all for the support!

v-jayw-msft
Community Support
Community Support

Hi @joostvanham ,

 

Create a measure as below and add it to visual filter to filter measure = 1 and you will get the IDs that have value X AND Y.

measure = 
var count_x = CALCULATE(DISTINCTCOUNT('Table'[Column with ID]),FILTER(ALLEXCEPT('Table','Table'[Column with ID]),'Table'[Classification]="X"))
var count_y = CALCULATE(DISTINCTCOUNT('Table'[Column with ID]),FILTER(ALLEXCEPT('Table','Table'[Column with ID]),'Table'[Classification]="Y"))
return
IF(count_x>0 && count_y>0, 1, 0)

 If you want a count of these IDs, you could create a sumx() measure.

Measure 2 = SUMX('Table',[measure])

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

I had a similar issue and this has resolved it. Thank you so much

Preeti_Yadav
Resolver I
Resolver I

Hi @joostvanham 

You can try creating the following measure:

 
Measure =
CALCULATE (
COUNT( 'Table'[a]),FILTER('Table','Table'[b] IN {"X" ,"Y"})
)
 
 
Did I answer your question? Mark my post as a solution!Give kudos!!

Thank you
Preeti

Hi Preeti,

 

Thank you! Your solution gives me OR X OR Y rather than the ID's that have an occurance for both X AND Y. Any thoughts there?

 

Kindest regards,

Joost

Hi @joostvanham 

As per your requirement you might try this :

 
Measure =
CALCULATE (
COUNT( 'Table'[a]),FILTER('Table','Table'[b] ="X" || 'Table'[b]="Y")
)
 
 
Did I answer your question? Mark my post as a solution!Give kudos!!

Thank you
Preeti
Fowmy
Super User
Super User

@joostvanham 

Create this measure:

Count = 

CALCULATE (
    COUNT( TABLE[ID]),
    TABLE[Classification] IN {"X","Y"} 
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi Fowmy,

 

Thank you! Your solution gives me OR X OR Y rather than the ID's that have an occurance for both X AND Y. Any thoughts there?

 

Kindest regards,

Joost

@joostvanham 

 

Based on your sample data, my calculation will give you a result of 4 as it counts x and y.  
If you need the distinct count then you can change the COUNT to DISTINCTCOUNT

 

can you share the expected result and how it should be calculated otherwise ?

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.