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
NMOORE
Helper II
Helper II

Sum columns filtering table on multiple containsstring values

Hi,

 

Using the table attached as an example 'Financial_Tab'.

 

Row IDCBS CodeCBS NameBudget
11.2.3.21NOP1 EX1 £ 10
21.2.3.21NOP2 EX1 £5
31.2.4.21NOP2 EX1 £15
41.2.4.21NOP4EX1 £25
51.2.4.21NOP2EX1 £5
61.2.4.21NOP3 EX1 £15
71.2.4.21NOP4 EX1 £10
81.2.4.22NOP1EX1 £5
91.2.3.22NOP2EX1 £15
1022.1.2.4.22NOP2EX1 £10

 

I want to sum [Budget] based on whether "1.2.4" is within [CBS Code], & where "NOP1" or "NOP2" or "NOP3" is within [CBS Name]. Returning the bold rows above.

 

My primary issue is looking for a succinct and functional way of searching for NOP1/NOP2/NOP3 in one go. I'm returning blank results. I think IN {} could be used but I cant get it to work with containsstring.

 

I really appreciate any help.

 

Thanks

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @NMOORE 

 

Check this measure:

AA =
SUMX (
    FILTER (
        'Table',
        CONTAINSSTRING ( 'Table'[CBS Code], "1.2.4" )
            && LEFT ( 'Table'[CBS Name], 4 ) IN { "NOP1", "NOP2", "NOP3" }
    ),
    [Budget]
)

 

VahidDM_0-1668383424148.png

 

 

 

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

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

Hi @NMOORE 

 

Check this measure:

AA =
SUMX (
    FILTER (
        'Table',
        CONTAINSSTRING ( 'Table'[CBS Code], "1.2.4" )
            && LEFT ( 'Table'[CBS Name], 4 ) IN { "NOP1", "NOP2", "NOP3" }
    ),
    [Budget]
)

 

VahidDM_0-1668383424148.png

 

 

 

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

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

Thank you very much, I will accept as solution (but wasn't sure if that will close this case!?) but either way I just wanted to ask one more question.


Can it just use the IN function to search anywhere in the CBS Name for NOP1 NOP2 NOP3, rather than search the first 4 left characters, as I can't guarantee they will always be there. I tried to remove the LEFT part but it didn’t like it.


Thanks again

Yes, If my solution works, it would be better accepte it as the solution to help the other members find it more quickly and close the case.

You can change that to CONTAINSSTRING with some OR to cover those 3 conditions.

 

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

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.