Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Table Transformer Macro - custom SQL

Megan February 28, 2023

I am trying to calculate two values using the Table Transformer Macro and custom SQL.

The values are Cost of Delay and WSJF. The calculated sum of Cost of Delay is used to calculate WSJF.

Here is a sample table I am utilizing:

VariableScore Value
Revenue8
Cost Savings1
Development Effort13
Strategic Value20
Legal Risk5
Time Criticality5

I was able to get the two values calculated and displayed separately, and displayed next to one another, but ideally I'd like them to be part of the same table.

To calculate Cost of Delay I used the following function

SELECT SUM ('Score Value') As 'Cost of Delay'
FROM T1
WHERE Variable IN ("Revenue", "Cost Savings", "Strategic Value", "Time Criticality");

On it's own it prints out as expected

Cost of Delay34

To calculate the other value I need, WSJF, I used the following

`SELECT 100* 
(
    (
SELECT SUM ('Score Value') As 'Cost of Delay'
FROM T*
WHERE Variable IN ("Revenue", "Cost Savings", "Strategic Value", "Time Criticality")
) / (
SELECT SUM ('Score Value') As 'Other'
FROM T1
WHERE Variable IN ("Legal Risk", "Development Effort")
  ) 
 )
 AS WSJF;`

Which correctly gives me

WSJF189

Ideally I'd like a table be displayed with the combination of these two

VALUESCORE
Cost of Delay34
WSJF189

I am at a loss for how to connect these two functions into one. I have tried asking stack overflow but every suggestion leads to errors, I'm guessing due to nuances with the macro and confluence.

2 answers

2 votes
Katerina Rudkovskaya _Stiltsoft_
Atlassian Partner
March 1, 2023

Hi @Megan,

I can suggest the following workaround for the case:


Wed 15-1.png

The internal Table Transformer macros are used for your original queries and ad additional line with future headers:

SELECT
"Score" AS 'Value',
SUM ('Score Value') AS 'Cost of Delay'
FROM T1
WHERE Variable IN ("Revenue", "Cost Savings", "Strategic Value", "Time Criticality")

Wed 15-2.png

SELECT
"Score" AS 'Value',
100*
(
(
SELECT SUM ('Score Value') As 'Cost of Delay'
FROM T*
WHERE Variable IN ("Revenue", "Cost Savings", "Strategic Value", "Time Criticality")
) / (
SELECT SUM ('Score Value') As 'Other'
FROM T1
WHERE Variable IN ("Legal Risk", "Development Effort")
)
)
AS WSJF

Wed 15-3.png

And we also use the Settings -> Transpose result table option to transpose tables for both Transformers.


The external Table Transformer macro is used simply to merge your result tables:

SELECT * FROM T*

Wed 15-4.png

Hope it helps.

Megan February 1, 2024

Hello - do you know how it is possible to do this calculation if I need to add weights to each of these values? So calculated the weighted sum 

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.
February 1, 2024

You may switch to the Table Spreadsheet macro and perform your calculations in a more user-friendly Excel-like style.

Megan February 1, 2024

Do you have a calculation if I don't have that macro available to me?

0 votes
Dominic Lagger
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.
February 28, 2023

Hi @Megan 

My first thought was to use the union statement like in this example

Here is the UNION documented. 

Hope this helps.

Regards, Dominic

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events