Want to colour a table row automatically based on the value of a cell

Chad Waldron March 27, 2022

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

1 answer

3 votes
Katerina Kovriga _Stiltsoft_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2022

Hi @Chad Waldron ,

Wrap your table into the two Table Transformer macros subsequently:

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

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

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). 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events