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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
bendsteel6
Helper I
Helper I

Filter with Multiple Contains and 'Not Contains'

Hi,

I'm trying to create a measure that will show me the number of records where:

 

OTHER_COST_DESC contains either '23917401' or '24546941' but DOES NOT contains 'FREIGHT'.

 

I'm trying to use this:

Num_EGR_CLAIMS =

CALCULATE(COUNTROWS(
FILTER(OTHER_COSTS,CONTAINSSTRING(OTHER_COSTS[OTHER_COST_DESCRIPTION],"23917401")

||CONTAINSSTRING(OTHER_COSTS[OTHER_COST_DESCRIPTION],"24546941")),
FILTER(OTHER_COSTS,NOT(CONTAINSSTRING(OTHER_COSTS[OTHER_COST_DESCRIPTION],"FREIGHT")))
)

 

but I get errors in the 'not contains' part.  I've tried so many different combinations but cannot get it ot work.  Any suggestions?

 

Thanks!

1 ACCEPTED SOLUTION
NishPatel
Resolver II
Resolver II

Please try below measure,

Num_EGR_CLAIMS =
CALCULATE (
COUNTROWS (
FILTER (
OTHER_COSTS,
OTHER_COSTS[OTHER_COST_DESCRIPTION] <> "FREIGHT"
&& ( OTHER_COSTS[OTHER_COST_DESCRIPTION] = "23917401"
|| OTHER_COSTS[OTHER_COST_DESCRIPTION] = "24546941" )
)
)
)

View solution in original post

2 REPLIES 2
bendsteel6
Helper I
Helper I

Yes!  It works!  Thank you @NishPatel.  I've accepted this as the solution.

NishPatel
Resolver II
Resolver II

Please try below measure,

Num_EGR_CLAIMS =
CALCULATE (
COUNTROWS (
FILTER (
OTHER_COSTS,
OTHER_COSTS[OTHER_COST_DESCRIPTION] <> "FREIGHT"
&& ( OTHER_COSTS[OTHER_COST_DESCRIPTION] = "23917401"
|| OTHER_COSTS[OTHER_COST_DESCRIPTION] = "24546941" )
)
)
)

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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