Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Add a background color to cell

Marat March 14, 2019 edited

Hello.

I am using the SQL for Confluence plugin (bob swift). I would like to tint cells in tables by condition.
For example, I use the script:

SELECT MONTH([modify_date]) AS month, CONVERT(decimal(10,2),1.00*((CONVERT(decimal(10,2),1.00*SUM(response_1))/(Count(surv_req_id)/12))/3)) AS average
FROM [surv_req]
where  issued_date between  '2018-01-01' and '2018-12-31'
GROUP BY MONTH([modify_date])

ORDER BY month 


And I get such a table. 
How do I change the color of the cells in the average column to red if the value is less than 5

sql.PNG

db - MSSQL

 

1 answer

0 votes
Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 15, 2019

Hey Marat,

Looking through the documentation for the Bob Swift SQL and Table macros, I don't see an apparent way to selectively change the background color of individual cells. Or even full rows conditionally for that matter.

What I've done in the past for this kind of need is use the emoticons in Confluence which will render with the SQL plugin and a CASE statement in the SQL. Using CASE, you can output the value normally if the value is above 5, or with (x) in front of the number (the red X emoticon in Confluence) if it is below 5. When Confluence processes the text coming from the plugin - the first row in your screenshot would have "(x) 4.75" for example - it will display the (x) as the red X emoticon.

Hope that helps!
Daniel

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events