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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
judithcreek
New Member

Check if column contains any value from another table's column

I have a table with a single column that contains text:

system status table.PNG

 

In a query, I want to check if a column has at least one of the System Statuses above:

system statuses field.PNG

 

Ultimately, I will add a column to the query that shows if the WBS status column has at least one of the system statuses from the first table.  How can I do this?  Thanks

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

In this particular case, I'd recommend splitting the text into a list and using List.ContainsAny.

 

Try putting this into the Custom Column box:

 

List.ContainsAny(
    Text.Split([WBS Status], " "),
    SingleColumn[System Status]
)

 

AlexisOlson_1-1640120023796.png

 

Full sample query you can paste into the Advanced Editor to check out yourself:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvYJdlEIcg12VAhy9HdWitWJVgpy9VFwdA4IUfD084QLOPmEOMMFgJoU/PydIKJwJSGuzv5gjUqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"WBS Status" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WBS Status", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Check", each List.ContainsAny(Text.Split([WBS Status], " "), SingleColumn[System Status]), type logical)
in
    #"Added Custom"

 

AlexisOlson_0-1640119872962.png

 

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

Thank you!

AlexisOlson
Super User
Super User

In this particular case, I'd recommend splitting the text into a list and using List.ContainsAny.

 

Try putting this into the Custom Column box:

 

List.ContainsAny(
    Text.Split([WBS Status], " "),
    SingleColumn[System Status]
)

 

AlexisOlson_1-1640120023796.png

 

Full sample query you can paste into the Advanced Editor to check out yourself:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvYJdlEIcg12VAhy9HdWitWJVgpy9VFwdA4IUfD084QLOPmEOMMFgJoU/PydIKJwJSGuzv5gjUqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"WBS Status" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"WBS Status", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Check", each List.ContainsAny(Text.Split([WBS Status], " "), SingleColumn[System Status]), type logical)
in
    #"Added Custom"

 

AlexisOlson_0-1640119872962.png

 

This is beautiful.  Thanks so much!

CNENFRNL
Community Champion
Community Champion

 

 

let
    SYSTEM = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8vTzVIrViVYKcXX2BzOcfYJdlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"System Status" = _t]),
    WBS = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTw9PNUcFJw9gl2UYrViVZyVnBRcAWz3BSCFdyhErEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"WBS Status" = _t]),

    Status = SYSTEM[System Status],

    Chk_List.Accumulate = Table.AddColumn(WBS, "Chk_List.Accumulate", each List.Accumulate(Status, false, (s,c) => s or Text.Contains([WBS Status], c))),
    Chk_List.Intersect = Table.AddColumn(Chk_List.Accumulate, "Chk_List.Intersect", each let wbs=Text.Split([WBS Status], " ") in List.Intersect({wbs, Status})<>{}),
    Chk_Regex =
        let
            RE = (regex as text, str as text) =>
            let
                html = "<script>var regex = " & regex & "; var str = """ & str & """; var res = regex.test(str); document.write(res)</script>"
            in
                Web.Page(html)[Data]{0}[Children]{0}[Children]{1}[Text]{0},
            ptn = "/" & Text.Combine(List.Transform(Status, each "\b"&_&"\b"), "|") & "/i"
        in
            Table.AddColumn(Chk_List.Intersect, "Chek_Regex", each RE(ptn, [WBS Status]))
in
    Chk_Regex

 

 

CNENFRNL_0-1640119764055.png

 

Screenshot 2021-12-21 215637.png

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors