Link relative ratio and year-over-year computation

From the text file quartersale.txt, retrieve the quarterly sales data. Compute the growth ratios of sales of each quarter compared with that of its previous quarter and the same quarter in the previous year respectively.

Solution:

A
1
=file@s("quartersale.txt").import@t()
2
=A1.derive('Link-relative','Year-on-year')
3
=A2.sort(Year,Quarter)
4
>A3.run('Link-relative'=if(#==1,0,round((Amount-Amount[-1])/Amount[-1],4)))
5
=A3.group(Year)
6
>A5.(~.run('Year-on-year'=if(A5.#==1,0,round((Amount-A5[-1](#).Amount)/A5[-1](#).Amount,4))))

The computing result in A3 is shown below:

Note: The field name with dash is used in the computation, for example, the Link-relative must be quoted with single quotes when being referenced.