Xlambda
Well-known Member
- Joined
- Mar 8, 2021
- Messages
- 860
- Office Version
- 365
- Platform
- Windows
AIJOIN arrays Inner Join, same functionality as in Power Querry join/merge scenario called Inner Join. Calls ATEXTJOIN , ARRANGE , APPEND2H
l, left array, r, right array
klf: link "key" of left array, integer or array of integers. 2 or {3,2} . 0 or ignored will be consider 1
krt: link "key" of right array, integer or array of integers. 2 or {3,2} . 0 or ignored will be consider 1
Other functions on minisheet ARRANGE , APIVOT
l, left array, r, right array
klf: link "key" of left array, integer or array of integers. 2 or {3,2} . 0 or ignored will be consider 1
krt: link "key" of right array, integer or array of integers. 2 or {3,2} . 0 or ignored will be consider 1
Other functions on minisheet ARRANGE , APIVOT
Excel Formula:
=LAMBDA(l,r,klf,krt,
LET(d,"|",t,"not found",kl,UNIQUE(IF(klf=0,1,klf),1),kr,UNIQUE(IF(krt=0,1,krt),1),
cl,COLUMNS(l),ql,SEQUENCE(,cl),cr,COLUMNS(r),qr,SEQUENCE(,cr),rl,ROWS(l),sl,SEQUENCE(rl),rr,ROWS(r),sr,SEQUENCE(rr),ckr,COLUMNS(kr),
a,INDEX(l,sl,kl),b,INDEX(r,sr,kr),ta,ATEXTJOIN(a,,,d),tb,ATEXTJOIN(b,,,d),x,XMATCH(ta,tb),xn,ISNUMBER(x),ia,FILTER(sl,xn,t),ib,FILTER(x,xn),
al,INDEX(l,ia,ql),ar,ARRANGE(INDEX(r,ib,qr),kr),
ml,OR(ISNA(XMATCH(kl,ql))),mr,OR(ISNA(XMATCH(kr,qr))),
IFS(OR(ml,mr),"check keys",ia=t,t,TRUE,APPEND2H(al,ar,ckr+1))
)
)
LAMBDA 7.0.xlsx | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |||
1 | PQ name: Inner Join (And logical test) | =AIJOIN(A2:C14,E2:H10,{3,2},{2,4}) | array 1 | array 2 | find common names in both arrays | |||||||||||||||||||||
2 | Units | Color | Product | Code | Product | Price | Color | Units | Color | Product | Code | Price | Sol Marroquin | Raven Beatty | =AIJOIN(P2:P13,S2:S13,,) | |||||||||||
3 | 48 | Red | Quad | CR-r | Carlota | 26 | Red | 48 | Red | Quad | QD-r | 43 | Kiera Mcfall | Roxanna Mercier | Raven Beatty | |||||||||||
4 | 156 | Blue | Quad | KK-b | Kiki | 13 | Blue | 156 | Blue | Quad | QD-b | 41 | Raven Beatty | Fanny Denning | Wei Lockwood | |||||||||||
5 | 168 | Red | Quad | QD-r | Quad | 43 | Red | 168 | Red | Quad | QD-r | 43 | Elinore Dees | Lesha Nobles | Angelita Packer | |||||||||||
6 | 132 | Blue | Carlota | SH-r | Sunshine | 19 | Red | 108 | Red | Sunshine | SH-r | 19 | Wei Lockwood | Wei Lockwood | Beaulah Wenger | |||||||||||
7 | 72 | Blue | Carlota | CR-g | Carlota | 24 | Green | 128 | Blue | Quad | QD-b | 41 | Donald Eldridge | Gertrudis Fitzpatrick | Malvina Hamer | |||||||||||
8 | 108 | Red | Sunshine | QD-b | Quad | 41 | Blue | 96 | Red | Carlota | CR-r | 26 | Claudio Beam | Angelita Packer | ||||||||||||
9 | 128 | Blue | Quad | SH-b | Sunshine | 18 | Blue | 60 | Red | Sunshine | SH-r | 19 | Angelita Packer | Beaulah Wenger | if we invert order of arrays in formula | |||||||||||
10 | 96 | Red | Carlota | KK-r | Kiki | 20 | Red | 24 | Blue | Sunshine | SH-b | 18 | Reyna Luke | Malvina Hamer | we get the same result | |||||||||||
11 | 60 | Red | Sunshine | 24 | Blue | Quad | QD-b | 41 | Beaulah Wenger | Bernita Crutcher | =AIJOIN(S2:S13,P2:P13,,) | |||||||||||||||
12 | 24 | Blue | Sunshine | inner join left to right(dups in left array) | Malvina Hamer | Shiela Anaya | Raven Beatty | |||||||||||||||||||
13 | 120 | Blue | Carlota | Obs: | If there are duplicates of keys | Vivan Keeney | Yolonda Armstead | Wei Lockwood | ||||||||||||||||||
14 | 24 | Blue | Quad | on left array, all will be shown | Angelita Packer | |||||||||||||||||||||
15 | error debug. | =ARRANGE(J2#,{3,4,2,5}) | =APIVOT(J17:N25,1,3,5,1) | counts | Beaulah Wenger | |||||||||||||||||||||
16 | =AIJOIN(A3:C14,E3:H10,4,2) | Product | Code | Color | Price | Units | (1\3) 5 vf=1 | Blue | Red | Grand Total | Malvina Hamer | |||||||||||||||
17 | check keys | Quad | QD-r | Red | 43 | 48 | Carlota | 0 | 1 | 1 | ||||||||||||||||
18 | Quad | QD-b | Blue | 41 | 156 | Quad | 3 | 2 | 5 | |||||||||||||||||
19 | (key left column out of range) | Quad | QD-r | Red | 43 | 168 | Sunshine | 1 | 2 | 3 | ||||||||||||||||
20 | Sunshine | SH-r | Red | 19 | 108 | Grand Total | 4 | 5 | 9 | |||||||||||||||||
21 | =AIJOIN(A3:C14,E3:H10,3,4) | Quad | QD-b | Blue | 41 | 128 | ||||||||||||||||||||
22 | not found | Carlota | CR-r | Red | 26 | 96 | =APIVOT(J17:N25,1,3,5,) | sum units | ||||||||||||||||||
23 | Sunshine | SH-r | Red | 19 | 60 | (1\3) 5 vf=0 | Blue | Red | Grand Total | |||||||||||||||||
24 | (keys in range but | Sunshine | SH-b | Blue | 18 | 24 | Carlota | 0 | 96 | 96 | ||||||||||||||||
25 | no common data found) | Quad | QD-b | Blue | 41 | 24 | Quad | 308 | 216 | 524 | ||||||||||||||||
26 | Sunshine | 24 | 168 | 192 | ||||||||||||||||||||||
27 | =AIJOIN(E2:H10,A2:C14,{2,4},{3,2}) | Grand Total | 332 | 480 | 812 | |||||||||||||||||||||
28 | Code | Product | Price | Color | Units | |||||||||||||||||||||
29 | CR-r | Carlota | 26 | Red | 96 | other functions used on minisheet | ||||||||||||||||||||
30 | QD-r | Quad | 43 | Red | 48 | ARRANGE | ||||||||||||||||||||
31 | SH-r | Sunshine | 19 | Red | 108 | APIVOT | ||||||||||||||||||||
32 | QD-b | Quad | 41 | Blue | 156 | |||||||||||||||||||||
33 | SH-b | Sunshine | 18 | Blue | 24 | |||||||||||||||||||||
34 | inner join right to left(dups in left array) | |||||||||||||||||||||||||
35 | Obs: | If there are duplicates of keys | ||||||||||||||||||||||||
36 | only first occurrence is shown | |||||||||||||||||||||||||
AIJOIN post |
Cell Formulas | ||
---|---|---|
Range | Formula | |
J1,J27,P22,E21,E16,P15,J15,U11,U2 | J1 | =FORMULATEXT(J2) |
J2:N11 | J2 | =AIJOIN(A2:C14,E2:H10,{3,2},{2,4}) |
U3:U7 | U3 | =AIJOIN(P2:P13,S2:S13,,) |
U12:U16 | U12 | =AIJOIN(S2:S13,P2:P13,,) |
J16:N25 | J16 | =ARRANGE(J2#,{3,4,2,5}) |
P16:S20 | P16 | =APIVOT(J17:N25,1,3,5,1) |
E17 | E17 | =AIJOIN(A3:C14,E3:H10,4,2) |
E22 | E22 | =AIJOIN(A3:C14,E3:H10,3,4) |
P23:S27 | P23 | =APIVOT(J17:N25,1,3,5,) |
J28:N33 | J28 | =AIJOIN(E2:H10,A2:C14,{2,4},{3,2}) |
Dynamic array formulas. |
Upvote
0