Crystal Reports Functions

Systematix Offers Professional Training

Our expert trainers can help you get the best results.

If you would like any further information please contact one of our training advisors.

post image

Crystal Reports Functions

Crystal Reports functions users can graphically design data connections and report layouts. In the Database Expert, users can select and link tables from a wide variety of data sources, including Microsoft SQL Server databases, Microsoft Access databases, Microsoft Excel spreadsheets, Oracle databases, other databases and local file-system information. Crystal Reports designers can place fields from any of these sources on the report design surface, and can also employ them with functions in custom formulas which are then laid out on the design surface. Formulas are evaluated at several phases in the report generation process as specified by the developer.

Both fields and formulas have a wide array of formatting options available, which designers can apply absolutely or conditionally. The data is grouped into bands, each of which can be further split and conditionally suppressed as required. Crystal Reports supports subreports, graphing, and a a certain amount of GIS functionality.

Crystal Reports functions are provided that can be used to build formulas. All the functions are listed in the Function Tree of the Formula Workshop window. These Crystal Reports functions include String, Maths, Type Conversion, Date and Time.

String Functions

Function Description
AscW(str) Determines the ASCII value of a character.
ChrW(x) Determines the character equivalent of an ASCII value.
IsNumeric(str) Determines if the string can be properly converted
to a number.
InStr(start, str1, str2, compare) Determines if str2 is a substring of str1. The start
and compare arguments are both optional.
InStrRev(start, str1, str2, compare) Determines if str2 is a substring of str1. Essentially, it performs the same function as InStr() except that it starts at the end of the string and searches towards the beginning.
Len(str) Provides the number of characters in a string.
Val(str) Determines the numeric equivalent of the string.

Data Display Manipulation Functions

Filter(str, find, include, compare) Performs a search for a substring from an array of strings and returns an array that matches the specified criteria.
Replace(str, find, replace, start, count, compare) Performs a search for a string and replaces it with
another string.
ReplicateString(str, #copies) Provides multiple copies of a string.
Space(x) Enables the conversion of a specified number of spaces to a single string.
Join(list, delimiter) Enables the conversion of an array of strings into one string. Every string can be separated with a specific delimiter.
Split(str, delimiter, count, compare) Enables the splitting of a single string into an array of strings. The delimiter that separates every string value can be specified.

Functions for data conversion

Constants and variables used in the same formula must be of the same data type. Type conversion functions in Crystal Reports allow you to convert one data type into another and avoid data incomparability within a formula

ToNumber(string) Converts string values to a number.
ToNumber(boolean) Converts boolean values to a number.
IsDate(string), IsTime(), IsDateTime() Evaluates if a string has the value of a valid date/
time.
IsNumber(string) Evaluates a string for being a valid number.
ToWords(number), ToWords(number, decimals) Converts a number to its word equivalent.

Commonly used Maths functions

Mathematical functions can evaluate both whole numbers and numbers with decimal places.

Abs(number) Converts any negative value to its positive equivalent.
Fix(number, decimals) Converts any number with a large decimal places to a number with a specified number of significant digits. The number of required decimals can be specified.
Round(number, decimals) Rounds up a number with large decimals a specified number of significant digits.

Commonly used Date and Time functions

Date and Time functions can be used individually or combined to obtain the desired date output.

CurrentDate Displays the current date.
CurrentTime Displays the current time.
CurrentDateTime Displays the current date and time.
DateSerial(year, month, day) Displays the date in the year, month and day format.
DateTime(hour, minute, second) Displays the time in the hours, minutes and seconds format.
DateAdd(interval, number, date) Increases the date by a certain interval.
DateDiff(interval, startdate, enddate, firstdayofweek) Evaluates the difference between two dates.
DatePart(interval, date, firstdayofweek, firstweekofyear) Displays a number that represents the current interval of a date.
MonthName(date, abbreviate) Displays the month name as a three-letter abbreviation.
Timer Displays the number of seconds that have elapsed since midnight.
WeekDay(date, firstdayofweek) Displays a number that represents the day of the week.
WeekdayName(weekday, abbreviate, firstdayofweek) Displays the week name as a three-letter abbreviation.