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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Evarie
Regular Visitor

Counting values which are present in two different tables

Hi everyone,

 

I've been looking for a good hour or so now and have had no luck finding an answer to my question, so I'm sorry if this has already been answered.

 

I have two different data tables which contain information about two different kinds of submissions businesses might make. These tables are related to each other via a Business lookup table which contains the Business ID values as the key. What I want is to be able to count the number of businesses which have entries in both tables, as shown below:

 

Data Table 1

Sub type A IDBusiness ID
a1A
a2B
a3C
a4D

 

Data Table 2

Sub type B IDBusiness ID
b1A
b2B
b3F
b4G

 

Lookup Table 1

Business IDName
AName 1
BName 2
CName 3
DName 4
EName 5
FName 6
GName 7

 

At this point I want a Measure which will count the number of businesses which have made both types of submission.


The result should be 2 in this case as Businesses A and B have made both types of submission.

 

Ultimately the goal is to have something like a pie chart which will show the total number of businesses with slices for those who have made 'A' submissions only, those who have made both 'A' and 'B' submissions, those who have made 'B' submissions only, and those who have made no submissions at all.

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Evarie ,

 

I can think of getting the intersection between the business id's in tables 1 and 2 and then counting the rows

test =
VAR __SUB1 =
    VALUES ( Table1[Business ID] )
VAR __SUB2 =
    VALUES ( Table2[Business ID] )
RETURN
    COUNTROWS ( INTERSECT ( __SUB1, __SUB2 ) )




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @Evarie ,

 

I can think of getting the intersection between the business id's in tables 1 and 2 and then counting the rows

test =
VAR __SUB1 =
    VALUES ( Table1[Business ID] )
VAR __SUB2 =
    VALUES ( Table2[Business ID] )
RETURN
    COUNTROWS ( INTERSECT ( __SUB1, __SUB2 ) )




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

You legend, thanks 🙂 today I learned about declaring variables! That will make things a lot easier in the future, haha!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors