cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How do I count the number of rows containing specific values in a different table?

I need to write a measure that gives me the distinct count of items in one table that do not appear in another table.

 

Table1 appears as follows:

 

ID 

1001

1002

1003

1004

 

Table2 appears as follows:

 

ID        

1001

1002

1004

1001

1002

 

I want to write a measure that returns a result of 1 because ID 1003 in Table1 does not appear in Table2.

 

Any and all help would be greatly appreciated.

1 ACCEPTED SOLUTION
Zubair_Muhammad
Super User
Super User

@Anonymous 

 

Also you can use this MEASURE

 

Measure =
COUNTROWS ( EXCEPT ( VALUES ( Table1[ID] ), VALUES ( Table2[ID] ) ) )

Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Super User
Super User

@Anonymous 

 

Also you can use this MEASURE

 

Measure =
COUNTROWS ( EXCEPT ( VALUES ( Table1[ID] ), VALUES ( Table2[ID] ) ) )

Regards
Zubair

Please try my custom visuals
DoubleJ
Responsive Resident
Responsive Resident

You could do this in 2 steps:

  1.  Create a calculated column in Table1 that looks up if the ID exists in Table2:
    IsInTable2 = LOOKUPVALUE(Table2[ID],Table1[ID],Table1[ID])
    You can hide this column as it only stores an intermediate result.

  2. Create a measure that counts the Blanks in the created colum
    NotInTable2 = COUNTBLANK(Table1[IsInTable2])

Hope this helps

JJ

Anonymous
Not applicable

Thanks for the suggestion. I appreciate you taking the time to submit it.

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!