Forum Discussion
Formulas Challenge for 365
This page will have to be updated soon:
https://support.microsoft.com/en-us/office/create-a-3-d-reference-to-the-same-cell-range-on-multiple-worksheets-40ca91ff-9dcb-4ad1-99d2-787d0bc888b6
"VSTACK ... support 3D references. Very cool."
Yes, that was quite a discovery. Stay in touch over the results of further exploration. Although this forum is largely devoted to Q&A, I would like to see more discussion and sharing of experience.
You can see from my response that I am not fully committed to the shortest formula concept, including 44 spaces and 6 line feeds in a formula of length 123 definitely rates a 'could do better'! I have also used thunks in the Max problem as a device for getting 2 row arrays through MAP. The more obvious BYROW does not allow multiple parameters.
The final version of you Max problem is more comfortable for me because I am used to picking out arrays from multidimensional layouts.
As for your comment regarding VBA, last week on another forum, I wrote a formula which turned out to be needed because an add-in had ceased to work. The places where I would still need VBA include writing event handlers or using the object model to interrogate relationships between shape objects. Most calculation would appear to be better achieved through the use of worksheet formulae.
- Patrick2788May 03, 2022Silver ContributorAdmittedly, the shortest formula approach may not be the best if taking into account sustainability and being able to use the formula in more workbooks. I've been looking for situations to create universal LAMBDAs that I can use again and again. I've gone back to some old vba exercises to see if I could make LAMBDAs do the same thing as vba. I've run into the dreaded 'array of arrays' limitation (TEXTSPLIT, naturally) when trying to write a LAMBDA to un-pivot some data. I believe it's possible with INDEX (and maybe OFFSET) but not worth the trouble if PowerQuery can do it in a snap.
- PeterBartholomew1May 03, 2022Silver Contributor
Patrick2788 I am not happy with the array of array limitations but Thunks can be used to overcome the problem in many instances. The attached workbook contains a Lambda function
= Expandλ(arrayϑ)
which turns a column of row-thunks back into a 2D array. I would far prefer such tricks were not necessary but it is something I have been bitching about for years (along with array breakup that is now solved by Lambda helper functions).
Expandλ = LAMBDA(ϑ, LET( n₁, ROWS(ϑ), n₂, MAX(MAP(ϑ,Columnsλ)), MAKEARRAY(n₁,n₂, LAMBDA(i₁,i₂, INDEX(INDEX(ϑ,i₁,1)(),i₂) ) ) ) ); Columnsλ = LAMBDA(xϑ,COLUMNS(xϑ())); Thunkλ = LAMBDA(x, LAMBDA(x));Microsoft Word - Will modern Excel finally change the way Models are built v2.0.docx (eusprig.org)
If it is any use to you, I could also offer Lambda functions that read multidimensional data from an arbitrary cross-tab dataset (I have only gone to 4D but there is no reason why it should not be applied to higher dimensional data were that relevant). The second Lambda function uses the first and generates a normalised dataset or will generate any of the normal pivot table crosstabs. It is also possible to aggregate a column by addition.