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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Tevon713
Helper IV
Helper IV

Distinct Count of 2 tables if they matches + specific value

Hi All... I have 2 tables.

 

Created a measure is to find distinct count of "Acct" in table 1:  

Count Unique Acct = DISTINCTCOUNT(Table1[Acct]) or should it be count row?

 

I also need help in trying to find the following:

1. Find matches of "Acct" in Table 2 to "Acct" in Table 1 if so then return distinct count or count row.

2. Second part similar to previous #1 but to find distinct count for specific region ie "East" in Table 2 is 2 as 2 matches to table 1 and "West" should be 1 and so on.

 

Tevon713_0-1667341983206.png

 

Thank you all for your help.

 

1 ACCEPTED SOLUTION

Thanks @Anonymous.

 

I was thinking something more along the line of the following, which appeared to work.

 

Matches Measure = CALCULATE(DISTINCTCOUNT(Table2[Acct]) , FILTER(Table2,LOOKUPVALUE(Table1[Acct],Table1[Acct], Table2[Acct])))
 
Tevon713_0-1667396427712.png

And for specific region be like this.... 

 

Matches Measure 2 = CALCULATE(DISTINCTCOUNT(Table2[Acct]) , FILTER(Table2,LOOKUPVALUE(Table1[Acct],Table1[Acct], Table2[Acct])), Table2[Region]="East")

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Tevon713 ,

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _select=SELECTCOLUMNS('Table2',"1",[Acct])
var _table1=
SUMMARIZE('Table1','Table1'[Acct],'Table1'[Region],
"Flag",IF('Table1'[Acct] in _select,1,0))
return
IF(
    MAX('Table2'[Region]) in SELECTCOLUMNS(_table1,"Region",[Region]) ,
    COUNTX(FILTER(_table1,[Flag]=1),[Region]))

2. Result:

vyangliumsft_0-1667353608475.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thanks @Anonymous.

 

I was thinking something more along the line of the following, which appeared to work.

 

Matches Measure = CALCULATE(DISTINCTCOUNT(Table2[Acct]) , FILTER(Table2,LOOKUPVALUE(Table1[Acct],Table1[Acct], Table2[Acct])))
 
Tevon713_0-1667396427712.png

And for specific region be like this.... 

 

Matches Measure 2 = CALCULATE(DISTINCTCOUNT(Table2[Acct]) , FILTER(Table2,LOOKUPVALUE(Table1[Acct],Table1[Acct], Table2[Acct])), Table2[Region]="East")

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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