Solved

Scaled multiplier

Posted on 2014-03-06
4
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

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 52

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

632 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