0

I cannot find any documentation to calculate the %of first value in a column. For example, the first value in a column is 13, the next one is 2, then it should calculate 2/13. If the third value is 1, then it should calculate 1/13 etc. So, all column values should be divided by the first one. These are all dynamic values, so I cannot hard code it.

I would like to do this in a calculated Looker field but the closest I can do is to calculate the %of the previous rows value. This is obviously not working for all rows after the second one. For that, it should do 1/13, not 1/2!

Here is the Calculated Field which will calculate %of previous:

${total_users} / offset(${total_users}, -1)

Here is the table:
enter image description here

Please advise!

Eric Keen
  • 403
  • 4
  • 15
LaLaTi
  • 1,455
  • 3
  • 18
  • 31

1 Answers1

2

offset(${total_users}, -1) is going to return the value in the row above the one running the calc, so you're dividing each row by the row above it. To divide each value by the top row, you'll want index(expression, n), so the final calc would look like

${total_users} / index(${total_users}, 1)

index() returns the value expression in the nth row.

Will
  • 4,299
  • 5
  • 32
  • 50