Hi Team,
I am trying to find a way to format the row of my table based on the values in a column. For e.g, I would want the rows of the Class named 1 colored in yellow, 2 in blue and 3 in green. Most of the codes, even this in link below, looks like we'd have to conditionally format each column for colours and then another conditional formatting for new columns.
https://community.atlassian.com/t5/Confluence-questions/Want-to-colour-a-table-row-automatically-based-on-the-value-of-a/qaq-p/1984456
This is my sample data but my original data would have over a dozen columns. Also, is there a way (and how) to work this out with CSS Styling? I am basic to both sql and CSS so I have difficulty working this out.
Hi @MudCo ,
If you are talking about the Table Transformer macro provided by our Table Filter, Charts & Spreadsheets for Confluence app, then your approach is correct regarding the FORMATWIKI function: you need to conditionally color each column one by one.
The Stylesheet tab and CSS coding help you to format your tables in general (the whole table, the header row, the second column, the fifth row, and so on). You may find plenty of examples in our documentation.
If your source table has a lot of columns and it is hard for you to copy the parts of your FORMATWIKI query, you may take the Table Spreadsheet macro and use the Excel-like conditional formatting there.
Hello there,
Yes, sorry I missed to mention that it is Table Transformer Macro. I used FORMATWIKI to highlight but could only do one cell, below is my code for the same. I am understanding that there is no way to colour the existing cell but we will need to end it as a new column. I tried to understand the code in some of the examples but was not very successful
SELECT *,CASEWHEN ('Class') IS "1"THEN FORMATWIKI("{cell:bgColor=#CCCCFF|align=center}" + 'Class' + "{cell}")ELSE FORMATWIKI("{cell:bgColor=#8FCA7D|align=center}" + 'Class' + "{cell}")END AS 'CLASS'FROM T1
Not sure that I got this part "I am understanding that there is no way to colour the existing cell but we will need to end it as a new column." but you may check this example for reference and adjust your query (there we work with Status column and you have Class, Name, Score, etc. columns): https://community.atlassian.com/t5/Confluence-questions/Table-transformer-macro-how-to-color-both-the-text-and/qaq-p/2725075
Thanks I made the change and found my error in understanding. I was seeing a few examples where people were ending in a new column so I thought that was how it was supposed to be done and I also ended it as 'END AS 'CLASS' instead of 'Class' which of course created a new column named CLASS. By changing that to 'Class', i.e, the original name of the column, the formatting is retained to the original column. Now I understand this, how do I go about colouring the row instead the just the cell? how do I give conditions to each column when my only condition was originally based on the value of column 'Class'?
SELECT *,CASEWHEN ('Class') IS "1"THEN FORMATWIKI("{cell:bgColor=#CCCCFF|align=center}" + 'Class' + "{cell}")ELSE FORMATWIKI("{cell:bgColor=#8FCA7D|align=center}" + 'Class' + "{cell}")END AS 'Class'FROM T*
It looks like you're new here. Sign in or register to get started.