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

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

Reply
Anonymous
Not applicable

How to check if a string from a column in table A contains in table B and perform an action?

Hi Everyone,

I have a question on DAX formula which allows me to iterate over a column in one table and perform a concatnate action on another column if the value exsists in that column.

 

Example
I Have tableA as shown below

PathUsername
A001@test.net|B001@test.net|C001@test.net
A001@test.net|B001@test.net|C001@test.net|D001@test.net

 

(Image view so the columns are shown properly)stramzik_0-1595321951386.png

 

I Also have tableB as shown below

SearchStringAddString
D001@test.netE001@test.net
C001@test.netF001@test.net

(Image view so the columns are shown properly) test.png

 

What I'm trying to do is check if the each values in "SearchString" of tableB is in every row of "PathUsername" of tableA and if yes then concatnate the value of "AddString" corresponding to that "SearchString" from tableB to "PathUsername" of tableA as below

PathUsernameProxyUsername
A001@test.net|B001@test.net|C001@test.netA001@test.net|B001@test.net|C001@test.net|F001@test.net
A001@test.net|B001@test.net|C001@test.net|D001@test.netA001@test.net|B001@test.net|C001@test.net|D001@test.net|E001@test.net|F001@test.net

(Image view below so the columns are shown properly)stramzik_1-1595322004366.png

 

If you notice, if there are multiple values it also needs to be concatnated(row two of above table includes the add string of C001 and also D001)

 

Kindly advise how I can acheive this in DAX thank you.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try like

concatenatex(filter(tableB, containsstring(tableA[PathUsername], tableB[SearchString])),tableB[AddString],"|")

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

View solution in original post

Anonymous
Not applicable

You may use this approach.

 

ProxyUserName =
tableA[PathUsername]
    & CONCATENATEX (
        tableB,
        IF (
            NOT (
                ISBLANK ( SEARCH ( tableB[SearchString], tableA[PathUsername], 1, BLANK () ) )
            ),
            tableB[AddString],
            BLANK ()
        ),
        "|"
    )

You will have to slightly modify the code to ensure that blanks and delimiters are added correctly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@amitchandak @Anonymous Thank you very much both the solution works with a little bit tweeking. Really appriciate your help.

Anonymous
Not applicable

You may use this approach.

 

ProxyUserName =
tableA[PathUsername]
    & CONCATENATEX (
        tableB,
        IF (
            NOT (
                ISBLANK ( SEARCH ( tableB[SearchString], tableA[PathUsername], 1, BLANK () ) )
            ),
            tableB[AddString],
            BLANK ()
        ),
        "|"
    )

You will have to slightly modify the code to ensure that blanks and delimiters are added correctly.

amitchandak
Super User
Super User

@Anonymous , Try like

concatenatex(filter(tableB, containsstring(tableA[PathUsername], tableB[SearchString])),tableB[AddString],"|")

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
Anonymous
Not applicable

@amitchandak 

 

I didn't knew that DAX has a function called CONTAINSSTRING. I just checked and found that there are few CONTAINS functions like CONTAINS, CONTAINSROW, CONTAINSTRING, CONTAINSTRINGEXACT, PATHCONTAINS. 
Are these new functions added recently? 

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.