Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
iagovar
Regular Visitor

M text.contains with OR logical operator, and non-casesensitive matching?

Hi, I have a column with site domains like:

 

  • juegos.abc.com
  • blogs.abc.com
  • reddit.com
  • elpais.com

I want to crate a conditional column, that tells me if a domain is "media" or "community" based on a given list of domains.

I can do it manually from "create conditional column" in PowerBi but it will take me a million years.

Instead I've tried:

 

"Added Conditional Column18" = Table.AddColumn(#"Added Conditional Column17", "sitio.tipo", each if Text.Contains([Content.thread.site], "elpais OR elmundo OR elconfidencial OR abc OR lavanguardia OR 20minutos OR eldiario OR rtve OR elespanol OR eleconomista OR publico OR telecinco OR lasexta OR cuatro") then "medio" else "comunidad" )

 

Not working.

Also tried:

 

"Added Conditional Column18" = Table.AddColumn(#"Added Conditional Column17", "sitio.tipo", each if Text.Contains([Content.thread.site], "elpais" OR "elmundo" OR "elconfidencial" OR "abc" OR "lavanguardia" OR "20minutos" OR "eldiario" OR "rtve" OR "elespanol" OR "eleconomista" OR "publico" OR "telecinco" OR "lasexta" OR "cuatro") then "medio" else "comunidad" )

 

Same problem. I tried to find how to use operators withing the documentation, but it doesn't say much. Just what operators you can use, but I don't really know how to use it within this formula.

 

I also noticed with other conditional columns that it does precision matching, so, for example, if I specify "ABC" and the cell contains "abc" it won't match. I want it to be non-casesensitive, is it possible?

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @iagovar,

 

Please try below logical code:

 

#"Added Conditional Column" = 
Table.AddColumn(#"PreviousStep", "sitio.tipo",
each if List.AnyTrue(List.Transform({"elpais","elmundo","elconfidencial","abc","lavanguardia","20minutos","eldiario","rtve","elespanol","eleconomista","publico","telecinco","lasexta","cuatro"} ,(substring) => Text.Contains([Content.thread.site], substring,Comparer.OrdinalIgnoreCase)))
then "medio" else "comunidad" )

 

Best regards,
Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @iagovar,

 

Please try below logical code:

 

#"Added Conditional Column" = 
Table.AddColumn(#"PreviousStep", "sitio.tipo",
each if List.AnyTrue(List.Transform({"elpais","elmundo","elconfidencial","abc","lavanguardia","20minutos","eldiario","rtve","elespanol","eleconomista","publico","telecinco","lasexta","cuatro"} ,(substring) => Text.Contains([Content.thread.site], substring,Comparer.OrdinalIgnoreCase)))
then "medio" else "comunidad" )

 

Best regards,
Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.