Forum Discussion

amelia's avatar
08-12-2022

Graying out rows in Pivot Table

Hi! I have a pivot table and would like to grey out some of the rows. These rows are for future weeks, or dates that are larger than the current week. I would rather grey out those rows instead of removing them, does anyone know how to do this? Thank you 🙂 

1 Reply

Replies have been turned off for this discussion
  • harikm007's avatar
    harikm007
    Data Warehouse

    Hi amelia ,

    One solution is to change color of one column and spread the color using the script in this post: 

    https://www.binextlevel.com/post/pivot2-spread-color-from-one-column-to-entire-row

     

    In your case, use below script to change color of date column and apply the script from above post:

    (Note: Below script is for Pivot2)

     

    widget.transformPivot(
        {
            type: ['member']
        },
        function setCellBackground(metadata, cell) {
            
    		columnIndex = 0 //index of date column in pivot
    		
    		if(metadata.colIndex == columnIndex && cell.value != 'Days in Date') //Update Date column title
    		{
    			
    			
    			if(new Date(cell.value) > new Date())
    			{
    				cell.style.backgroundColor = '#acadac';
    			}
    			
    				
    		}
    		
    
        }
    );

     

    -Hari