Formula to Calculate Difference in Value After Finding First Non Blank Cell

%3CLINGO-SUB%20id%3D%22lingo-sub-2139986%22%20slang%3D%22en-US%22%3EFormula%20to%20Calculate%20Difference%20in%20Value%20After%20Finding%20First%20Non%20Blank%20Cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2139986%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20help%20with%20a%20formula%20and%20the%20subsequent%20calculation.%20Please%20see%20the%20attached%20workbook.%20This%20is%20a%20sample%20work%20book%20illustrating%20my%20dilemma.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EColumn%20B%20is%20the%20date%20of%20purchase%3C%2FP%3E%3CP%3EColumn%20C%20is%20the%20vendor%3C%2FP%3E%3CP%3EColumn%20D%20is%20the%20item%3C%2FP%3E%3CP%3EColumn%20F%20returns%20a%20%221%22%20each%20time%20a%20vendor%20has%20a%20new%20order%20date%2C%20and%20begins%20fresh%20for%20each%20new%20Company.%3C%2FP%3E%3CP%3EColumn%20G%20returns%20a%20%221%22%20only%20if%20the%20%22Item%205%22%20was%20purchased%20by%20the%20company.%20Item%205%20is%20our%20company's%20best%20product%20offering.%3C%2FP%3E%3CP%3ENow%2C%20Column%20E%20returns%20the%20calculation%20of%20days%20since%20today's%20date%20and%20each%20date%20they%20purchased%20%22Item%205%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I%20desire%20is%20a%20new%20column%20that%20produces%20only%20the%20days%20since%20their%20most%20recent%20purchase%20of%20%22Item%205%22%2C%20which%20for%20Company%20a%20would%20be%20600.%20However%20as%20we%20move%20down%20the%20column%2C%20I%20would%20like%20it%20to%20find%20and%20calculate%20the%20number%20of%20days%20(or%20the%20difference)%20between%20the%20each%20time%20they%20purchased%20%22Item%205%22.%3C%2FP%3E%3CP%3ESo%20for%20Company%20A%2C%20the%20results%20would%20be%3A%20600%2C%20108%3C%2FP%3E%3CP%3EFor%20Company%20B%2C%20the%20results%20would%20be%3A%20928%3C%2FP%3E%3CP%3EFor%20Company%20C%2C%20the%20results%20would%20be%3A%20937%2C%2070%3C%2FP%3E%3CP%3EFor%20Company%20D%2C%20the%20results%20would%20be%20250%2C%20174%2C%20238%3C%2FP%3E%3CP%3EI%20would%20like%20it%20to%20produce%20blank%20cells%20in%20between%20each%20values.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20ahead%20of%20time!%3C%2FP%3E%3CP%3EMy%20ultimate%20goal%20is%20to%20extrapolate%20data%20that%20calculates%20the%20average%20reorder%20rate%20for%20our%20vendors%2C%20and%20then%20checking%20to%20see%20if%20this%20number%20is%20decreasing%20(they%20are%20ordering%20more%20often)%20as%20time%20goes%20on.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2139986%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-2140208%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20to%20Calculate%20Difference%20in%20Value%20After%20Finding%20First%20Non%20Blank%20Cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2140208%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F968530%22%20target%3D%22_blank%22%3E%40BrittD2%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAssuming%20that%20you%20have%20Excel%20in%20Office%202019%20or%20Microsoft%20365%2C%20enter%20the%20following%20array%20formula%20in%20H2%2C%20comfirmed%20with%20Ctrl%2BShift%2BEnter%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIF(G2%3D1%2CTEXTJOIN(%22%2C%20%22%2CTRUE%2CIF(%24C%242%3A%24C2%3D%24C2%2C%24E%242%3A%24E2%2C%22%22))%2C%22%22)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFill%20down.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2140258%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20to%20Calculate%20Difference%20in%20Value%20After%20Finding%20First%20Non%20Blank%20Cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2140258%22%20slang%3D%22en-US%22%3EHans%2C%20thank%20you.%20I%20should've%20been%20more%20clear.%20I%20only%20want%20one%20single%20value%20per%20cell.%3CBR%20%2F%3ESo%20H13%20is%20600%2C%20and%20H25%20is%20708.%3CBR%20%2F%3EH51%20is%20250%2C%20H53%20is%20174%20and%20H58%20is%20238.%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello all,

 

I need help with a formula and the subsequent calculation. Please see the attached workbook. This is a sample work book illustrating my dilemma. 

 

Column B is the date of purchase

Column C is the vendor

Column D is the item

Column F returns a "1" each time a vendor has a new order date, and begins fresh for each new Company.

Column G returns a "1" only if the "Item 5" was purchased by the company. Item 5 is our company's best product offering.

Now, Column E returns the calculation of days since today's date and each date they purchased "Item 5"

 

What I desire is a new column that produces only the days since their most recent purchase of "Item 5", which for Company a would be 600. However as we move down the column, I would like it to find and calculate the number of days (or the difference) between the each time they purchased "Item 5".

So for Company A, the results would be: 600, 108

For Company B, the results would be: 928

For Company C, the results would be: 937, 70

For Company D, the results would be 250, 174, 238

I would like it to produce blank cells in between each values.

 

Thank you ahead of time!

My ultimate goal is to extrapolate data that calculates the average reorder rate for our vendors, and then checking to see if this number is decreasing (they are ordering more often) as time goes on.

9 Replies

@BrittD2 

Assuming that you have Excel in Office 2019 or Microsoft 365, enter the following array formula in H2, comfirmed with Ctrl+Shift+Enter:

 

=IF(G2=1,TEXTJOIN(", ",TRUE,IF($C$2:$C2=$C2,$E$2:$E2,"")),"")

 

Fill down.

Hans, thank you. I should've been more clear. I only want one single value per cell.
So H13 is 600, and H25 is 708.
H51 is 250, H53 is 174 and H58 is 238.

@BrittD2 

In H2:

 

=IF(G2=1,E2-MAXIFS($E$1:$E1,$C$1:$C1,$C2),"")

 

Fill down.

Thats great, thank you for your assistance!

@Hans Vogelaar 

 

You helped me so beautifully last time, I wondered if you might be able to please help again. 

 

On this thread, you gave the formula for Column H to calculate the running difference in the values. 

 

Now I would like a new Column "I" and a formula to return only the second value found for each grouping of rows, and otherwise return blank, essentially returning the second smallest number in each sequence and starting over for each new company.

 

So I25 would return 108

I43 would return 70

I53 would return 174

 

Thank you ahead of time!

@BrittD2 

Does this do what you want? In I2:

 

=IF(AND(G2=1,COUNTIFS(C$2:C2,C2,H$2:H2,">0")=2),H2,"")

 

Fill down.

@Hans Vogelaar

It did. I'm very grateful for your help, thank you!