You are viewing the documentation for Blueriq 17. Documentation for other versions is available in our documentation directory.
Learn more about the conversion functions TEXT, INTEGER, NUMBER, CURRENCY, PERCENTAGE, DATE, DATETIME, BOOLEAN.
Convert a value of one data type into a value of another data type using conversion functions. The following conversion functions are available:
from string to integer, number, currency, percentage, date, dateTime or Boolean
from integer to string, number, currency or percentage
from number to string, integer, currency or percentage
from currency to string, integer or number
from percentage to string, integer or number
from date to string or dateTime
from dateTime to string or date
from Boolean to string, integer or number
Overview
Function | Description |
---|---|
TEXT | Converts a value of another data type into a string. |
INTEGER | Converts a value of another data type into an integer. |
NUMBER | Converts a value of another data type into a number. |
CURRENCY | Converts a value of another data type into a currency. |
PERCENTAGE | Converts a value of another data type into a percentage. |
DATE | Converts a value of another data type into a date. |
DATETIME | Converts a value of another data type into a datetime. |
BOOLEAN | Converts a value of a string into a boolean. |
Output formats in the runtime.
Functions
TEXT
Converts a value of another data type into a string.
Syntax
TEXT(integer value, [format], [locale]) TEXT(number value, [format], [locale]) TEXT(currency value, [format], [locale]) TEXT(percentage value, [format], [locale]) TEXT(date value, [format]) TEXT(dateTime value, [format]) TEXT(Boolean value, [format])
Inputs
value - The value of the data type that is converted to string.
format (optional) - The format used for conversion. Format must be enclosed by quotes, e.g. “00.00”.
locale (optional) - Locale specifies a combination of language and country. A locale in the option set will override the one that is used as default in the project. Commonly used are en-US, en-GB, nl-NL, nl-BE, fr-FR. The list of language codes can be found here. A list of country codes can be found here.
Default formats
For the TEXT function, the format specifies how the given datatype is converted towards a string. When no format is specified the defaults are as follows:
- boolean to string - true;false
- integer to string - no default format, the complete integer is set as string (no leading zeros)
- number to string - rounded to one digit
- percentage to string - rounded to one digit
- currency to string - rounded to one digit
- date to string - yyyy-MM-dd
- datetime to string - yyyy-MM-dd hh:mm:ss
For more info on date and datetime formats, please see Date and time formats or patterns.
Return type
- string
Examples
TEXT(PERCENTAGE(1.2), “00.00”, “nl-NL”) results in a string value “01,20”
TEXT(123456.78,"#0,000","nl-NL") results in 123.457. A thousand separator has been added. The thousand separator is a point, as that is the defined one in the nl-NL locale.
INTEGER
Converts a value of another data type into an integer.
Syntax
INTEGER(string value, [format], [locale]) INTEGER(number value) INTEGER(currency value) INTEGER(percentage value) INTEGER(Boolean value)
Inputs
value - The value of the data type that is converted to integer.
format (optional) - The format used for conversion. Format must be enclosed by quotes, e.g. "00.00".
locale (optional) - Locale specifies a combination of language and country. A locale in the option set will override the one that is used as default in the project. Commonly used are en-US, en-GB, nl-NL, nl-BE, fr-FR. The list of language codes can be found here. A list of country codes can be found here.
Default formats
For all conversion functions that use a string as parameter, the [format] describes the format in which the input string value parameter is in. When not specifying a format, by default this format is used:
- string to integer - no default format, the complete string is parsed to integer (leading zeros are possible and will be removed).
Return type
- integer
Examples
- INTEGER(“1,0”, ”#0.0”, “nl-NL”) results in an integer value 1.
NUMBER
Converts a value of another data type into a number.
Syntax
NUMBER(string value, [format], [locale]) NUMBER(integer value) NUMBER(currency value) NUMBER(percentage value) NUMBER(Boolean value)
Inputs
value - The value of the data type that is converted to number.
format (optional) - The format used for conversion. Format must be enclosed by quotes, e.g. “00.00”.
locale (optional) - Locale specifies a combination of language and country. A locale in the option set will override the one that is used as default in the project. Commonly used are en-US, en-GB, nl-NL, nl-BE, fr-FR. The list of language codes can be found here. A list of country codes can be found here.
Default formats
For all conversion functions that use a string as parameter, the [format] describes the format in which the input string value parameter is in. When not specifying a format, by default this format is used:
- string to number - 4 digits.
Return type
- number
Examples
- NUMBER(TRUE) results in a number value 1.0000
CURRENCY
Converts a value of another data type into a currency.
Syntax
CURRENCY(string value, [format], [locale]) CURRENCY(integer value) CURRENCY(number value)
Inputs
value - The value of the data type that is converted to currency.
format (optional) - The format used for conversion. Format must be enclosed by quotes, e.g. “00.00”.
locale (optional) - Locale specifies a combination of language and country. A locale in the option set will override the one that is used as default in the project. Commonly used are en-US, en-GB, nl-NL, nl-BE, fr-FR. The list of language codes can be found here. A list of country codes can be found here.
Default formats
For all conversion functions that use a string as parameter, the [format] describes the format in which the input string value parameter is in. When not specifying a format, by default this format is used:
- currency - 2 digits.
Return type
- currency
Examples
- CURRENCY(“1.2”, “invalidPattern”) results in a currency value 1.20 (an unknown pattern will be ignored)
PERCENTAGE
Converts a value of another data type into a percentage.
Syntax
PERCENTAGE(string, [format], [locale]) PERCENTAGE(integer) PERCENTAGE(number)
Inputs
value - The value of the data type that is converted to percentage.
format (optional) - The format used for conversion. Format must be enclosed by quotes, e.g. “00.00”.
locale (optional) - Locale specifies a combination of language and country. A locale in the option set will override the one that is used as default in the project. Commonly used are en-US, en-GB, nl-NL, nl-BE, fr-FR. The list of language codes can be found here. A list of country codes can be found here.
Default formats
For all conversion functions that use a string as parameter, the [format] describes the format in which the input string value parameter is in. When not specifying a format, by default this format is used:
- string to percentage - 2 digits.
Return type
- percentage
Examples
- PERCENTAGE ("22") results in a percentage value of 22,00 (default format is used).
DATE
Converts a value of another data type into a date.
Syntax
DATE(string value, format) DATE(dateTime value)
Inputs
value - The string of dateTime value to be converted to a date type.
format (optional) - The format used for conversion. Format must be enclosed by quotes, e.g. "yyyy-MM-dd". For more info on specifying date format patterns, please see Date and time formats or patterns.
Default formats
When the format is omitted the ISO-8601 date format yyyy-MM-dd (Most to least significant principle) is used for converting the value to a date.
However we advice to use an explicit date format in your conversion function to avoid any confusion about the format used for conversion.
Return type
- date
Examples string to date conversion
- DATE("2024-07-22", "yyyy-MM-dd") converts the string value "2024-07-22" into a value of type date.
- DATE("22/07/2024", "dd/MM/yyyy") converts the string value "22/07/2024" into a value of type date.
Example dateTime to date conversion
- Assume we have a dateTime attribute Person.TimeOfBirth
DATE(Person.TimeOfBirth) will return the date part of this attribute.
Note
The way in which dates are displayed in the UI is determined by the date display formats, which can be configured per language code. For example the Dutch nl-NL date format could be configured as "dd-MM-yyyy", whereas the English en-US date format can be defined as "MM/dd/yyyy".
The converted date in our example could look like "22-07-2024" when displayed in Dutch (nl-NL) and like "07/22/2024" when displayed in English (en-US).
More information about language specific formats can be found in Reference Guide: Language formats.
DATETIME
Converts a value of another data type into a datetime.
Syntax
DATETIME(string value, [format]) DATETIME(date value)
Inputs
value - The value of the data type that is converted to datetime.
format (optional) - The format used for conversion. Format must be enclosed by quotes, e.g. “yyyy-MM-dd hh:mm:ss”. For more info on specifying datetime format patterns, please see Date and time formats or patterns.
Default formats
When the format is omitted the ISO-8601 date time format yyyy-MM-dd hh:mm:ss (Most to least significant principle) is used for converting the value to a datetime.
However we advice to use an explicit datetime format in your conversion function to avoid any confusion about the format used for conversion.
Return type
- date
String to datetime examples
- DATETIME("22-07-2024 16:38:40", "dd-MM-yyyy hh:mm:ss) converts the string "22-07-2024 16:38:40" in a datetime value.
- DATETIME("20240722 16.38.40", "yyyyMMdd hh.mm.ss") converts the string "20240722 16.38.40" in a datetime value.
Date to datetime example
- Assume we have a date attribute Person.DateOfBirth
DATETIME(Person.DateOfBirth) converts the date value to a datetime value by extending the date value with the timestamp 00:00:00.
Note
The way in which date and time values are displayed in the UI is determined by the date and time display formats, which can be configured per language code. For example the Dutch nl-NL date format could be configured as "dd-MM-yyyy hh:mm:ss", whereas the English en-US date format can be defined as "MM/dd/yyyy hh.mm.ss".
The converted date time in our example could look like "22-07-2024 16:38:40" when displayed in Dutch (nl-NL) and like "07/22/2024 16.38.40" when displayed in English (en-US).
More information about language specific formats can be found in Reference Guide: Language formats.
38:40Back to Top
BOOLEAN
Converts a value of a string into a boolean.
Syntax
BOOLEAN(string, [format])
Inputs
string - The string value that is converted to boolean.
format (optional) - The format used for conversion. Format must be enclosed by quotes, e.g. ”1;0”.
Default formats
For all conversion functions that use a string as parameter, the [format] describes the format in which the input string value parameter is in. When not specifying a format, by default this format is used:
- string to boolean - true;false.
Return type
- boolean
Examples
- BOOLEAN(“1”,”1;0”) results in a boolean value TRUE.
Output formats in the runtime
Please see the Reference Guide: Language Formats to change how the runtime displays attributes.
3 Comments
Unknown User (i.van.der.hoeven)
I want to convert a multivalued string ( ["1", "16", "18", "10", "11", "0"] ) to integers. Any suggestions how I could do that? INTEGER does not support array inputs (in BQ 11.0, anyway... )
Frank van der Vaart
Hi Ivo,
You can repeat over multivalued attributes (introduced in Blueriq 10.4) and catch each string value in a (singlevalued) string attribute, convert it to integer and add it to a multivalued integer. I did a small test, and it works as expected .
You'll need the LIST function to add the first integer.
ISUNKNOWN(
UNION( Entity.MultiInteger , INTEGER( Entity.SingleString ) ),
LIST( INTEGER( Entity.SingleString ) )
)
Unknown User (b.verzuu)
Hi Frank van der Vaart,
Thanks for responding! I think I've found the reason why Ivo asked this question.
It was needed to, one way or another, transform a single string value "1000-2000-3000" to a multivalued INT. There is no other way to do this now without iterating through the whole list one by one.
Since the order of the items in the list is not relevant to these rules, I tried using the INTEGER( value, format, locale) function to somehow parse the string to a multivalued int. Combining SPLIT() and INTEGER() doesn't seem to work either because it tries to resolve a multivalued value into a singlevalued one instead parsing each single value into a list containing integers.
In my opinion it's too bad we have to use repeat flowing for this since this approach forces me to "capture" this logic in a certain "place and time" within the flowing of my application. It would've been ideal if this would somehow be possible to do without having to model a flow around it. That's my two cents.
Thanks again though, I'll be implementing this solution!