Calculation for a Discount Unit Price.

I need a calculation that would take Unit Price and either multiple or subtract the Discount Amount, based off it being a percent or dollar amount, that returns me the discounted unit price. Can anyone help me? I know its probably an ifElse but haven't quite figured it out. Thanks!

  • Hi Nicole Rios,

    The stock field, Line Item Total (total_amount) on the Quoted Line Item module does what you have described using the following formula:

    ifElse(and(isNumeric(toString($quantity)), isNumeric(toString($discount_price))),
    currencySubtract(
    currencyMultiply(
    $discount_price,
    $quantity
    ),
    ifElse(equal($discount_select, "1"),
    currencyMultiply(currencyMultiply($discount_price, $quantity), currencyDivide($discount_amount, 100)),
    ifElse(isNumeric(toString($discount_amount)), $discount_amount, 0)
    )
    ),
    ""
    )

    I hope this helps.

  • Hi Patrick,

    Thanks! I tried this but is there a way to have it not based on quantity or just quantity 1? I noticed once you do quantity 2 it doubles the discount. 

  • Hi Nicole Rios,

    This is the formula without its references to quantity (I have not tested this):

    ifElse(and(isNumeric(toString($quantity)), isNumeric(toString($discount_price))),
    currencySubtract(
    $discount_price,
    ifElse(equal($discount_select, "1"),
    currencyMultiply($discount_price, currencyDivide($discount_amount, 100)),
    ifElse(isNumeric(toString($discount_amount)), $discount_amount, 0)
    )
    ),
    ""
    )

  • Hi Patrick,

    I just tried it out. It caused the unit price and line item total to jump to a -5,000 dollar amount. It was a good try though.

    Thank you!

    Nicole 

  • Hi Nicole Rios,

    Would you be willing to describe your use case for this?

    Also, which field and where is the field you are calculating? In the Quoted Line Item RecordView, or somewhere else?

  • Hi Nicole Rios,

    I just tested the above calculation that makes no reference to quantity in a custom Currency field in the Quoted Line Item RecordView layout, and it worked exactly as expected, as shown in these two screenshots:

    Dollar Discount:

    Percent Discount:

  • Hi Patrick,

    The goal was to have Unit Price, in the Quoted Line Items, in the Quote Module, show the discounted unit price. So in the image below you have a quantity 1, a list price of $385, a discount of $10, unit price $375, and the line item total should be $375. Adding a different quantity would cause everything but the Unit Price to increase. 

    Hopefully, this makes sense  

  • Hi Nicole Rios,

    The formula I gave you works as expected for me in the same use case:

  • Just put the calculation in a new field. It works!! Thanks so much! Now its just the matter of getting the new field onto the quoted line items on the Quote. Right now it's throwing a server error so I'm working on getting that fixed. 

    Thanks again!!

    Nicole