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

Divide by zero on Table transformer

emagnun May 24, 2021

Hi I'm trying to calculate growth over year. As you can see below yellow highlighted, product B has "zero divide by number" case and growth is shown as "infinity". How to get this shown as 100%. ?? 

My Table transformer Query is as below.

============================
SELECT *,
ROUND(((T1.'Count FY2020' - T1.'Count FY2019')/T1.'Count FY2019')*100, 2) AS 'Growth, %'
FROM T1

============================

Capture.JPG

1 answer

1 accepted

1 vote
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.
May 25, 2021

Hi @emagnun ,

Please try the following:

Tue 1-1.png

Tue 1-2.png

SELECT T1.'Product Type', T1.'Count FY2019', T1.'Count FY2020',
CASE
WHEN ROUND((T1.'Count FY2020'*100/T1.'Count FY2019' - 100), 2) LIKE "Infinity"
THEN "100"
ELSE ROUND((T1.'Count FY2020'*100/T1.'Count FY2019' - 100), 2)
END
AS 'Growth, %'
FROM T*

Tue 1-3.png

emagnun May 25, 2021

It worked, thanks.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events