Sum Of Positive and Negative Sequence

ibmy

Board Regular
Joined
Mar 4, 2020
Messages
106
Office Version
  1. 2016
Platform
  1. Windows
Hi,

14.7.xlsb
ABC
1dataexpected result
2
3-0.2
40.11
50.120.2
60
70
8-0.1
90.110.1
10-0.1
11-0.1
120.11
130.22
140.130.4
15-0.1
160.110.1
Sheet5

Need 2 formula which use Column A and Column B as reference.
To find out which formula run faster in my low spec laptop ?
Data have about 60-90k row daily.

Column A as reference:
Rule : Reset postive sequence sum when Column A value <= 0 & Reset negative sequence sum when Column A value >= 0

Column B as reference:
Check Column B value for 1,2,3,4,etc..., then take value from Column A to count. No count on blank cell.

p/s: I guess for negative sequence sum just changing the symbol (> / < ) in formula, right?

14.7.xlsb
ABC
1dataexpected result
2
3-0.11-0.1
40.1
5-0.11
6-0.12-0.2
70
8-0.11
9-0.12
10-0.13-0.3
110.1
Sheet6

Thank you.
 
Last edited:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Can you try this formula and let me know if works or not?

=IF(AND(ISBLANK(B3),ISNUMBER(B2)),SUM(OFFSET(A2,0,0,-B2)), "")

paste it in C2 and drag it down from there

PS. I am not sure how to make it light weight

here is a screencap of what I did
1594722828659.png
 
Upvote 0
If you want the column B to be autrogenerate
Assuming is arranged in the way you showed it in first image,
B2 as =IF(AND(A2>0,ISNUMBER(B1)),B1+1,IF(AND(A2>0,NOT(ISBLANK(B1))),1, ""))
C3 as =IF(AND(NOT(ISNUMBER(B4)),ISNUMBER(B3)),SUM(OFFSET(A3,0,0,-B3)), "")
drag the formula as long as required.
Please keep in mind that formula in column B should start from B2
If it works, I would ask you to go through the results, and see if there aren't any mistakes, and post them if you find them
(I am also learning)
1594727533369.png

1594727557369.png
 
Upvote 0
How about
+Fluff New.xlsm
AB
1dataexpected result
2
3-0.2 
40.1 
50.10.2
60 
70 
8-0.1 
90.10.1
10-0.1 
11-0.1 
120.1 
130.2 
140.10.4
15-0.1 
160.10.1
Data
Cell Formulas
RangeFormula
B3:B16B3=IF(AND(A3>0,A4<=0),SUMIF(A$3:A3,">0")-SUM(B$2:B2),"")
 
Upvote 0
Solution
@QuestionBaker & @Fluff Thanks for the formula. Both are working ?

I have 2 new request:

(1)
eu 7.9.xlsb
ABC
1dataformula 1formula 2
2
3-0.1
4-0.2
50.20.2
60.10.3
70.10.40.4
8-0.1
9-0.1
100.10.1
110.10.2
120.10.3
130.20.50.5
140
150.10.10.1
16-0.1
170.10.1
180.10.20.2
19-0.1
Sheet3
Instead of display total sum of positive/negative value. It now display sum for each row as long as it not break the rule.

For postive value rule:
Reset sum when next row is <=0

Then, apply formula in Column C to show only max value for each sequence in Column B.

(2)
eu 7.9.xlsb
ABCD
1data Adata Bformula 1formula 2
2
30.50.10.50.5
40.3-0.5
50.10.10.1
60.10.10.2
70.10.30.30.3
800
90.70
10-0.90.5
11-0.90
120.110.1
130.71.10.80.8
1402
Sheet6
This data a bit advance since it need to consider other column as well.

For postive value rule:
Current Column A & B must positive value >0
Reset when next row or next column <=0

Then, apply formula in Column D to show only max value for each sequence from Column C.
 
Upvote 0
As this is a totally different question, please start a new thread.
Thanks
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top