Question

Percent change and difference

  • 26 August 2020
  • 3 replies
  • 2424 views

Hello!

I created a custom filter to calculate transactions in last month and same month last year (year over year analysis).

I would like to calculate difference between those two values and percent change. Is there any way I can add a new table calculation or measure to calculate these values?

I can calculate sum using sum function in table calculation. Want to calculate difference in similar manner.


3 replies

i am new to looker. used the below to get the percent of previous. 

measure: sale_qty_change {
    type: number
    sql:  ${sale_qty} / offset(${sale_qty}, -1);;
  }

 

giving me an error in the explore:

The Google BigQuery Standard SQL database encountered an error while running this query.

Query execution failed: - OFFSET is not a function. It can only be used for array element access using array[OFFSET(position)] at [7:64]

 


Hi @mprogano!

Thank you for your quick response 🙂 This works perfectly fine!

Userlevel 3

You can! Using table calculations 🙂


Reply