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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors