SOLVED

Lookup/bring in values from data array into table

%3CLINGO-SUB%20id%3D%22lingo-sub-2592769%22%20slang%3D%22en-US%22%3ELookup%2Fbring%20in%20values%20from%20data%20array%20into%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2592769%22%20slang%3D%22en-US%22%3E%3CP%3EI%20want%20to%20take%20the%20data%20from%20an%20array%20and%20lookup%20based%20on%20the%20ID%20%23%2C%20current%20month%2C%20and%20correct%20year%20but%20not%20sure%20how%20to%20get%20there.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20put%20the%20answer%20of%20how%20it%20should%20be%20to%20the%20right%20of%20the%20table%20but%20not%20sure%20how%20to%20get%20it%20from%20the%20data%20on%20the%20right%20to%20the%20table%20on%20the%20left.%3C%2FP%3E%3CP%3E%E2%80%83%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screen%20Shot%202021-07-27%20at%208.45.32%20PM.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F298773i83C3F251F2B5527F%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screen%20Shot%202021-07-27%20at%208.45.32%20PM.png%22%20alt%3D%22Screen%20Shot%202021-07-27%20at%208.45.32%20PM.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2592769%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2592967%22%20slang%3D%22en-US%22%3ERe%3A%20Lookup%2Fbring%20in%20values%20from%20data%20array%20into%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2592967%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F830570%22%20target%3D%22_blank%22%3E%40Jpalaci1%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20are%20many%20variations%20that%20can%20be%20used%20depending%20both%20upon%20personal%20preferences%20and%20Excel%20version.%26nbsp%3B%20Since%20I%20develop%20for%20Excel%20365%2C%20I%20would%20go%20for%20INDEX%20and%20XMATCH%2C%20though%20XLOOKUPS%20would%20also%20be%20possible.%26nbsp%3B%20A%20common%20trick%20for%20matching%20two%20rows%2Fcolumns%20is%20to%20concatenate%20them.%26nbsp%3B%20In%20the%20present%20case%2C%20the%20year%20and%20month%20can%20be%20combined%20more%20naturally%20as%20an%20Excel%20date%20serial%20value.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20LET(%0A%20%20date%2C%20%20%20%20DATE(%5B%40Year%5D%2C%20%5B%40Month%5D%2C%201)%2C%0A%20%20dateHdr%2C%20DATE(year%2C%20month%2C%201)%2C%0A%20%20rowNum%2C%20%20XMATCH(%5B%40ID%5D%2CID)%2C%0A%20%20colNum%2C%20%20XMATCH(date%2C%20dateHdr)%2C%0A%20%20INDEX(Value%2C%20rowNum%2C%20colNum)%20)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Contributor

I want to take the data from an array and lookup based on the ID #, current month, and correct year but not sure how to get there.

 

I put the answer of how it should be to the right of the table but not sure how to get it from the data on the right to the table on the left.

Screen Shot 2021-07-27 at 8.45.32 PM.png

3 Replies
best response confirmed by Jpalaci1 (Contributor)
Solution

@Jpalaci1 

There are many variations that can be used depending both upon personal preferences and Excel version.  Since I develop for Excel 365, I would go for INDEX and XMATCH, though XLOOKUPS would also be possible.  A common trick for matching two rows/columns is to concatenate them.  In the present case, the year and month can be combined more naturally as an Excel date serial value.

= LET(
  date,    DATE([@Year], [@Month], 1),
  dateHdr, DATE(year, month, 1),
  rowNum,  XMATCH([@ID],ID),
  colNum,  XMATCH(date, dateHdr),
  INDEX(Value, rowNum, colNum) )
Thank you! That really helped. Thank you for showing me the names ranges. I was aware of them but never really used them. Definitely use way more.

@Jpalaci1 

Thanks for the feedback.  I haven't used a cell reference since 2015, but that is a matter of personal taste!  Something else you might like to try is to copy the formula somewhere outside the confines of the table ([@Year] should now read Table1[@Year]) and the result could be a single value or an error depending on the row in which you place the formula.

 

Now remove the '@' so that entire ranges are referenced; you should get the result array as a spilt range.