Compare 2 words character by character

If you ever want to compare 2 words character by character then you can use 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

.

Common words = 
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 =
    CONCATENATEX( FILTER ( FirstWordCharacters, [@FW] IN SecondWordCharacters  ), [@FW], ", " )
RETURN
    Result
1 Like

Thank you for sharing tips around your experiences around Power BI, please don’t hesitate to add more discussion or add value to wherever you think you possess the experience or knowledge that can help other members here in the forum. We appreciate the initiative and your help in this group!