How to customize the units for values of PivotGrid at client-side in JavaScript?
This KB document explains how to customize the units for values in JavaScript PivotGrid OLAP at client mode using JavaScript.
Solution:
You can customize the units for PivotGrid values as kilo, million, billion, etc. using JavaScript code.
Step 1:
Render the PivotGrid as your platform needs.
JavaScript
$("#PivotGrid1").ejPivotGrid(
{
url: "/Olap", renderSuccess: "successEvent"
});
MVC
@Html.EJ().Pivot().PivotGrid("PivotGrid1").ClientSideEvents(clientSideEvents => clientSideEvents.RenderSuccess("successEvent"))
ASP
<ej:PivotGrid ID="PivotGrid1" runat="server" ClientIDMode="Static"> <clientsideevents renderSuccess="successEvent" /> </ej:PivotGrid>
Step 2:
Add the following codes in the “renderSuccess” event.
function successEvent(args) {
var pivotGridObj = $("#PivotGrid1").data("ejPivotGrid");
for (var i = 0; i < pivotGridObj._JSONRecords.length; i++) {
var number = ej.globalize.parseFloat(pivotGridObj._JSONRecords[i].Value.toString(), "en-US"); // Convert the formatted value to number
if ($.isNumeric(number)) {
var digit = number;
//var tabUnits = [" million", " billion", " trillion", " quadrillion"];
//Store the units in the array
var tabUnits = ["K", "M", "B", "T"];
var highnumber = false;
var bignumber = 1000;
var tabposition = -1;
var unit;
if (number >= bignumber) {
highnumber = true;
while (number >= bignumber) {
bignumber *= 1000; tabposition++;
}
number /= (bignumber / 1000);
unit = tabUnits[tabposition];
} else unit = "";
if (unit == undefined) return digit.toExponential(2);
var toround = (highnumber == true) ? 100 : 10;
var result = Math.round(number * toround) / toround;
pivotGridObj._JSONRecords[i].Value = "$" + result.toLocaleString().replace(",", ".") + '' + unit;
}
}
pivotGridObj.renderControlFromJSON();
}

Custom units
Conclusion
I hope you enjoyed learning about how to customize the units for values of PivotGrid at client-side.
You can refer to our JavaScript PivotGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript PivotGrid example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!