Adding custom font colors for a transposed row in a table

I want to label the positive numbers in green and negatives in red but only for the second row. How can this be achieved?

Current chart settings is as shown below

Best Answer

  • david_cunningham
    Answer ✓

    So this would require you to use an HTML table, which would mean restructuring your data because transpose isn't an option. But if you're really set on changing the font color instead of the cell color, you can achieve that by using this beast mode.

    CASE
    WHEN SUM(value) < 0 THEN CONCAT('<p style="color:red;">',SUM(value),'</p>')
    ELSE CONCAT('<p style="color:green;">',SUM(value),'</p>')
    END

    David Cunningham

    ** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
    ** Did this solve your problem? Accept it as a solution! ✔️**

Answers

  • Sean_Tully
    Sean_Tully Contributor

    Not exactly the same, but you can add rules to the Colors chart properties to shade the cell red. I don't think that you can do the font color there, though. If you uncheck "Apply format to table row" it will only shade the cell, so you will get the same effect (highlighting the negatives), but via shade rather than font color.

  • The easiest way to achieve this is to set the negative numbers to show in red, and then use card color rules to set > 0 to show in green. The red negative number setting will override the green.

    However, this approach causes the cell to be filled in, just an FYI.

    David Cunningham

    ** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
    ** Did this solve your problem? Accept it as a solution! ✔️**

  • I have already tried both the approaches, but would prefer the changes to be displayed only for fonts than for cells

  • david_cunningham
    Answer ✓

    So this would require you to use an HTML table, which would mean restructuring your data because transpose isn't an option. But if you're really set on changing the font color instead of the cell color, you can achieve that by using this beast mode.

    CASE
    WHEN SUM(value) < 0 THEN CONCAT('<p style="color:red;">',SUM(value),'</p>')
    ELSE CONCAT('<p style="color:green;">',SUM(value),'</p>')
    END

    David Cunningham

    ** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
    ** Did this solve your problem? Accept it as a solution! ✔️**