Running total calculation

edvrdsdvskj

New Member
Joined
Jun 3, 2018
Messages
10
Hello,

I need a formula for running a total calculation array which would be used in XLOOKUP formula to find the number based on some criteria.
The formula I've tried to create is listed in the cell L2. Unfortunately, but can't use the helper column or refer to other sheets.

Any ideas or in general is it possible using only formulas?

Book1
ABCDEFGHIJKL
1UsernamePeriodS% units/totalL% units/totalXL% units/totalTotal% unit_countRunning total%2023-01RunTotalFormula which workDoesn't work
2User-12023-010.0%1.4%47.7%1.0%1.0%0.0%0.0%0.0%#VALUE!
3User-22023-011.0%2.9%3.6%1.2%2.2%1.0%1.0%1.0%#VALUE!
4User-32023-012.7%10.5%0.5%3.1%5.3%2.7%3.7%3.7%#VALUE!
5User-42023-0112.0%22.5%15.9%12.8%18.1%12.0%15.7%15.7%#VALUE!
6User-52023-0113.2%17.2%6.8%13.3%31.4%13.2%28.9%28.9%#VALUE!
7User-62023-0115.1%3.0%0.9%14.0%45.4%15.1%44.0%44.0%#VALUE!
8User-72023-0126.9%11.5%9.1%25.6%71.0%26.9%70.9%70.9%#VALUE!
9User-82023-0129.1%30.9%15.5%29.0%100.0%29.1%100.0%100.0%#VALUE!
10User-12023-027.1%2.4%0.1%6.3%106.3%
11User-22023-026.5%8.0%9.2%6.8%113.1%
12User-32023-029.6%7.0%1.3%8.9%122.0%
13User-42023-0211.0%12.3%7.1%11.0%133.0%
14User-52023-0210.4%18.7%16.9%11.6%144.6%
15User-62023-0211.1%17.5%14.1%11.9%156.5%
16User-72023-0219.3%16.1%12.2%18.7%175.1%
17User-82023-0224.8%18.0%38.9%24.9%200.0%
Sheet1
Cell Formulas
RangeFormula
I2:I9I2=SORT(FILTER($C$2:$C$17,$B$2:$B$17=I$1))
K2:K9K2=SUBTOTAL(9,OFFSET(I2,0,0,SEQUENCE(COUNT(I2#)),1))
L2:L9L2=SUBTOTAL(9,OFFSET(INDEX(SORT(FILTER($C$2:$C$17,$B$2:$B$17=I$1)),1),0,0,SEQUENCE(COUNT(SORT(FILTER($C$2:$C$17,$B$2:$B$17=I$1)))),1))
J2:J9J2=SUM($I$2:I2)
G2:G17G2=SUM($F$2:F2)
Dynamic array formulas.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
The problem was solved using MMULT function.

Book1
M
1MMULT func.
20.0%
31.0%
43.7%
515.7%
628.9%
744.0%
870.9%
9100.0%
Sheet1
Cell Formulas
RangeFormula
M2:M9M2=MMULT(--(SEQUENCE(ROWS(SORT(FILTER($C$2:$C$17,$B$2:$B$17=I$1))))>=SEQUENCE(,ROWS(SORT(FILTER($C$2:$C$17,$B$2:$B$17=I$1))))),SORT(FILTER($C$2:$C$17,$B$2:$B$17=I$1)))
Dynamic array formulas.
 
Upvote 0
Here is another shorter option:
MrExcel_20231113.xlsx
N
1SCAN option
20
30.010152
40.03701
50.15736
60.289156
70.439686
80.708999
91
Sheet7
Cell Formulas
RangeFormula
N2:N9N2=SCAN(0,FILTER(C2:C17,B2:B17=I1),LAMBDA(a,v,v+a))
Dynamic array formulas.
 
Upvote 0
You could also shorten that formula using LET
Excel Formula:
=LET(f,SORT(FILTER($C$2:$C$17,$B$2:$B$17=I$1)),r,ROWS(f),MMULT(--(SEQUENCE(r)>=SEQUENCE(,r)),f))
 
Upvote 0
@KRice that formula needs the sort, if you change I1 to 2023-02 you will get a different result from the OP.
 
Upvote 0
That's a good point @Fluff ...thank you. That brings up an important question for @edvrdsdvskj ...based on your initial description, it appears you want to sort the S% values from small to large before performing the running total. Is that correct? If so, a corrected version is shown below. My earlier offering maintained the same order as the original source table, which appears to be in Username order (although I didn't explicitly sort by Username).
MrExcel_20231113.xlsx
N
1SCAN option
20
30.010152
40.03701
50.15736
60.289156
70.439686
80.708999
91
Sheet7
Cell Formulas
RangeFormula
N2:N9N2=SCAN(0,SORT(FILTER(C2:C17,B2:B17=I1)),LAMBDA(a,v,v+a))
Dynamic array formulas.
 
Upvote 0
Thanks for the clarification. We're happy to help.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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