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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bjanzen
Frequent Visitor

Comparing 2 columns for matches

Hello Everyone,

       I have been trying to solve for a problem to see what is possible.

 

I have two tables that contain subnets. 

 

 Table 1

Subnets

10.0.50.0

10.0.60.0

10.0.70.0

 

Table 2

10.0.50.0

10.0.70.0

10.0.80.0

 

I would like to compaire the 2 tables to have a pie char to say something like true/false depending on if there are matches.

 

I am a little lost as to what command would allow that type would something like ISERROR  work for this?

 

thanks for any pointers!

 

Brett

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi bjanzen,

 

Based on your description, you want to compare column Subnets in two tables row by row, right?

 

To achieve your requirement, please follow steps below:

1.Create index column in two tables, click Edit Queries->Add Column->Index Column.

1.PNG

2.Create relationship between two tables based on index column, click Manage Relationships->New->Select index column in table1->Select index column in table2->One to One and Both direction->Make this relationship Active->Apply security filter in both directions.

 2.PNG3.PNG

3.After a relationship has been built, you can create a measure two compare two columns of different table:

Compare = IF(Table1[Subnets] = RELATED(Table2[Subnets]), 0, 1)

4.Then calculate the number of matched Subnets and unmatched Subnets using DAX formula below:

Number Of True = CALCULATE(COUNT(Table1[Index]), FILTER(Table1, Table1[Compare] = 0))
Number Of False = CALCULATE(COUNT(Table1[Index]), FILTER(Table1, Table1[Compare] = 1))

5.In final, create a pie chart to compare number of Subnets in two table like below:

4.PNG

You can refer to the sample PBIX file here: https://www.dropbox.com/s/3rzo88hjpi7lx5t/For%20bjanzen.pbix?dl=0

 

Best Regards,

Jimmy Tao

View solution in original post

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

Hi bjanzen,

 

Based on your description, you want to compare column Subnets in two tables row by row, right?

 

To achieve your requirement, please follow steps below:

1.Create index column in two tables, click Edit Queries->Add Column->Index Column.

1.PNG

2.Create relationship between two tables based on index column, click Manage Relationships->New->Select index column in table1->Select index column in table2->One to One and Both direction->Make this relationship Active->Apply security filter in both directions.

 2.PNG3.PNG

3.After a relationship has been built, you can create a measure two compare two columns of different table:

Compare = IF(Table1[Subnets] = RELATED(Table2[Subnets]), 0, 1)

4.Then calculate the number of matched Subnets and unmatched Subnets using DAX formula below:

Number Of True = CALCULATE(COUNT(Table1[Index]), FILTER(Table1, Table1[Compare] = 0))
Number Of False = CALCULATE(COUNT(Table1[Index]), FILTER(Table1, Table1[Compare] = 1))

5.In final, create a pie chart to compare number of Subnets in two table like below:

4.PNG

You can refer to the sample PBIX file here: https://www.dropbox.com/s/3rzo88hjpi7lx5t/For%20bjanzen.pbix?dl=0

 

Best Regards,

Jimmy Tao

That is exactly what I am trying to do, thanks so much for this. 

 

The more and more I use Power BI the more potential I can see this tool having.

 

thanks @v-yuta-msft!
Brett

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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