cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Powebiguru2
New Member

Calculated Column for Text Containing from another Column

Hello,

 

I am looking for a way to create a calculated column called "Matching" where it compares Column B against column A.

The output I am looking for is column D.

 

I have tried doing Text.Contains function but not expecting the results I need. 

 

Looking for the best way to do this in either Power Query or within the Data Model! 

 

Powebiguru2_0-1684784327199.png

Thank you!

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

Hi @Powebiguru2 ,

 

Please try this custom column in Power Query.

= if List.Contains(Text.Split([App Approvers], ", "), [Approver]) then "True" else "False"

vstephenmsft_0-1685069260098.png

This formula uses the Text.Split function to split the values in Column App Approvers into a list, and then uses the List.Contains function to check if the value in Column Approver is in the list. If it is, the formula returns "True". If it isn't, the formula returns "False".

 

 

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

View solution in original post

5 REPLIES 5
v-stephen-msft
Community Support
Community Support

Hi @Powebiguru2 ,

 

Please try this custom column in Power Query.

= if List.Contains(Text.Split([App Approvers], ", "), [Approver]) then "True" else "False"

vstephenmsft_0-1685069260098.png

This formula uses the Text.Split function to split the values in Column App Approvers into a list, and then uses the List.Contains function to check if the value in Column Approver is in the list. If it is, the formula returns "True". If it isn't, the formula returns "False".

 

 

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

HotChilli
Super User
Super User

Please post the Power Query code you have tried.

= if Text.Contains([Approver],[App Approver]) then "True" else "False"

m_dekorte
Solution Sage
Solution Sage

Hi @Powebiguru2,

 

Give this a go. You can copy this script into a new blank query.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sovzkxVCM7NLMnQUfBKLM7NzEPiJmdD2Eo6Skic2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"App Approvers" = _t, Approver = _t]),
    AddMatching = Table.AddColumn(Source, "Matching", each Text.Contains([App Approvers], [Approver]), type logical)
in
    AddMatching

 

with this result.

m_dekorte_0-1684787164425.png

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

This solution results in "True" for all the rows.

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors