Index match equivalent in Access

Kobierok

New Member
Joined
Jan 12, 2016
Messages
3
Hi All,

Im trying to create a query in Access which in fact is replication of index match excel function:

I have a source table

ObjectDiso**** 1Diso**** 2Diso**** 3
X1%2%4%
Y3%1%2%
Z5%0%1%

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

and would like to create a query which would feed another table

ObjectTYPE%
XDiso**** 11%
XDiso**** 2
XDiso**** 3
YDiso**** 1
YDiso**** 2
YDiso**** 3
ZDiso**** 1
ZDiso**** 2
ZDiso**** 3

<colgroup><col><col><col></colgroup><tbody>
</tbody>


in excel I would use index match, but dont know how to proceed in access as all typical relation type queries failed.
Is anyone dealt with such an issue and could suggest any solution?


Regards,

Karolina
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
This is just a thought; You could use a tab in the Excel doc., and do the Index-Match formulas, then reference the answer in the Access database, and work with it from there...
 
Upvote 0
Here is a SQL statement for you.

SELECT table3.Object, "Diso**** 1" AS Type, table3.[Diso**** 1] AS [Percent]
FROM table3;
UNION
SELECT table3.Object, "Diso**** 2" AS Type, table3.[Diso**** 2] AS [Percent]
FROM table3;
UNION
SELECT table3.Object, "Diso**** 3" AS Type, table3.[Diso**** 3] AS [Percent]
FROM table3;

this could all be avoided if your data in your source table was normalized.
 
Last edited:
Upvote 0
Thank you so much :) it worked perfectly!



Here is a SQL statement for you.

SELECT table3.Object, "Diso**** 1" AS Type, table3.[Diso**** 1] AS [Percent]
FROM table3;
UNION
SELECT table3.Object, "Diso**** 2" AS Type, table3.[Diso**** 2] AS [Percent]
FROM table3;
UNION
SELECT table3.Object, "Diso**** 3" AS Type, table3.[Diso**** 3] AS [Percent]
FROM table3;

this could all be avoided if your data in your source table was normalized.
 
Upvote 0
hello Mr @alansidman, i have the same problem and i don't know exactly how to use your solution. could you please support? it would be very helpful as i have a project for work.. horatiu00@gmail.com is my email. Thank you so much in advance!
 
Upvote 0
Prices Prices

IDModelAustriaGermanyUK
1​
LaptopS
$2.00​
$7.00​
$11.00​
2​
LaptopM
$3.00​
$5.00​
$8.00​
3​
DesktopE
$5.00​
$9.00​
$10.00​
4​
DesktopE
$12.00​
$14.00​
$7.00​
5​
LaptopM
$6.00​
$15.00​
$17.00​
Table1 Table1

IDModelPriceCountry
1​
LaptopS
Germany
2​
DesktopE
Austria
3​
LaptopM
UK
I need the Price field from table Table1 to be populated with the data from table Prices based on the Model and Country.
 
Upvote 0
Prices Prices

IDModelAustriaGermanyUK
1​
LaptopS
$2.00​
$7.00​
$11.00​
2​
LaptopM
$3.00​
$5.00​
$8.00​
3​
DesktopE
$5.00​
$9.00​
$10.00​
4​
DesktopE
$12.00​
$14.00​
$7.00​
5​
LaptopM
$6.00​
$15.00​
$17.00​
Table1 Table1

IDModelPriceCountry
1​
LaptopS
Germany
2​
DesktopE
Austria
3​
LaptopM
UK
I need the Price field from table Table1 to be populated with the data from table Prices based on the Model and Country.
One of your big problems is your Proces table is not normalized (see the "Applying the normalization rules" section in this article: Database design basics). It can be very difficult to get data from tables that are not normalized.

In a normalized table, you typically do NOT need to create new fields to add new data. In your example, what if you wanted to add more countries? You could not do it without adding new fields, which creates a whole lot of other database maintenance.

If you designed your Prices data table according to the Rules of Normalization, your strucutre should look something like this:
IDModelCountryPrice
1​
LaptopSAustria
$2.00​
1​
LaptopSGermany
$7.00​
1​
LaptopSUK
$11.00​
2​
LaptopMAustria
$3.00​
2​
LaptopMGermany
$5.00​
2​
LaptopMUK
$8.00​
3​
DesktopEAustria
$5.00​
3​
DesktopEGermany
$9.00​
3​
DesktopEUK
$10.00​
4​
DesktopEAustria
$12.00​
4​
DesktopEGermany
$14.00​
4​
DesktopEUK
$7.00​
5​
LaptopMAustria
$6.00​
5​
LaptopMGermany
$15.00​
5​
LaptopMUK
$17.00​

(Note: I am not sure if "ID" is meant to by tied to the "Model", or if it is just a unique record identifier. If the later, you would just have the numbers 1-15 then).

Notice how "County" is a field. So if you need to add other countries, you don't need to add new fields,. just new data rows.

Then if you have another Table of Countries and Models, you would just get the price by doing a query between the two tables, joining on the "Model" and "Country" fields, and retuning the price from the Prices table.

Note in databases, you should NEVER put/store calculations or fields that are calculated at the table level. You return these in a query.
 
Upvote 0
Thank you for the support @Joe4 ! My original database is having 50 countries and 20 models and every 6 months the prices are changing. So instead of 20 rows i will have to do 1000 every 6 months . Is no other way? :(
 
Upvote 0

Forum statistics

Threads
1,221,519
Messages
6,160,298
Members
451,636
Latest member
ddweller151

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