locked
【DAX】 How to use Switch function to define if each cell contains some specific letter? RRS feed

  • Question



  • Hi I met a problem in DAX. The function I want to achieve: in the A column, whenever it contains the word "TPT" or word "TFT", then it returns "internal customer" in B column. The rest returns "external customer".

    I know how to do it in SQL, is like update.. where ..like '%TPT%' or .. like '%TFT%'

    But when I added the table to data model and tried to use similar wildcard way in DAX, it didn't work. I have tried *,%,^, all didn't work.

    It would be great helpful if someone could suggest. Thanks in advance.

    =switch(
         true(),
        Table1[customer] = "*TPT*","Internal customer",
         Table1[customer] = "*TFT*","Internal customer",
        "External customer"

    Monday, May 18, 2015 8:13 AM

All replies

  • Have you tried using CONTAINS?
    Monday, June 11, 2018 4:51 PM
  • I don't know which is stranger, that you asked this completely off-topic question here in the Expression Design forum, or that someone actually found it here and essayed an answer. Jeez...

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Friday, June 15, 2018 4:46 AM