Join dynamic array formulae

Georgiboy

Well-known Member
Joined
Nov 7, 2008
Messages
1,501
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I have been learning dynamic array formulae as i move from a more VBA background to formulae. I was trying to help someone on here earlier and got very stuck, we are talking about three hours of stuck trying to figure this out and i feel it should be quite simple..

I have the below and i have been trying to join the formula in column E to the formula in column C:
Book1
ABCDE
1ExampleCodeExisting NumbersMissing Numbers
2Example1Example0, 1, 2, 3, 5, 6, 8, 94, 7
3Example2BSmith0, 1, 3, 6, 7, 9, 10, 11, 12, 13, 15, 17, 18, 192, 4, 5, 8, 14, 16
4Example3Dave1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17, 18, 193, 9, 15
5Example5
6Example6
7Example8
8Example9
9BSmith
10BSmith1
11BSmith3
12BSmith6
13BSmith7
14BSmith9
15BSmith10
16BSmith11
17BSmith12
18BSmith13
19BSmith15
20BSmith17
21BSmith18
22BSmith19
23Dave1
24Dave2
25Dave4
26Dave5
27Dave6
28Dave7
29Dave8
30Dave10
31Dave11
32Dave12
33Dave13
34Dave14
35Dave16
36Dave17
37Dave18
38Dave19
Sheet1
Cell Formulas
RangeFormula
C2:D4C2=LET( nums,IFERROR(--BYROW(A1:A38,LAMBDA(x,RIGHT(x,LEN(x)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},x&"0123456789"))+1))),0), words,SUBSTITUTE(A1:A38,nums,""), u,UNIQUE(words), result,BYROW(u,LAMBDA(br,TEXTJOIN(", ",,FILTER(nums,words=br)))), HSTACK(u,result))
E2:E4E2=BYROW(C2#,LAMBDA(x,TEXTJOIN(", ",TRUE,LET(ts,--TEXTSPLIT(INDEX(x,,2),", "),sq,SEQUENCE(,MAX(ts)),FILTER(sq,NOT(ISNUMBER(MATCH(sq,ts,0))))))))
Dynamic array formulas.


As above it works but i wanted them in one formula so i could omit the 'Existing Numbers' column and leave 'Code' & 'Missing Numbers' columns.

Below is my best go at joining them together:
Book1
ABCDE
1ExampleCodeExisting NumbersMissing Numbers
2Example1Example0, 1, 2, 3, 5, 6, 8, 9#CALC!
3Example2BSmith0, 1, 3, 6, 7, 9, 10, 11, 12, 13, 15, 17, 18, 19#CALC!
4Example3Dave1, 2, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 16, 17, 18, 19#CALC!
5Example5
6Example6
7Example8
8Example9
9BSmith
10BSmith1
11BSmith3
12BSmith6
13BSmith7
14BSmith9
15BSmith10
16BSmith11
17BSmith12
18BSmith13
19BSmith15
20BSmith17
21BSmith18
22BSmith19
23Dave1
24Dave2
25Dave4
26Dave5
27Dave6
28Dave7
29Dave8
30Dave10
31Dave11
32Dave12
33Dave13
34Dave14
35Dave16
36Dave17
37Dave18
38Dave19
Sheet2
Cell Formulas
RangeFormula
C2:E4C2=LET( nums,IFERROR(--BYROW(A1:A38,LAMBDA(x,RIGHT(x,LEN(x)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},x&"0123456789"))+1))),0), words,SUBSTITUTE(A1:A38,nums,""), u,UNIQUE(words), result,BYROW(u,LAMBDA(br,TEXTJOIN(", ",,FILTER(nums,words=br)))), tj,BYROW(result,LAMBDA(x,TEXTJOIN(", ",TRUE,LET(ts,--TEXTSPLIT(x,", "),sq,SEQUENCE(,MAX(ts)),FILTER(sq,NOT(ISNUMBER(MATCH(sq,ts,0)))))))), HSTACK(u,result,tj))
Dynamic array formulas.


I suppose i am looking for an explanation of what i have done wrong and a way of doing it right?

