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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
amani1980
Frequent Visitor

Classify data based on another table (fuzzy match or CONTAINSSTRING)

Hi,

 

I'm trying to group tickets into product category based on comparing one table to another. The match on ticket type from one table to another isn't exact. It's more like if the ticket string string in Table 1(AA0765AA) contains a part of the one in Table 2 (765), then that will be classified as Bananas. It's not an exact comparison. The output table will look like this.

 

amani1980_1-1730654330660.png

 

I suppose CONTAINSSTRING will work. However I can't seem to get the syntax right. I'm trying group Table 1 into Type and do some analysis. Can someone help me with this please? Model here.

 

Thanks in advance,

AM

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @amani1980 ,

 

try to extract the numbers from the string

1) in Power Query, how:

https://monocroft.com/extract-numbers-from-a-string-in-power-bi/

 

2) If you insist to do it with DAX code and supposing the dataset is as uniform as we see in the sample, you can try to write a calculated column with DAX like:

ticket=

VALUE(MID(table1[Ticket No], 4, 4))

 

then try to join with table2 and use RELATED to get the type column.

 

View solution in original post

2 REPLIES 2
Omid_Motamedise
Super User
Super User

Use Power Query and in the merge command check the fuzzy merging as highlighted below

 

Omid_Motamedise_0-1730689710937.png

 

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
FreemanZ
Super User
Super User

hi @amani1980 ,

 

try to extract the numbers from the string

1) in Power Query, how:

https://monocroft.com/extract-numbers-from-a-string-in-power-bi/

 

2) If you insist to do it with DAX code and supposing the dataset is as uniform as we see in the sample, you can try to write a calculated column with DAX like:

ticket=

VALUE(MID(table1[Ticket No], 4, 4))

 

then try to join with table2 and use RELATED to get the type column.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.