SOLVED

Extract a subset of a table in another sheet (and keep the link to the master table)

%3CLINGO-SUB%20id%3D%22lingo-sub-1509067%22%20slang%3D%22en-US%22%3EExtract%20a%20subset%20of%20a%20table%20in%20another%20sheet%20(and%20keep%20the%20link%20to%20the%20master%20table)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509067%22%20slang%3D%22en-US%22%3E%3CP%3ELet%20me%20start%20by%20saying%20I%20am%20working%20on%20a%20Mac%20with%20excel%20365%20and%20am%20challenged%20by%20the%20following%20problem.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20large%20master%20table%20or%20dated%20transactions%20that%20I%20append%20to%20periodically.%20The%20table%20has%20hard%20entries%20%26nbsp%3Band%20calculated%20columns.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20extract%20a%20subset%20of%20the%20table%20into%20a%20new%20table%20on%20a%20separate%20worksheet%20based%20on%20the%20values%20in%20a%20specific%20column%20and%20a%20subset%20of%20columns%20from%20the%20master%20table%20(non%20sequential)%20in%20a%20dynamic%20way.%20currently%20I%20filter%20the%20master%20and%20then%20copy%20the%20data%20for%20the%20app%2C%20time%20consuming%20and%20prone%20to%20errors.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tried%20with%26nbsp%3B%3DXLOOKUP(%24G%241%2C'Master%20Import'!%24K%242%3A%24K%249254%2C'Master%20Import'!%24A%242%3A%24Q%249254)%20and%20thought%20I%20could%20use%20it%20as%20an%20array%20formula...%20no%20success.%20actually%20would%20like%20the%20return%20data%20to%20be%20select%20columns%20not%20all%20the%20columns.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20also%20tried%20to%20make%20something%20with%20matcha%20nd%20index%20but%20don't%20really%20know%20what%20I%20am%20doing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1509067%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1509195%22%20slang%3D%22en-US%22%3ERe%3A%20Extract%20a%20subset%20of%20a%20table%20in%20another%20sheet%20(and%20keep%20the%20link%20to%20the%20master%20table)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1509195%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F721718%22%20target%3D%22_blank%22%3E%40sintx%3C%2FA%3E%26nbsp%3BPerhaps%20your%20Excel%20version%20already%20supports%20the%20new%20FILTER%20function.%20It%20spills%20the%20subset%20from%20a%20larger%20table%20based%20on%20criteria%20set%20in%20the%20formula.%20Basically%20the%20same%20as%20the%20filtering%2C%20copying%2C%20pasteing%20that%20you%20do%20now%2C%20but%20it's%20all%20dynamic%20and%20will%20update%20automatically%20with%20the%20larger%20table.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1525307%22%20slang%3D%22en-US%22%3ERe%3A%20Extract%20a%20subset%20of%20a%20table%20in%20another%20sheet%20(and%20keep%20the%20link%20to%20the%20master%20table)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1525307%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3BThank%20you%20very%20much%2C%20Indeed%20the%20Filter%20function%20is%20working%20well.%3C%2FP%3E%3CP%3EIt%20does%20seem%20to%20require%20that%20the%20Filter%20rule%20needs%20to%20be%20related%20to%20a%20cell%20reference.%20(%20cannot%20be%20a%20text%20entered%20directly)%3C%2FP%3E%3CP%3EAn%20additional%20question%20is%20with%20reference%20to%20the%20below%20formula%2C%20I%20now%20have%20multiple%20filter%20formula's%20to%20extract%20the%20specific%20column%20or%20consecutive%20columns.%20Is%20there%20a%20way%20to%20either%20have%20a%20listing%20of%20desired%20columns%20in%20the%20array%20or%20a%20formula%20that%20builds%20the%20filter%20function%2C%20making%20it%20dynamic%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DFILTER('Master%20Import'!%24B%242%3A%24B%249456%2C'Master%20Import'!%24F%242%3A%24F%249456%3D%24B%242)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1525507%22%20slang%3D%22en-US%22%3ERe%3A%20Extract%20a%20subset%20of%20a%20table%20in%20another%20sheet%20(and%20keep%20the%20link%20to%20the%20master%20table)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1525507%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F721718%22%20target%3D%22_blank%22%3E%40sintx%3C%2FA%3E%26nbsp%3BPlease%20clarify.%20Don't%20really%20understand%20either%20of%20your%20questions.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1525708%22%20slang%3D%22en-US%22%3ERe%3A%20Extract%20a%20subset%20of%20a%20table%20in%20another%20sheet%20(and%20keep%20the%20link%20to%20the%20master%20table)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1525708%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F721718%22%20target%3D%22_blank%22%3E%40sintx%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFirstly%2C%20XLOOKUP%20will%20not%20return%20a%202D%20spilt%20array.%26nbsp%3B%20It%20will%20either%20match%20an%20array%20of%20'foreign%20keys'%20but%20for%20a%20single%20column%20only%20OR%20it%20will%20return%20an%20entire%20record%20(as%20a%20range%20reference)%20but%20for%20a%20single%20key%20(the%20relative%20reference%20operator%26nbsp%3B%40%20will%20pick%20the%20foreign%20keys%20one%20by%20one%20when%20filled%20down.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%20fixed%20set%20of%20column%20results%20can%20be%20stitched%20together%20using%20CHOOSE%20but%20the%20columns%20are%20then%20not%20dynamic.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20CHOOSE(%7B1%2C2%2C3%7D%2C%0A%20%20XLOOKUP(fKey%2CpKey%2CData%5BColumn2%5D)%2C%0A%20%20XLOOKUP(fKey%2CpKey%2CData%5BColumn6%5D)%2C%0A%20%20XLOOKUP(fKey%2CpKey%2CData%5BColumn3%5D)%20)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlternatively%2C%20INDEX%2FXMATCH%20will%20return%20a%202D%20array%20as%20you%20suggest.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20INDEX(Data%2CXMATCH(fKey%2CpKey)%2CselectCol)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%26nbsp%3B-ERR%3AREF-NOT-FOUND-%40Riny_van_Eekelen%26nbsp%3Bsuggests%2C%20FILTER%20is%20also%20effective%2C%20but%20building%20the%20filter%20criteria%20may%20not%20be%20straightforward%20(a%20COUNTIFS%20to%20test%20each%20primary%20key%20to%20see%20whether%20it%20is%20present%20in%20the%20list%20of%20foreign%20keys)%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Let me start by saying I am working on a Mac with excel 365 and am challenged by the following problem.

 

I have a large master table or dated transactions that I append to periodically. The table has hard entries  and calculated columns. 

I am trying to extract a subset of the table into a new table on a separate worksheet based on the values in a specific column and a subset of columns from the master table (non sequential) in a dynamic way. currently I filter the master and then copy the data for the app, time consuming and prone to errors.

 

I have tried with =XLOOKUP($G$1,'Master Import'!$K$2:$K$9254,'Master Import'!$A$2:$Q$9254) and thought I could use it as an array formula... no success. actually would like the return data to be select columns not all the columns.

 

I also tried to make something with matcha nd index but don't really know what I am doing.

 

4 Replies
Highlighted

@sintx Perhaps your Excel version already supports the new FILTER function. It spills the subset from a larger table based on criteria set in the formula. Basically the same as the filtering, copying, pasteing that you do now, but it's all dynamic and will update automatically with the larger table. 

Highlighted
Best Response confirmed by sintx (New Contributor)
Solution

@Riny_van_Eekelen 

 Thank you very much, Indeed the Filter function is working well.

It does seem to require that the Filter rule needs to be related to a cell reference. ( cannot be a text entered directly)

An additional question is with reference to the below formula, I now have multiple filter formula's to extract the specific column or consecutive columns. Is there a way to either have a listing of desired columns in the array or a formula that builds the filter function, making it dynamic?

 

=FILTER('Master Import'!$B$2:$B$9456,'Master Import'!$F$2:$F$9456=$B$2)

Highlighted

@sintx Please clarify. Don't really understand either of your questions.

Highlighted

@sintx 

Firstly, XLOOKUP will not return a 2D spilt array.  It will either match an array of 'foreign keys' but for a single column only OR it will return an entire record (as a range reference) but for a single key (the relative reference operator @ will pick the foreign keys one by one when filled down.

 

A fixed set of column results can be stitched together using CHOOSE but the columns are then not dynamic.  

 

= CHOOSE({1,2,3},
  XLOOKUP(fKey,pKey,Data[Column2]),
  XLOOKUP(fKey,pKey,Data[Column6]),
  XLOOKUP(fKey,pKey,Data[Column3]) )

 

Alternatively, INDEX/XMATCH will return a 2D array as you suggest.

 

= INDEX(Data,XMATCH(fKey,pKey),selectCol)

 

As @Riny_van_Eekelen suggests, FILTER is also effective, but building the filter criteria may not be straightforward (a COUNTIFS to test each primary key to see whether it is present in the list of foreign keys)