Solved

Scaled multiplier

Posted on 2014-03-06
4
158 Views
Last Modified: 2014-03-09
I have a number in a table. I would like to build a query that will multiply that number by a decimal. The tricky part is the decimal increases based on the value of the number. There are 5 scales

Any part of the number between 0 and 315,000 Multiply by  0.000158730
Any part between 315,00 and 374,000 add the prior part and multiply remainder by  0.000423729
Any part between 374,000 and 480,000 add the prior parts and multiply remainder by  0.000471698
Any part between 480,000 and 585,000 add the prior parts and multiply remainder by   0.000714286
Any part between 585,000 and up add the prior parts and multiply remainder 0.000588235

The number will be anywhere from 0 to 1,000,000. There is only one number to do it to, not like a whole column of numbers. It just needs to be done once. Any idea how I would make this happen?

Thanks!
0
Comment
Question by:cansevin
  • 2
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39909600
Hi,

You could use this logic to create an UDF

Sub Macro()
myNumber = 999999
Res1 = Min(315000, myNumber) * 0.00015873
Res2 = Min(59000, Max(0, myNumber - 315000)) * 0.000423729
Res3 = Min(106000, Max(0, myNumber - 374000)) * 0.000471698
Res4 = Min(105000, Max(0, myNumber - 480000)) * 0.000714286
Res5 = Max(0, myNumber - 585000) * 0.000588235
Result = Res1 + Res2 + Res3 + Res4 + Res5
End Sub

Function Max(First, Second)
If First > Second Then
    Max = First
Else
    Max = Second
End If
End Function

Function Min(First, Second)
If First < Second Then
    Min = First
Else
    Min = Second
End If
End Function

Open in new window

EDIT

or

Result: IIf([Rec]>=315000;315000;[Rec])*0.00015873+IIf([Rec]-315000>0;IIf([Rec]>=374000;59000;[Rec]-315000);0)*0.000423729+IIf([Rec]-374000>0;IIf([Rec]>=480000;106000;[Rec]-374000);0)*0.000471698+IIf([Rec]-480000>0;IIf([Rec]>=585000;105000;[Rec]-480000);0)*0.000714286+IIf([Rec]-585000>0;[Rec]-585000;0)*0.000588235

Open in new window

Regards
0
 

Author Comment

by:cansevin
ID: 39912757
Thanks! I am trying to use your 2nd option... the long line of code.

Unfortunately when I copy and pasted the code. It says "The expression you entered contains invalid syntax". When I hit "OK", it goes in a highlights the first semi-colon between the two 315000's.

Any idea?

Thanks for your help, much appreciated!
0
 

Author Closing Comment

by:cansevin
ID: 39912980
Thanks!
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 39916812
Like you have probably remarked the ; is equivalent of , in my localization

I have forgotten to replace it

Regards
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
work allocation; web development; vba; access; 4 46
Access Date Query 28 30
Another multiple criteria puzzle 4 19
SQL Query 3 0
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now