cancel
Showing results for 
Search instead for 
Did you mean: 

Pivot 2.0 - Hiding Columns from the Display

Ophir_Buchman
Sisense Team Member
Sisense Team Member
When creating a Pivot 2.0 chart (Linux) you may want to hide a specific column.
There are various reasons for doing so:
  • I want to sort by a column that shouldn't be displayed
  • I want to display a column when exporting the table to Excel or CSV, but hide it on the dashboard

Add the following widget script to your pivot chart:

columnsToHide = [3,4]

widget.transformPivot(
{},
function (metadata, cell)
{
columnsToHide.forEach(function(col) {
if (metadata.colIndex == col) { // Add a second condition ( && metadata.rowIndex > 0 ) if you want to keep the table header
cell.content = ' '
cell.style = {
maxWidth: '0px',
borderColor: 'white',
color: 'white'
}
}
})
}
);
Before After
Ophir_Buchman_0-1655368363998.png Ophir_Buchman_1-1655368535823.png
1 REPLY 1

gowtham_sisense
Sisense Team Member
Sisense Team Member

Note: If you have multiple pivot tables in your dashboard, put this inside the initialized event of the widget and declare columnsToHide as a const variable

widget.on('initialized', function (ev, se) {
	const columnsToHide = [3,4]

	widget.transformPivot(
	  {},
	  function (metadata, cell) 
	  {
		columnsToHide.forEach(function(col) {
		  if (metadata.colIndex == col-1) { // Add a second condition ( && metadata.rowIndex > 0 ) if you want to keep the table header
			cell.content = ' '
			cell.style = { 
			  maxWidth: '0px', 
			  borderColor: 'white',
			  color: 'white'
			}
		  }
		})
	  }
	);
});

 

Stay Healthy,
Gowtham Senthilkumar