Obtaining Price based on Date

Marhier

Board Regular
Joined
Feb 21, 2017
Messages
128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Good afternoon everyone, I hope you're well.
I've got a problem I'm hoping someone can help me solve; I'll try my best to explain what I'm trying to do.

I'm trying to write a formula that looks at cell $D3, finds it from table reference Data2[StockCode] (on a different worksheet), then looks at cell G$2, finds that from table reference Data2[PriceStartDate] and returns the price from table reference Data2[PurchasePrice].

Where I want my results looks as follows:

1683124994224.png


This would be a lot simpler if the 'Data2' table had each month's price in, but all I have is when the price starts, so as an example:

1683126205970.png


So I need the formula to look cell reference G$2, then look at Data2[PriceStartDate] and figure out what the price should be for the month in G$2.

The final result should look as follows:

1683126780915.png


Hopefully I've explained that well.
If someone could come up with a formula for it, it would be greatly appreciated.

I should note that I've added $'s to my references as I want to be able to drag the formula up and down to cover my whole range.
I would also like the table references to be absolute references as well.

All help is greatly appreciated.
Thank you.
Regards,
Marhier.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
How about
Excel Formula:
=INDEX(FILTER(Data2[PurchasePrice],(Data2[StockCode]=d3)*(Data2[PriceStartDate]<=g2)),1)
 
Upvote 0
Solution
Thanks for the fast reply, Fluff.
This returns a #CALC!
 
Upvote 0
That suggests that nothing matches both criteria.
Check that the dates in the Data2[PriceStartDate] column are real dates & not numbers. They look as though they could be text.
 
Upvote 0
Hi Fluff.
I've checked, and all the cells in column Data2[PriceStartDate] are formatted as dates.
 
Upvote 0
If you format the entire column as General, do you still see dates?
 
Upvote 0
No, when changing to general, they turn to numbers.
 
Upvote 0
Ok, That's fine. Check that you don't have any leading/trailing spaces in the stock code cells.
 
Upvote 0
Hi Fluff.

Spot on!
I did a find and replace on the stock code column and there was a space at the end of each stock code.

I can confirm the formula you suggested works a treat!
I really can't thank you enough for this; you've helped me a few times in the past and I really appreciate it.

Thank you.
Regards,
Marhier.
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,077
Members
449,094
Latest member
mystic19

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