Referencing a cell adjacent to the first and last instance of a reference value: please help

tommy_b

New Member
Joined
Feb 10, 2016
Messages
4
Hi,

I'm trying to formula that returns a cell value from a column that's adjacent to the first and last instance of my reference cell. Here's a sample of the data:

DateOrder #Sequence
3/15/201730133092000020
12/13/201830135893000010
12/13/201830135895000010
1/9/201730137118000010
1/31/201730137118000020
1/31/201730137118000060
1/6/201730137179000040
1/3/201730137198000040
1/3/201730137198000050
1/5/201730137198000060
1/5/201730137198000070
1/5/201730137198000080
1/6/201730137266000010
1/6/201730137266000040
1/6/201730137266000050
1/9/201730137266000060
1/16/201730137266000070
1/3/201730137318000010
1/11/201730137318000040
1/11/201730137318000050
1/16/201730137318000060
1/17/201730137318000070
1/19/201730137318000080

<tbody>
</tbody>


Ultimately what I'm trying to do is get the delta between the first sequence that appears for an order # and the last sequence. I have no idea how to make this happen.

For instance, in this data set, I'd want to find the date of first instance of 301373180000 (Sequence 10 on 1/3/2017) and the last instance it appears (sequence 80 on 1/19/2017).

I've thought about using a sequential SUMIF statement that counts the instance of the WO and then take the MAX and MIN values using a separate table where I copy out all the first instances of an order # using VLOOKUP or INDEX/MATCH but I'm not Excel savvy enough to make it work. Also, my data set is roughly 20,000 rows and there are a bunch more columns so Excel keeps crashing when I try to apply the formulas to the entire table. It's frustrating. Any help would be appreciated.

Thank you.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I think this might help. It calculates the absolute difference between the first Sequence figure and the last, based on Order# and Date. Cell I2 does it all in a single cell.

<strike>
</strike>

Book1
ABCDEFGHI
1DateOrder#SequenceOrder#FirstLastDeltaDelta (single cell)
23/15/17301330920000203013731800002017-01-032017-01-1970
312/13/1830135893000010Sequence108070
412/13/1830135895000010
51/09/1730137118000010
61/31/1730137118000020
71/31/1730137118000060
81/06/1730137179000040
91/03/1730137198000040
101/03/1730137198000050
111/05/1730137198000060
121/05/1730137198000070
131/05/1730137198000080
141/06/1730137266000010
151/06/1730137266000040
161/06/1730137266000050
171/09/1730137266000060
181/16/1730137266000070
191/03/1730137318000010
201/11/1730137318000040
211/11/1730137318000050
221/16/1730137318000060
231/17/1730137318000070
241/19/1730137318000080
Sheet60
Cell Formulas
RangeFormula
I2=ABS(SUM((AGGREGATE(15,6,A2:A24/($E$2=B2:B24),1)=A2:A24)*($E$2=B2:B24)*C2:C24)-SUM((AGGREGATE(14,6,A2:A24/($E$2=B2:B24),1)=A2:A24)*($E$2=B2:B24)*C2:C24))
F2=AGGREGATE(15,6,A2:A24/($E$2=B2:B24),1)
F3=SUM((AGGREGATE(15,6,A2:A24/($E$2=B2:B24),1)=A2:A24)*($E$2=B2:B24)*C2:C24)
G2=AGGREGATE(14,6,A2:A24/($E$2=B2:B24),1)
G3=SUM((AGGREGATE(14,6,A2:A24/($E$2=B2:B24),1)=A2:A24)*($E$2=B2:B24)*C2:C24)
H3=ABS(F3-G3)
 
Last edited:
Upvote 0
DRSTeele, thank you for the response. I've never used AGGREGATE before and I'm looking forward to learning more about it.

I should have stated in my OP that I'm looking to take the delta between the date of the first and last sequence that shows up for each WO. I'm not sure how to parse out every discrete Order # into a separate table. My data set is currently at 32,000 rows (I'm using power query to bring a table in from our ERP system). Is there a way to easily grab each discrete order # and transcribe it to a new table? Or would it make sense to house the delta in a new column but only for the largest sequence value?

Ultimately, my goal will be to evaluate the average time for the orders to move through our processes.
 
Upvote 0
Also, could you explain how the '/' is working in the reference parameter of the AGGREGATE function? It looks like you're dividing the entire column by a boolean expression. Is that correct or does the '=' do something else in an excel function?

Thank you.
 
Upvote 0
You can extract a list of unique orders numbers many ways, including PQ, PivotTables, native filter operations, or the easiest way: by using the new spiller functions in Excel365. In our case,

Code:
[FONT=Verdana]=UNIQUE(B2:B24)[/FONT]

See here and related videos in the MrExcel channel for explanations of Excels new functions. https://www.youtube.com/watch?v=vy8y4CN-IHY

The "/" in function AGGREGATE is used to intentionally create errors in the array housed inside it. That way, determining the minimum value is not hindered by the zeros that would be created by a "*" multiplication operation. The key here is that AGGREGATE will ignore array errors when the argument 6 is used.

See this youtube video and others in that ExcelIsFun channel for insight into AGGREGATE. https://www.youtube.com/watch?v=u7B__903dUQ&t=1s&list=LL0pw634NtPT66QP2LcA6YRA&index=79
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,438
Members
448,897
Latest member
dukenia71

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top