LibreOffice Calc: Use different max value for color scale conditional formatting in each row
I have a dataset like the following (only much larger): Each row represents a task with a maximum number of points available in column B
. Every column starting at C
represents a Person with their score for every task.
Now, what I want to do is color every score according to the percentage of the total available points for that task. That is, I want to apply a color scale, but the maximum value is different for every row (it is the number in the B
column). The result should look something like this.
Is there any way to do this without manually defining the colorscale for each row separately? (As I mentioned, the real dataset is much larger.)
Here is the example dataset for you to test against.
no max Alice Bob Claudia David
1 10 9 7 6 10
2 7 7 7 3 7
3 9 7 5 6 9
4 12 10 8 12 5
5 5 4 2 3 4
6 10 6 2 4 7
After filing a bug report, i got a hint that there's a different but known LO calc bug involved, thus i can only propose a workaround (which worked with your test data):
-
Define the conditional formatting for cell range C2:F2, with min defined as value "0" and max as formula "=INDIRECT("B" & ROW())". The INDIRECT() function takes a string that represents a cell reference, in this case "B3" for the third row, "B4" for the fourth and so on, dynamically built based on the current row number; INDIRECT will evaluate the cell reference, yielding the max value from column B for the current row. While the relative cell reference "=$B2" won't get adapted if copied to different rows, INDIRECT() should return the correct max cell.
-
Paste the format from C2:F2 to C3:F7, either by selecting C2:F2 and using the "Paste Format" button, or by copying and using "Paste Special" -> "Format".
-
Save the file as xlsx (!) and reopen it. Without this step (or when saving in ods format), the conditional formatting won't get updated according to the current row's max value. That's the bug we had to get around.
Now, the conditional formatting should work for the complete range B2:F7, based on the B value for each row. I've used a data bar as conditional formatting, because it shows very clear if incorrent min/max values are used.