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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Pandadev
Post Prodigy
Post Prodigy

Look for text in column and see if it is contained in different column same row , in same table

I have a list codes that are located in the same table , they are shown in two seperate columns.

I am trying to find a way to detect a match , when they are not exactly the same.

Example

CodeA       CodeB

000123     123

678A         001/678A

HV/0189   0189

 

These should all be classed as a match as

123 is contained in CodeA

678A is contained in CodeB

0189 is contained Code A

Is there a formula that can help with this please

1 ACCEPTED SOLUTION
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try this column:

Column = 
IF (
    CONTAINSSTRING ( 'Table'[CodeB], 'Table'[CodeA] )
        || CONTAINSSTRING ( 'Table'[CodeA], 'Table'[CodeB] )
        || IF (
            CONTAINSSTRING ( 'Table'[CodeB], "-" ),
            CONTAINSSTRING (
                'Table'[CodeA],
                LEFT ( 'Table'[CodeB], FIND ( "-", 'Table'[CodeB], 1, 1 ) - 1 )
            )
                && CONTAINSSTRING (
                    'Table'[CodeA],
                    RIGHT (
                        'Table'[CodeB],
                        LEN ( 'Table'[CodeB] ) - FIND ( "-", 'Table'[CodeB], 1, 1 )
                    )
                )
        ),
    "Match",
    "No Match"
)

The result shows:

18.PNG

See my attached pbix file.

 

Best Regards,

Giotto

View solution in original post

4 REPLIES 4
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try this column:

Column = 
IF (
    CONTAINSSTRING ( 'Table'[CodeB], 'Table'[CodeA] )
        || CONTAINSSTRING ( 'Table'[CodeA], 'Table'[CodeB] )
        || IF (
            CONTAINSSTRING ( 'Table'[CodeB], "-" ),
            CONTAINSSTRING (
                'Table'[CodeA],
                LEFT ( 'Table'[CodeB], FIND ( "-", 'Table'[CodeB], 1, 1 ) - 1 )
            )
                && CONTAINSSTRING (
                    'Table'[CodeA],
                    RIGHT (
                        'Table'[CodeB],
                        LEN ( 'Table'[CodeB] ) - FIND ( "-", 'Table'[CodeB], 1, 1 )
                    )
                )
        ),
    "Match",
    "No Match"
)

The result shows:

18.PNG

See my attached pbix file.

 

Best Regards,

Giotto

amitchandak
Super User
Super User

@Pandadev , Create a new column like

 

IF(SEARCH([CodeA],[CodeB],,0) >0 , [CodeA] & " is contained in CodeB",
if( SEARCH([CodeB],[CodeA],,0) >0 ,[CodeB] & " is contained in CodeA" , "No Match"))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

Sure, use SEARCH or FIND. Column would be like:

 

Column =
  IF(SEARCH([CodeA],[CodeB],,-1) <> -1 || SEARCH([CodeB],[CodeA],,-1) <> -1,"match","no match")


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks , that is nearly perfect.

Just a couple of codes that dont work with this method

TH1499 and TH-1499

TE 1191 AND TE-1191

which is caused by spaces , and ,/-

is there an easy way to remove these

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors