Access Index Match type question

karcpr

New Member
Joined
Sep 21, 2011
Messages
13
I need your help if you don't mind. I am working off access and all of of "excel/access guru's" have never heard of index/match, so I didn't feel that I could really take their advice seriously.

So, my question is this. I have an index match that is relatively simple. Get the qty, find where it goes, identify the cost and be done. Is there a way to do this in access without SQL or VBA? I am not terribly skilled with either language and see that others have have luck but it is through writing code and I don't know if I can reproduce the code if I had to do it again.

Is there anything without doing a boatload of stacked IIF statement formulas?

QtyQuantity 01Quantity 02Quantity 03Quantity 04Quantity 05Quantity 06Quantity 07Quantity 08Quantity 09Quantity 10Quantity 11Quantity 12Unit Cost 1Unit Cost 2Unit Cost 3Unit Cost 4Unit Cost 5Unit Cost 6Unit Cost 7Unit Cost 8Unit Cost 9Unit Cost 10Unit Cost 11Unit Cost 12
35120100250500999999999999999999999999999999999999999999999999999999999999999121.88121.88103.6103.6103.6
17120100250500999999999999999999999999999999999999999999999999999999999999999121.88121.88103.6103.6103.6
85120100250500999999999999999999999999999999999999999999999999999999999999999121.88121.88103.6103.6103.6
9252575125275500999999999999999999999999999999999999999999999999999999250.17230.92196.28196.28196.28
47012010025050099999999999999999999999999999999999999999999999999999999999999939.2439.2433.3533.3533.35
12512010025050099999999999999999999999999999999999999999999999999999999999999939.2439.2433.3533.3533.35

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Can you explain exactly what it is you are trying to do?
You posted some data, which is good. Now can you explain your expected results and the logic behind it?
 
Upvote 0
Hi Joe,
I am working with 250k+ parts. Below I attached what I would have done on excel. I could do this on excel but with the bandwidth, I would really like to do it on access. I can also easily nest some of these items but I wanted to keep it simple. Thank you for your reply.

ABCDEFGHI JKLMNOPQRSTVWXYZAAABACADAEAFAGAHAIAJAKALAMANAO
QtyQuantity 01Quantity 02Quantity 03Quantity 04Quantity 05Quantity 06Quantity 07Quantity 08Quantity 09Quantity 10Quantity 11Quantity 12Unit Cost 1Unit Cost 2Unit Cost 3Unit Cost 4Unit Cost 5Unit Cost 6Unit Cost 7Unit Cost 8Unit Cost 9Unit Cost 10Unit Cost 11Unit Cost 12MATCHmatch formulaDesired Breakbreak formulaNext column next break costnext break cost formulaExtended current pricingextended current pricing formulaextended next breakextended next break formuladelta between break 1 and 2delta between break 1 and 2 formula% difference% difference formula
35120100250500999999999999999999999999999999999999999999999999999999999999999121.9121.9103.6103.6103.6 121.88INDEX(N3:Y3,MATCH(A3,B3:M3,1))20INDEX(B3:M3,MATCH(A3,B3:M3,1))100INDEX(B3:M3,MATCH(A3,B3:M3,1)+1)103.6INDEX(N3:Y3,MATCH(A3,B3:M3,1)+1) $ 2,437.60 MATCH*Desired_break $ 10,360.00 Next_column*Next_col_break_cost $ 7,922.40Extended_next_break-Extended_Current_Pricing76%1-(Extended current pricing/extended next break)

<colgroup><col><col span="5"><col span="7"><col span="5"><col span="4"><col span="3"><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>


-Chris
 
Upvote 0
What makes this very tough to do in Access is that your data table is not Normalized (working with data that is not Normalized can be very difficult to do in Relational Database like Access, SQL, or Oracle). If you can normalize your data, you can do what you want without having to use VBA.

In a normalized data table, you would not have multiple columns in a single record for each Quantity and Cost. Rather, you would have multiple records, with a single Quantity and Cost column, like this:
ItemNumQuantityCost
011$121.90
0220$121.90
03100$103.60
04250$103.60
05500$103.60
06999999999$0.00
07999999999$0.00
08999999999$0.00
09999999999$0.00
10999999999$0.00
11999999999$0.00
12999999999$0.00

<tbody>
</tbody>

Let's call this Table1. This is basically the table of the values you want to lookup. Now, let's create another table that has the value we want to lookup, like this:
LookupQuantity
35

<caption> Table2 </caption><thead>
</thead><tbody>
</tbody><tfoot></tfoot>

Then, we can create a Query using Table2 as the Source. To this Query, we add our LookupQuantity field, and then we add the following calculated fields:
Code:
Match_Formula: DMax("Quantity","Table1","Quantity < " & [LookupQuantity])+0
Break_Formula: DLookUp("Cost","Table1","Quantity =" & [Match_Formula])+0
The results of that query give you the values you are looking for.
LookupQuantityMatch_FormulaBreak_Formula
3520121.9

<caption> Query1 </caption><thead>
</thead><tbody>
</tbody><tfoot></tfoot>
 
Upvote 0
Joe,
Unfortunately, I will not have the opportunity to normalize the data. Since this is based on multiple parts which have multiple different dynamic breaks, it is not a possibility.

If it is not able to be done via formula, is there a fairly simplistic VBA code that can achieve this?
 
Upvote 0
The thing to understand about Access, is that it is not simply a replacement for Excel. It is a very different "beast", by nature. Where Excel is a spreadsheet program, Access is a relational database program. As such, they think and work very differently. When looking for things, Access wants to look in a single field, down multiple records (as opposed to across multiple fields in a single record, like you are trying to do).

Just like with Excel, though, you could come up with some complex formulas or VBA code to force it to do a lot of things the hard way. What you want to do can conceivably be done with VBA. For an experienced VBA Programmer, it probably wouldn't be too difficult, though I don't know if I would call it simple. If you have a single table, and the value you are looking up and all the fields you are looking into are contained within each single record (line), I would probably go the route of trying to create UDFs for each value you are trying to look up.
 
Upvote 0

Forum statistics

Threads
1,222,017
Messages
6,163,398
Members
451,835
Latest member
kristianb63

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