Forums

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

Table Transformer - Calculation NPS out of Pivot data

Escmarc
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!
May 22, 2024

Hi community

I have a table and would like to calculate the NPS (Net Promoter Score) per quarter with the "table transformer" plugin. Data input is dynamic and data are grouped automatically from a CSV. Can someone help me to create a working sql statement? 

Input: Table transformer table2024-05-22 10_11_21-Kopie von Migration Feedback results - Technology Domain Engineering - SwisscomP.png

 

Table transformer Formula from a working example

SELECT
/*Calc NPS
https://omf.ai/lexikon/nps/
*/
ROUND(
((COUNT(CASE WHEN 'Literal of How likely are you to recommend the TDE App Party to a colleague?' >= 9 THEN 1 END)
/COUNT(*))*100)-

((COUNT(CASE WHEN 'Literal of How likely are you to recommend the TDE App Party to a colleague?' <= 6 THEN 1 END)
/COUNT(*))*100),2)

AS NPS
FROM T1

 

Expected Output

Fertigstellungszeit : NPS

2023 Q1 : 0

2023 Q3 : -25 

 

Data input from CSV

2024-05-22 10_28_31-Kopie von Migration Feedback results - Technology Domain Engineering - SwisscomP.png

1 answer

1 accepted

3 votes
Answer accepted
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.
May 22, 2024

Hi @Escmarc ,

We can suggest trying the following workaround:

Wed 17-1.png

Here my manually created table is a replication of your pivot table.

Then in the internal Table Transformer macro we flatten the array:

SEARCH / AS @a EX(TEXT('Col 2')->split(";")) /
RETURN(@a->'Col 1' AS 'Col 1', _ AS 'Col 2') FROM T1

Wed 17-2.png

In the second Table Transformer macro we calculate the types of the answers:

SELECT
'Col 1',
SUM(IF('Type' = "Promoter", 1, 0)) AS 'Promoter',
SUM(IF('Type' = "Detractor", 1, 0)) AS 'Detractor',
SUM(IF('Type' = "Medium number", 1, 0)) AS 'Medium number'
FROM
(SELECT *,
CASE
WHEN 'Col 2' >= 9 THEN "Promoter"
WHEN 'Col 2' <= 6 THEN "Detractor"
ELSE "Medium number"
END
AS 'Type'
FROM T*)
GROUP BY 'Col 1'

Wed 17-3.png

And in the external Table Transformer macro we calculate the NPS:

SELECT 'Col 1',
'Promoter'/('Promoter'+'Detractor'+'Medium number')*100 -
'Detractor'/('Promoter'+'Detractor'+'Medium number')*100 AS 'NPS'
FROM T*

Wed 17-4.png

Hope it helps your case.

Escmarc
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!
May 22, 2024

@Stiltsoft support ,

Ingenious approach. I didn't realise that this kind of nesting worked. I tested and it worked. Thank you very much!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events