Use For loop in Lookml

Hi All,

For my use case, I would want to assign a variable whose original value would be 0 but based on a certain dimension's value I can add values to a variable and then call it as a different column.

Something like this:

variable = 0

for i in range(0, length of the column amount):

if code in ['deposit', 'accelerate', ]:
variable += amount

if variable < 0:

variable = 0

and then return the variable as a dimension/measure.

 

Code and amount are two dimensions used in the view.

The reason I'm looking for a loop is that the calculation (add, sub) can only happen in a specific order.

Let me know if any additional info would help.

0 1 333
1 REPLY 1
Top Labels in this Space