Xlambda
Well-known Member
- Joined
- Mar 8, 2021
- Messages
- 860
- Office Version
- 365
- Platform
- Windows
ACOUNT Array Count, or self-count, 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. Calls AFLAT, ARESIZE. Uses NEW!! MAP, MAKEARRAY
Will start with the basic lambda "formulas" structure. This concept follows the conclusion we got from last post of ASCAN thread, and took shape since the AMORTIZE thread, which has several lambda "formulas" combinations of new helper functions, in various constructions.
For the ones who did not view ASCAN thread, general idea was: These new lambda helper functions are so intrinsic versatile and powerful that, (I think), their main purpose is not to help us in lambda constructions, quite the opposite, they were created to help us in lambdas "deconstruction".
Applied to this very case, we have a lambda function that calls 2 other lambdas, lot of cosmetics, but the core of the function consists in 2 quite simple lambda "formulas" that can be used explicitly every time we need them, without calling the "whole" lambda. Mastering lambda formulas becomes more importantant than whatever lambada function we decide to design.
Excel Formula:
=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)),""))
)
)
For the ones who did not view ASCAN thread, general idea was: These new lambda helper functions are so intrinsic versatile and powerful that, (I think), their main purpose is not to help us in lambda constructions, quite the opposite, they were created to help us in lambdas "deconstruction".
Applied to this very case, we have a lambda function that calls 2 other lambdas, lot of cosmetics, but the core of the function consists in 2 quite simple lambda "formulas" that can be used explicitly every time we need them, without calling the "whole" lambda. Mastering lambda formulas becomes more importantant than whatever lambada function we decide to design.
LAMBDA 1.1.4.xlsx | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | |||
1 | 1. self count 1D array | since countif(s) can not support array calculations | ||||||||||||||||||||
2 | good old countif(a,a) | because of range argument, a lambda formula can replace it: | ||||||||||||||||||||
3 | aa | =COUNTIF(aa,aa) | =MAP(aa,LAMBDA(x,SUM(--(x=aa)))) | |||||||||||||||||||
4 | a | 3 | 3 | |||||||||||||||||||
5 | a | 3 | 3 | |||||||||||||||||||
6 | d | 2 | 2 | |||||||||||||||||||
7 | d | 2 | 2 | |||||||||||||||||||
8 | a | 3 | 3 | |||||||||||||||||||
9 | c | 2 | 2 | |||||||||||||||||||
10 | b | 1 | 1 | |||||||||||||||||||
11 | c | 2 | 2 | |||||||||||||||||||
12 | ||||||||||||||||||||||
13 | 2. self occurrence count 1D arrays | |||||||||||||||||||||
14 | countif expandable range | lambda formula with embedded expandable range functionality | ||||||||||||||||||||
15 | =aa | =COUNTIF($A$16:A16,A16) | =MAKEARRAY(8,,LAMBDA(r,i,SUM(--(INDEX(aa,SEQUENCE(r))=INDEX(aa,r))))) | |||||||||||||||||||
16 | a | 1 | 1 | |||||||||||||||||||
17 | a | 2 | 2 | |||||||||||||||||||
18 | d | 1 | 1 | |||||||||||||||||||
19 | d | 2 | 2 | |||||||||||||||||||
20 | a | 3 | 3 | |||||||||||||||||||
21 | c | 1 | 1 | |||||||||||||||||||
22 | b | 1 | 1 | |||||||||||||||||||
23 | c | 2 | 2 | |||||||||||||||||||
24 | ||||||||||||||||||||||
25 | 3. unique total count | |||||||||||||||||||||
26 | lambda formula | |||||||||||||||||||||
27 | =UNIQUE(aa) | =COUNTIF(aa,UNIQUE(aa)) | =MAP(UNIQUE(aa),LAMBDA(x,SUM(--(x=aa)))) | |||||||||||||||||||
28 | a | 3 | 3 | |||||||||||||||||||
29 | d | 2 | 2 | |||||||||||||||||||
30 | c | 2 | 2 | |||||||||||||||||||
31 | b | 1 | 1 | |||||||||||||||||||
32 | ||||||||||||||||||||||
ACOUNT post 1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
C3,E3,A27,C27,E27,A15,C15,E15 | C3 | =FORMULATEXT(C4) |
C4:C11 | C4 | =COUNTIF(aa,aa) |
E4:E11 | E4 | =MAP(aa,LAMBDA(x,SUM(--(x=aa)))) |
A16:A23 | A16 | =aa |
E16:E23 | E16 | =MAKEARRAY(8,,LAMBDA(r,i,SUM(--(INDEX(aa,SEQUENCE(r))=INDEX(aa,r))))) |
C16:C23 | C16 | =COUNTIF($A$16:A16,A16) |
A28:A31 | A28 | =UNIQUE(aa) |
C28:C31 | C28 | =COUNTIF(aa,UNIQUE(aa)) |
E28:E31 | E28 | =MAP(UNIQUE(aa),LAMBDA(x,SUM(--(x=aa)))) |
Dynamic array formulas. |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
aa | ='ACOUNT post 1'!$A$4:$A$11 | E28, E16, E4, C28, C4, A28, A16 |
Last edited:
Upvote
0