Chained lookup through a date series

SubtleNoob

New Member
Joined
Nov 22, 2015
Messages
11
Hello,

I need to loop a look up multiple times to find the final value for a range of dates.

So in an additional column in the below table i need to lookup into the next quarter the value in "Inputs Combined", then look up that value into the next quarter and so on until a max date.

Such that in rows, row 2 goes to row 6, row 6 to row 7. Outputting row 7 Asset value. But this would need to be in rows 2, 6 and 7 in the new column.

It needs to be something of a looped look up.

Reporting_DateAsset_NumberMarket_ValueInputs combined
30/09/2018​
21975​
6,822,164
30/09/2018​
21979​
14,355,242
21977​
30/09/2018​
21977​
33,506,866
21975​
31/12/2018​
21975​
6,470,263
31/12/2018​
21979​
13,971,294
21977​
31/12/2018​
21977​
38,220,950
21975​
31/03/2019​
21975​
6,916,398
31/03/2019​
21979​
13,971,294
21977​
31/03/2019​
21977​
38,220,950
21975​

A macro solution or a formula would be welcome. I think it requires a macro.

Many thanks.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Is this what you mean? It is always a good idea to show your expected results with your example in order to clarify your description.

Note that the lookup range extends 1 row below the data.

Book1
ABCDE
1Reporting_DateAsset_NumberMarket_ValueInputs combinedOutput
230/09/2018219756,822,164.00
330/09/20182197914,355,242.002197733,506,866.00
430/09/20182197733,506,866.00219756,470,263.00
531/12/2018219756,470,263.00
631/12/20182197913,971,294.002197738,220,950.00
731/12/20182197738,220,950.00219756,916,398.00
831/03/2019219756,916,398.00
931/03/20192197913,971,294.002197738,220,950.00
1031/03/20192197738,220,950.0021975
Sheet2
Cell Formulas
RangeFormula
E2:E10E2=IF($D2="","",IFERROR(VLOOKUP($D2,$B3:$C$11,2,0),""))
 
Upvote 0
Thank you for getting back so quickly. Apologies for not adding the solution column. It should look like the below.

Reporting_DateAsset_NumberMarket_ValueInputs combinedExpected
30/09/2018​
21979​
14,355,242
21977​
21975​
31/12/2018​
21977​
38,220,950
21975​
21975​
31/03/2019​
21975​
6,916,398
21975​
 
Upvote 0
How should the results look on the larger example? Is it just those rows that should have a result, with the rest blank?
 
Upvote 0
All rows should have a result. The look up will look from one result to the next quarter, then from that result to the next quarter. The rows which have a blank value in column "Inputs combined" should show column "Asset_Number".

There will be roughly 170,000 lines.
 
Upvote 0
look from one result to the next quarter, then from that result to the next quarter.
This is the part that I'm having trouble making sense of, I would need to see the larger example from post 1 with the full range of expected results and some indication of how you arrive at each one.

Remember, you understand what you need, we can only go on the information that you provide.
 
Upvote 0
Okay, sorry I am finding it a little hard to articulate. I will try a different approach. I have made an example of values 1 to 3. Below is a formula which would work if the sample was not so big. Column "CalculationRequired" is the column that I need help with.

I need to find the final corresponding value. The final values of 1, 2 and 3 are 1, 2, 3. But before then they might be called 2, 3, 1. The column lookup value is something I have made that tells me the value for three months later to look up.

It creates a chain to follow, in the case of Jan-10 for starting value 1:

Value 1, says look up 2 in Apr-10.
In Apr-10 value 2 says look up 1 in Jul-10.
In Jul-10 value 1 says look up 3.
In Oct-10 value 3 says your value is 3.


DateValueLookupValueCalculationRequiredFormula
Jan-10​
1​
2​
3​
=SUMPRODUCT(($A$2:$A$13=EOMONTH(A2,9))*($B$2:$B$13=SUMPRODUCT(($A$2:$A$13=EOMONTH(A2,6))*($B$2:$B$13=SUMPRODUCT(($A$2:$A$13=EOMONTH(A2,3))*($B$2:$B$13=C2),$C$2:$C$13)),$C$2:$C$13)),$C$2:$C$13)
Jan-10​
2​
3​
1​
=SUMPRODUCT(($A$2:$A$13=EOMONTH(A3,9))*($B$2:$B$13=SUMPRODUCT(($A$2:$A$13=EOMONTH(A3,6))*($B$2:$B$13=SUMPRODUCT(($A$2:$A$13=EOMONTH(A3,3))*($B$2:$B$13=C3),$C$2:$C$13)),$C$2:$C$13)),$C$2:$C$13)
Jan-10​
3​
1​
2​
=SUMPRODUCT(($A$2:$A$13=EOMONTH(A4,9))*($B$2:$B$13=SUMPRODUCT(($A$2:$A$13=EOMONTH(A4,6))*($B$2:$B$13=SUMPRODUCT(($A$2:$A$13=EOMONTH(A4,3))*($B$2:$B$13=C4),$C$2:$C$13)),$C$2:$C$13)),$C$2:$C$13)
Apr-10​
1​
2​
2​
Apr-10​
2​
1​
3​
Apr-10​
3​
3​
1​
Jul-10​
1​
3​
3​
Jul-10​
2​
2​
2​
Jul-10​
3​
1​
1​
Oct-10​
1​
1​
1​
Oct-10​
2​
2​
2​
Oct-10​
3​
3​
3​
 
Upvote 0
That helps a lot, I follow what you 're trying to do now. I don't think that it's going to be easy with any approach.

I agree with your original statement that it will most likely require vba (a macro) but I'm going to have a look at formula methods first (probably not practical with ~170k rows, but it helps me think more logically with the vba).
 
Upvote 0
I've given up on formulas and resorted to vba.

Are the dates in the first column always quarter end dates (31/3, 30/6, 30/9, and 31/12) or can they be variable?

Will there be any point where an entry for a given quarter could be missing and the loop needs to skip to the next quarter (advance 6 months instead of 3) or should such a gap always be considered as the end of the loop?

Is the data always sorted in date order (oldest first)?
 
Upvote 0

Forum statistics

Threads
1,215,222
Messages
6,123,709
Members
449,118
Latest member
MichealRed

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