Want to colour a table row automatically based on the value of a cell
Asked by Chad Waldron:

I'm having issues trying to colour a table row automatically based on the value of a cell.  
I am wrapping a table in the Table Transformer macros and I'm bad with SQL :P

Basically, I'm wanting to change the colour of a whole row when either 'Fail', 'Partial' or 'Pass' is added to the second column.

Better yet, would it be possible to get the status of my Xray test execution result and change the row based on that status?

See my table below, thanks in advance.

![table.png](https://community.atlassian.com/t5/image/serverpage/image-id/190156i9A888E20BF6713D5/image-size/large?v=v2&px=999 "table.png")


Answers:
author: Katerina Kovriga {Stiltsoft}
body: Hi [@Chad Waldron](/t5/user/viewprofilepage/user-id/4330760) ,

Wrap your table into the two [Table Transformer](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+Transformer+macro?utm_source=atl_community&utm_medium=answer&utm_campaign=table-filter-traffic-sources&utm_vendorID=1216111) macros subsequently:

![Tue 6-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/190400i192533A9846AC28E/image-size/large?v=v2&px=999 "Tue 6-1.png")

The internal Table Transformer macro will be used to fulfill empty cells if there are any in your source table - so that they will be colored beautifully later:

SELECT  
CASE WHEN **T1.'Fail/Partial'** IS NULL THEN "-"  
ELSE **T1.'Fail/Partial'**   
END  
AS **'Fail/Partial'** ,  
CASE WHEN **T1.'Column 1'** IS NULL THEN "-"  
ELSE **T1.'Column 1'**   
END  
AS **'Column 1'** ,  
CASE WHEN **T1.'Column 2'** IS NULL THEN "-"  
ELSE **T1.'Column 2'**   
END  
AS **'Column 2'**   
FROM T1

![Tue 6-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/190405i74D2264BB6323198/image-size/large?v=v2&px=999 "Tue 6-2.png")

The external Table Transformer is used for conditional formatting:

SELECT  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Fail/Partial' = "Fail" THEN "#FFA07A"  
WHEN T1.'Fail/Partial' = "Partial" THEN "#ADD8E6"  
WHEN T1.'Fail/Partial' = "Pass" THEN "#9FE2BF"  
ELSE "#D3D3D3"  
END  
+ "}" + **T1.'Fail/Partial'** + "{cell}")  
AS **'Fail/Partial'** ,  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Fail/Partial' = "Fail" THEN "#FFA07A"  
WHEN T1.'Fail/Partial' = "Partial" THEN "#ADD8E6"  
WHEN T1.'Fail/Partial' = "Pass" THEN "#9FE2BF"  
ELSE "#D3D3D3"  
END  
+ "}" + **T1.'Column 1'** + "{cell}")  
AS **'Column 1'** ,  
FORMATWIKI("{cell:bgColor=" +  
CASE WHEN T1.'Fail/Partial' = "Fail" THEN "#FFA07A"  
WHEN T1.'Fail/Partial' = "Partial" THEN "#ADD8E6"  
WHEN T1.'Fail/Partial' = "Pass" THEN "#9FE2BF"  
ELSE "#D3D3D3"  
END  
+ "}" + **T1.'Column 2'** + "{cell}")  
AS **'Column 2'**   
FROM T1

![Tue 6-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/190407i9CA2112CF7F42FEF/image-size/large?v=v2&px=999 "Tue 6-3.png")

In my queries I took exactly your column's name **T1.'Fail/Partial'** for the conditions, but the **T1.'Column 1'** , **T1.'Column 2'**, etc. should be changed for your own headers (and you should repeat the same pattern for all the columns of your table).


Tags: colour

confluence-server

custom-field

server

table