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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
simon-uk
Frequent Visitor

Compare 2 rows in 2 tables and find the number of differences

Hi

 

I am trying to compare the rows in 2 tables to return the number fo difference in a single row with the same key:

Table 1

Entity        Param 1   Param 2    Param 3   Param 4   Param 5    Param 6    Param 7 Param 8      Param 9 Param 10 Param 11

Test                 11            2            3          4             5           6            7          19            9          12          11

 

Table 2

Entity         Param 1  Param 2    Param 3    Param 4  Param 5    Param 6    Param 7   Param 8   Param 9   Param 10 Param 11

Test                 1           2    3    45678910  11

 

I would expect to return

 

Test = 4 differences (utlimately I would like to drill to those diefferneces)

 

Can anyone help

1 ACCEPTED SOLUTION

The unpivotting is done in the Query Editor and will be applied on every refresh of the data. This means Power BI will do;

1. retrieve the data in original format

2. Applies all steps as per Query Definition

3. Updates all visuals.

 

In step two is the unpivoting of the tables and will persist 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Kudo's are welcome 🙂





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

Proud to be a Super User!




View solution in original post

3 REPLIES 3
JarroVGIT
Resident Rockstar
Resident Rockstar

Interesting question, I gave it a shot by doing the following;

I've created two tables with Entity and 5 Param columns:

Table1Table1

Table2 - Note Param1 en Param4Table2 - Note Param1 en Param4

 

Comparing these in current form is very difficult, so I unpivoted the Param-columns in both;

Tabel2 - Unpivoted and renamed columnsTabel2 - Unpivoted and renamed columnsTabel1 - Unpivoted and renamed columnsTabel1 - Unpivoted and renamed columns

 

Now, we can create a calculated column in one of the tables (I've chosen Table1) and entity by entity (in this case just 'Test') check whether the value corresponding with the Param(X) is the same in Table 2. The formula is:

 

 

IsNotTheSame = CALCULATE(COUNTA(Table1[ParamValue]), FILTER(Table2, Table2[Entity] = Table1[Entity] && Table2[Params] = Table1[Params] && Table2[ParamValue] <> Table1[ParamValue]))

 

 

Now, you can use this column in calculating how many discrepancies there are between Entities in Table1 and Table2:

image.png

 

 

Please mark this answer as Solution if this answered your question 🙂





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

Proud to be a Super User!




Hi djerro123

 

Nice neat answer but......can I automate the unpivot and rename functions as my source data is in the 'pivotted' format?

 

Regards

 

Simon

The unpivotting is done in the Query Editor and will be applied on every refresh of the data. This means Power BI will do;

1. retrieve the data in original format

2. Applies all steps as per Query Definition

3. Updates all visuals.

 

In step two is the unpivoting of the tables and will persist 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Kudo's are welcome 🙂





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

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.