Forum Discussion
djclements
Sep 22, 2025Silver Contributor
Rack of Lambda
There’s been a lot of content shared recently to commemorate the upcoming 40th anniversary of Microsoft Excel. Personally, I’ve only been using Excel for around half that time, but October also marks...
Harun24HR
Sep 26, 2025Silver Contributor
I was studying your rack of lambda formulas and trying to understand how they works. UNPIVOT() formula is really cool. However, could you write a generic lambda formula to unpivot delimited words (comma or any other delimiter) as well as unpivot based on numbers given. Attached is an sample input and desired output. I can achieve this by a complex long formula using REDUCE() and combination of few other formulas. I would expect something like =UNPIVOTDELIMITER(B4:C6,D4:D6). Here B4:C6 is row label and D4:D6 is delimited words. Same for second example like =UNPIVOTBYNUM(B14:C16,D14:D16). Any better changes/features is highly appreciated.
- djclementsSep 27, 2025Silver Contributor
Personally, I don't think a new function is warranted for the delimited values example, as you can simply combine UNPIVOT with TEXTTOCOLS to achieve the desired results. There was actually an example of this (albeit a bit hidden) in cell V3 of the InstanceNum worksheet in my original sample file. With this new example, though, you could try the following:
=UNPIVOT(B4:C6,,TEXTTOCOLS(D4:D6,", "),,1)If you don't like that "ColumnID" is included in the final output, use CHOOSECOLS to remove it (see attached sample file).
The second example, I would say, is more closely related to my REPTA function, or even the PMTSUMMARY function that we drafted yesterday. As a matter of fact, you can use PMTSUMMARY to achieve the desired results:
=DROP(PMTSUMMARY(B14:D16,1,D14:D16,,1),,-1)However, this function is somewhat overkill for this particular scenario because all that's really needed is TOCOL-IF(S)-SEQUENCE with or without CHOOSEROWS:
REPTROWS = LAMBDA(fields,number_times, CHOOSE( 1 + (COLUMNS(fields) = 1) + (TYPE(number_times) = 64) * 2, CHOOSEROWS(fields, TOCOL(IF(SEQUENCE(, number_times), SEQUENCE(ROWS(fields))))), TOCOL(IF(SEQUENCE(, number_times), fields)), CHOOSEROWS(fields, TOCOL(IFS(number_times >= SEQUENCE(, MAX(number_times)), SEQUENCE(ROWS(fields))), 2)), TOCOL(IFS(number_times >= SEQUENCE(, MAX(number_times)), fields), 2) ) )The syntax would then simply be:
=REPTROWS(B14:D16,D14:D16)Cheers!
- Harun24HRSep 27, 2025Silver Contributor
Great! Thank you so much. I will study rack of lambdas all formulas.