Jump to content

This topic is 5672 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted (edited)

Hi,

I have been struggling with this. I have a database of items for sale. Each item can have a constant discount, so "Widget A" always gets a discount of 10%, this of course is easy to calculate:

Price * Discount (.1)

But what if I wanted "Widget B" to have a 10% discount from 0-100 units, 15% from 101-500 units, 20% from 500+ units? Discount becomes a dynamic variable based on Quantity. Does anyone have any tips for this kind of calculation?

Edited by Guest
Posted

How about this?

A calculated field DiscountRate, defined by:

Case(Quantity < 101; 0.10 ; Quantity < 501 ; 0.15 ; 0.20)

Then a second calculated field, Discount, defined by:

Discount = DiscountRate * Price

Posted

Cool, it's always more simple than I think.

If I could ask for one more bit of advice. What if those quantities (100 and 500) and those discounts (10, 15, 20) differ from product to product? "Widget C" could have a 30% discount only take effect at 10000+ units. I was thinking that the discounts and associated quantities could live in a different related table, that way each item could have any number of discounts. Any way to make that Case statement more portable/reusable?

This topic is 5672 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.