sisense.com
✅ You are viewing documentation for the latest version of Compose SDK.
Version:

Function formatNumber

formatNumber(value, config?): string

Formats a single numeric value using the provided NumberFormatConfig.

Missing config falls back to defaults: Numbers type, auto decimal scale, thousand separator enabled, all abbreviations (K/M/B/T) enabled.

Returns an empty string when value is NaN.

Parameters

ParameterTypeDescription
valuenumberThe numeric value to format.
config?NumberFormatConfigFormatting configuration.

Returns

string

Formatted string representation of the value.

Example

formatNumber(1234567);
// returns '1.23M'

formatNumber(0.42, { name: 'Percent', decimalScale: 1 });
// returns '42.0%'

formatNumber(1500, { name: 'Currency', symbol: '€', prefix: true });
// returns '€1.5K'
Last Updated: