Link to home
Create AccountLog in
Avatar of tim44202
tim44202Flag for United States of America

asked on

Crystal Formula error

The following produces a syntax error:
IF "vw_Medicaid_Utilization_Weeks_Left"."Weekly Average" <> 0
THEN
"vw_Medicaid_Utilization_Weeks_Left"."FY Hours Available"/"vw_Medicaid_Utilization_Weeks_Left"."Weekly Average"
ELSE
9999

The following produces a divide by zero error:
"vw_Medicaid_Utilization_Weeks_Left"."FY Hours Available"/"vw_Medicaid_Utilization_Weeks_Left"."Weekly Average"
Avatar of Kurt Reinhardt
Kurt Reinhardt
Flag of United States of America image

Try this:

IF
  "vw_Medicaid_Utilization_Weeks_Left"."Weekly Average" = 0
THEN
   9999
Else
"vw_Medicaid_Utilization_Weeks_Left"."FY Hours Available"/"vw_Medicaid_Utilization_Weeks_Left"."Weekly Average"

Basically the same thing, but changes the order.
Actually, you shouldn't be using the quotes unless you're creating a SQL Expression against a database that supports that format and this isn't proper syntax for a SQL Expression.  In a Crystal Reports formula, it should be something like this:

IF
  {vw_Medicaid_Utilization_Weeks_Left.Weekly Average} = 0
THEN
   9999
Else
{vw_Medicaid_Utilization_Weeks_Left.FY Hours Available}/{vw_Medicaid_Utilization_Weeks_Left.Weekly Average}
Avatar of tim44202

ASKER

Rhinok,

Same error
Rhinok,

Same error with your second suggestion.  BTW the quoted version was created by selecting fields in the Crystal Formula Workshop
the quoted version was created by selecting fields in the Crystal Formula Workshop

That's not possible, since it's not Crystal Reports recognized syntax.  French braces denote database fields in the formula editor, not quotes. The format with the quotes is only available through the SQL Expression editor (and even then it depends what type of database you're hitting).  Chances are you're just in the wrong editor.
User generated image
ASKER CERTIFIED SOLUTION
Avatar of Kurt Reinhardt
Kurt Reinhardt
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer