Comparing Timetables: Index-Match Formula to find Closest Value with Multiple Conditions?

ParMizan

New Member
Joined
Apr 25, 2014
Messages
6
Hello All, this is my first post, so apologies if I come across noob-ish!

What I am trying to do is compare 'Prices' between different 'Providers' for 'Trips' that they all run/operate - Public Transport for instance. The raw data might look something like this if simplified:

ProviderTripDateTimePrice
AX25/04/201409:0015
AX25/04/201415:0020
AX25/04/201421:0018
AY25/04/201407:006
AY25/04/201412:009
AY25/04/201418:007
BX25/04/201409:4516
BX25/04/201414:3019
BX25/04/201422:0020
BY25/04/201408:008
BY25/04/201413:306
BY25/04/201417:459

<tbody>
</tbody>

I want to compare prices between 'Providers' side by side for the same 'Trip' running on the same 'Date' and 'Time.' The problem I have is that all Providers do not always operate at the same Time, so I want to compare the Price for the closest possible time in this case - larger, smaller or even when they are the same. This rules out 'Approximate Vlookups' which is a shame.

I want the comparison table, in a separate sheet, to look like this, using the timetable for Provider A:

TripDateTimePrice APrice B
X25/04/201409:001516
X25/04/201415:002019
X25/04/201421:001820

<tbody>
</tbody>

* Is using formulas the best way to achieve this? Please let me know - I have very-basic VBA skills.

I can fill the Price A column quite easily using a 'Sumifs' formula. But I'm having real trouble filling column Price B with the correct data.

I've been trying to use Vlookups and Index-Match formulas to fill column Price B using the raw data but haven't had much luck. I know how to find the closest possible time match using:

{=INDEX(return_range,MATCH(MIN(ABS(time_range - Time)),ABS(time_range - Time),0)}

But I don't know how to include conditions to ensure that Trip and Date values are exactly the same for both Providers A and B. I've tried to combine the above formula with an If statement like so:

{=INDEX(IF(test,return_range),MATCH(MIN(ABS(time_range - Time)),ABS(time_range - Time),0)}

But cannot get it to work correctly. Is there an alternative to this formula?

Any help would be greatly appreciated!

Thanks.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,215,432
Messages
6,124,858
Members
449,194
Latest member
HellScout

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