0

(* this question is one step further to this question. *)

I have the following table on the left with several rows and columns as input.

I would like to obtain a table on the right by formulas.

Ideally, I'm looking for one or more dynamic array formulas in J3, K3 and L3, which take D3:G3, C4:C6, and D4:G6 (or C3:G6) as arguments.

A solution with LAMBDA function would be second best (though you could still propose one), because not everyone is using beta channel.

Could anyone help?

enter image description here

4
  • You can use INDEX/MATCH/MATCH with the solution from your previous question. Tbh Power Query is a much better solution than formulas tho. Commented Nov 7, 2021 at 14:36
  • I prefer not to require intermediate rows/columns. These are solutions I prepare for someone else, so I really try to be exhaustive and find best solution. Commented Nov 7, 2021 at 14:38
  • Power Query does not require intermediate rows/columns. Commented Nov 7, 2021 at 14:40
  • I think this question could be done without adding helper rows/columns, but the formula would be a little bit longer than my previous question. In this case, I prefer formula solutions to power query. Commented Nov 7, 2021 at 14:54

2 Answers 2

3

=LET(x,ROWS(A2:A4),y,COLUMNS(B1:E1),z,SEQUENCE(x*y)-1,CHOOSE({1,2,3},INDEX(B1:E1,1+MOD(z,y)),INDEX(A2:A4,1+INT(z/y)),INDEX(B2:E4,1+INT(z/y),1+MOD(z,y))))

With credits to Jos Woolley for doing all of the pre-work.

and to filter out the empty values and rows without values you could use:

=LET(x,ROWS(A2:A4),y,COLUMNS(B1:E1),z,SEQUENCE(x*y)-1,a,INDEX(B2:E4,1+INT(z/y),1+MOD(z,y)),b,CHOOSE({1,2,3},INDEX(B1:E1,1+MOD(z,y)),INDEX(A2:A4,1+INT(z/y)),IF(a="","",a)),FILTER(b,INDEX(b,,3)<>""))

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

actually, i need to fill out the rows where the third element is empty.
You can apply the CHOOSE-part to a variable, e.g. resultMatrix (like the ones before), then you can extend the formula with FILTER(resultMatrix ;INDEX(resultMatrix;;3)=0)
1

Slightly different approach this time:

=LET(x,SMALL(IF(D4:G6<>"",10^5*SEQUENCE(ROWS(D4:G6))+SEQUENCE(,COLUMNS(D4:G6))),SEQUENCE(COUNT(D4:G6))),y,INT(x/10^5),z,MOD(x,10^5),CHOOSE({1,2,3},INDEX(D3:G3,z),INDEX(C4:C6,y),INDEX(D4:G6,y,z)))

Most likely can be improved upon, however.

Edit: Note: in your example the non-blank entries in D4:G6 are all numeric. If this is not necessarily always the case then replace COUNT(D4:G6) with COUNTIF(D4:G6,"<>") for a more generalised set-up.

1 Comment

that’s smart, i notice you like to use large numbers to do tricks, but that also makes the solution not work in extreme cases (e.g., when the table is very big).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.