☝️Small business or a startup? See if you qualify for our special offer.
+
All documentation

getFormat

getFormat(measureName: String, aggregation: String): FormatObject

[starting from version: 1.4]

Returns the number format of the specified measure or the default format if run without parameters.

Learn more about number formatting.

Parameters

Parameter/TypeDescription
measureName
String
optional The measure's unique name. Must be used with the aggregation parameter unless the measure is calculated.
To get the default format, skip the measureName.
aggregation
String
optional The measure’s aggregation. Must be used with the measureName.
If the measure is calculated, skip the aggregation.

Returns

FormatObject, which is the default number format or the number format applied to the specified measure.

Examples

1) How to get a precision of the default number format:

let format = pivot.getFormat();
alert("Precision: " + format.decimalPlaces);

Try on JSFiddle.

2) How to change a currency symbol for a specific measure:

let format = pivot.getFormat("Price", "sum");
format.currencySymbol = "$";
//format.currencySymbol = "£" // pound sterling
//format.currencySymbol = "€" // euro
//format.currencySymbol = "¥" // yen
pivot.setFormat(format, "Price", "sum");
pivot.refresh();

Open the example on JSFiddle.

See also

setFormat
FormatObject
Number formatting guide