Lookup Query Criteria vs Return Value

mackc557

Board Regular
Joined
Nov 3, 2021
Messages
125
Office Version
  1. 2019
Platform
  1. Windows
I'm trying to create a Lookup Query for a tax percentage. My Table contains a AutoNum for the purpose of order, a Number named StoreID, and a Number named TaxRate. There are other things, but they aren't relevant to this. I'm trying to get the most recently stored TaxRate (using the AutoNum) that the StoreID had. For example: Store1 January rate is 0.875, Store1 February rate is 0.88, Store1 March rate is 0.7, when entering Store1 April the box should show 0.7 since it's the most recent. Any ideas on how to set up a query for this? I really don't want to use SQL.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
You should really NOT use the AutoNum field in any sort of calculations. The sole purpose of an AutoNum field is to give a record a unique identifier. Order cannot be guaranteed with it.
It would be better to work off of your Store ID field, and use some sort of date field so each record can be ordered properly.
Then you could do an Aggregate Query, selecting the Max Date field for each store, and then link that query back to your original table (based on BOTH the Store ID and Date fields) to return the Tax Rate for that date.

By the way, when you use the Query Builder, you actually are creating SQL code (behind the scenes).
 
Upvote 0
Solution
By the way, when you use the Query Builder, you actually are creating SQL code (behind the scenes).
I am aware of this, I just would prefer not to do much of the SQL coding myself. I've taken classes on it and have trouble with it.

You should really NOT use the AutoNum field in any sort of calculations. The sole purpose of an AutoNum field is to give a record a unique identifier. Order cannot be guaranteed with it.
It would be better to work off of your Store ID field, and use some sort of date field so each record can be ordered properly.
Then you could do an Aggregate Query, selecting the Max Date field for each store, and then link that query back to your original table (based on BOTH the Store ID and Date fields) to return the Tax Rate for that date.
I do understand that the AutoNum can't guarantee order. That being said, I can't seem to properly get the expected results, so I will trust your judgement and use a date field.
 
Upvote 0
If you cannot get it to work out, post a sample of your updated data (with dates), and I can help you come up with it.
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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