Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Table Transformer Macro - If else condition

I am using confluence to track the risks and the table has these columns:

  1. Risk Detail
  2. Open Date
  3. Status - (Open/Closed)
  4. Closed Date
  5. Aging (in days)
  6. Remarks

I am calculating the aging by using the below query for the open issues. 

SELECT *, ROUND(DATEDIFF(day,'Open Date',CURRENT_TIMESTAMP))+ " day(s)" as 'Aging' from T1

For the closed issues, I need to find the elapsed time between Open and Closed dates. 

So can someone help me to construct the query to check if the status is closed then use this query

SELECT *, ROUND(DATEDIFF(day,'Open Date',CURRENT_TIMESTAMP))+ " day(s)" as 'Aging' from T1

Else

SELECT *, ROUND(DATEDIFF(day,'Open Date','Closed Date'))+ " day(s)" as 'Aging' from T1

1 answer

Hi @Shathya Bhama V R ,

You may try the following SQL queries:

Option 1

SELECT *,

CASE WHEN T1.'Status' LIKE "Closed"

THEN ROUND(DATEDIFF(day,'Open Date','Closed Date'))+ " day(s)"

ELSE

ROUND(DATEDIFF(day,'Open Date',CURRENT_TIMESTAMP))+ " day(s)"

END

as 'Aging' from T1

Option 2

SELECT *,

CASE WHEN T1.'Status' LIKE "Open"

THEN ROUND(DATEDIFF(day,'Open Date',CURRENT_TIMESTAMP))+ " day(s)"

WHEN T1.'Status' LIKE "Closed"

THEN ROUND(DATEDIFF(day,'Open Date','Closed Date'))+ " day(s)"

END

as 'Aging' from T1

TT 3.png

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

146 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you