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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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 ???



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

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)


Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.