Forum Discussion

Rinat's avatar
Rinat
Icon for Helper I rankHelper I
4 years ago
Solved

power query text.contains multiple conditions

Hi all.

I'm trying to make new custom column based on values in u_regulatoryflag column. It contains IDs whihc I'm makin human readable text out of these. Here is a Sample code:

 

dv_u_regulatory_flag = Table.AddColumn(#"Filtered values", "dv_u_regulatory_flag", 
    
    each if Text.Contains([u_regulatoryflag], "29744385db18cc508a363a0f9d961950") then "Value1" 
    
    else if Text.Contains([u_regulatoryflag], "5384c385db18cc508a363a0f9d96198f") then "Value2" 

    else if Text.Contains([u_regulatoryflag], "29744385db18cc508a363a0f9d961950") and Text.Contains([u_regulatoryflag], "5384c385db18cc508a363a0f9d96198f") then "Value1, Value2"

    else null)

in
    dv_u_regulatory_flag

First two conditions always work. The third one with "and" doesn' work. However if I comment the first two conditions the third one starts working.

Can someone please explain this behaviour and help me to put together the query?

 

Thank you.

2 Replies

  • HotChilli's avatar
    HotChilli
    Icon for Community Champion rankCommunity Champion

    I think you need to check the more complex condition first