Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,367,806
Community Members
 
Community Events
168
Community Groups

Is it possible to color a table row based on the value of a column

I have a table that is build from data coming from an outside source. I want each row to be colored in a color that is comming from a column named Color, which contains RGB value of a color.

Is this possible?

1 answer

1 accepted

2 votes
Answer accepted

Hi @Alexander Stoyanov ,

You may try the Table Filter and Charts for Confluence app.

Wrap you table in the Table Transformer macro and apply conditional formatting with the help of the Wiki markup:

Fri 1-1.png

 

Type in your custom SQL query:

Fri 1-2.png

SELECT
FORMATWIKI("{cell:bgColor=" +
CASE WHEN T1.'Color' LIKE "(122,28,134)" THEN "#7a1c86"
WHEN T1.'Color' LIKE "(10,186,181)" THEN "#0abab5"
ELSE "#ccff00"
END
+ "}" + T1.'Column A' + "{cell}") AS 'Column A with Background',
FORMATWIKI("{cell:bgColor=" +
CASE WHEN T1.'Color' LIKE "(122,28,134)" THEN "#7a1c86"
WHEN T1.'Color' LIKE "(10,186,181)" THEN "#0abab5"
ELSE "#ccff00"
END
+ "}" + T1.'Column B' + "{cell}") AS 'Column B with Background',
FORMATWIKI("{cell:bgColor=" +
CASE WHEN T1.'Color' LIKE "(122,28,134)" THEN "#7a1c86"
WHEN T1.'Color' LIKE "(10,186,181)" THEN "#0abab5"
ELSE "#ccff00"
END
+ "}" + T1.'Color' + "{cell}") AS 'Color with Background'
FROM T*

 

And preview the result:

Fri 1-3.png

 

And what concerns uploading your source table from the external source, the app also provides the Table from CSV and Table from JSON macros that support outputting data from a URL or an attached file.

Thanks for the replay @Katerina Kovriga _Stiltsoft_ . It looks very promising and I was not aware of the table transformer macro. When I paste your code with the sample table you have provided I get

TypeError: alasql.fn.FORMATWIKI is not a function

Where is FORMATWIKI defined?

I get TypeError: alasql.fn.FORMATWIKI is not a function as well.

@Alexander Stoyanov , @Dom , please, check if the version of the Table Filter and Charts for Confluence app is 6.1.0 or newer.

Here is our documentation about cells formatting with the Table Transformer macro. You'll find a lot of use cases there.

If the version of the app is up-to-date but you still can't reproduce our examples, please, raise a support ticket (specify the version of the app and attach your screenshots, we'll investigate the issue).

Like Dom likes this

Behind on the version; the major version update has to be vetted so I can't just click the update button. :)

I imagine I will not have any problem once I can update. Thanks!

Like # people like this

If the table is generated by "table from json" macro, can  " Table Transformer" macro be used ? 

Yes, all our macros are compatible. So, you can wrap your Table from JSON macro in the Table Transformer, Table Filter, Pivot Table macro, etc. and further transform, filter and aggregate your table.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events