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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
cn4422
Helper V
Helper V

NOT(CONTAINSSTRING) - multiple values

Hi,

I'm trying to implement a measure with NOT(CONSTAINSSTRING) with 2 values, as in the following example:

 
Test =
CALCULATE(
SUM('GA, FB, Spend'[spend]),
'GA, FB, Spend'[account_name] = "DE",
CONTAINSSTRING('GA, FB, Spend'[campaign], "Gemischt*"),
NOT(CONTAINSSTRING('GA, FB, Spend'[ad_group_name], "PR01*") && NOT(CONTAINSSTRING('GA, FB, Spend'[ad_group_name], "PR02*")
)))

 

The first NOT(CONTAINS) filter is working but the second one is being ignored.

 

Any idea what's wrong with this measure?

Thx in advance! 🙂

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

I think you might have the nesting wrong. What you currently have is

Test =
CALCULATE (
    SUM ( 'GA, FB, Spend'[spend] ),
    'GA, FB, Spend'[account_name] = "DE",
    CONTAINSSTRING ( 'GA, FB, Spend'[campaign], "Gemischt*" ),
    NOT (
        CONTAINSSTRING ( 'GA, FB, Spend'[ad_group_name], "PR01*" )
            && NOT ( CONTAINSSTRING ( 'GA, FB, Spend'[ad_group_name], "PR02*" ) )
    )
)

If you're trying to exclude both PR01 and PR02 try

Test =
CALCULATE (
    SUM ( 'GA, FB, Spend'[spend] ),
    'GA, FB, Spend'[account_name] = "DE",
    CONTAINSSTRING ( 'GA, FB, Spend'[campaign], "Gemischt*" ),
    NOT CONTAINSSTRING ( 'GA, FB, Spend'[ad_group_name], "PR01*" )
        && NOT CONTAINSSTRING ( 'GA, FB, Spend'[ad_group_name], "PR02*" )
)

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

I think you might have the nesting wrong. What you currently have is

Test =
CALCULATE (
    SUM ( 'GA, FB, Spend'[spend] ),
    'GA, FB, Spend'[account_name] = "DE",
    CONTAINSSTRING ( 'GA, FB, Spend'[campaign], "Gemischt*" ),
    NOT (
        CONTAINSSTRING ( 'GA, FB, Spend'[ad_group_name], "PR01*" )
            && NOT ( CONTAINSSTRING ( 'GA, FB, Spend'[ad_group_name], "PR02*" ) )
    )
)

If you're trying to exclude both PR01 and PR02 try

Test =
CALCULATE (
    SUM ( 'GA, FB, Spend'[spend] ),
    'GA, FB, Spend'[account_name] = "DE",
    CONTAINSSTRING ( 'GA, FB, Spend'[campaign], "Gemischt*" ),
    NOT CONTAINSSTRING ( 'GA, FB, Spend'[ad_group_name], "PR01*" )
        && NOT CONTAINSSTRING ( 'GA, FB, Spend'[ad_group_name], "PR02*" )
)

@johnt75 Ah, thank you very much, that did the trick! 👌

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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