How to determine state of a checkbox in a Confluence table
Asked by Scott Gillespie:

Confluence Server/Data Center

Is there a way to identify status via Table Transformer SQL? For example, it would be great if this would work: IF *Table Cell with checkbox status* = *Checked*, then \<perform action\>.

We use checkboxes in several tables so users can quickly update a status, like "Ready for Billing" by checking a box. This is easier and faster to update than using the Status macro.

It's understood (and disappointing) that Table Filter does not distinguish checked vs. unchecked status. There are many threads related to this, including one that is somewhat useful about using a Pivot Table to count checked vs. unchecked status, but I can find nothing about operating on individual cell status.

Thanks in advance for any guidance.


Answers:
author: Katerina Rudkovskaya [Stiltsoft]
body: Hi [@Scott Gillespie](/t5/user/viewprofilepage/user-id/1024139),  

Our macros understand the checked and empty checkboxes, please see the screenshots below related to the Table Filter macro:  

![Fri 5-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/256990i892BA9ADBF15568C/image-size/large?v=v2&px=999 "Fri 5-1.png")![Fri 5-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/256991iB9073241F732EEA7/image-size/large?v=v2&px=999 "Fri 5-2.png")  

What concerns the Table Transformer macro, please refer to the cells with checkboxes as **"Completed"** and **"Incomplete"** for your CASE WHEN queries.  

I mean something like this: ... T1.'Checkbox' = "Completed" ...

comments: author: Scott Gillespie
body: Thanks so much, Katerina! I was clearly misinformed about Table Filter. And the SQL tip is part of what I needed. To be clear, does a checkbox only have a complete/incomplete state regardless of what text follows it?  

So now, let me see if you have a solution for this. If the answer above is yes, this may not be possible with my current table layout. A table has a column to indicate if an issue is with Customer, Supplier, or Other, with a short explanation string. So, that's 3 checkboxes and a free-form string per cell. Is there a way for SQL to determine which of those checkboxes is ticked, and pick up the comment?


author: Stiltsoft support
body: Hi [@Scott Gillespie](/t5/user/viewprofilepage/user-id/5118135) ,

The Table Filter and Pivot Table macros understand the whole task (checkbox+description) as a whole thing and operate with it in terms of checked and unchecked item. The description itself is not taken into consideration, only the state of the checkbox is important.

But the Table Transformer macro is a bit tricky: to consider checkboxes and descriptions separately, you need to have them into separate cells (one checkbox per cell). But if you try to split the checkbox from the description via the SQL query, the checkbox won't be recognized and the query will be working with your description (as with the string, I mean).

So, to achieve your case, you may reorganize the table structure and keep your checkboxes and descriptions separately (a separate cell for each item). Please see an example below:

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

Then you'll be able to check both the state of the checkbox and the contents of its description. The query may look like this, for example:

SELECT \*,  
CASE WHEN 'Checkbox' = "Completed" AND 'Description' LIKE "%Customer%"  
THEN FORMATWIKI("{status:colour=Yellow\|title=Customer's fault}")  
WHEN 'Checkbox' = "Completed" AND 'Description' LIKE "%Supplier%"  
THEN FORMATWIKI("{status:colour=Blue\|title=Supplier's fault}")  
WHEN 'Checkbox' = "Completed"  
THEN FORMATWIKI("{status:colour=Gray\|title=Other}")  
END  
AS 'Status'  
FROM T1

![Sat 1-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/257079i4690F063D431365D/image-size/large?v=v2&px=999 "Sat 1-2.png")

Then you may use the Table Filter macro or Pivot Table macro on top of the Table Transformer macro to filter/aggregate your projects by statuses:

![Sat 1-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/257080i22F32F68E9F003BD/image-size/large?v=v2&px=999 "Sat 1-3.png")![Sat 1-4.png](https://community.atlassian.com/t5/image/serverpage/image-id/257081iA3A34634E215F850/image-size/large?v=v2&px=999 "Sat 1-4.png")

Hope this workaround helps your case.


author: Katie A
body: [@Katerina Rudkovskaya \[Stiltsoft\]](/t5/user/viewprofilepage/user-id/3738229) I have a question related to your answer.  
How does this apply when the Table Transformer is wrapping a "Task Report" macro?

For example, I wanted the description to be just a string, so I use this SQL

SELECT  
T1.'Task appears on',T1.'Assignee',T1.'Label(s)',  
MATCH_REGEXP(T1.'Description',"(?\<=\\")\[\^\\"\]\*","u") AS 'Description'  
FROM T1

This shows the same as a Task report, but my "Description" column now only has the text between "". (Like \[\] "Katie's Task" @katie ///date will now display Description only as "Katie's Task")

![Screenshot 2024-01-24 at 11.35.01 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/302351iADFE28117592811C/image-size/large?v=v2&px=999 "Screenshot 2024-01-24 at 11.35.01 AM.png")

![Screenshot 2024-01-24 at 11.35.57 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/302352i2FA6E3F119CAC63B/image-size/large?v=v2&px=999 "Screenshot 2024-01-24 at 11.35.57 AM.png")

BUT the due date is no longer formatted nicely with a color indicating how soon it is due. Is there way to pull the due date from the description instead and keep the color scheme?

I tried re-ordering my tasks with the due date at the front, using SQL on "description" column to capture everything at the beginning. This does pull out the date, but it loses the knowledge that it is a "task" so it loses the formatting. Is there a way to trick the output to knowing it is a task still so that it doesn't lose the formatting?  

![Screenshot 2024-01-24 at 12.45.15 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/302354i3333EABDE362D2C8/image-size/large?v=v2&px=999 "Screenshot 2024-01-24 at 12.45.15 PM.png")

![Screenshot 2024-01-24 at 12.45.46 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/302355i33CD7A88F5DBB957/image-size/large?v=v2&px=999 "Screenshot 2024-01-24 at 12.45.46 PM.png")

Any tips are welcome!

Katie


author: Stiltsoft support
body: Hi [@Katie A](/t5/user/viewprofilepage/user-id/5380137) ,

Unfortunately, the Table Transformer loses the formatting if the data was modified. If you just select the column, it stays. But if you do smth with the column, is disappears.

You may use another Table Transformer on top of the first one and format your dates (color the background) using the FORMATWIKI function and comparing dates with, for example, "today".


author: Yatiraj Sharma
body: Hi [@Stiltsoft support](/t5/user/viewprofilepage/user-id/5062270) ,

It is losing the formatting anyway I tried this as what you mentioned above with Table Transformer..

I cant see it is updating the Status.

SELECT \*,  
CASE WHEN 'Checkbox' = "Completed" AND 'Activity' LIKE "%Ensure Billing Value Stream Structure is up to date%"  
THEN FORMATWIKI("{status:colour=Green\|title=Done}")  
END  
AS 'Status'  
FROM T1

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


author: Raphael R
body: It is important to note here that the expected value inside the Checkbox column is language dependent. So if you're using Confluence in German,

CASE WHEN 'Checkbox' = "Completed"

will not work. You have to use

CASE WHEN 'Checkbox' = "Abgeschlossen"

or

CASE WHEN 'Checkbox' = "nicht abgeschlossen"

You can find out the exact words for your language by wrapping a "chart from table" macro around an example table like this:

![example.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/329379iECE9D31FDC065D53/image-size/large?v=v2&px=999 "example.jpg")


author: Stiltsoft support
body: Hi [@Yatiraj Sharma](/t5/user/viewprofilepage/user-id/4918147) ,

Have also added the example here in a new thread: <https://community.atlassian.com/t5/Confluence-questions/How-do-I-update-status-macro-automatically-if-my-confluence/qaq-p/2723192#U2724675>

Also big thank you to [@Raphael R](/t5/user/viewprofilepage/user-id/846128) for the thorough explanation regarding the different languages.

Maybe some additional hints from our side regarding the case: you don't need to create the 'Status' column at all, the column is created automatically by the SQL query and the In progress/Done statuses are also set automatically.

When you check/uncheck the statuses in the page view mode, at first you change the status and then reload the page - after the reloading the statuses are updated.

Maybe this is your issue that you don't see updated statuses.


author: Yatiraj Sharma
body: It is hiding the value of status column which was originally keyed in manually. if we add the Table Transformer macro.

Only in editing mode it is visible as given in second screen shot.

After marking checkbox it is updating the status as Done but it will not be visible unless that page url is refreshed.

![Screenshot 2024-06-12 135743.png](https://community.atlassian.com/t5/image/serverpage/image-id/329397iDF61A765C4AF67F8/image-size/large?v=v2&px=999 "Screenshot 2024-06-12 135743.png")

![Screenshot 2024-06-12 135807.png](https://community.atlassian.com/t5/image/serverpage/image-id/329394i042C01CC8F0878BD/image-size/large?v=v2&px=999 "Screenshot 2024-06-12 135807.png")![Screenshot 2024-06-12 135827.png](https://community.atlassian.com/t5/image/serverpage/image-id/329395iE10AF21969E3D6C4/image-size/large?v=v2&px=999 "Screenshot 2024-06-12 135827.png")


author: Yatiraj Sharma
body: I am adding a Status column as I need the Status Macro and I dont think SQL will add the status macro (It will add the columns and value in it....

But I am trying to address the issue as given my above screen shot, it will not show value even though status macro values are present in the column. And also, it will not show even though it is updated as "Completed" We have to refresh the page.

Any solution for these problems.


author: Stiltsoft support
body: If you need some other column with manually created statuses (the Status macros), of course, you may create it but call it somehow different from the status column that is created by the Table Transformer macro.

For example, if you use this query from my example

SELECT \*,  
CASE WHEN 'Checkbox' = "Completed"  
THEN FORMATWIKI("{status:colour=Green\|title=Done}")  
ELSE FORMATWIKI("{status:colour=Yellow\|title=In Progress}")  
END  
AS 'Status'  
FROM T\*

then the Table Transformer automatically creates the 'Status' column with virtual statuses. If your column with manually created statuses is also called 'Status', then it will be rewritten.

So, if you need to preserve it (and have two columns with statuses), then you should name it differently.

If the question is, that in the macro generated column with statuses you have the "Done" status but don't see the "In progress" status, the issue is in your SQL query:

CASE WHEN 'Checkbox' = "Completed" AND 'Activity' LIKE "%Ensure Billing Value Stream Structure is up to date%"  
THEN FORMATWIKI("{status:colour=Green\|title=Done}")  
END  
AS 'Status'

Here you set only "Done" statuses if the condition is true and nothing in the condition is not true.

In my example if the condition is not true, I set the "In progress" status (the ELSE part):

**ELSE** FORMATWIKI("{status:colour=Yellow\|title=In Progress}")  
END  
AS 'Status'  

What concerns the page refreshing - it's an expected behavior for all the macros. You check checkboxes, refresh the page and the statuses are also updated.


author: Yatiraj Sharma
body: Thank you so much [@Stiltsoft support](/t5/user/viewprofilepage/user-id/5062270) , I am doing like below now

I will have status column only with Status macros in it if I would have not then SQL creates the column but does not add the status macros, (I tried refreshing it as well but it does not.)

Now I have below SQL

SELECT \*,  
CASE WHEN 'Checkbox' = "Completed"  
THEN FORMATWIKI("{status:colour=Green\|title=DONE}")  
WHEN 'Checkbox' != "Completed"  
THEN FORMATWIKI("{status:colour=Grey\|title=TO DO}")  
END  
AS 'Status'  
FROM T1

Which gives me result as below

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

Now if I check one of the box and refresh the page it gives me below

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

But now when I am trying to add the SQL like below (and I tried today as well) it is not taking second WHEN AND condition i.e. checking if the Due date is less than or greater than today or NOW

SELECT \*,  
CASE WHEN 'Checkbox' = "Completed"  
THEN FORMATWIKI("{status:colour=Green\|title=DONE}")  
WHEN 'Checkbox' != "Completed" AND 'Due Date' \> NOW  
THEN FORMATWIKI("{status:colour=Grey\|title=TO DO}")  
WHEN 'Checkbox' != "Completed" AND 'Due Date' \< NOW  
THEN FORMATWIKI("{status:colour=RED\|title=TO DO}")  
END  
AS 'Status'  
FROM T1

It is not showing anything even what I had previously as "TO DO"


author: Stiltsoft support
body: Try the following query:

SELECT \*,  
CASE WHEN 'Checkbox' = "Completed"  
THEN FORMATWIKI("{status:colour=Green\|title=DONE}")  
WHEN 'Checkbox' != "Completed" AND DATEDIFF(day,"today",'Due Date') \< 0  
THEN FORMATWIKI("{status:colour=Grey\|title=TO DO}")  
WHEN 'Checkbox' != "Completed" AND DATEDIFF(day,"today",'Due Date') \>= 0  
THEN FORMATWIKI("{status:colour=Red\|title=TO DO}")  
END  
AS 'Status'  
FROM T1

The "Red" color should be written as "Red" (not "RED") and the Date format inside the settings tab of your Table Transformer macro should correspond to the date format used in your table.

For your example it is dd M yy (07 Apr 2024) or d M yy (7 Apr 2024).


author: Yatiraj Sharma
body: Thanks a lot [@Stiltsoft support](/t5/user/viewprofilepage/user-id/5062270) ,

This is absolutely helpful, I modified the same and now it is acting as one of good checklist that we can use using Table Transformer macro... You are not rising star.. You are actually Rocking Star... Thank you again..

SELECT \*,  
CASE  
WHEN 'Checkbox' = "Completed"  
THEN FORMATWIKI("{status:colour=Blue\|title=DONE}")  
WHEN 'Checkbox' != "Completed" AND 'Comments' IS NOT NULL AND DATEDIFF(day,"today",'Due Date') \>= 10  
THEN FORMATWIKI("{status:colour=Green\|title=IN PROGRESS}")  
WHEN 'Checkbox' != "Completed" AND 'Comments' IS NOT NULL AND DATEDIFF(day,"today",'Due Date') BETWEEN 1 and 9  
THEN FORMATWIKI("{status:colour=Yellow\|title=IN PROGRESS}")  
WHEN 'Checkbox' != "Completed" AND 'Comments' IS NOT NULL AND DATEDIFF(day,"today",'Due Date') \<= 0  
THEN FORMATWIKI("{status:colour=Red\|title=IN PROGRESS}")  
WHEN 'Checkbox' != "Completed" AND 'Comments' IS NULL AND DATEDIFF(day,"today",'Due Date') \>= 10  
THEN FORMATWIKI("{status:colour=Grey\|title=TO DO}")  
WHEN 'Checkbox' != "Completed" AND 'Comments' IS NULL AND DATEDIFF(day,"today",'Due Date') BETWEEN 1 and 9  
THEN FORMATWIKI("{status:colour=Yellow\|title=TO DO}")  
WHEN 'Checkbox' != "Completed" AND 'Comments' IS NULL AND DATEDIFF(day,"today",'Due Date') \<= 0  
THEN FORMATWIKI("{status:colour=Red\|title=TO DO}")  
END  
AS 'Status'  
FROM T1


Tags: checkbox

confluence-server

filter

server

table

table-filter

table-filter-and-charts

table-transformer