UC6 - Calculate Year Variation

This use case shows how to calculate a year variation, that is the difference between a given year and the preceding year.

See Also
MAP
Defining Data Queries

Context: In this example, you want to have a processing graph with:

  • An ordered data flow.
  • A MAP operator retrieving the results of the previous year and calculating the delta. For example, the revenue delta between year n-1 and year.

To get the delta revenue in percentage, you can configure the MAP operator as follows:

  1. Define 2 variables, previousYear and deltaRevenue, both set to Decimal, with NULL as expression.
  2. Define the corresponding variable updates:

    • deltaRevenue with the expression:
      previousYear IS NULL ?NULL:(input.revenue / previousYear)*100

      Here you want to return NULL for the first year as it has no previous year, and multiply by 100 for the percentage calculation.

    • previousYear with the expression:
      input.revenue

  3. For Output, specify the following expression:

    {deltaRevenue:deltaRevenue,input:input}