cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cong_nguyen_acc
Frequent Visitor

Sum with Conditions

Hi,

 

I have a calculation that needs your help like this:

+ Data table contains amount of each sections :

SectAmount
190
165
275
460
530
570

 

+ Section List , the calculation for each section varies, for ex. ; Sect 3 = 1 + 2, Sect 6 = 3 - 4 - 5, these section will not be on data table.

SectCal_Note
1 
2 
31 + 2
4 
5 
63 - 4 - 5

 

My goal is to sum each section with the outcome like this

SectCal_NoteDesired Outcome
1 155
2 75
31 + 2230
4 60
5 100
63 - 4 - 570

 

Please help me on this ? 

 

Thanks,

3 REPLIES 3
vanessafvg
Super User
Super User

can i ask what you are trying to do with the data, does it need to be structured in this way? 

 

or would this work?     are you wanting to end up with just the final number?

outcomes =
var three = CALCULATE(sum('Table'[Amount]), 'Table'[Sect] in {1,2})
return three - CALCULATE(sum('Table'[Amount]), 'Table'[Sect] = 4) - CALCULATE(sum('Table'[Amount]), 'Table'[Sect] = 5)




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




vivran22
Community Champion
Community Champion

Hello @cong_nguyen_acc 

 

How you are defining the sections? Are they standard/fixed or dynamic?

 

Cheers!
Vivek

https://www.vivran.in/
Connect on LinkedIn

Dear vivran22,

Calculation in section list is fixed.

 

 

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!