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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
NMOORE
Helper II
Helper II

Calculate with multiple contains filters

Hi,

 

I'm trying to sum one column based on subsequent filers in DAX. Hopefully the below demonstrates what I want to do:

 
Tier 1 Total =
    CALCULATE(
        SUM(Table_A [Budget]),
        FILTER(Table_A,CONTAINSSTRING(Table_A[CBS Code],"1.1.2.4")),
        FILTER(Table_A,CONTAINSSTRING(Table_A[CBS Name], "NOP1")),
        FILTER(Table_A,CONTAINSSTRING(Table_A[CBS Name], "NOP2")),
        FILTER(Table_A,CONTAINSSTRING(Table_A[CBS Name], "NOP3")))

 

If I use the the formula in bold it's fine. However I want to include multiple contain filters on [CBS name] and include all 3. I can find what to do if they are straight forward filters but as I'm using the contains feature it makes it a bit trickier. I've tried || and IN functions and failed.

 

I could probably make it work creating multiple variables and summing them together but it feels like it should be easier.

 

I really appreciate any help.

 

Thanks

2 REPLIES 2
Anonymous
Not applicable

Hi  @NMOORE ,

Here are the steps you can follow:

1. Create calculated column.

Tier 1 Total =
var _1={"NOP1","NOP2","NOP3"}
return
SUMX(FILTER(ALL('Table'),
CONTAINSSTRING('Table'[CBS Code],"1.1.2.4")&&
'Table'[CBS Name] in _1),[Budget])

2. Result:

vyangliumsft_0-1668133957868.png

 

If the results don't meet your expectations, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thanks alot for your reply. I would upload a PBIX file but it won't let me. It's returning a blank on my data.

 

If you add text at the end of CBS code and CBS name values on your table as per below it wont filter accordingly.  I'm not sure why the contains string function is not working?

 

CBS CodeCBS NameBudget
1.1.2.3.21NOP1 EX11
1.1.2.3.21NOP2 EX12
1.1.2.3.21NOP2 EX15
1.1.2.4.21NOP1EX16
1.1.2.4.21NOP2EX14
1.1.2.4.21NOP3 EX17
1.1.2.4.21NOP4 EX11
1.1.2.4.222.1NOP1EX15
1.1.2.4.222.1NOP2EX15

 

Thanks again

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.