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

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,

Thanks in advance for your help!
0
evend
Asked:
evend
  • 3
  • 2
1 Solution
 
mlmccCommented:
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
 
evendAuthor 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
 
mlmccCommented:
Try this

Local NumberVar AdjustedAmount;

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

If AdjustedAmount > {CapacityField} then
    AdjustedAmount := {CapacityField};

AdjustedAmount 

Open in new window


mlmcc
0
 
evendAuthor 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
 
mlmccCommented:
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

Open in new window


mlmcc
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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