Results 1 to 6 of 6
  1. #1
    Arnold is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    43

    Multiple IIf and Multiple Calculation in query

    Hello All,

    My DB has Items in [Categories] x,y, and z.
    Each has a unique mark up over the the [cost]
    x = *1.20


    y = *1.25
    z = *1.30

    Depending on the [cost] I would like to add an additional perc.
    <50 = .20
    >50<200 = .10
    >200 = .05

    After the above calculation I would like to add [shipping],(and Round to to 2 decimals)

    SO ItemA [cost] (55.00) that belongs to [categories]z and [shipping](12.00)
    (55*1.40)+12.00 = 89.

    How would I calculate this?

    Thanks in advance

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    something like:

    ([cost] * ([CategoryMarkup] + iif(cost <50, .2, iif(cost > 200, .05, .1)))) + [ShippingCharge]

    check the bracketing though I'm not sure I got it right.

  3. #3
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Given your data.
    55*z + additional comes to 7.15 for me. can you verify?

  4. #4
    Arnold is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    43
    Thank you

    If I would like to add multiple IIf to this
    [cost]<50 and [categories]y IIf [cost]>200 [categories]x etc.
    how would I do it?

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You have two variables driving the end cost of your item.

    The category (x, y and z)
    The Cost of the original item (broken out by cost)

    If you can define your categories for the COST based percentage in a TABLE like (I assume) you are doing with your categories (x, y and z)

    you do not need multiple IIF's to account for every combination.

    your category is adding a percentage (.2, .25 and .3) and your original item cost is adding a percentage (.2, .1 and .05) the formula I gave you will work assuming you only have three price range categories, if you have more than 3 I would build a table supporting that structure that you can change over time rather than having to change your formulas everywhere they exist.

    The formula assumes CATEGORYMARKUP is your 1.2, 1.25 or 1.3, the part of the formula that reads iif(cost <50, .2, iif(cost > 200, .05, .1)) is figuring out the cost bracket percentage increase, when the original cost is multiplied by this you should get the proper number

    In your case (55 * (1.3 + .1)) + [ShippingCharge] or (55 * 1.4) + [ShippingCharge] ====> 77 + [ShippingCharge]

  6. #6
    Arnold is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    43
    Thanks

    I think I got it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-26-2014, 03:02 PM
  2. Replies: 2
    Last Post: 12-04-2013, 03:49 PM
  3. Replies: 6
    Last Post: 07-29-2013, 05:05 AM
  4. Replies: 5
    Last Post: 02-23-2013, 06:36 PM
  5. Same calculation on multiple fields
    By tko in forum Queries
    Replies: 4
    Last Post: 05-29-2011, 12:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums