INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Business Objects: Crystal Reports 1 Formulas FAQ

## Formula Help

 How to print multiple discrete and range parameter values and date range parameters in Crystal Reports Version 8.5. by ElenaT faq767-1206 Posted: 25 Oct 01 Printing date range parameters in the report header wasn't too difficult, but I had a hard time figuring out how to print multiple discrete and range parameter values in Crystal Reports Version 8.5.  I spent a long time searching through the posts and FAQs on this website and the articles in Crystal Care Technical Support, but I kept running into the errors: "a number, currency amount, boolean, date, time, date-time, or string is required here" and the infamous "the result of a formula cannot be an array."Finally, I found the Crystal Reports 7 article c2005435 athttp://support.crystaldecisions.net/library/kbase/articles/c2005435.aspwhich led me to my final solution.  The three formulas below use Crystal Syntax in Crystal Reports Version 8.5.Formula @DateRange is for printing a simple date range.Formula @CompanyRange is for printing NUMERIC multiple discrete and range parameter values.Formula @FaultRange is for printing STRING multiple discrete and range parameter values.Note that the @CompanyRange and @FaultRange are very similar except that the empty value for numeric arrays is "0", while the empty value for string arrays is "".The last line of each formula removes the final ", ".// Formula @DateRange// - Prints Date Range in Header// - Samples://   Dates from 10/01/01 to 10/25/01//   Dates from First to 10/25/01//   Dates from 10/01/01 to Last//WhilePrintingRecords;if ToText(Minimum({?DateParam})) = "" then    "Dates from First to " +                    ToText(Maximum({?DateParam}))elseif ToText(Maximum({?DateParam})) = "" then     "Dates from " + ToText(Minimum({?DateParam})) +           " to Last"else    "Dates from " + ToText(Minimum({?DateParam})) +            " to " + ToText(Maximum({?DateParam}));// Formula @CompanyRange //  - Prints Company Ranges in Header//  - Note: parameter {?Company} is NUMERIC//  - Sample:  //    Companies: First to 103, 106, 112 to 118, 127 to Last//WhilePrintingRecords;StringVar CompRange := "Companies: ";NumberVar CompCount := Count({?Company});NumberVar x;     For x := 1 to CompCount     Step +1         Do (if ToText(Minimum({?Company}[x])) = "0" then                CompRange := CompRange +                             "First to " +                              ToText(Maximum({?Company}[x]))                             + ", "            else            if ToText(Maximum({?Company}[x])) = "0" then                 CompRange := CompRange +                              ToText(Minimum({?Company}[x]))                             + " to Last, "            else            if ToText(Minimum({?Company}[x])) =                ToText(Maximum({?Company}[x])) then                 CompRange := CompRange +                              ToText(Maximum({?Company}[x]))                             + ", "             else                CompRange := CompRange +                              ToText(Minimum({?Company}[x]))                             + " to " +                              ToText(Maximum({?Company}[x]))                             + ", "            );CompRange := Left(CompRange,Length(CompRange) - 2);// Formula @FaultRange //  - Prints Fault Code Ranges in Header//  - Note: parameter {?FaultCode} is a STRING//  - Sample:  //    Fault Codes: First to C, F, J, M to P, S to Last//WhilePrintingRecords;StringVar FaltRange := "Fault Codes: ";NumberVar FaltCount := Count({?FaultCode});NumberVar x;    For x := 1 to FaltCount    Step +1       Do (if ToText(Minimum({?FaultCode}[x])) = "" then               FaltRange := FaltRange +                             "First to " +                             ToText(Maximum({?FaultCode}[x]))                            + ", "          else          if ToText(Maximum({?FaultCode}[x])) = "" then                FaltRange := FaltRange +                             ToText(Minimum({?FaultCode}[x]))                            + " to Last, "          else          if ToText(Minimum({?FaultCode}[x])) =              ToText(Maximum({?FaultCode}[x])) then                FaltRange := FaltRange +                             ToText(Maximum({?FaultCode}[x]))                            + ", "           else               FaltRange := FaltRange +                             ToText(Minimum({?FaultCode}[x]))                            + " to " +                             ToText(Maximum({?FaultCode}[x]))                            + ", "          );FaltRange := Left(FaltRange,Length(FaltRange) - 2); Back to Business Objects: Crystal Reports 1 Formulas FAQ Index Back to Business Objects: Crystal Reports 1 Formulas Forum

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!