13 Replies Latest reply on Jan 28, 2012 12:59 AM by Sorbsbuster

# A different kind of percentage calculation??

### Title

A different kind of percentage calculation??

### Post

Hi,

Im pulling my hair out with this and the few vodkas ive had probably are not helping too.

I need some assistance on how to set this up.

I have the following fields.

Sub total

Discount

freight

total

new total

What im trying to do is when the order is setup correctly the subtotal is filled in, the discount and total but ive added discount and new total as i keep rounding jobs off for customers.

I want it to,  say the sub total is \$103frieght is \$40 and the total is \$143, i want to be able to put in \$140 in the new total and it calculates the percentage difference between new total and subtotal and put the percentage in discount and adjusts the total to the new.

i tried.

discount = new total / subtotal as percentage

Total = subtotal - discount

but no joy.

Hopefully ive not confused anyone and someone can help.

cheers

Stuart

• ###### 1. Re: A different kind of percentage calculation??

So you would have a starting point of:

Sub total    100
Discount
Nett            100
freight         25
total          125

new total

And you want to enter a over-written total to be, say 120, so it would look like this:

Sub total    100
Discount        5%
Nett             95
freight         25
total          120

(new total    120)

I believe the calculation you want is:

(  (SubTotal + Freight ) - NewTotal ) / SubTotal

This will show the discount as if it entirely came off the SubTotal, ie: the discount was not applied to the freight.

• ###### 2. Re: A different kind of percentage calculation??

Thanks for that, it works but my only problem now is in the discount field its showing the percentage of the original price not how much discount is applied.

• ###### 3. Re: A different kind of percentage calculation??

Sorry, I don't understand your post.  I thought you wanted the discount to show as a percentage ("...and put the percentage in discount").  Do you want it to show as a \$ amount?  If that is the case the calculation is

NewTotal - (SubTotal + Freight )

• ###### 4. Re: A different kind of percentage calculation??

the thing you said at the start was correct but instead of it saying  discount 10% it was saying discount 90%  - showing this the price is 90% of what it was originally and not order has a discount of 10%.

catch my drift :)

thanks

• ###### 5. Re: A different kind of percentage calculation??

Ah!  Then my calc was wrong!  Just subtract it from 1.

• ###### 6. Re: A different kind of percentage calculation??

so i would do this

(  (SubTotal + Freight ) - NewTotal ) / SubTotal -1

??? sorry for seeming so vauge... its late and my brain went to bed a while ago. :)

• ###### 7. Re: A different kind of percentage calculation??

No, that would be subtracting 1 from it, not it from 1.  It should be:

1 - ( (  (SubTotal + Freight ) - NewTotal ) / SubTotal )

(Although I am confused. Using the figures I gave in my example, the maths should be:

(SubTotal + Freight ) - NewTotal ) / SubTotal

=

( ( 100 + 25 ) - 120 ) / 100

=

( 125 - 120 ) / 100

That equals 5%, not 95%, so I believe my original calculation is correct.

• ###### 8. Re: A different kind of percentage calculation??

Haha, welcome to my world.

Im not sure how to get it to show what the discount is and not what a percentage of the original numbner is.

Ive been messing with the -1 and things but still no joy :(

• ###### 9. Re: A different kind of percentage calculation??

You said: "it calculates the percentage difference between new total and subtotal and put the percentage in discount" and "...discount = new total / subtotal as percentage".

To show the absolute \$ amount as opposed to the % amount you would not divide it by the original sum.  It would be:

(SubTotal + Freight ) - NewTotal

• ###### 10. Re: A different kind of percentage calculation??

I think you have lost me again lol.

what im getting is

Sub \$75

Freight  \$25

Discount 75%

Total \$100

new total \$75

--

Discount shoud be showing 25% as its 25% discount  not 75% which is saying that \$75 is 75% of the original total.

• ###### 11. Re: A different kind of percentage calculation??

I am very confused.  Can you please clarify if you want the field called discount to show \$x or x%.

If you want it to look like this:

Subtotal       \$75
Freight         \$25

(true total     \$100)

Discount      25%

NewTotal      \$75

Then use  this calculation:

( (Subtotal + Freight ) - NewTotal ) / (Subtotal + Freight )

In this case that will give the result 0.25, which you can format to display as 25%

If you want it to show as \$x then use:

(Subtotal + Freight ) - NewTotal

That will show \$25

• ###### 12. Re: A different kind of percentage calculation??

Hi.

Im sorry for the confusion.

You are correct originally that i want the customer to see what percentage discount they are getting off the original price,.

Im glad you did the price one too as after i put the % it would end up 0.1 for most jobs and a price value looks better.

The only thing i have now using the price is that it shows the full value if i dont have a number in the newtotal box.

Is there a way to not run the calculation if the newtotal box is empty?

• ###### 13. Re: A different kind of percentage calculation??

" put the % it would end up 0.1 for most jobs" - but you would format the field in the Inspector as a percentage, so that will show as 10%.

To your second question, change the Discount Amount calculation to be:

Case (

IsEmpty ( NewTotal ) ; "" ;

(Subtotal + Freight ) - NewTotal

)

will leave the discount field empty if there is no value in newTotal.