Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Aria
Contributor III
Contributor III

how to calculate values within one column

Hi experts,

I have a table as below.

column1valueresult
a121
b111/12
b222/12
b333/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!!

3 Replies
rbartley
Specialist II
Specialist II

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

...

OmarBenSalem

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

rbartley
Specialist II
Specialist II

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.