Forum Discussion

foyadeyi's avatar
foyadeyi
Frequent Visitor
5 years ago
Solved

Conditions containing multiple strings in a column

I am trying to make conditions that contain certain strings and all the solutions I found online didnt work or tedious. I have a column that contains over 400 cities and I am trying to group them int...
  • Samarth_18's avatar
    Samarth_18
    5 years ago

    Okay foyadeyi in that case we have to create a custom column through "Edit Query" with below code:-

    if 
    List.AnyTrue(List.Transform({"Berlin","Bremen","Hamburg"},(substring ) => Text.Contains([city],substring)))
    then 
    "North"
     else if List.AnyTrue(List.Transform({ "Munich", "Ausgburg", "Wurzburg"},(substring ) => Text.Contains([city],substring)))
    then "South"
    else if List.AnyTrue(List.Transform({ "Luverkusen", "Bielefeld", "Trier" },(substring ) => Text.Contains([city],substring)))
    then "West"
    else [city]