Results 1 to 11 of 11

Thread: RESOLVED - Math Question (Discounts and such)

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Resolved RESOLVED - Math Question (Discounts and such)

    Hello all,
    This pertains to processing sales orders for a retailer.
    A dollar or percentage discount can be given to an individual item in an order.
    On top of that, a percentage discount can be given to the order as a whole (in which case, this percentage off is applied to each individual item in the order).

    Let's say an item costing $100 is discounted $20. So the price of the item at this point is now $80.
    At the end of the sale, a 30% overall discount is applied to the order. So now 30% off of the $80 (not $100) is taken for the item described above, thus discounting the item $24 more.
    So the total amount off of the item is $44, and the customer pays $56 for that item.

    Now - if at some later time, we wanted to look at data to reconstruct what happened on that sale, would it be possible to do so given only these three pieces of information:
    Regular Price of Item = $100
    Total Amount Off = $44
    Order Level Discount = 30%

    In other words, is there an equation that can be used to determine what portion of the $44 was a result of the 30% discount, and portion was the dollar discount?
    Last edited by BruceG; Apr 14th, 2014 at 10:19 AM. Reason: resolved
    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Math Question (Discounts and such)

    Would it not make more sense and be easier to not store the $44 but store the amount of the discount or discounted price instead. i.e. $20 or $80

  3. #3
    Member
    Join Date
    Oct 2011
    Posts
    43

    Re: Math Question (Discounts and such)

    not something like x + (100 - x)*0.3 = 44 ? -

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Math Question (Discounts and such)

    I-and-I and dbasnett: thanks very much, I thought it might be something along those lines, but couldn't quite formulate it (what can I tell ya, it's been more years than I care to mention since I had algebra class). Now all I have to do is come up with some VB code to handle this ...
    "It's cold gin time again ..."

    Check out my website here.

  6. #6

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Math Question (Discounts and such)

    Well, I'm not too proud to ask - what would the VB code look like to solve that equation?
    "It's cold gin time again ..."

    Check out my website here.

  7. #7
    Member
    Join Date
    Oct 2011
    Posts
    43

    Re: Math Question (Discounts and such)

    Quote Originally Posted by BruceG View Post
    Well, I'm not too proud to ask - what would the VB code look like to solve that equation?
    If you want to work with sales stuff you will probable work with decimals, so declare 4 doubles (give them the values you want) and just translate the formula to an x = ... ?

  8. #8

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Math Question (Discounts and such)

    Basically, I need a function that solves for "x" (x being the DollarAmountOff), where
    x + ((RegularItemPrice - x) * OrderLevelDiscount) = TotalAmountOff
    "It's cold gin time again ..."

    Check out my website here.

  9. #9
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Math Question (Discounts and such)

    quick and dirty (my data types aren't exactly right):

    Code:
    Private Sub btnCalc_Click(sender As System.Object, e As System.EventArgs) Handles btnCalc.Click
            Dim regPrice As Integer
            Dim totalOff As Single
            Dim olDiscount As Single
            Dim itemDiscoutAmt As Single
            Dim orderDiscountAmt As Single
    
            regPrice = 100
            totalOff = 44
            olDiscount = 0.3
    
            itemDiscoutAmt = regPrice - (regPrice - totalOff) / (1 - olDiscount)
            orderDiscountAmt = totalOff - itemDiscoutAmt
        End Sub

  10. #10

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Math Question (Discounts and such)

    vbfbryce - thanks very much, that helps me out.
    Thanks again to all for your help.
    "It's cold gin time again ..."

    Check out my website here.

  11. #11
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Math Question (Discounts and such)

    Quote Originally Posted by BruceG View Post
    Well, I'm not too proud to ask - what would the VB code look like to solve that equation?
    Code:
        'based on the example
        'cash discount - x
        Dim cashDisc As Decimal
    
        'item price
        Dim itemPrice As Decimal = 100D
    
        'total off
        Dim totOff As Decimal = 44D
    
        'order discount
        Dim ordDisc As Decimal = 0.3D
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            'x + (itemPrice - x) * ordDisc = totOff 
            'distribute
            'x + (itemPrice * ordDisc) - (x * ordDisc) = totOff 
            'x - (x * ordDisc) + (itemPrice * ordDisc) = totOff 
    
            'combine like terms
            'x - (x * ordDisc) in our exaqmple is .7x
            Dim tempCD As Decimal = 1 - ordDisc
            Dim tempIO As Decimal = itemPrice * ordDisc 'itemPrice * ordDisc
            'isoalte variable
            'tempCD*x + tempIO = totOff 
            'tempCD*x  = totOff - tempIO
            '(tempCD*x)/tempCD  = (totOff - tempIO)/tempCD
            Dim tempTO As Decimal = totOff - tempIO
            'x  = (tempTO)/tempCD
            Dim x As Decimal = tempTO / tempCD
            Debug.WriteLine(x)
        End Sub
    Use the debugger to step through this. One piece of advice, use Decimal for money.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width