• Status: Solved
• Priority: Medium
• Security: Public
• Views: 388

# Crystal Rounding

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
evend
• 3
• 2
1 Solution

Commented:
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 Commented:
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

Commented:
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 Commented:
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

Commented:
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

• 3
• 2
Tackle projects and never again get stuck behind a technical roadblock.