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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Compare 2 Strings for matching characters

Hello - i want to create an an indicator that lets me know if 2 strings have any of the same characters. This value can return anything - TRUE/FALSE, or a count of matching characters, "Y"/"N", etc.

 

Examples:

"123A" v "ABC" would return TRUE

"AZ4" vs "983" would return FALSE

"150BE" vs "IZF" would return FALSE

"AMZY1" vs "M25?1" would return TRUE

3 REPLIES 3
AntrikshSharma
Super User
Super User

Try this:

col =
VAR FirstWord =
    LOWER ( Colors[Colors] )
VAR SecondWord =
    LOWER ( Colors[Column] )
VAR FirstWordNumSeries =
    GENERATESERIES ( 1, LEN ( FirstWord ), 1 )
VAR SecondWordNumSeries =
    GENERATESERIES ( 1, LEN ( SecondWord ), 1 )
VAR FirstWordCharacters =
    SELECTCOLUMNS (
        ADDCOLUMNS ( FirstWordNumSeries, "FW", MID ( FirstWord, [Value], 1 ) ),
        "@FW", [FW]
    )
VAR SecondWordCharacters =
    SELECTCOLUMNS (
        ADDCOLUMNS ( SecondWordNumSeries, "SW", MID ( SecondWord, [Value], 1 ) ),
        "@SW", [SW]
    )
VAR Result =
    IF (
        COUNTROWS ( FILTER ( FirstWordCharacters, [@FW] IN SecondWordCharacters ) ) > 0,
        TRUE (),
        FALSE ()
    )
RETURN
    Result

1.PNG2.PNG

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Are these 2 string separate Columns ?

 

Regards,

HN

Anonymous
Not applicable

one is a column, the other is a measure 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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