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.

This formula 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:

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

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.

This formula uses between 2 and 6 decimal places:

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

While no decimal places are required to format 72%, the minimum is specified as 2, meaning that "72.00%" is returned (for US English).

However, if the first parameter is set to 0.721234567890,72123456789 instead, "72.123457%" is returned. The returned value respects the maximum number of decimal places to use, which is set to 6.

Thousands separators

The fourth parameter may be set to TRUE to prevent thousands separators from being used. This formula returns "2430.00%" (for an app set to US English), and not "2,430.00%":

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

Padding the number with leading zeroes

The fifth parameter, MinimumNumberOfIntegerDigits, may be used to pad the number with leading zeroes, if necessary. This formula returns "0023.60%" for an app set to US English:

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

Named parameters

When a large number of parameters are provided to FORMATPERCENTAGE, it can be hard to keep track of which values go with which parameters. To make this easier, a parameter name, followed by :, may precede its value.

These formulas are equivalent:

FORMATPERCENTAGE(0.236, 0, 0, TRUE, 4)FORMATPERCENTAGE(0,236; 0; 0; TRUE; 4)
FORMATPERCENTAGE(Number: 0.236, MinimumNumberOfDecimalPlaces: 0, MaximumNumberOfDecimalPlaces: 0, OmitThousandsSeparators: FALSE, MinimumNumberOfIntegerDigits: 4)FORMATPERCENTAGE(Number: 0,236; MinimumNumberOfDecimalPlaces: 0; MaximumNumberOfDecimalPlaces: 0; OmitThousandsSeparators: FALSE; MinimumNumberOfIntegerDigits: 4)

All parameters don't need to be named, but once a parameter has been named, the remaining parameters must also be named.

Named parameters make it possible to provide parameters out-of-order and to omit optional parameters that normally would have been expected to precede a parameter, had it not been named. Omitted optional parameters use default values.

The formula above uses default values for all parameters other than Number and MinimumNumberOfIntegerDigits. As such, those optional parameters can be removed from the formula:

FORMATPERCENTAGE(0.236, MinimumNumberOfIntegerDigits: 4)FORMATPERCENTAGE(0,236; MinimumNumberOfIntegerDigits: 4)

Use named parameters when they help make a formula easier to read.

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.