JennyW
11-10-2025Cloud Apps
How to add different colours to each row in pivot table?
Hello,
I have a pivot table which includes the day in one column.
I want to give each row a different colour. Also, the entire row has to be coloured.
For example:
Does anyone have a s...
- 11-18-2025
Hi JennyW ,
If I understand it correctly, you need to color the Pivot Table's rows based on the content of a date field. If a row contains 'Monday', a certain color should be applied, and if it contains 'Tuesday', a different color should be set.
If that's the case, please try the script provided below. This script will work if the date field is the first column in the table.const dayColorMapping = { 'sunday': '#9cbff7', 'monday': '#ee9cf7', 'tuesday': '#f79cba', 'wednesday': '#9cebf7', 'thursday': '#abf79c', 'friday': '#f7f49c', 'saturday': '#f79c9c' } const weekday = ["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]; const dateColumnIndex = 0; widget.transformPivot( { }, function setCellBackground(metadata, cell) { if(metadata.rowIndex > 0){ const date = new Date(metadata.rows[dateColumnIndex].member); const day = weekday[date.getDay()]; if(day in dayColorMapping) { cell.style.backgroundColor = dayColorMapping[day]; } } } );Result:
Let me know if that works!
- Hari