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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
millie23
Frequent Visitor

Trying to do an if function with both contains and doesn't contain

I need something like:

if Text.Contains([Case Subject], "Word1", "Word2", "Word3", "Word4") or not Text.Contains([Case Subject], "Word5", "Word6") then 1 else 0)

 

I basically need an OR function here, and the goal is to basically add up the 1s when it comes to my visualisation. Can someone else?

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @millie23,

 

Give this function a go

(string as text) => 
    if List.Count( Splitter.SplitTextByAnyDelimiter({"Word1", "Word2", "Word3", "Word4"})(string)) >1 
        or List.Count( Splitter.SplitTextByAnyDelimiter({"Word5", "Word6"})(string)) =1 
    then 1 
    else 0

 

Here's an example of how to implement that into your own code

let
    fxContains = (string as text) => 
        if List.Count( Splitter.SplitTextByAnyDelimiter({"Word1", "Word2", "Word3", "Word4"})(string)) >1 
            or List.Count( Splitter.SplitTextByAnyDelimiter({"Word5", "Word6"})(string)) =1 
        then 1 
        else 0,
    myTable = #table({"Text"}, {{"Word1Up"}, {"2Word5"}, {"Fish"}}),
    AddCondition = Table.AddColumn( myTable, "test", each fxContains([Text]))
in
    AddCondition

 

Here's the output of that final query

m_dekorte_0-1711552123885.png

 

I hope this is helpful

 

View solution in original post

1 REPLY 1
m_dekorte
Super User
Super User

Hi @millie23,

 

Give this function a go

(string as text) => 
    if List.Count( Splitter.SplitTextByAnyDelimiter({"Word1", "Word2", "Word3", "Word4"})(string)) >1 
        or List.Count( Splitter.SplitTextByAnyDelimiter({"Word5", "Word6"})(string)) =1 
    then 1 
    else 0

 

Here's an example of how to implement that into your own code

let
    fxContains = (string as text) => 
        if List.Count( Splitter.SplitTextByAnyDelimiter({"Word1", "Word2", "Word3", "Word4"})(string)) >1 
            or List.Count( Splitter.SplitTextByAnyDelimiter({"Word5", "Word6"})(string)) =1 
        then 1 
        else 0,
    myTable = #table({"Text"}, {{"Word1Up"}, {"2Word5"}, {"Fish"}}),
    AddCondition = Table.AddColumn( myTable, "test", each fxContains([Text]))
in
    AddCondition

 

Here's the output of that final query

m_dekorte_0-1711552123885.png

 

I hope this is helpful

 

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors