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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
diaz_edinson
Frequent Visitor

Multiple True / False filter expression

Hi,

I am trying to create a measure that sums the cost values, filtering by string type columns that contain certain parameters, however, although the measure theoretically has no errors, it is giving me wrong results, because it doesnt apply any of the filters. I tried to do it in three different ways as shown below, but none of them work properly. 

Next I show you what I did so that please help me

 

COST =
CALCULATE(
SUM(FACTS[Cost]),
CONTAINSSTRING(LOWER(FACTS[Campaign name]),"ff") = TRUE ||
CONTAINSSTRING(LOWER(FACTS[Creative]),"ff")=TRUE ||
CONTAINSSTRING(LOWER(FACTS[CONTENIDO]),"ff")=TRUE||
CONTAINSSTRING(LOWER(FACTS[Campaign name]),"pub")=TRUE &&
CONTAINSSTRING(LOWER(FACTS[Funnel Stage]),"do")=TRUE
)

 

in this case I have the following error:

The expression contains multiple columns, but in a True / False expression that is used as a table filter expression, only one column can be used.

so I included the filter statement:


COST2 =
SUMX(
FILTER(
FACTS,
(CONTAINSSTRING(LOWER(FACTS[Campaign name]),"ff")=TRUE) ||
(CONTAINSSTRING(LOWER(FACTS[Creative]),"ff")=TRUE) ||
(CONTAINSSTRING(LOWER(FACTS[CONTENIDO]),"ff")=TRUE) ||
(CONTAINSSTRING(LOWER(FACTS[Gerencia]),"pub")=TRUE) &&
(CONTAINSSTRING(LOWER(FACTS[Funnel Stage]),"do")=TRUE)
),
FACTS[Cost]
)

 

but it doesn't work properly either 😞


COST3 =
CALCULATE(
SUM(FACTS[Cost]),
FILTER(
FACTS,
CONTAINSSTRING(LOWER(FACTS[Campaign name]),"ff") = TRUE ||
CONTAINSSTRING(LOWER(FACTS[Creative]),"ff")=TRUE ||
CONTAINSSTRING(LOWER(FACTS[CONTENIDO]),"ff")=TRUE||
CONTAINSSTRING(LOWER(FACTS[Campaign name]),"pub")=TRUE &&
CONTAINSSTRING(LOWER(FACTS[Funnel Stage]),"do")=TRUE
)
)

 

Any ideas that can help me?

1 ACCEPTED SOLUTION

the reason I used CONTAINSSTRING is that the text contains the arguments "ff" or "do". but I solved it using this:

 

Cost = 
VAR NESFF =
    CALCULATE(
        SUM(FACTS[Cost]),
        FILTER(
            FACTS,
            IF(
                CONTAINSSTRING(LOWER(FACTS[Campaign name]),"ff") ||
                CONTAINSSTRING(LOWER(FACTS[Creative]),"ff")  || 
                CONTAINSSTRING(LOWER(FACTS[Ad content]),"ff") ||
                CONTAINSSTRING(LOWER(FACTS[Ad content]),"PUB"), 1, 0
            )=0
        )
    )
RETURN
NESFF

 

Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

HI @diaz_edinson,

I'm not so sure why you keeping used CONTAINSSTRING functions. In fact, you can write a filter function to append with these conditions. Please try to use the following measure formula if it helps:

COST =
CALCULATE (
    SUM ( FACTS[Cost] ),
    FILTER (
        ALLSELECTED ( FACTS ),
        LOWER ( FACTS[Campaign name] ) = "ff"
            || LOWER ( FACTS[Creative] ) = "ff"
            || LOWER ( FACTS[CONTENIDO] ) = "ff"
            || AND (
                LOWER ( FACTS[Campaign name] ) = "pub",
                LOWER ( FACTS[Funnel Stage] ) = "do"
            )
    )
)

If above not works, can please share some dummy data with a similar data structure and expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

the reason I used CONTAINSSTRING is that the text contains the arguments "ff" or "do". but I solved it using this:

 

Cost = 
VAR NESFF =
    CALCULATE(
        SUM(FACTS[Cost]),
        FILTER(
            FACTS,
            IF(
                CONTAINSSTRING(LOWER(FACTS[Campaign name]),"ff") ||
                CONTAINSSTRING(LOWER(FACTS[Creative]),"ff")  || 
                CONTAINSSTRING(LOWER(FACTS[Ad content]),"ff") ||
                CONTAINSSTRING(LOWER(FACTS[Ad content]),"PUB"), 1, 0
            )=0
        )
    )
RETURN
NESFF

 

Regards

lbendlin
Super User
Super User

Please provide sample data in usable format (not as a picture).

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.