Finding next biggest numbers

toongal12

Board Regular
Joined
Dec 1, 2016
Messages
150
I have a bunch of dates with two numbers connected to it. They are not in order and relate to many different items.

I need to be able to output into a different table the next following date and the next two numbers if one or both of the numbers change.


Example: "Current" Data

ItemDate# One# Two
Item0011/4/1711
Item0021/4/1812
Item0011/30/1711
Item0011/4/1912
Item0021/4/2033

<tbody>
</tbody>



For example, currently Item001 is 1 and 1.

In a different table, If # One and/or # Two changed, I need to display it in a table. If either changed, both numbers will be recorded with the date.

In this case, Item001 changed in the # Two column from 1 to 2 so now it should display: 1/4/19 and 1 and 2


2nd Table: "Next" Data

ItemNext DateNext # OneNext # Two
Item0011/4/1912

<tbody>
</tbody>


I am having trouble figuring out what formula to put into each of the three cells (Next Date, Next One, Next Two) that will output even if only one number changes. Sometimes it will result in the next change in both numbers, when I only want the next set.

I was trying to use MAX-IF, but it gives me the highest One and Two, when I just want the next one in order.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Couldn't exactly find to what the change should be compared to; so this could be completely wrong solution for your intended use; but perhaps this helps:


Excel 2016 (Windows) 64 bit
ABCDEFG
1ItemDate# One# TwoRef dateItem001
2Item0014-1-201711Item4-1-2017
3Item0024-1-201812# One1
4Item00130-1-201711# Two1
5Item0014-1-201912
6Item0024-1-202033
7
8Item0014-1-201912
Sheet1
Cell Formulas
RangeFormula
A8{=INDEX($A$2:$A$6,MATCH(1,($B$2:$B$6>$G$2)*($A$2:$A$6=$G$1)*(($C$2:$C$6=$G$3+1)+($D$2:$D$6=$G$4+1)),0))}
B8{=INDEX($B$2:$B$6,MATCH(1,($B$2:$B$6>$G$2)*($A$2:$A$6=$G$1)*(($C$2:$C$6=$G$3+1)+($D$2:$D$6=$G$4+1)),0))}
C8{=INDEX($C$2:$C$6,MATCH(1,($B$2:$B$6>$G$2)*($A$2:$A$6=$G$1)*(($C$2:$C$6=$G$3+1)+($D$2:$D$6=$G$4+1)),0))}
D8{=INDEX($D$2:$D$6,MATCH(1,($B$2:$B$6>$G$2)*($A$2:$A$6=$G$1)*(($C$2:$C$6=$G$3+1)+($D$2:$D$6=$G$4+1)),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
The comparison is to find the next number that occurs in the # one column or # two column. It looks like your formula finds when the next date happens, but I need to find when the next change in #One or # two happens :( The output should be 1/4/19 with 1 and 2 because that is the next time the One or Two columns change.

Couldn't exactly find to what the change should be compared to; so this could be completely wrong solution for your intended use; but perhaps this helps:

Excel 2016 (Windows) 64 bit
ABCDEFG
1ItemDate# One# TwoRef dateItem001
2Item0014-1-201711Item4-1-2017
3Item0024-1-201812# One1
4Item00130-1-201711# Two1
5Item0014-1-201912
6Item0024-1-202033
7
8Item0014-1-201912

<tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
A8{=INDEX($A$2:$A$6,MATCH(1,($B$2:$B$6>$G$2)*($A$2:$A$6=$G$1)*(($C$2:$C$6=$G$3+1)+($D$2:$D$6=$G$4+1)),0))}
B8{=INDEX($B$2:$B$6,MATCH(1,($B$2:$B$6>$G$2)*($A$2:$A$6=$G$1)*(($C$2:$C$6=$G$3+1)+($D$2:$D$6=$G$4+1)),0))}
C8{=INDEX($C$2:$C$6,MATCH(1,($B$2:$B$6>$G$2)*($A$2:$A$6=$G$1)*(($C$2:$C$6=$G$3+1)+($D$2:$D$6=$G$4+1)),0))}
D8{=INDEX($D$2:$D$6,MATCH(1,($B$2:$B$6>$G$2)*($A$2:$A$6=$G$1)*(($C$2:$C$6=$G$3+1)+($D$2:$D$6=$G$4+1)),0))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Last edited:
Upvote 0
My formula finds the next occurrence of the item as 4 matches are true:
1. the item must identical; AND
2. the date must be greater then the date the current item has; AND
3. #one is greater then the current item; OR
4. #two is greater than the current item.

Perhaps this view will create clarity:

Excel 2016 (Windows) 64 bit
ABCDEFG
1Table 1
2ItemDate# One# TwoRef dateItem001
3Item0014-1-201711Item4-1-2017
4Item0024-1-201812# One1
5Item00130-1-201711# Two1
6Item0014-1-201911
7Item0014-1-202111
8Item0015-1-202111
9Item0016-1-202121
10Item0017-1-202111
11Item0024-1-202033
12
13Table 2
14ItemDate# One# Two
15Item0016-1-202121
Sheet1
Cell Formulas
RangeFormula
A15{=INDEX($A$3:$A$11,MATCH(1,($B$3:$B$11>$G$3)*($A$3:$A$11=$G$2)*(($C$3:$C$11=$G$4+1)+($D$3:$D$11=$G$5+1)),0))}
B15{=INDEX($B$3:$B$11,MATCH(1,($B$3:$B$11>$G$3)*($A$3:$A$11=$G$2)*(($C$3:$C$11=$G$4+1)+($D$3:$D$11=$G$5+1)),0))}
C15{=INDEX($C$3:$C$11,MATCH(1,($B$3:$B$11>$G$3)*($A$3:$A$11=$G$2)*(($C$3:$C$11=$G$4+1)+($D$3:$D$11=$G$5+1)),0))}
D15{=INDEX($D$3:$D$11,MATCH(1,($B$3:$B$11>$G$3)*($A$3:$A$11=$G$2)*(($C$3:$C$11=$G$4+1)+($D$3:$D$11=$G$5+1)),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.


as shown in Row 8
 
Upvote 0
I apologize, I didn't see Row 8, I thought it was a duplicate entry :(

When I tried to use it, I receive #N/A.

Also, the numbers always always increments of 1, they are different

My formula finds the next occurrence of the item as 4 matches are true:
1. the item must identical; AND
2. the date must be greater then the date the current item has; AND
3. #one is greater then the current item; OR
4. #two is greater than the current item.

Perhaps this view will create clarity:
Excel 2016 (Windows) 64 bit
ABCDEFG
1Table 1
2ItemDate# One# TwoRef dateItem001
3Item0014-1-201711Item4-1-2017
4Item0024-1-201812# One1
5Item00130-1-201711# Two1
6Item0014-1-201911
7Item0014-1-202111
8Item0015-1-202111
9Item0016-1-202121
10Item0017-1-202111
11Item0024-1-202033
12
13Table 2
14ItemDate# One# Two
15Item0016-1-202121

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
A15{=INDEX($A$3:$A$11,MATCH(1,($B$3:$B$11>$G$3)*($A$3:$A$11=$G$2)*(($C$3:$C$11=$G$4+1)+($D$3:$D$11=$G$5+1)),0))}
B15{=INDEX($B$3:$B$11,MATCH(1,($B$3:$B$11>$G$3)*($A$3:$A$11=$G$2)*(($C$3:$C$11=$G$4+1)+($D$3:$D$11=$G$5+1)),0))}
C15{=INDEX($C$3:$C$11,MATCH(1,($B$3:$B$11>$G$3)*($A$3:$A$11=$G$2)*(($C$3:$C$11=$G$4+1)+($D$3:$D$11=$G$5+1)),0))}
D15{=INDEX($D$3:$D$11,MATCH(1,($B$3:$B$11>$G$3)*($A$3:$A$11=$G$2)*(($C$3:$C$11=$G$4+1)+($D$3:$D$11=$G$5+1)),0))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



as shown in Row 8
 
Upvote 0
toongal12,

Do you see jorismoerings' point?

Item002 1/4/18 1 2
Item002 1/4/20 3 3

qualifies according to the rules.

Is there another criteria not mentioned, yet?
 
Upvote 0
Also, an item can appear many times. There will be a "current" item, but the "current" item can be any date chosen, so it could be in 2017 or it could be in 2013. The output table just has to be able to choose the next set of numbers after the selected one.

I apologize for forgetting to add in this detail.
 
Last edited:
Upvote 0
You didn't define what's to consider as the "current" or the selected Item. So compare the table against ......?
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,842
Members
449,471
Latest member
lachbee

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