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
vnqtrang
Helper I
Helper I

Compare strings of columns in different tables

Hello,

 

I would like to compare the strings of 2 tables A and B to the table Source: 

 

TableSource

CodeNameSerial number
TE230SXMAC231
TE231SXMBC232
TE123SBFAX765
TE432XSDRX221
TE231SXMDC232
TE432GFRGD655
TE900FEDSR400
TE888FEESREDS
   

TableA

CodeNameSerial Number
TE230SXMAC231
TE231SXMDC232
TE432GFRGD655
TE900FEDSR455
TE432XSDRX221
TE231SXMBC232
TE123SBAAX700

 

TableB

NameSerial Number
SXMAC231
SXMBD233
GFRGD699
FEDSR455
XSDDX221
SXMAC232
XSDRX221
SXMDC232
GFRGD655

 

 

The resuls should be somthing like below : 

TableSource       
Code_SourceName_SourceSerial number_SourceCode_AName_ASerial Number_AName_BSerial Number_B
TE230SXMAC231TE230SXMAC231SXMAC231
TE231SXMBC232TE231SXMBC232SXMBD233
TE123SBFAX765TE123SBAAX700  
TE432XSDRX221TE432XSDRX221XSDRX221
TE231SXMDC232TE231SXMDC232SXMDC232
TE431GFRGD655   GFRGD655
TE900FEDSR400TE900FEDSR455FEDSR455
TE888FEESREDS     

 

The table A and Table source will compared based on the column "Code", the table B doesn't have column "Code", so it will be based on the column "Name"

 

Could you please advise ? 

 

Many thanks in advance.

Tg

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @vnqtrang ,

 

You can try like below:

M1_name =
IF ( MAX ( 'TableSource'[Name] ) <> MAX ( 'TableA'[NameA] ), "red", "black" )

M1_serial = 
  IF(MAX('TableSource'[Serial number]) <> MAX('TableA'[Serial Number_A]), "red" ,"black")

 

vhenrykmstf_0-1661330442910.png

vhenrykmstf_1-1661330470514.png

 

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @vnqtrang ,

 

You can try like below:

M1_name =
IF ( MAX ( 'TableSource'[Name] ) <> MAX ( 'TableA'[NameA] ), "red", "black" )

M1_serial = 
  IF(MAX('TableSource'[Serial number]) <> MAX('TableA'[Serial Number_A]), "red" ,"black")

 

vhenrykmstf_0-1661330442910.png

vhenrykmstf_1-1661330470514.png

 

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

 

vnqtrang
Helper I
Helper I

Hi @Greg_Deckler 

 Thank you for your reply. 

Could you please advise how I could count the different cases ? It means counting the 0 in each measure. 

 

Tg 

@vnqtrang Sorry, you lost me. What are you going for, conditional formatting like you showed in your screen shot or the count of items that don't match or actually displaying the codes that don't match or ???


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@vnqtrang Assuming relationships between the tables you could create measures like this for flagging used in conditional formatting:

Measure Flag = 
  VAR __Name = MAX('TableSource'[Name])
  VAR __TableAName = MAX('TableA'[Name])
RETURN
  IF(__Name = __TableAName, 1, 0)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.