Remove Columns That Contain All Nulls From Pivot Table
Application
Use this script in a pivot table where a column may have all NULL values to clean up the UI.
The irrelevant columns are dropped after being loaded
widget.on('ready', function(){
var tlen = parseInt($('.p-container thead tr td').last().prev().attr('fidx')) + 2 //counts how many cols total
var dims = $('#pivot_ td.p-dim-head').length // counts the number of dims
for (var i = dims; i < tlen; i++) {
var stuff = $('#pivot_ td.p-value[fidx='+i+']:not(.p-total-row-val)').text().trim()
//if the text content is empty then hide the column
if(stuff ==''){
//$('td[fidx="' + i +'"]').css('display', 'none'); //hides column
$('td[fidx="' + i +'"]').remove(); //hides column
}
};
});
Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022