Dear Pbb:
If you want 40.5 to round down to 40.0 you are going to need a custom
rounding routine.
Once you have it rounded, you can retrieve the Marginrate with a JOIN on
that value, but I'm a bit leary of that. There much can go wrong there, and
can cause whole rows of data to disappear. So, I'd recommend a subquery
where you can control the NULL values that could result from a failed
lookup.
I offer this query as a starting point:
SELECT Salespgactual, Round(Salespgactual) AS LookupSales,
Nz((SELECT Marginincentive
FROM [Margin Acc table 1] M
WHERE M.Marginrate = I.Round(Salespgactual)), 99)
AS Marginincentive
FROM [Sales info] I
If the margin is not found, it will return a rate of 99. Choose any other
value you like for this. Hopefully, you won't need this value anyway.
You can use the value from lines 2-4 above inside a calculation if you like.
Please let me know if this helped, and if I can be of any further
assistance.
Tom Ellison
Pbb said:
:
Dear Pbb:
Does your SalesInfo table have a row for every integer value of Margin?
Or
does it have some other structure? Please show how this must work, with
examples. If the value of Salespgactual is 40.5 with which value in
[Margin Acc table 1].Marginrate does that align. How about 40.99?
Please show some of what is in [Margin Acc table 1] and explain the rule
you
use in looking up a value. There are a lot of potential alternatives.
Tom Ellison
I need help, I have a query where I rounded some numbers with:
Margin:Round([Sales info.Salespgactual]+0.0001,2) this rounds my number
to
whole numbers. So if I have 40.27 % it rounded it to 40.00% so on and
so
forth. My question is this I need to do a dlookup that looks at the
40.00%
in my query and looks up in a table called [Margin Acc table 1] the
40.00%
which is [Marginrate] and returns the value of .68% [Marginincentive]
which
is in column 3 of the Margin Acc table 1. I am having problems getting
it
look at the query for the answer. Please help
Continue from last post:
I did not get to finish it, it posted, so I hope that answered your
questions. Thanks for your help.....
Pbb
This is how the table looks,
Marginacctable Marginrate Marginincentive
1 41.00 0.68
1 42.00 0.75
1 43.00 0.80
1 44.00 0.90
Etc, So I want to lookup the 41 ,42, 43 etc and return the value
0.68,0.75,0.80 etc for each person margin. One this number is returned I
want
to use the 0.68 or 0.75 or 0.80 to calculate that percentage number
against
actual sales to return a commission due.
Thanks again...