Forum Discussion

JK-1's avatar
JK-1
Helper II
1 year ago
Solved

DAX switch but using containsstring

Is there a way to have CONTAINSSTRING in the below instead, as using IN as part of the VAR _Name requires an exact, and I have some examples elsewhere where it would be easier to use containsstring. ...
  • Shahid12523's avatar
    1 year ago

    Yes — replace IN with CONTAINSSTRING inside SWITCH(TRUE())

     

    Result =
    VAR _Name = 'Table1'[Name]
    RETURN
    SWITCH(
    TRUE(),
    CONTAINSSTRING(_Name, "South"), "30",
    CONTAINSSTRING(_Name, "North"), "28",
    CONTAINSSTRING(_Name, "East"), "22",
    CONTAINSSTRING(_Name, "West"), "20",
    ""
    )