Survey Tabulation > Advanced expressions > UNICOM Intelligence function library > Text functions > FormatValue
 
FormatValue
Returns a string that is the result of formatting a value according to one or more specified styles. The FormatValue function is identical to Format, except that the metadata to be used for formatting is provided by one variable, while the value to be formatted may come from elsewhere.
Syntax
FormatValue(ValFormat, Val [, Style [, Width [, Locale]]])
Parameters
ValFormat
Type: None
A variable that provides the metadata to be used for formatting.
Val
Type: None
The value to be formatted.
Style
Type: Text
Optional. One or more formatting codes. Multiple codes must be separated by semicolons.
Width
Type: Long
Optional. The minimum width of the formatted string.
Locale
Type: Long
Optional. The output locale to use for regional variations in formatting. If Locale is omitted or is negative, the current output locale is used for formatting.
(return)
Type: Text
Val formatted as a text string.
Remarks
See Format.
Example: Using the FormatValue function in an SQL query
This example shows the use of the FormatValue function in an SQL query that can be run against the Museum sample data set provided with the UNICOM Intelligence Developer Documentation Library. The query lists the categories in the museums variable, and for each category shows the total number of male and female respondents who selected that category:
SELECT FormatValue(museums, GROUPBY.COL[0], 'b') Museum,
    SUM(gender = {male}) Male,
    SUM(gender = {female}) Female
FROM vdata GROUP BY museums ON DefinedCategories(museums)
In the above example, the FormatValue function is effectively used to display the label of each category in the set returned by DefinedCategories(museums). Because the result of DefinedCategories(museums) is a set of category values with no connection to the metadata for the museums variable, it is not possible to use the Format to return the label of each category in the set. Instead, the FormatValue function is used so that the museums variable can be specified as providing the metadata for the formatting of the category values returned by DefinedCategories(museums).
For more information on the extended SQL syntax used in this query, see Advanced SQL queries.
Here is the result set of running the example query:
Museum Male Female
--------------------------------- ---- ------
National Museum of Science 209 124
Museum of Design 49 43
Institute of Textiles and Fashion 31 16
Archeological Museum 18 8
National Art Gallery 7 12
Northern Gallery 11 10
Other 16 21
(null) 0 0
See also
Text functions