cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gianmarco
Helper I
Helper I

Sum values by description that contains a common part of a string

Dear Friends,

I have the following table:

DescriptionValue
Apple One3
Orange One8
Apple Two4
Orange Two10

 

I have to sum those values which contains "Two" in the description.

How can one achieve that without using a lot of CALCULATE formulas?

Thanks

 

2 ACCEPTED SOLUTIONS
selimovd
Community Champion
Community Champion

Hey @gianmarco ,

 

I think the best approach is without any CALCULATE at all 😉

Try that one:

Sum contains Two =
SUMX(
    myTable,
    IF(
        CONTAINSSTRING( myTable[Description], "two" ),
        myTable[Value]
    )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

CNENFRNL
Super User III
Super User III

Sum TWO = 
CALCULATE(
    SUM( 'Table'[Value] ),
    CONTAINSSTRING( 'Table'[Description], "TWO" )
)

Screenshot 2021-06-17 172254.png

View solution in original post

4 REPLIES 4
CNENFRNL
Super User III
Super User III

Sum TWO = 
CALCULATE(
    SUM( 'Table'[Value] ),
    CONTAINSSTRING( 'Table'[Description], "TWO" )
)

Screenshot 2021-06-17 172254.png

View solution in original post

selimovd
Community Champion
Community Champion

Hey @gianmarco ,

 

I think the best approach is without any CALCULATE at all 😉

Try that one:

Sum contains Two =
SUMX(
    myTable,
    IF(
        CONTAINSSTRING( myTable[Description], "two" ),
        myTable[Value]
    )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

Dear @selimovd

thank you so much! Both of your formulas solve my issue! I'm gonna accept @CNENFRNL's solution as he replied me earlier. Anyway, again, thank you a lot!

selimovd
Community Champion
Community Champion

Hey @gianmarco ,

 

you can also accept multiple posts as solution if they work for you 😉

But I'm happy you found a result for your problem.

 

Have a great weekend

Denis

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors