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

Alexander Stoyanov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 6, 2020

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

4 votes
Answer accepted
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.
November 6, 2020

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.

Alexander Stoyanov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 6, 2020

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?

Dom November 19, 2020

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

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.
November 19, 2020

@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 # people like this
Dom November 19, 2020

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
shunquan shen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 30, 2022

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

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.
August 30, 2022

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.

Like # people like this
Stiltsoft support
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.
August 22, 2024

And you may also use the Spreadsheet from Table macro for the case: turn your manually created or macro generated tables into live spreadsheets and apply familiar Excel-like conditional formatting.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events