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 August 31st. Request your voucher.

Reply
serhii2000
Frequent Visitor

DAX measure to count ID's that have items in another table

Dear collegues!
I need to count People_ID in 'People' table that have Item_A_ID in 'Item_A' table. The final task is to have share of People_ID in 'People' table that have Item_A_ID in 'Item_A' table.

Now, I have counted People_ID as People_count = COUNT('People'[People_ID]).

My initial solution was to create calculated column in 'People' table that calculates number of Item_A_ID from 'Item_A' table (each People_id could have 0, 1 or more such items). And then I have created measure CALCULATE(COUNT('People'[People_ID]),'People'[Number_Of_ItemA_ID]>=1). But it does not allow to filter share of People_ID by Category ID.

Could you advice me about possible solution with DAX measure?

Thank you in advance.

 

 

model.png

1 ACCEPTED SOLUTION

@serhii2000 

I was having a 2nd read of your requirement. Actually the DISTINCTCOUNT of the people ID which do exist in Items A table will give you the number you desire and will be filtered by Category. 
Measure = DISTINCTCOUNT ( 'Items A'[People ID] )

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

Hi @serhii2000 

you can try

CALCULATE(COUNT('People'[People_ID]),'People'[Number_Of_ItemA_ID]>=1,CROSSFILTER (People[People ID], 'Items A'[People ID], BOTH)).

Thank you for your reply. But unfortunately it does not work for me. I guess it is because of calculated column 'People'[Number_Of_ItemA_ID], not measure. Slicer with CategoryID cannot filter share of People_ID by Category ID. But I am not sure how to solve it.

@serhii2000 

I was having a 2nd read of your requirement. Actually the DISTINCTCOUNT of the people ID which do exist in Items A table will give you the number you desire and will be filtered by Category. 
Measure = DISTINCTCOUNT ( 'Items A'[People ID] )

Thank you! I did not accept your solution earlier because there was an extra active relationship in my model, that was not described in my question. I have deactivated unnecessary active relationship with wrapping it in CALCULATE with CROSSFILTER=none and your solution works well.

The task is to count People_ID in 'People' table that exist in 'Item_A' table, not just to count distinct People_ID in 'Item_A' table. And at the same time I need to have possibility to filter People_ID by Category....

 

In other words I need to have

#1 count of all People_ID in 'People' table

#2 count of People_ID in 'People' table that exist in 'Item_A' table in order to have share of #1

#3 create slicer that filters #2 by Category

"The task is to count People_ID in 'People' table that exist in 'Item_A' table"

this is exactly the People_ID that exist in Item_A Table!
Just count them!

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.