Skip to Content

change in formula based on quantity

Hi team,

I have this "inherited" working formula:

if (isnull({ServiceInfo.ThirdPartyServiceProvider}) or {ServiceInfo.ThirdPartyServiceProvider}= 'None')
then

Select {ServiceCode.LineOfBusiness}
Case 'FRONTLOAD': 5.5*4.33/60*{@TruckCost}*{ServiceInfo_vw_CurrentServices.Quantity}*{@servicefrequency}
Case 'REARLOAD': 6*4.33/60*{@TruckCost}*{@servicefrequency}+ .5*4.33/60*{@TruckCost}*{ServiceInfo_vw_CurrentServices.Quantity}*{@servicefrequency}-.5*4.33/60*{@TruckCost}*{@servicefrequency}
Case 'RECYCLING': 6*4.33/60*{@TruckCost}*{@servicefrequency}+ .5*4.33/60*{@TruckCost}*{ServiceInfo_vw_CurrentServices.Quantity}*{@servicefrequency}-.5*4.33/60*{@TruckCost}*{@servicefrequency}

Default : 0

as you can see, the formula references the Quantity - and it also contains time.

For the Frontload example, the time it assess is 5.5 (= 5.5 minutes, see the first number in the formula)

now I am asked to change the formula so that what you see above, is only applicable if the quantity is 1.

IF there are additional quantities, then the assessment has to change the time to .5 (= 30 seconds)

example:

if isnull({ServiceInfo.ThirdPartyServiceProvider}) or {ServiceInfo.ThirdPartyServiceProvider}= 'None' and {ServiceCode.LineOfBusiness} = "Frontload" then

(if {ServiceInfo_vw_CurrentServices.Quantity} = 1 then 5.5*4.33/60*{@TruckCost}*{@servicefrequency} else
if {ServiceInfo_vw_CurrentServices.Quantity} > 1 then ((5.5*4.33/60*{@TruckCost}*{@servicefrequency})+(.5*4.33/60*{@TruckCost}*{@servicefrequency}*({ServiceInfo_vw_CurrentServices.Quantity}-1))

BUT this formula gives me a message the ) is missing.. I have tried it all different kind of ways.. it sounds logical to me the way it is now. Can you please help?

THANKS

Sabine.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 02, 2014 at 03:39 PM

    Try something like this:

    if (isnull({ServiceInfo.ThirdPartyServiceProvider}) or {ServiceInfo.ThirdPartyServiceProvider}= 'None') and {ServiceCode.LineOfBusiness} = "Frontload" then

    (if {ServiceInfo_vw_CurrentServices.Quantity} = 1 then

    5.5*4.33/60*{@TruckCost}*{@servicefrequency}

    else

    if {ServiceInfo_vw_CurrentServices.Quantity} > 1 then

    (5.5*4.33/60*{TruckCost}*{servicefrequency})+(.5*4.33/60*{TruckCost}*{servicefrequency}*({ServiceInfo_vw_CurrentServices.Quantity}-1))

    I did two things here:

    1. Because of the way "Or" works, I put parentheses around the Or statement - without them it will process for every record where {ServiceInfo.ThirdPartyServiceProvider} is null and only look at the {ServiceCode.LineOfBusiness} value if {ServiceInfo.ThirdPartyServiceProvider} = 'None'

    2. I changed " if {ServiceInfo_vw_CurrentServices.Quantity} > 1 then ((" to " if {ServiceInfo_vw_CurrentServices.Quantity} > 1 then (" - taking out one of the parentheses.

    -Dell

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 02, 2014 at 03:26 PM

    ok - I was able to fix the question with the missing ) ....but now something else seems to be entirely wrong because all my results are 0...

    here is how I updated it:

    if isnull({ServiceInfo.ThirdPartyServiceProvider}) or {ServiceInfo.ThirdPartyServiceProvider}= 'None' and {ServiceCode.LineOfBusiness} = "FRONTLOAD" then

    (if {ServiceInfo_vw_CurrentServices.Quantity} = 1 then 5.5*4.33/60*{@TruckCost}*{@servicefrequency} else
    if {ServiceInfo_vw_CurrentServices.Quantity} > 1 then (5.5*4.33/60*{@TruckCost}*1*{@servicefrequency})+(.5*4.33/60*{@TruckCost}*{@servicefrequency}*({ServiceInfo_vw_CurrentServices.Quantity}-1)))

    else

    if isnull({ServiceInfo.ThirdPartyServiceProvider}) or {ServiceInfo.ThirdPartyServiceProvider}= 'None' and {ServiceCode.LineOfBusiness} = "REARLOAD" then

    (if {ServiceInfo_vw_CurrentServices.Quantity} = 1 then 6*4.33/60*{@TruckCost}*{@servicefrequency} else
    if {ServiceInfo_vw_CurrentServices.Quantity} > 1 then (6*4.33/60*{@TruckCost}*{@servicefrequency})+(.5*4.33/60*{@TruckCost}*{@servicefrequency}*({ServiceInfo_vw_CurrentServices.Quantity}-1)))

    else

    if isnull({ServiceInfo.ThirdPartyServiceProvider}) or {ServiceInfo.ThirdPartyServiceProvider}= 'None' and {ServiceCode.LineOfBusiness} = "RECYCLING" then

    (if {ServiceInfo_vw_CurrentServices.Quantity} = 1 then 6*4.33/60*{@TruckCost}*{@servicefrequency} else
    if {ServiceInfo_vw_CurrentServices.Quantity} > 1 then (6*4.33/60*{@TruckCost}*{@servicefrequency})+(.5*4.33/60*{@TruckCost}*{@servicefrequency}*({ServiceInfo_vw_CurrentServices.Quantity}-1)))

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.