Descriptive Statistic & Basic Maths functions

ASCAN

Reference

» Reference, Discussion, & Example Applications:

About

Calculates running totals on arrays or vectors (by row, or by column).

Inputs:

  • a : array
  • [d] : direction argument; 0 or omitted scan by array; >= 1 by clms; <= -1 by rows

More Info:

Can handle blanks, null strings, text, errors, d argument wrong input.

Code

M.S. Excel
ASCAN = LAMBDA(a, [d],
    LET(
        n, ISNUMBER(a),
        r, IF(n, a, 0),
        o, IF(d, d ^ 0 * SIGN(d), 0),
        y, IF(o = 1, TRANSPOSE(r), r),
        s, SCAN(0, y, LAMBDA(v, a, v + a)),
        x, s - IF(o, INDEX(s, , 1) - INDEX(y, , 1)),
        IF(n, IF(o = 1, TRANSPOSE(x), x), a)
    )
);