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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DONB87
Frequent Visitor

Contains check of two Columns in two tables

Hii All

I have a probelm. I have to tables with two columns.

Table 1

Personname: Costumername  1 ( Smith)
                      Costumername 2 ( Green)

                     Costumername 3 ( Summer)

 

Table 2
PERNAME: Costumername 1 ( Jerry  Paul Clarkson)
                  Costumername 2 (Jenny Summer Smith)
                  Costumername 3 (Mr Clark  Paul Jackson)

 

What i need is if there is a contain make = 1 and if not then 0.

 

I have tried a lot of functions but nothing helped. In other words i need a contains function that are checking the table 1 colum with the table 2 column.

 

Thanks and best wishes

 

Donb87

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@DONB87 
Please do Trim and Clean to Table1 column then use the following M code and refer to attached sample file for more details.

1.png2.png

= Table.AddColumn(#"Cleaned Text","Custom", each if Text.Contains(Text.Upper(Text.Combine(#"Table2"[PERNAME],",")),Text.Upper([Personname])) then 1 else 0)

 

View solution in original post

8 REPLIES 8
tamerj1
Super User
Super User

@DONB87 
Please do Trim and Clean to Table1 column then use the following M code and refer to attached sample file for more details.

1.png2.png

= Table.AddColumn(#"Cleaned Text","Custom", each if Text.Contains(Text.Upper(Text.Combine(#"Table2"[PERNAME],",")),Text.Upper([Personname])) then 1 else 0)

 

DONB87
Frequent Visitor

Hii @tamerj1 

Unfortunatelly im getting only 0, because it compares the entire cell and not contains 😞 Maybe other ideas, that can help my to resolve my probelm.

 

Best wishes

 

Donb87

@DONB87 

Actually no. Text.Contains compares contains not whole text.
Again, power query is case sensitive.

DONB87
Frequent Visitor

Hii @tamerj1 

 

What i need is this:

DONB87_0-1675950875675.png

 

I have tried your code but im getting only 0.

 

DONB87_1-1675950908934.png

 

Thanks a lot for your help!

 

BEst

 

Donb87

@DONB87 
Power Query is case sensetive. First capitalize both columns then add the custom column.

tamerj1
Super User
Super User

Hi @DONB87 
Please refr to attached sample file with the solution.

1.png

Check = 
INT ( 
    NOT ISEMPTY ( 
        FILTER ( 
            Table2,
            CONTAINSSTRING ( Table2[PERNAME], Table1[Personname]  )
        )
    ) 
)

HI @tamerj1 
Can i implement this function in a custom column?

 

Best wishes

 

Donb87

@DONB87 

1.png

= Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains(Text.Combine(#"Table2"[PERNAME],","),[Personname]) then 1 else 0)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors