Solved

# Crystal Rounding

Posted on 2012-09-15
374 Views
I need help with a formula to look up the product family for a given product.

Then if that

If Product family field is "LSS" calculate "AVPS field" times 2 and round up to nearest 1,
If product family field is, "Soda" calculate "AVPS field " times 1.5 and Round to nearest 6,
If product family field is "candy" calculate "avps field" time 2.25 and round down to nearest even,

0
Question by:evend

LVL 100

Expert Comment

Try this

If {ProductField} = "LSS" then
RoundUp({AVPSField} * 2)
Else if {ProductField} = "Soda" then
(ROUNDUP({AVPSField}*1.5) / 6) * 6
Else if {ProductField} = "Candy" then
(RoundUp({AVPSField}*2.25 / 2)*2
Else
{AVPSField}

mlmcc
0

Author Comment

Thanks I had to adjust ()'s to  ROUNDUP(({@Average}*{?LSS SFP}) / 6) * 6 for it to work.
I forgot one part of the formula can you help?  If the formula for each line ends with a # higher then capacity then the result should equal Capacity.

How would I make that happen?

Thanks!
0

LVL 100

Expert Comment

Try this

``````Local NumberVar AdjustedAmount;

If {ProductField} = "LSS" then
Else if {ProductField} = "Soda" then
AdjustedAmount := ROUNDUP({AVPSField}*1.5 / 6) * 6
Else if {ProductField} = "Candy" then
Else

``````

mlmcc
0

Author Comment

Mlmcc I am getting a variable name error against the firt line with {@NewPar};

Local NumberVar {@NewPar};

If {product_families.description} = "20z Carb Soft Drinks" then
{@NewPar} := RoundUp({@Average} * 2)
Else if {product_families.description} = "20z Non Carb Bev" then
{@NewPar} := ROUNDUP({@Average}*1.5 / 6) * 6
Else
{@NewPar} := {@Average};

If {@NewPar} > {Vend_Visit_Items.capacity} then
{@NewPar} := {Vend_Visit_Items.capacity};

{@NewPar}
0

LVL 100

Accepted Solution

Variables can't have special characters in the name.

``````Local NumberVar NewPar;

If {product_families.description} = "20z Carb Soft Drinks" then
NewPar := RoundUp({@Average} * 2)
Else if {product_families.description} = "20z Non Carb Bev" then
NewPar := ROUNDUP({@Average}*1.5 / 6) * 6
Else
NewPar := {@Average};

If @NewPar > {Vend_Visit_Items.capacity} then
NewPar := {Vend_Visit_Items.capacity};

NewPar
``````

mlmcc
0

## Featured Post

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!