SOLVED

Getting the above value of the currently processed array (result array during formula execution)

%3CLINGO-SUB%20id%3D%22lingo-sub-3216062%22%20slang%3D%22en-US%22%3EGetting%20the%20above%20value%20of%20the%20currently%20processed%20array%20(result%20array%20during%20formula%20execution)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3216062%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20know%20how%20to%20get%20a%20value%20from%20an%20above%20cell%20of%20a%20cell%20with%20a%20formula%20being%20executed%20but%20I%20am%20struggling%20to%20do%20the%20same%20with%20an%20array.%20You%20can%20simply%20refer%20to%20the%20above%20cell%20and%20then%20let%20the%20drag%20function%20of%20excel%20do%20the%20magic%20for%20the%20other%20consequence%20cells.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20doing%20that%20with%20a%20dynamic%20array%20that%20has%20a%20single%20formula%20is%20new%20to%20me.%20I%20want%20to%20be%20able%20to%20get%20the%20above%20(calculated)%20value%20of%20a%20result%20array%20(currently%20being%20executed%20by%20a%20formula).%3C%2FP%3E%3CP%3ETake%20a%20look%20at%20the%20attached%20picture%2C%20you%20can%20see%20at%20C3%20I%20failed%20to%20refer%20to%20the%20above%20row%20of%20the%20result%20array.%20The%20expected%20column%20in%20E2%20is%20what%20the%20result%20should%20be.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22ref.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F351416iB809002012F6EACE%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ref.png%22%20alt%3D%22ref.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJos%20Woolley%20in%20the%20StackOverflow%20forum%20suggested%20a%20solution%20(see%20%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F71263294%2Fgetting-the-above-value-of-the-currently-processed-array-result-array-during-fo%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E)%20with%20the%20%22LOOKUP%22%20function%2C%20but%20it%20was%20too%20slow%20for%20my%20set%20of%20data%20as%20a%20full%20column%20scan%20is%20performed%20for%20each%20row.%20While%20I%20can%20simply%20use%20the%20cell%20drag%20function%20and%20apply%20the%20individual%20formula%20for%20each%20cell%20in%20column%20C%20to%20have%20faster%20performance%2C%20it%20is%20not%20practical%20if%20I%20want%20to%20automate%20that%20in%20the%20case%20of%20a%20large%20dynamic%20set%20of%20data.%20Besides%2C%20I%20am%20really%20wondering%20about%20the%20possibility%20of%20doing%20that%20with%20the%20dynamic%20array.%3C%2FP%3E%3CP%3ENote%3A%20dynamic%20array%20to%20Power%20Query%20is%20not%20yet%20supported%20in%20my%20version%20of%20excel.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EPlease%20help%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3216062%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-3216144%22%20slang%3D%22en-US%22%3ERe%3A%20Getting%20the%20above%20value%20of%20the%20currently%20processed%20array%20(result%20array%20during%20formula%20execution)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3216144%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1318424%22%20target%3D%22_blank%22%3E%40aaboodi%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20comment%20on%20StackOverflow%20%22%3CSPAN%3E%26nbsp%3BI%20only%20get%20%22From%20Table%2FRange%22%26nbsp%3B.%20But%20this%20one%20works%20with%20dynamic%20arrays%20as%20well.%20At%20least%20you%20may%20try%20if%20Power%20Query%20in%20attached%20file%20works%20in%20your%20environment.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3216145%22%20slang%3D%22en-US%22%3ERe%3A%20Getting%20the%20above%20value%20of%20the%20currently%20processed%20array%20(result%20array%20during%20formula%20execution)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3216145%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1318424%22%20target%3D%22_blank%22%3E%40aaboodi%3C%2FA%3E%26nbsp%3BIf%20you%20can't%20connect%20to%20the%20DA%2C%20why%20not%20create%20a%20named%20range%20called%20%22myRange%22%2C%20for%20instance%2C%20referring%20to%20B3%23%20and%20connect%20to%20that%20named%20range%20in%20PQ%20and%20use%20the%20Fill%20Down%20there%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3216273%22%20slang%3D%22en-US%22%3ERe%3A%20Getting%20the%20above%20value%20of%20the%20currently%20processed%20array%20(result%20array%20during%20formula%20execution)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3216273%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20a%20lot%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBoth%20solutions%20work%20and%20are%20clear%20and%20fast%20enough%20for%20the%20data%20set%20I%20have.%20I%20liked%20the%20SCAN-LAMBDA%20solution.%3C%2FP%3E%3CP%3EFor%20the%20sake%20of%20benefit%20could%20you%20please%20elaborate%20more%20on%20the%20use%20of%20the%20SCAN%20function%3B%20this%20is%20the%20first%20time%20I%20encounter%20it.%20I%20don't%20understand%20how%20'first'%20gets%20updated%20during%20the%20steps.%20From%20the%20way%20I%20look%20at%20it%2C%20it%20should%20always%20put%20G1.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegarding%20my%20comment%2C%20it%20seems%20I%20did%20not%20know%20how%20to%20do%20it.%20Thanks%20to%20your%20file%20and%20your%20clear%20PQ%20steps%20I%20understand%20how%20to%20do%20it.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3216356%22%20slang%3D%22en-US%22%3ERe%3A%20Getting%20the%20above%20value%20of%20the%20currently%20processed%20array%20(result%20array%20during%20formula%20execution)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3216356%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%3B%3C%2FP%3E%3CP%3Eyes%2C%20I%20realize%20I%20can%20do%20it%20after%20your%20replies.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,

