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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
nirrobi
Helper V
Helper V

Find the difference between 2 columns PQ / DAX

Hi all ,

I have table similar to the below.

I need to have have column that check if column 2 & 3 are identical - easy

I also need to have column that show the differnce between the columns

 

e.g.

1   identical

2   A - missing A

3   A - additional A

4 - ,  - additional ,

5 - space

 

is it possible to acheive with PQ / DAX ?

 

 

Column1Column2Column3

1AAAAAA
2AAAAA
3AAAAAAA
4ABAB,
5AAAA A
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @nirrobi,

 

You can add a custom column in Query Editor:

if ([Column1] = [Column2]) then
"identical"
else
if (Text.Length([Column1]) > Text.Length([Column2])) then
Text.Replace([Column1], [Column2], "") &"- missing "& Text.Replace([Column1], [Column2], "")
else
if (Text.Length([Column1]) < Text.Length([Column2])) then
Text.Replace([Column2], [Column1], "") &"- additional "& Text.Replace([Column2], [Column1], "")
else
""

This solves everything except point 5 in your example, but it's a good approach.

 

Regards.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @nirrobi,

 

You can add a custom column in Query Editor:

if ([Column1] = [Column2]) then
"identical"
else
if (Text.Length([Column1]) > Text.Length([Column2])) then
Text.Replace([Column1], [Column2], "") &"- missing "& Text.Replace([Column1], [Column2], "")
else
if (Text.Length([Column1]) < Text.Length([Column2])) then
Text.Replace([Column2], [Column1], "") &"- additional "& Text.Replace([Column2], [Column1], "")
else
""

This solves everything except point 5 in your example, but it's a good approach.

 

Regards.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors