How can I change decimal places in pivot table element?

Hi everyone!
How can I change decimal places in pivot table element?

Thanks!

I would be interested in knowing that as well.

1 Like

Me too!! I just want to format numbers to an integer - can’t be too much to ask?

Hi,

I just got an email from Moe asking if I can get more involved in the community. I’m grateful to tada and am excited to pay it forward. Tag me if you need some special java code.

I encountered a similar annoyance in the past and successfully resolved it through the implementation of a rather rudimentary code.

I used AI to ask it to add context and notes to the code. Change values as per your requirements.

TB.render('component_3', function(data) {

    // Get the table element by its id
    var table = document.getElementById("x_element_page_22_3");
    
    // Get all the table cells
    var cells = table.getElementsByTagName("td");
    
    // Loop through each cell and format the numeric values
    for (var i = 0; i < cells.length; i++) {
      var cell = cells[i];
      var value = cell.innerHTML;
    
      // Check if the value is a number
      if (!isNaN(value)) {
        // Format the number with decimal places and periods
        var formattedValue = parseFloat(value).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
        
        // Update the cell with the formatted value
        cell.innerHTML = formattedValue;
      }
    }  
});

Many thanks for your reply David! I tried the javascript above and modified it with my element ids, but it doesn’t change the decimal places?

TB.render(‘component_44’, function(data) {

// Get the table element by its id
var table = document.getElementById("x_element_page_31_44");

// Get all the table cells
var cells = table.getElementsByTagName("td");

// Loop through each cell and format the numeric values
for (var i = 0; i < cells.length; i++) {
  var cell = cells[i];
  var value = cell.innerHTML;

  // Check if the value is a number
  if (!isNaN(value)) {
    // Format the number with decimal places and periods
    var formattedValue = parseFloat(value).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    
    // Update the cell with the formatted value
    cell.innerHTML = formattedValue;
  }
}  

});