0

I have the dynamic range A (A#) and I want to calculate the cumulative sum of each "subrange" in B. The result musst be something as shown in column B. In other words I need a dynamic function/ formula which recognises the consecutive numbers in A und computes their total each time.

A is a Dynamic range (A#) containing the input number and B should have the sum of each range containing consecutive numbers (1 or 0)

1
  • Not a single question that you have raised on SO has been answered. Commented Jun 14, 2022 at 20:50

2 Answers 2

0

I only managed to solve this with a helper column C

C1: 1
C2: =IF(A1=A2,C1,C1+1)

C2 is draggable all the way down where you need it

B1: =IF(A1=A2,"",SUMIFS(A1,A1,A1))
B2: =IF(A2=A3,"",SUMIFS($A$1:A2,$C$1:C2,C2,$A$1:A2,A2))

B2 is draggable all the way down where you need it

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

With Office 365 you can use this LET to create a dynamic array that spills into Column B as you have shown:

=LET( a, A1#,
        sa, SCAN( 0, a, LAMBDA(a,b, a + b ) ),
        rSeq, SEQUENCE( ROWS( a ) ),
        a_1, INDEX( a, rSeq + 1 ),
        change, IFERROR( a_1 <> a, 1 ),
        sChange, SCAN( 0, change*sa, LAMBDA(a,b, MAX( a, b ) ) ),
        IF( change, sChange - IF( rSeq=1, 0, INDEX( sChange, rSeq - 1) ), "" ) )

where A1# is the input array.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.