Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Conditions Not working In power Query

I have attached Sample Data Below i am trying to new column in power bi based few conditions .   if Itemcode start with ME ,FA,FM,FC,MK new column value should  0. Now if  one more condition if Ite...
  • m_dekorte's avatar
    m_dekorte
    2 years ago

    Then I suspect the value 180 which was passed as a number, is actually a text simply turn that into a sting as illustated below.

    Table.AddColumn(
    #"Renamed Columns9",
    "prod Cat",
    each
    if ([#"Product Category (Product Information)"] = "M0101 - RRP HTP Sticks" and
    [#"Markets"] = "CA04" and
    [#"Cigarettes Per Pack (Product Information)"] = "180" and
    [#"Cigarettes Per Outer (*)"] = "180") then 2
    else if Text.StartsWith([#"Item Code - Copy.2"], "FA") then 0
    else if Text.StartsWith([#"Item Code - Copy.2"], "FM") then 0
    else if Text.StartsWith([#"Item Code - Copy.2"], "FC") then 0
    else if Text.StartsWith([#"Item Code - Copy.2"], "MK") then 0
    else if Text.StartsWith([#"Item Code - Copy.2"], "ME") then 0
    else 1
    )

     I hope this is helpful