How can I subtract two numbers in the same column?

Holly Perry April 20, 2022

Hi! I would like to know the best way to automatically show the difference between two cells in the same column. It should be a percent change from week to week. I'm using table transformer and SQL, and was wondering if there was code I could write to make this happen. 

I was able to write SQL for the first column because I hardcoded a number into my formula:

SELECT T1.'Overall',
((T1.'Overall'-558785)/558785)*100 AS 'Percentage from Original, %'
FROM T1

but this is not effective for calculating the weekly percentage difference. Any help would be incredibly appreciated! See screen grab. Screen Shot 2022-04-20 at 12.32.09 PM.png

2 answers

1 accepted

3 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.
April 21, 2022

Hi @Holly Perry ,

It may be a little tricky to achieve with the Table Transformer macro, but here is the solution that our developers have come up with:

Thu 7-1.png

SELECT TT1.*,
TT2.'Week' AS 'Previous week',
((TT1.'Overall'-TT2.'Overall')/TT2.'Overall')*100 AS 'Percentage from Original, %'
FROM T1 AS TT1
LEFT JOIN T1 AS TT2 ON TT1.'Week' = (TT2.'Week' + 1)

Thu 7-2.png

We think that it will be easier to use the Table Spreadsheet macro - you'll be able to work with it like in Excel (use cells' formulas, etc.). It will be more user friendly to achieve the case.

Holly Perry April 21, 2022

This is incredible and works perfectly - thank you so so much! :) You are the best!

0 votes
Srinatha T
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 20, 2022

Hi @Holly Perry ,

Welcome to Atlassian community. 

If you are using the table transformer then you should be able to use the formulas as per below doc

I could not try that but should be achievable i belive. 

Have a good day.!

Thanks,

Srinath T

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events