cancel
Showing results for 
Search instead for 
Did you mean: 
TriAnthony
Sisense Team Member
Sisense Team Member

Question

How to apply Financial Formatting to Pivot Tables?

Answer

Financial reports usually have specific styling requirements where negative numbers are shown in parentheses as opposed to having a leading minus sign. They are also usually written in red.  

The script below formats all the negative numbers in pivot tables exactly as the requirements above. Feel free to modify it if you have different formatting requirements.

// Format negative numbers
widget.transformPivot({ type: ['value'] }, function(metadata, cell) {
	
    if(cell.value >= 0 || !cell.value) {
        cell.content = cell.value;
		cell.contentType = 'html';

    } else
	{
	  	cell.content ='(' + (-1*cell.value).toString() + ')';
  		cell.style.color = 'red';
        cell.contentType = 'html'; 
    }
});
Rate this article:
Version history
Last update:
‎07-17-2024 08:00 AM
Updated by:
Contributors