Search for Date of Last Price Change

andrewr1

New Member
Joined
Dec 19, 2012
Messages
6
I was hoping that someone can help me in writing array formulas in excel that would return pricing from "Last Ordered" and the "Date of price changed" from a list of invoices.

Below would be the example of the information that I need from the data table. Please help.

Item#: 201 (entered value)
Last Ordered: 4/24/18 (formula, the latest invoice that includes the item#, this is where I need the help)
Current Price: $7.00 (formula, pricing from latest invoice, which can be a simple vlookup from "Last Order")
Date of Price Change : 8/28/17 (formula, the most recent invoice that is <> the Current Price, this is where I need the help)
Previous Price: $6.50 (formula, which can be a simple vlookup from "Date of Price Change")

In this example the "Date of Price Change" formula would skip over 11/20/17 because the pricing is still $7.00. The pricing is not <> the current price. And would instead return 8/28/17 because that price < current price.

Thanks again for any help


Data
Column A
Column B
Column C
Date
Item #
Price
5/11/18
324
$7.00
4/24/18
201
$7.00
1/1/18
324
$6.00
11/20/17
201
$7.00
10/9/17
324
$6.00
10/9/17
324
$6.00
8/28/17
201
$6.50
7/17/17
201
$6.50
6/5/17
324
$5.50
4/24/17
201
$6.00
3/13/17
324
$5.50
1/30/17
201
6.50

<tbody>
</tbody>
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try:

ABCDEFG
1DateItem #PriceItem
25/11/2018324$7.00201
34/24/2018201$7.00
41/1/2018324$6.00Last Ordered:4/24/20184/24/2018
511/20/2017201$7.00Current Price$7.00
610/9/2017324$6.00Previous Price$6.50
710/9/2017324$6.00Previous Date8/28/2017
88/28/2017201$6.50
97/17/2017201$6.50
106/5/2017324$5.50
114/24/2017201$6.00
123/13/2017324$5.50
131/30/20172016.5

<tbody>
</tbody>
Sheet14

Worksheet Formulas
CellFormula
F4=MAXIFS(A2:A13,B2:B13,E2)

<tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
G4{=MAX(IF(B2:B13=E2,A2:A13))}
F5{=INDEX(C2:C13,MATCH(E2&"|"&F4,B2:B13&"|"&A2:A13,0))}
F6{=IFERROR(INDEX(C2:C13,SMALL(IF(B2:B13=E2,IF(C2:C13<>F5,ROW(C2:C13)-ROW(C2)+1)),1)),"")}
F7{=IF(F6="","",INDEX(A2:A13,MATCH(E2&"|"&F6,B2:B13&"|"&C2:C13,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>



If you don't have the MAXIFS function (F4 formula), the G4 array formula should work.
 
Upvote 0
Given the layout of your data, I think that you could also try these formulas, none of which require the Ctrl+Shift+Enter confirmation.
(Note that my dates are in d/m/y format)

Excel Workbook
ABCDEF
1DateItem #PriceItem201
211/05/2018324$7.00Last Ordered24/04/2018
324/04/2018201$7.00Current Price$7.00
41/01/2018324$6.00Previous Price$6.50
520/11/2017201$7.00Previous Date28/08/2017
69/10/2017324$6.00
79/10/2017324$6.00
828/08/2017201$6.50
917/07/2017201$6.50
105/06/2017324$5.50
1124/04/2017201$6.00
1213/03/2017324$5.50
1330/01/2017201$6.50
Price Changes
 
Upvote 0
Thanks Eric that worked great! Doesn't an array take up a significant of memory? If I need to repeat these formulas a significant number of times, is that going to give Excel a problem.
 
Upvote 0
Thanks Pete, that also worked well! I like the see the different techniques.

I have not worked with the aggregate function in indexes. I am going to have to look into that one. Thanks again.
 
Upvote 0
Glad it works for you!

An array takes up as much memory as it needs to handle the range you give it. And if you give it a large range, it could take a lot of time too. The problem is that your question seems to require array processing. If your sheet starts to bog down, you could give Peter's formulas a shot. His F4:F5 formulas are still array formulas, even if they don't require CSE, but since they use different functions, they still could be faster. I couldn't say without some testing.

If those still cause issues, you could replace them with an event macro. Whenever you enter your item number in E2 or F1, or whatever cell(s) you want, the macro would kick off and look up the results. So it would only run as needed. Let us know how the formulas work first though.
 
Upvote 0
Thanks Pete, that also worked well! I like the see the different techniques.

I have not worked with the aggregate function in indexes. I am going to have to look into that one. Thanks again.
Glad to contribute. I agree with Eric's comments about the array formulas. If you have a lot of them and the ranges being assessed are large, there could be a performance impact but let's just see how it goes.
 
Upvote 0
Try:

ABCDEFG
1DateItem #PriceItem
25/11/2018324$7.00201
34/24/2018201$7.00
41/1/2018324$6.00Last Ordered:4/24/20184/24/2018
511/20/2017201$7.00Current Price$7.00
610/9/2017324$6.00Previous Price$6.50
710/9/2017324$6.00Previous Date8/28/2017
88/28/2017201$6.50
97/17/2017201$6.50
106/5/2017324$5.50
114/24/2017201$6.00
123/13/2017324$5.50
131/30/20172016.5

<tbody>
</tbody>
Sheet14

Worksheet Formulas
CellFormula
F4=MAXIFS(A2:A13,B2:B13,E2)

<tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
G4{=MAX(IF(B2:B13=E2,A2:A13))}
F5{=INDEX(C2:C13,MATCH(E2&"|"&F4,B2:B13&"|"&A2:A13,0))}
F6{=IFERROR(INDEX(C2:C13,SMALL(IF(B2:B13=E2,IF(C2:C13<>F5,ROW(C2:C13)-ROW(C2)+1)),1)),"")}
F7{=IF(F6="","",INDEX(A2:A13,MATCH(E2&"|"&F6,B2:B13&"|"&C2:C13,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>



If you don't have the MAXIFS function (F4 formula), the G4 array formula should work.
This is all great information and thanks for sharing it. :) Now, I tried these formulas because I have a similar issue. I am tracking price changes with each vendor we purchase from for parts and whatnot. Now I have a table similar to Eric. I attempted your instructions and eureka it worked until I sorted my table from descending to ascending order for the date, to test the theory. When I did that the current date changed to previous date and visa versa. Also, for previous cost it was only pulling the original cost that I put in for the first time for the item. Not the date in between the current and original date when the price had changed. ie. Originally purchased item on Aug 14, '07 for .96, then there was a change on Sept 17, 09, purchased at 3.00, and the current date and price is 3.30 and that change was Jan 24, '13. Im assuming the formulas should have pulled my September price, no? So what am I doing wrong? Please help.
 
Upvote 0

Forum statistics

Threads
1,215,332
Messages
6,124,313
Members
449,152
Latest member
PressEscape

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