Summary
Description
In Sage Report Designer, as well as adding variables to show values, you can also add expressions to return values based on variables. For example, you can show a percentage value of sales invoices, or calculate the number of days between 2 different dates. In addition to basic calculations, you can also use more advanced functions.
Resolution
Below is a list of some of the more advanced functions you can use within Sage Report Designer. For full details and examples of how to use the functions, please refer to the Function details tab.
| Function | Description |
|---|---|
| Ceiling( ) | Rounds the value up to the nearest integer. |
| Concat( ) | Combines two values into one, creating a new value. |
| Contains( ) | Searches for characters in a string. |
| Count( ) | Counts the number of instances on a report. |
| CountIf( ) | Counts the number of instances on a report where the specified conditions are satisfied. |
| CountUnique( ) | Counts the number of unique instances of a specified variable. |
| Cstring(variable) | Converts a numeric field to an alphanumeric string. |
| DateTimeToFormattedString( ) | Controls how dates appear. |
| DayfromDate( ) | Returns the day part of a date. |
| EndsWith( ) | Displays whether or not a string ends with a specified character. |
| Floor( ) | Rounds the value down to the nearest integer. |
| FormatString( ) | Prints a string, for example, a piece of text, with one or more predefined expressions inserted into the string using placeholders. |
| If( ) | Displays certain values depending on the condition specified. |
| Indexof( ) | Finds the position of a particular character in a string. |
| Length( ) | Displays how many characters exist in a string. |
| Max( ) | Displays the maximum value in a sequence. |
| Min( ) | Displays the minimum value in a sequence. |
| MonthfromDate( ) | Returns the month part of a date. |
| Now( ) | Displays the current PC date. |
| PadLeft( ) | To ensure a field contains a certain number of characters, this function inserts additional characters to the left of the value. |
| PadRight( ) | To ensure a field contains a certain number of characters, this function inserts additional characters to the right of the value. |
| ParseDateTime( ) | Converts alphanumeric fields to date fields for use in expressions and filters. |
| Previous( ) | Changes a value based on the previous line value. |
| Remove( ) | Removes a specified number of characters from a stated starting point in the string. |
| Replace( ) | Replaces a specified character in a string with another character. |
| StartsWith( ) | Displays whether or not a string starts with a specified character. Cannot be used as a report filter. |
| StringToFloat( ) | Converts alphanumeric fields to numeric fields for use in expressions and filters, when the fields contain decimal numbers. |
| StringToInteger( ) | Converts alphanumeric fields to numeric fields for use in expressions and filters, when the fields contain whole numbers. |
| Substring( ) | Displays part of a string from a specified starting point. |
| SumIf( ) | Totals only the values that meet the condition specified. |
| ToLower( ) | Converts the field to lower case. |
| ToUpper( ) | Converts the field to upper case. |
| Truncate( ) | Rounds a value to the nearest whole number in the direction of zero. |
| YearfromDate( ) | Returns the year part of a date. |
To see details of how to use a function, select it from the list below:
Ceiling
| Function | Reason for use | Other information |
|---|---|---|
| Ceiling( ) | Determines the closest integer that is more than the specified number. It rounds up | |
Examples:
| ||
Concat
| Function | Reason for use | Other information |
|---|---|---|
| Concat( ) | To combine two values into one, creating a new value. | |
Example:
| ||
Contains
| Function | Reason for use | Other information |
|---|---|---|
| Contains( ) | Searches for characters in a string. |
|
Example:
| ||
Count
| Function | Reason for use | Other information |
|---|---|---|
| Count( ) | Counts the number of instances on a report. |
|
Example:To count the number of customer records on a report: Count(SLCustomerAccounts.CustomerAccountNumber) | ||
CountIf
| Function | Reason for use | Other information |
|---|---|---|
| CountIf( ) | Counts the number of instances on a report if the specified conditions are satisfied. |
|
Example:To count the number of customer records on a report that contain an A in the account reference: Countif(SLCustomerAccounts.CustomerAccountNumber like "%A%") | ||
CountUnique
| Function | Reason for use | Other information |
|---|---|---|
| CountUnique( ) | Counts the number of unique instances of a specified variable. | |
Example:On the Simple Stock Transaction History report, to show the number of sources/destinations the item has been associated with: | ||
CString
| Function | Reason for use | Other information |
|---|---|---|
| CString( ) | Converts a numeric field to an alphanumeric string or text. |
|
Example:
| ||
DateTimeToFormattedString
| Function | Reason for use | Other information |
|---|---|---|
| DateTimeToFormattedString( ) | Controls how dates appear. |
|
Examples:
| ||
DayfromDate
| Function | Reason for use | Other information |
|---|---|---|
| DayfromDate( ) | Returns the day part of a date. | |
Example:If a customer's account was opened on 14/02/2013, the following function shows 14: Dayfromdate(SLCustomerAccounts.AccountOpened) | ||
EndsWith
| Function | Reason for use | Other information |
|---|---|---|
| EndsWith( ) | Displays whether or not a string ends with a specified character. |
|
Examples:
| ||
Floor
| Function | Reason for use | Other information |
|---|---|---|
| Floor( ) | Determines the closest integer that is less than the specified number. It rounds down. | You can use this to display pounds when displaying pounds and pence separately. |
Examples:
| ||
FormatString
| Function | Reason for use | Other information |
|---|---|---|
| FormatString( ) | Prints a string, for example, a piece of text, with one or more predefined expressions inserted into the string using placeholders. The function is written as: FormatString("string before placeholder zero {0} string after placeholder zero {1} string after placeholder one etc.", placeholder expression 0, placeholder expression 1) | The placeholders appear as {0}, {1} and so on. They can be individually formatted, for example:
|
Examples:
This would show for example, Customer ABB001 has a balance of 16,003.00 and 250.00 credit remaining. FormatString("Customer{0} has a balance of {1:c2} and {2:c2} credit remaining.", SLCustomerAccounts.CustomerAccountNumber, SLCustomerAccounts.AccountBalance, (SLCustomerAccounts.CreditLimit - SLCustomerAccounts.AccountBalance)) This example would show Customer ABB001 has a balance of £16,003.00 and £250.00 credit remaining. | ||
If
| Function | Reason for use | Other information |
|---|---|---|
| If( ) | To display certain values depending on the condition specified. |
|
Example:
For further information about constructing If statement expressions, please refer to article . | ||
Indexof
| Function | Reason for use | Other information |
|---|---|---|
| Indexof( ) | Finds the position of a particular character in a string. | This can be combined with the Substring function to only return the value of a field up to a certain character. |
Examples:
| ||
Length
| Function | Reason for use | Other information |
|---|---|---|
| Length( ) | Displays how many characters exist in a string. | |
Example:To display how many characters appear in a customer's account name: Length(SLCustomerAccounts.CustomerAccountName) | ||
Max
| Function | Reason for use | Other information |
|---|---|---|
| Max( ) | Displays the maximum value in a sequence. |
|
Example:To show the highest gross amount on a sales day book report: Max(SLPostedCustomerTrans.BaseGrossValue) | ||
Min
| Function | Reason for use | Other information |
|---|---|---|
| Min( ) | Displays the minimum value in a sequence. |
|
Example:To show the lowest gross amount on a sales day book report: Min(SLPostedCustomerTrans.BaseGrossValue) | ||
MonthfromDate
| Function | Reason for use | Other information |
|---|---|---|
| MonthfromDate( ) | Returns the month part of a date. | |
Example:If a customer's account was opened on 14/02/2013, the following function shows 2: Monthfromdate(SLCustomerAccounts.AccountOpened) | ||
Now
| Function | Reason for use | Other information |
|---|---|---|
| Now( ) | Displays the current PC date. |
|
Example:
| ||
PadLeft
| Function | Reason for use | Other information |
|---|---|---|
| PadLeft( ) | To ensure a field contains a certain number of characters, this function inserts additional characters to the left of the value. The function is written as: PadLeft(the value to pad, the character used to pad the field, the number of characters the field should contain) | When using this function with a numeric field, you must also use CString to convert the numeric value to an alphanumeric string. |
Example:
| ||
PadRight
| Function | Reason for use | Other information |
|---|---|---|
| PadRight( ) | To ensure a field contains a certain number of characters, this function inserts additional characters to the right of the value. The function is written as: PadRight(the value to pad, the character used to pad the field, the number of characters the field should contain) | When using this function with a numeric field, you must also use CString to convert the numeric value to an alphanumeric string. |
Example:
| ||
ParseDateTime
| Function | Reason for use | Other information |
|---|---|---|
| ParseDateTime( ) | Converts alphanumeric fields into date fields that you can use in expressions and filters. For example, if the first line of the notes in an invoice contains a date, you can use this function to perform calculations based on the date. | For each record the relevant database value must contain a date and must be in a recognised date format. If not, when running the report, the following message appears: 'String was not recognised as a valid DateTime.' |
Example:
ParseDateTime(StockItems.Manufacturer) + 60 | ||
Previous
| Function | Reason for use | Other information |
|---|---|---|
| Previous( ) | To change a value based on the previous line value. | You can use this with If statements. |
Example:The customer is running the Sales Order Profitability report and has noticed that some item codes are showing on the same sales order more than once. They want to investigate this further and to highlight them some way. | ||
Remove
| Function | Reason for use | Other information |
|---|---|---|
| Remove( ) | Removes a specified number of characters from a stated starting point in the string. | You must always enter the starting position, where the first character is 0, and the number of characters to remove. |
Examples:
| ||
Replace
| Function | Reason for use | Other information |
|---|---|---|
| Replace( ) | Replaces the specified character in a string with another character. | This function is case sensitive. |
Examples:
| ||
StartsWith
| Function | Reason for use | Other information |
|---|---|---|
| StartsWith( ) | Displays whether or not a string starts with a specified character. |
|
Examples:
| ||
StringToFloat
| Function | Reason for use | Other information |
|---|---|---|
| StringToFloat( ) | Converts alphanumeric fields to numeric fields for use in expressions and filters, when the fields contain decimal numbers. | If the report is run for fields containing non numeric information, the following message appears: 'Input string is not in correct format.' |
Examples:
| ||
StringToInteger
| Function | Reason for use | Other information |
|---|---|---|
| StringToInteger( ) | Converts alphanumeric fields to numeric fields for use in expressions and filters, when the fields contain whole numbers. | This function only works when the report is run for records that contain numeric values in the selected field If you run the report to include records which contain no value or alphanumeric information, the following message appears: 'Input string was not in correct format.' |
Examples:
| ||
Substring
| Function | Reason for use | Other information |
|---|---|---|
| Substring( ) | Displays part of a string from a specified starting point. The function assigns the first character in a value the number 0, each subsequent character is numbered incrementally. For example, in the text ABCDE, A is equal to 0, B is equal to 1, and so on. |
|
Examples:
| ||
SumIf
| Function | Reason for use | Other information |
|---|---|---|
| SumIf( ) | To total only the values that meet the condition specified. The function is written as: SumIf(the value to sum, the condition that is to be met) | The Properties > Function should be set to None. |
Example:
| ||
ToLower
| Function | Reason for use | Other information |
|---|---|---|
| ToLower( ) | Converts the field to lower case. | |
Examples:
| ||
ToUpper
| Function | Reason for use | Other information |
|---|---|---|
| ToUpper( ) | Converts the field to upper case. | |
Examples:
| ||
Truncate
| Function | Reason for use | Other information |
|---|---|---|
| Truncate( ) | Rounds a value to the nearest whole number in the direction of zero. |
|
Example:
| ||
YearfromDate
| Function | Reason for use | Other information |
|---|---|---|
| YearfromDate( ) | Returns the year part of a date. | |
Example:If a customer's account was opened on 14/02/2013, the following function shows 2013: YearFromdate(SLCustomerAccounts.AccountOpened) | ||
Sage Business Partners can now log new cases online!
If you're unable to find the help you require from our online resources, log a new case with us without having to use phone or email. Simply select 'Manage your cases' from the dashboard or visit my.sage.co.uk/cases.
Sage 200 Services
Did you know Sage 200 customers now have access to a range of services direct with Sage. These include a bespoke Report Design Service, a library of How to Webinars and Ideas Portal just to name a few. Explore your potential using Sage 200 Services.