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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
vnqt
Helper V
Helper V

Count rows comparing 4 columns in 2 indirectly related tables

Hi ,

 

I have 2 tables belows

Table1

HostDNSDNIDNA
AP00010.246.10null10.240
AP00010.246.10local10.240
AP00110.246.10null10.240
AP00210.246.10null10.240
AP00310.246.10null10.240
AP00410.246.10null10.240
AP00510.246.10null10.240
AP00610.111cloud10.255
AP80010.246.10null10.240
AP80010.246.11local10.241
AP80110.246.12null10.242
AP80210.246.13null10.243
AP80010.246.14cloudnull
AP80010.246.15null10.240
AP80910.246.16null10.240
AP81010.246.17null10.240
AP81110.246.18null10.240
AP81210.246.19null10.240
AP81310.246.20null10.240
AP99910.246.21red10.240
AP99910.246.22pro10.240
AP99910.246.23red10.240
AP99910.246.24red10.246

 

Table2

NameHostDNSDNIDNA
Name 1AP00010.246.10null10.240
Name 2AP00010.246.10local10.240
Name 3AP00110.246.10null10.240
Name 4AP00210.246.10null10.240
Name 5AP00310.246.10null10.240
Name 6AP00410.246.10null10.240
Name 7AP00510.246.10null10.240
Name 8AP00610.111cloud10.255
Name 9AP80010.246.10null10.240
Name 10AP80010.246.11local10.241
Name 11AP80110.246.12null10.242
Name 12AP80210.246.13null10.243
Name 13AP80010.246.14cloudnull
Name 14AP80010.246.15null10.240
Name 15AP80910.246.16null10.240
Name 16AP81010.246.17null10.240
Name 17AP81110.246.18null10.240
Name 18AP81210.246.19null10.240
Name 19AP81310.246.20null10.240
Name 20AP999 red10.240
Name 21AP999 pro10.240
Name 22AP999 red10.240
Name 23AP999 red10.246
Name 24AP000 null10.240
Name 25AP00010.246.10local 
Name 26AP00110.246.10null 
Name 27AP00210.246.10null 
Name 28AP00310.246.10null 
Name 29AP00410.246.10null 
Name 30AP00510.246.10null10.240
Name 31AP00610.111cloud10.240
Name 32AP80010.246.10null10.240
Name 33AP80010.246.11local 
Name 34AP80110.246.12null10.240
Name 35AP80210.246.13null10.240
Name 36AP80010.246.14cloud10.255

 

I would like to add to table 1 a column : total of Names that 4 columns have same values as 4 columns in table 2. And I can have a list of name. 

Or a measure counts the names of the same Host that has the same value of DNS, DNA, DNI.

for exemple : 

 

Thank you in advance for your help.

1 ACCEPTED SOLUTION

Hi @vnqt ,

 

Please try following DAX:

Name list1 = CALCULATE(MAX('Table2'[Name]),FILTER('Table2','Table2'[Host] = 'Table1'[Host] && 'Table2'[DNS] = 'Table1'[DNS] && 'Table2'[DNI] = 'Table1'[DNI] && 'Table2'[DNA] = 'Table1'[DNA]))

Name list2 = 
IF('Table1'[Total of Names] > 1,CALCULATE(MIN('Table2'[Name]),FILTER('Table2','Table2'[Host] = 'Table1'[Host] && 'Table2'[DNS] = 'Table1'[DNS] && 'Table2'[DNI] = 'Table1'[DNI] && 'Table2'[DNA] = 'Table1'[DNA])))

 

Name list:

vyadongfmsft_0-1665645157693.png

 

If you want to export, you can copy table to excel.

 

Best regards,

Yadong Fang

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

View solution in original post

7 REPLIES 7
v-yadongf-msft
Community Support
Community Support

Hi @vnqt ,

 

Please create a new column:

Total of Names = CALCULATE(COUNT('Table2'[Name]),FILTER('Table2','Table2'[Host] = 'Table1'[Host] && 'Table2'[DNS] = 'Table1'[DNS] && 'Table2'[DNI] = 'Table1'[DNI] && 'Table2'[DNA] = 'Table1'[DNA]))

 

The result you want:

vyadongfmsft_0-1665541953905.png

 

Best regards,

Yadong Fang

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

Thank you for your solution. could you please advise how to export the list of Name for each Host ? 

 

 

Hi @vnqt ,

 

Please try following DAX:

Name list1 = CALCULATE(MAX('Table2'[Name]),FILTER('Table2','Table2'[Host] = 'Table1'[Host] && 'Table2'[DNS] = 'Table1'[DNS] && 'Table2'[DNI] = 'Table1'[DNI] && 'Table2'[DNA] = 'Table1'[DNA]))

Name list2 = 
IF('Table1'[Total of Names] > 1,CALCULATE(MIN('Table2'[Name]),FILTER('Table2','Table2'[Host] = 'Table1'[Host] && 'Table2'[DNS] = 'Table1'[DNS] && 'Table2'[DNI] = 'Table1'[DNI] && 'Table2'[DNA] = 'Table1'[DNA])))

 

Name list:

vyadongfmsft_0-1665645157693.png

 

If you want to export, you can copy table to excel.

 

Best regards,

Yadong Fang

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

Hi ,

 

We have many Hosts  that have more than 50 names. Creating a dax for each name is not a convenient solution. Could you help if there is other solution ? 

 

Thank you in advance. 

 

 

Hi @vnqt ,

 

Can you tell me what's your expected output?

 

Best regards,

Yadong Fang

Hi ,

 

We have many Hosts  that have more than 50 names. Creating a dax for each name is not a convenient solution. Could you help if there is other solution ? 

 

Thank you in advance. 

 

Hi @vnqt ,

 

I think the method I provided is a very effective method, although a little inconvenient, please try it.

 

Best regards,

Yadong Fang

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.