FORMATPERCENTAGE function

FORMATPERCENTAGE(number, minimumNumberOfDecimalPlaces?, maximumNumberOfDecimalPlaces?, omitThousandsSeparators?, minimumNumberOfIntegerDigits?) FORMATPERCENTAGE(number; minimumNumberOfDecimalPlaces?; maximumNumberOfDecimalPlaces?; omitThousandsSeparators?; minimumNumberOfIntegerDigits?)

number — Number or { Number }

The number to format.

minimumNumberOfDecimalPlaces — Number or { Number } (optional)

The minimum number of decimal places a number should be formatted with. Must be greater than or equal to zero and less than or equal to the maximum number of decimal places. If omitted, 0 is assumed.

maximumNumberOfDecimalPlaces — Number or { Number } (optional)

The maximum number of decimal places a number should be formatted with. Must be greater than or equal to the minimum number of decimal places. If omitted, this parameter is set to the minimum number of decimal places.

omitThousandsSeparators — Logical or { Logical } (optional)

FALSE to include thousands separators and TRUE to exclude them. If omitted, FALSE is assumed.

minimumNumberOfIntegerDigits — Number or { Number } (optional)

The minimum number of digits the integer part should be formatted with. If this parameter is greater than the number of digits of the integer part, it is padded with zeroes, meaning that 123 formatted with a minimum of five integer digits is rendered as "00123." If omitted, 1 is assumed.

Returns — Text or { Text }

A number formatted as a percentage.

Returns a number as text, representing a percentage. FORMATPERCENTAGE(0.726)FORMATPERCENTAGE(0,726), returns "73%".

FORMATPERCENTAGE takes the language of the app into account when converting numbers. For instance, a decimal point is used when the language is set to US English and a decimal comma is used when the language is set to French.

This function is specific to Calcapp.

Decimal places

The second and third parameters are used to control the number of decimal places the number is formatted with. If only the second parameter is given, it specifies the exact number of decimal places that are used. FORMATPERCENTAGE(0.726, 4)FORMATPERCENTAGE(0,726; 4) returns "72.6000%", using exactly four decimal places, if the language of the app is set to US English and "72,6000%" if the language is set to German.

If a third parameter is given, the second parameter is interpreted as the minimum number of decimal places that should be used and the third parameter is interpreted as the maximum number of decimal places that should be used. FORMATPERCENTAGE(0.72, 2, 6)FORMATPERCENTAGE(0,72; 2; 6) uses between 2 and 6 decimal places. While no decimal places are required to format 72%, the minimum is specified as 2, meaning that "72.00%" is returned (for US English). FORMATPERCENTAGE(0.72123456789, 2, 6)FORMATPERCENTAGE(0,72123456789; 2; 6), on the other hand, returns "72.123457%", because the maximum number of decimal places to use is specified as 6.

Thousands separators

The fourth parameter may be set to TRUE to prevent thousands separators from being used. FORMATPERCENTAGE(24.3, 2, 2, TRUE)FORMATPERCENTAGE(24,3; 2; 2; TRUE) returns "2430.00%" (for an app set to US English), and not "2,430.00%".

Padding the number with leading zeroes

The fifth parameter, minimumNumberOfIntegerDigits, may be used to set the minimum number of integer digits. In practice, this pads the number with leading zeroes, if necessary. FORMATPERCENTAGE(0.236, 2, 2, TRUE, 4)FORMATPERCENTAGE(0,236; 2; 2; TRUE; 4), returns "0023.60%" for an app set to US English.

Related functions

Examples

FORMATPERCENTAGE(0.726)FORMATPERCENTAGE(0,726)

Returns "73%".

FORMATPERCENTAGE({ 0.726, 0.213 }, 1)FORMATPERCENTAGE({ 0,726; 0,213 }; 1)

Returns the array { "72.6%", "21.3%" }{ "72.6%"; "21.3%" } if the language of the app is set to US English. The number of decimal places is set to 1. When invoked with an array, FORMATPERCENTAGE is invoked once per array element and the results are collected in an array.

FORMATPERCENTAGE(0.726, 4)FORMATPERCENTAGE(0,726; 4)

Returns "72.6000%" if the language of the app is set to US English, using exactly four decimal places.

FORMATPERCENTAGE(0.72, 2, 6)FORMATPERCENTAGE(0,72; 2; 6)

Returns "72.00%" if the language of the app is set to US English. As both the second and the third parameter are specified, 2 is taken to mean the minimum number of decimal places that should be used, and 6 is taken to mean the maximum number of decimal places that should be used.

FORMATPERCENTAGE(0.72123456789, 2, 6)FORMATPERCENTAGE(0,72123456789; 2; 6)

Returns "72.123457%" if the language of the app is set to US English. As both the second and the third parameter are specified, 2 is taken to mean the minimum number of decimal places that should be used, and 6 is taken to mean the maximum number of decimal places that should be used.

FORMATPERCENTAGE(24.3, 2, 2, TRUE)FORMATPERCENTAGE(24,3; 2; 2; TRUE)

Returns "2430.00%" (for an app set to US English), and not "2,430.00%". The fourth parameter prevents thousands separators from being used.

FORMATPERCENTAGE(0.236, 2, 2, TRUE, 4)FORMATPERCENTAGE(0,236; 2; 2; TRUE; 4)

Returns "0023.60%" (for an app set to US English). The fifth parameter, 4, specifies the minimum number of integer digits (before the decimal separator). This pads the number with leading zeroes, if necessary.