Finding the lowest cost dynamically

traveler84

New Member
Joined
Feb 17, 2020
Messages
12
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
On my spreadsheet, I have multiple addresses with vendor bids. The addresses might be slightly different such as an extra space or thoroughfare spelled (i.e. ST vs Street). So I was going to create a helper column that I will statically number for duplicated addresses. My list could be 10 addresses or could be 1000s. I'm trying to find a formula that can calculate the lowest cost in each group number for every address.

Here is a simplied version of the data: (could be 1 entry for an address or could be 10)
1683213393690.png


The output that I would like on another sheet would look like:
1683213429917.png


Where I am confused is how to keep running the formula to generate all the best options starting with 1 through the last number. In my mind, I am thinking of some kind of loop function that seeks all the remaining options until the last number. If the data was static, I am pretty confident I could figure it out but since the address lists could vary day to day, that's my challenge.

The SMALL function might work if I could figure out the loop till the last number and output each number. I am open to VBA which isn't my strong suit if that's what I need.

Thank you all so very much.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Perhaps this to include making all of the result table?

23 05 05.xlsm
ABCDEFG
11123 Elm$5001123 Elm500
21123 Elm street$6002100 Elm Street200
31123 Elm st$7003999 Elm300
4
52100 Elm Street$200
62100 Elm St.$600
7
83999 Elm$500
93999 Elm st$600
103999 Elm$300
11
Lowest
Cell Formulas
RangeFormula
E1:E3E1=LET(r,A1:A10000,UNIQUE(FILTER(r,r<>"")))
F1:F3F1=VLOOKUP(E1#,A1:B10000,2,0)
G1:G3G1=MINIFS(C1:C10000,A1:A10000,E1#)
Dynamic array formulas.
 
Upvote 1
Perhaps this to include making all of the result table?
Thanks Peter!

I started to explore expanding the results by adding the city, state, zip. Then I got greedy and added the vendor name next to the price. No matter if I change the Vlookup to True or False, it seems to not always give me the correct name to the corresponding price point.

Some are matching up but like this example here, but on location 3, it shows up as Acme but should be ZZZ. Is there a way to match the result with the lowest price point? Would I need an index / match formula for that one? Just not sure how to implement with a unique filter if it's even possible.

1683290162704.png
 
Upvote 0
How about
Fluff.xlsm
ABCDEFGHIJKLMNO
11123 ElmStatealw5001123 ElmStatealw500
21123 Elm streetStatebmx6002100 Elm StreetStateepaa200
31123 Elm stStatecny7003999 ElmStatejuaf300
4
52100 Elm StreetStateepaa200
62100 Elm St.Statefqab600
7
83999 ElmStatehsad500
93999 Elm stStateitae600
103999 ElmStatejuaf300
11
Sheet4
Cell Formulas
RangeFormula
I1:I3I1=UNIQUE(FILTER(A1:A1000,A1:A1000<>""))
O1:O3O1=MINIFS(G1:G1000,A1:A1000,I1#)
J1:N3J1=FILTER($B$1:$F$1000,($A$1:$A$1000=I1)*($G$1:$G$1000=O1))
Dynamic array formulas.
 
Upvote 0
That does work but would require for me to paste the J1:N3 values in every possible cell due to the unknown of volume that will be presented in each situation. The Unique filter works as I input more data but leaves the remaining cells blank due to no spill.

Excel Formula:
=XLOOKUP(A2,(A2)*(MRC=G2),Vendor)

I am stepping away from the example and copying/pasting the exact code in my sheet. The above works as well and provides the results but I wanted to figure out if there's a way to spill the results so I don't have to copy/paste in each cell. I got an error when I try to add # to either A2 or both.

Just trying to prevent copying the formulas and freezing up the sheet with 100,000 formulas copied just to account for the possibility of it being that many results.
 
Upvote 0
Realistically how many rows are you likely to have in col I
 
Upvote 0
Just to clarify on my reply earlier, A2 is the number I gave each address a unique number like 1,2,3,4,5, etc. A1 is a header. In the example, the unique values start in A1.

The largest amount of addresses was 50,000 at one time. But each address could have multiple vendor bids. Most of the time, it's between 10-1000 but it's not uncommon to see 10,000 or more.
 
Upvote 0
The only way I can of to get the formula to spill down is to use the REDUCE function, but over that number of rows it is likely to be very very slow.
Personally I think you would be better of dragging the formula down, unless someone else can think of another way.
 
Upvote 0
Had an idea, how about
Fluff.xlsm
ABCDEFGHIJKLMNO
11123 ElmStatealw5001123 ElmStatealw500
21123 Elm streetStatebmx6001123 Elm stStatecny500
31123 Elm stStatecny5002100 Elm StreetStateepaa200
43999 ElmStatejuaf300
52100 Elm StreetStateepaa200
62100 Elm St.Statefqab600
7
83999 ElmStatehsad500
93999 Elm stStateitae600
103999 ElmStatejuaf300
Sheet4
Cell Formulas
RangeFormula
I1:O4I1=LET(u,UNIQUE(FILTER(A1:A1000,A1:A1000<>"")),m,MINIFS(G:G,A:A,u),FILTER(A1:G1000,BYROW((A1:A1000=TOROW(u))*(G1:G1000=TOROW(m)),LAMBDA(br,SUM(br)))))
Dynamic array formulas.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,090
Messages
6,123,061
Members
449,091
Latest member
ikke

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