79787220

Date: 2025-10-10 10:09:44
Score: 1
Natty:
Report link

Thank you for that response @Argyll. You helped me go from this utter monstrosity:

=let(myarray, MAKEARRAY(6, MAX(Lookup!$F$2:$G$7), LAMBDA(row_index, column_index, if(column_index<=INDEX(Lookup!$F$2:$G$7, row_index, 2), if(column_index=1, INDEX(Lookup!$F$2:$G$7, row_index, 1), CONCATENATE(INDEX(Lookup!$F$2:$G$7, row_index, 1), "+", column_index-1)), ""))), MAKEARRAY(SUM(Lookup!$F$2:$G$7), 1, LAMBDA(row_index, column_index, INDEX(SPLIT(TEXTJOIN(",", 1, myarray), ","), column_index, row_index))))

To this:

=LET(ranks, TRANSPOSE(SPLIT(JOIN(", ", BYROW(F2:G7, LAMBDA(r, REPT(concat(index(r, 1, 1), ", "), index(r, 1, 2))))), ", ", FALSE, TRUE)), sca, scan(0, ranks, LAMBDA(a, c, a+1)), res, scan(0, sca, LAMBDA(a, c, if(c-1<1,"", if(index(ranks, c-1, 0)=index(ranks, c, 0), concat("+",TEXT(a+counta(c), 0)), "")))), byrow(sca, LAMBDA(a, CONCAT(index(ranks, a, 0), index(res, a, 0)))))

Which is much cleaner, or at least I *think* it is. It does the job anyway and uses no 'makearray' functions. Both take this in F1:G7 ;

Colour Levels
White 1
Green 2
Blue 3
Violet 4
Orange 5
Red 3

and turns it into;

White
Green
Green+1
Blue
Blue+1
Blue+2
Violet
Violet+1
Violet+2
Violet+3
Orange
Orange+1
Orange+2
Orange+3
Orange+4
Red
Red+1
Red+2

I know it doesn't use Offset, but you showing Offset gave me the idea to use Index the same way.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Argyll
  • Low reputation (1):
Posted by: Eewec