Formats numbers to produce text or string items with the selected display format or 'mask'.
- Returned Output: Text
- Library: PQL \ Common \ String
- Version: 2018.00.000
- Can be combined with and other PQL function throughout the application.
- It CANNOT be used with MDX or VBA functions. But it can be used on MDX-based content in other parts of the application.
* Click on the function's arguments above for more details on the input values.
- The numeric value can be any element that resolves to a numeric value.
- The text mask is a prescribed input that instructs the engine on how to format the number.
- Format produces a text string. It cannot be used for subsequent numeric operations.
Different Function types
- This function is like the Excel Format function.
- Use the DateFormat function to format dates.
The syntax for describing a format mask is based on Java specifications. Details on the specification can be found here.
To facilitate the use of the masking syntax, Pyramid has exposed a variety of format mask presets in the application. The following summarizes those options.
The mask is "%, .<D>f" - where D is the number of decimal places. It will inject commas into the figure as needed.
This produces 123,456.78
format(123456.78, "%, .2f")
This produces 123,456
format(123456.78, "%, .0f")
This produces 123,456.7
format(123456.78, "%, .1f")
Other Standard Options
Using the "k" mask, will show numbers in standard format, but in thousands.
Using the "m" mask will show numbers in standard format, but in millions.
This produces 123,456.78k
This produces 123.46m
The mask is "<C>%, .<D>f" - where C is the currency symbol and D is the number of decimal places. This is similar to normal numbers, except it includes details for the currency symbol.
This produces $123.44
format(123.436, "$%, .2f")
This produces €123
format(123.436, "€%, .0f")
The mask is "<D>" - where D is the number of decimal places. Unlike standard and currency formatting, the format engine multiplies the number by 100, appends a percentage sign (%) at the end and injects commas into the figure as needed
This produces 12,343.6%
This produces 43.67%
This produces 44%