Search code examples
stringtextpowerbidax

Power BI DAX: String manipulation--> how to search multiple values and return a mapping value


For example, I have a column of web site:

www.google_b.com
www.amazon_1-3b.com
www.amazon345.com

I know that google and amazon are the ones I want to retrieve for another column.

I want to have this column as below

www.google-a.com                google
www.google_b.com                google
www.amazon_1-3b.com             amazon
www.amazon345.com               amazon

I will have a list of the desired keywords to map with like [google, amazon, facebook, etc] Does anyone know how to get the dax formula?

It is more like a LIKE "%xyz%" syntax in SQL.

Thanks.


Solution

  • You can do this by passing on a SQL like case statement in a SWITCH

    Column = SWITCH(TRUE(), CONTAINSSTRING('fact'[Field],"amazon"),"amazon", CONTAINSSTRING('fact'[Field],"google"),"google")
    

    Solution