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
renir
New Member

How to compare 2 columns character by character?

Hello,

 

I want to compare two columns, character by character, and to get how many characters are equal in position and value.

Like the example below. The difference is in reality the length of the answer is 45 characters.

 

Correct answer   |    User answer   |   Matching characters

ABC                    |    ABD                |   2

ABC                    |    DDD               |   0

ABC                    |    AAA                |   1

ABC                    |    BBB                 |   1

ABC                    |    ABC                |   3

 

Thank you in advance!

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@renir , Create a new column in DAX

Column = COUNTROWS(filter( GENERATESERIES(1,LEN([Correct answer])), mid([Correct answer],[Value],1) =mid([User answer],[Value],1)))+0

View solution in original post

2 REPLIES 2
renir
New Member

Thanks @amitchandak , it's worked just fine!

amitchandak
Super User
Super User

@renir , Create a new column in DAX

Column = COUNTROWS(filter( GENERATESERIES(1,LEN([Correct answer])), mid([Correct answer],[Value],1) =mid([User answer],[Value],1)))+0

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.