Descriptive Statistic & Basic Maths functions
ACOUNT
Reference
» Reference, Discussion, & Example Applications:
About
Replaces functionality of: COUNTIF(S)(range,range), COUNTIF(S) with expandable ranges for occurrence counting and COUNTIF(S)(range,unique(range)) for unique total counts.
Inputs:
- a : array
- [ct] : count type argument: 0 or omitted, self-count; 1, occurrence self-count; 2, unique count
- [pu] : print unique argument: 0 or omitted, unique count; 1 or <> 0, array {unique values, unique count}
More Info:
NOTE: [pu] will only work for when [ct] is ‘2’.
Code
M.S. Excel
ACOUNT = LAMBDA(a, [ct], [pu],
LET(
r, ROWS(a),
f, AFLAT(a, 1),
w, ROWS(f),
q, UNIQUE(AFLAT(a)),
u, IF(ct = 2, q, f),
p, MAP(u, LAMBDA(x, SUM(--(x = f)))),
k, MAKEARRAY(w, , LAMBDA(r, i, SUM(--(INDEX(f, SEQUENCE(r)) = INDEX(f, r))))),
y, SWITCH(ct, 0, ARESIZE(p, r), 1, ARESIZE(k, r), 2, IF(pu, CHOOSE({1, 2}, q, p), p)),
IF(ISNA(y), "check arg.", IFERROR(IF(ct = 2, y, IF(a = "", "", y)), ""))
)
);
Feedback
Submit and view feedback