I know how to get a value from an above cell of a cell with a formula being executed but I am struggling to do the same with an array. You can simply refer to the above cell and then let the drag function of excel do the magic for the other consequence cells.

 

However, doing that with a dynamic array that has a single formula is new to me. I want to be able to get the above (calculated) value of a result array (currently being executed by a formula).

Take a look at the attached picture, you can see at C3 I failed to refer to the above row of the result array. The expected column in E2 is what the result should be.

 

ref.png

 

Jos Woolley in the StackOverflow forum suggested a solution (see here) with the "LOOKUP" function, but it was too slow for my set of data as a full column scan is performed for each row. While I can simply use the cell drag function and apply the individual formula for each cell in column C to have faster performance, it is not practical if I want to automate that in the case of a large dynamic set of data. Besides, I am really wondering about the possibility of doing that with the dynamic array.

Note: dynamic array to Power Query is not yet supported in my version of excel.


Please help

6 Replies
best response confirmed by aaboodi (New Contributor)
Solution

@aaboodi 

You comment on StackOverflow " I only get "From Table/Range" . But this one works with dynamic arrays as well. At least you may try if Power Query in attached file works in your environment.

@aaboodi If you can't connect to the DA, why not create a named range called "myRange", for instance, referring to B3# and connect to that named range in PQ and use the Fill Down there?

 

 

@Sergei Baklan 

Thanks a lot,

 

Both solutions work and are clear and fast enough for the data set I have. I liked the SCAN-LAMBDA solution.

For the sake of benefit could you please elaborate more on the use of the SCAN function; this is the first time I encounter it. I don't understand how 'first' gets updated during the steps. From the way I look at it, it should always put G1.

 

Regarding my comment, it seems I did not know how to do it. Thanks to your file and your clear PQ steps I understand how to do it.

@Riny_van_Eekelen 

 

yes, I realize I can do it after your replies.

 

thank you

@aaboodi 

SCAN has two parameters, initial value for the accumulator and an array which is scanned. Into the lambda function SCAN passes accumulator and value of the current array element. What is combined from them on each step is resulting in accumulator on that step and returned as an element of generated array.

 

Samples and definitions are here SCAN function (microsoft.com)