Forum Discussion

polman4's avatar
polman4
Helper I
3 years ago
Solved

Conditional Column (each if with two conditions)

Hello,

 

I'm trying to create a calculated column with two conditions on IF.

First criteria: If column1 contains "rtb+"

Second criteria: if column2 doesn't contain "Deals_"

 

 

 

#"RTB+ Impressions_clm" =
Table.AddColumn(Hb_Impressions_clm, "RTB+ Impressions", each if (Text.Contains([#"Column1"], "RTB+") 
and (not Text.Contains([#"Column2"], "Deals_")))
then [Impressions] 
else null)

 

 

 

What i'm doing wrong?

Thank you,
Grigoris

  • polman4 , seem fine

     

    if (Text.Contains([#"Column1"], "RTB+") and ( not Text.Contains([#"Column2"], "Deals_"))
    then [Impressions]
    else null

     

    but it is case sensitive , you can use Text.Upper, example

     

    if (Text.Contains(Text.Upper([#"Column1"]), "RTB+") and ( not Text.Contains([#"Column2"], "Deals_"))
    then [Impressions]
    else null

1 Reply

  • polman4 , seem fine

     

    if (Text.Contains([#"Column1"], "RTB+") and ( not Text.Contains([#"Column2"], "Deals_"))
    then [Impressions]
    else null

     

    but it is case sensitive , you can use Text.Upper, example

     

    if (Text.Contains(Text.Upper([#"Column1"]), "RTB+") and ( not Text.Contains([#"Column2"], "Deals_"))
    then [Impressions]
    else null