Not really looking for a faster/ better way to do it - just trying to learn but have got rather stuck :(
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Do you want the two arrays to process with each other?
What kind of join? (INNER only, LEFT OUTER + Whats in RIGHT not IN LEFT).

Does the column C formula result in a 2 column array? If so, I think you need to "pad" a placeholder in in the array based on column E.
 
Upvote 0
Is this what you mean?

Georgiboy.xlsm
ABC
1ExampleExample4, 7
2Example1BSmith2, 4, 5, 8, 14, 16
3Example2Dave3, 9, 15
4Example3
5Example5
6Example6
7Example8
8Example9
9BSmith
10BSmith1
11BSmith3
12BSmith6
13BSmith7
14BSmith9
15BSmith10
16BSmith11
17BSmith12
18BSmith13
19BSmith15
20BSmith17
21BSmith18
22BSmith19
23Dave1
24Dave2
25Dave4
26Dave5
27Dave6
28Dave7
29Dave8
30Dave10
31Dave11
32Dave12
33Dave13
34Dave14
35Dave16
36Dave17
37Dave18
38Dave19
Sheet1
Cell Formulas
RangeFormula
B1:C3B1=LET(rng,A1:A38,tb,TEXTBEFORE(rng&1,{0,1,2,3,4,5,6,7,8,9}),u,UNIQUE(tb),r,REPLACE(rng,1,LEN(tb),""),n,IF(r="",0,r+0), HSTACK(u,BYROW(u,LAMBDA(x,LET(f,FILTER(n,LEFT(rng,LEN(x))=x),s,SEQUENCE(MAX(f)),TEXTJOIN(", ",1,IF(ISNUMBER(MATCH(s,f,0)),"",s)))))))
Dynamic array formulas.
 
Upvote 0
Solution
Thank you @Peter_SSs that does do what i needed it to, however my simple brain is still somewhat perplexed on this.

If you could help me understand the below (smaller piece of info to work with) i would be happy.

On the below i have created a formula that is close to what i want to get to which is basically a filter of names by unique type:
Book1
ABCDE
1TypeNameFruitApple, Grapes, Plum, Orange, Pear
2FruitAppleVegetableCarrot, Beans, Cucumber, Cabbage
3FruitGrapesFrozenPies, Sausages, Cakes
4FruitPlum
5FruitOrange
6FruitPear
7VegetableCarrot
8VegetableBeans
9VegetableCucumber
10VegetableCabbage
11FrozenPies
12FrozenSausages
13FrozenCakes
Sheet1
Cell Formulas
RangeFormula
D1:E3D1=LET(u,UNIQUE(Table2[Type]),f,BYROW(u,LAMBDA(x,TEXTJOIN(", ",TRUE,FILTER(Table2[Name],Table2[Type]=x)))),HSTACK(u,f))
Dynamic array formulas.


I am trying to get to the below result with one similar formula to the above:
Book1
ABCDEFGHI
1TypeNameFruitAppleGrapesPlumOrangePear
2FruitAppleVegetableCarrotBeansCucumberCabbage
3FruitGrapesFrozenPiesSausagesCakes
4FruitPlum
5FruitOrange
6FruitPear
7VegetableCarrot
8VegetableBeans
9VegetableCucumber
10VegetableCabbage
11FrozenPies
12FrozenSausages
13FrozenCakes
Sheet2
Cell Formulas
RangeFormula
D1:D3D1=UNIQUE(Table24[Type])
E1:I1,E3:G3,E2:H2E1=TOROW(FILTER(Table24[Name],Table24[Type]=D1))
Dynamic array formulas.


I think i am missing something in the logic to allow the columns to spill. I have not started aa new thread as i believe i am missing the same piece of logic i was in the first formula. I just can'e get my head around why whatever i try does not work, i just get left with a #CALC error.

Why is is so difficult to filter to a unique list in the same formula?

Below is a formula i have tried:
Excel Formula:
=LET(u,TRANSPOSE(UNIQUE(Table245[Type])),f,BYCOL(u,LAMBDA(x,FILTER(Table245[Name],Table245[Type]=x))),HSTACK(u,f))

The end goal here was to get to the unique types to be the headers and to have the filtered names to be under the headers.
 
Upvote 0
Along these lines?

Georgiboy.xlsm
ABCDEFGHI
1TypeNameFruitAppleGrapesPlumOrangePear
2FruitAppleVegetableCarrotBeansCucumberCabbage
3FruitGrapesFrozenPiesSausagesCakes
4FruitPlum
5FruitOrange
6FruitPear
7VegetableCarrot
8VegetableBeans
9VegetableCucumber
10VegetableCabbage
11FrozenPies
12FrozenSausages
13FrozenCakes
Sheet3
Cell Formulas
RangeFormula
D1:I3D1=LET(u,UNIQUE(Table2[Type]),m,MAX(COUNTIF(Table2[Type],u)),f,WRAPROWS(TEXTSPLIT(TEXTJOIN(",",0,BYROW(u,LAMBDA(x,TEXTJOIN(",",0,EXPAND(FILTER(Table2[Name],Table2[Type]=x),m,,""))))),","),m),HSTACK(u,f))
Dynamic array formulas.
 
Upvote 0
Thanks @Peter_SSs will spend some time looking and try to get my head around it.

On having a quick look: the first inner TEXTJOIN creates what I had already, the outer TEXTJOIN joins all of the inner joins together then the outer TEXTSPLIT creates one long array of values (in one row) that the WRAPROWS then splits based on the count of names found in each type 'm'?

Cheers
 
Upvote 0
You're welcome.

If your data is large it may fail as TEXTJOIN has a limit of 32,767 characters.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top