Conditional Row Formatting for JQL Table displayed in Confluence
Asked by Tonja Davis:

Hello,

We have a JQL table that we use to pull our testing effort tickets into an executive dashboard.

I would like to apply conditional formatting to a row based on a value found in Labels. For instance, If I have "Good" in Labels, I want the row to be colored green, "Warning" I want yellow, and "Bad" I want red.

I have tried with table transformer using SQL and I cannot get it to work.

Any suggestions?


Answers:
author: Katerina Rudkovskaya [Stiltsoft]
body: Hello [@Tonja Davis](/t5/user/viewprofilepage/user-id/4501598) ,  

Please wrap your source table with Table Transformer and use the SQL query [like this](https://docs.stiltsoft.com/display/TFAC/Advanced+table+cells+formatting#Advancedtablecellsformatting-Conditionalformatting):  

SELECT  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Labels' + "{cell}")  
AS 'Lables',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'column 2' + "{cell}")  
AS 'column 2',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'column 3' + "{cell}")  
AS 'column 3'  
FROM T\*

![2021-08-04_12h57_36.png](https://community.atlassian.com/t5/image/serverpage/image-id/154419iF09C14F77B58627F/image-size/large?v=v2&px=999 "2021-08-04_12h57_36.png")![2021-08-04_12h57_45.png](https://community.atlassian.com/t5/image/serverpage/image-id/154420i5498E81274DC430D/image-size/large?v=v2&px=999 "2021-08-04_12h57_45.png")![2021-08-04_12h57_49.png](https://community.atlassian.com/t5/image/serverpage/image-id/154421i83C24E9EB6548E86/image-size/large?v=v2&px=999 "2021-08-04_12h57_49.png")

Here are other examples of [advanced table cells formatting](https://docs.stiltsoft.com/display/TFAC/Advanced+table+cells+formatting#Advancedtablecellsformatting-Conditionalformatting) you may find useful for your cases.

Katerina  
Stiltsoft

comments: author: Tonja Davis
body: My problem is I am not wrapping a Wikitable. I'm wrapping another macro (Advanced JQL Table) in Table Transformer and trying to parse information from Advanced JQL Table as conditional formatting for the cells

does that make sense? ![advanced table.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/154493i18968EF352A80AC6/image-size/large?v=v2&px=999 "advanced table.PNG")

I've expanded the SQL you gave above to include all of the cells that are displayed but I get an error when implementing the SQL even though it's formatted properly. The table displays but none of the cells are properly colored

![Error.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/154499i9CFD492CEA7BA7AE/image-size/large?v=v2&px=999 "Error.PNG")


author: Katerina Rudkovskaya [Stiltsoft]
body: Yes, our app works with both manually created and macros generated tables.

It seems that we've faced a bug. I'll release the fix for it soon.  

Now, please try to replace FROM T\* to FROM T1  

Would you please confirm that it works for you?  

Katerina  
Stiltsoft


author: Tonja Davis
body: Thank you for your assistance. I changed FROM t\* to FROM T1 and the error is the same. it doesn't like "FROM" at the end.   

I'll include the query I built from yours here. it's rather long but it's a ticket table so, it is what it is"

SELECT  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Labels' + "{cell}")  
AS 'Labels',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Key' + "{cell}")  
AS 'Key',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Summary' + "{cell}")  
AS 'Summary',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Created' + "{cell}")  
AS 'Created',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Updated' + "{cell}")  
AS 'Updated',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Assignee' + "{cell}")  
AS 'Assignee',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Reporter' + "{cell}")  
AS 'Reporter',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Status' + "{cell}")  
AS 'Status',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Resolution' + "{cell}")  
AS 'Resolution',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
FROM T1


author: Katerina Rudkovskaya [Stiltsoft]
body: Note that you are using this part of the SQL query twice:  

FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  

Please try to delete one of them.

![2021-08-05_13h44_33.png](https://community.atlassian.com/t5/image/serverpage/image-id/154665iADE6CC17FBC48C60/image-size/large?v=v2&px=999 "2021-08-05_13h44_33.png")

.................

![2021-08-05_13h44_39.png](https://community.atlassian.com/t5/image/serverpage/image-id/154666i879CF7EC48475BB6/image-size/large?v=v2&px=999 "2021-08-05_13h44_39.png")  

Katerina  
Stiltsoft


author: Tonja Davis
body: Thank you for your help. I did as suggested and - on the upside - the error is gone.

On the downside, The table is rearranged (minor issue that is not critical) but the cells are also not colored. For transparency, I deleted the one at the bottom (right before "FROM T1" I will try again deleting the one at the top

![new error.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/154717iABCFB0A0D1045B89/image-size/large?v=v2&px=999 "new error.PNG")


author: Tonja Davis
body: deleting the one at the top results in an error. the one at the bottom is the best one to delete.


author: Katerina Rudkovskaya [Stiltsoft]
body: Yes, it's because the second part is not the full written part of the query.

![2021-08-05_21h33_16.png](https://community.atlassian.com/t5/image/serverpage/image-id/154780iE10A1D7A7E935FF2/image-size/large?v=v2&px=999 "2021-08-05_21h33_16.png")![2021-08-05_21h33_27.png](https://community.atlassian.com/t5/image/serverpage/image-id/154781iD3E4D97D2D17E933/image-size/large?v=v2&px=999 "2021-08-05_21h33_27.png")

I use this query and colors apply:  

SELECT  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Key' + "{cell}")  
AS 'Key',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Summary' + "{cell}")  
AS 'Summary',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Created' + "{cell}")  
AS 'Created',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Updated' + "{cell}")  
AS 'Updated',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Assignee' + "{cell}")  
AS 'Assignee',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Reporter' + "{cell}")  
AS 'Reporter',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Status' + "{cell}")  
AS 'Status',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Resolution' + "{cell}")  
AS 'Resolution',  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Labels'="Good" THEN "green"  
WHEN T1.'Labels'="Warning" THEN "yellow"  
WHEN T1.'Labels'="Bad" THEN "red"  
ELSE T1.'Labels'  
END  
+ "}" + T1.'Labels' + "{cell}")  
AS 'Labels'  
FROM T1

Please copy and paste it into Table Transfromer.

If it doesn't work, please raise the ticket **[here](https://jsd.stiltsoft.com/servicedesk/customer/portal/2/user/login?destination=portal%2F2)** .  
Please attach the [page storage format](https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html) and tell us what version of the app and Confluence you're using.  

Katerina  
Stiltsoft


author: Tonja Davis
body: thank you for all your help. I've opened a ticket.


author: Kishan Sharma
body: Hi [@Tonja Davis](/t5/user/viewprofilepage/user-id/4501598) Welcome to the community. Please check [this thread](https://community.atlassian.com/t5/Confluence-questions/Conditional-Formatting-for-Confluence-tables/qaq-p/1568284) on a similar use case.

comments: author: Tonja Davis
body: Hello Kishan,

I did check that thread, unfortunately, it does not address my concern. there is an expectation that I have a WIKI Table. I do not. I am using Advanced Tables - JQL Table and trying to wrap table transformer around it. That is where my issue lies.


Tags: confluence-server

jql

server

table-transformer