Search code examples
excel-formuladynamic-arraysxlookup

How to re-order columns of data in excel / Why Xlookup formula does not work for full set of data?


I'm trying to re-arrange the columns in a data using xlookup function. But not sure why the formula not working in second case (when I try to do it for the whole table)

I would like to understand why it is not working... Any other solution to achieve column re-ordering using dynamic array formulas is also welcome.

enter image description here


Solution

  • Use INDEX/MATCH/MATCH instead:

    =INDEX(D6:G11,MATCH(C17:C22,C6:C11,0),MATCH(D16:G16,D5:G5,0))
    

    enter image description here

    As to why it does not work, the first formula is returning a 1 dimensional array to the outer XLOOKUP, while the second is returning a 2 dimensional array which the xlookup does not know how to handle.

    Index is made to take two one dimensional arrays, one vertical and one horizonatal and return the intersections.