Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi experts,
I have a table as below.
| column1 | value | result |
| a | 12 | 1 |
| b1 | 1 | 1/12 |
| b2 | 2 | 2/12 |
| b3 | 3 | 3/12 |
I want to calculate the value in column1 and display the results in "result" column, which is each value in column1 divided 'a' - the first value in column1.
How can I get the right column "result" through scripting?
Thanks!!
Hi,
To get the first row, you can use peek(column1,0), so in your load statement you would have something like:
LOAD
column1,
value,
value/peek(column1,0) as result
...
the first line is FIX? or if u change the table sorting it should change?
Besides, how do you DEFINE the first value?
All the answers /solutions will depend on your answers
Yes, it depends on the sorting you apply on the table in the load script in the ORDER by clause. Your question said:
"I want to calculate the value in column1 and display the results in "result" column, which is each value in column1 divided 'a' - the first value in column1."
So,
LOAD
column1,
value,
value/peek(column1,0) as result
....
ORDER by column1.
The ordering of the values in your table will depend on the datatype of column1.
If this isn't what you meant, please attach the equivalent in Excel or your Qlik Sense app.