Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

Above Function

Hi Friends

Can some one explain me with examples how to use above function

1 Solution

Accepted Solutions
Gysbert_Wassenaar

From the help file:

above([ total ] expression [ , offset [,n ]])

Returns the value of expression evaluated with the chart's dimension values as they appear on the row above the current row within a column segment in a table or, in the case of bitmap charts, in the chart's straight table equivalent (Actually all QlikView charts have a straight table equivalent with the exception of the pivot table which has a more complex structure.).

On the first row of a column segment a NULL value will be returned, as there is no row above this one.

If the chart is one-dimensional or if the expression is preceded by the total qualifier, the current column segment is always equal to the entire column.

If the table or table equivalent has multiple vertical dimensions, the current column segment will include only rows with the same values as the current row in all dimension columns except for the column showing the last dimension in the inter field sort order. The inter field sort order for pivot tables is defined simply by the order of the dimensions from left to right. For other chart types this can be manipulated in the Chart Properties: Sort dialog.

Specifying an offset greater than 1 lets you move the evaluation of expression to rows further up the current row. A negative offset number will actually make the above function equivalent to a below function with the corresponding positive offset number. Specifying an offset of 0 will evaluate the expression on the current row. Recursive calls will return NULL.

By specifying a third parameter n greater than 1, the function will return not one but a range of n values, one for each of n table rows counting upwards from the original cell. In this form, the function can be used as an argument to any of the special Chart Range Functions.

Examples:

sum( Sales ) / above( sum( Sales ))

above( sum( Sales ), 2 )

above( total sum( Sales ))

  

rangeavg (above(sum(x),1,3))returns an average of the three results of the sum(x) function evaluated on the three rows immediately above the current row.

talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

From the help file:

above([ total ] expression [ , offset [,n ]])

Returns the value of expression evaluated with the chart's dimension values as they appear on the row above the current row within a column segment in a table or, in the case of bitmap charts, in the chart's straight table equivalent (Actually all QlikView charts have a straight table equivalent with the exception of the pivot table which has a more complex structure.).

On the first row of a column segment a NULL value will be returned, as there is no row above this one.

If the chart is one-dimensional or if the expression is preceded by the total qualifier, the current column segment is always equal to the entire column.

If the table or table equivalent has multiple vertical dimensions, the current column segment will include only rows with the same values as the current row in all dimension columns except for the column showing the last dimension in the inter field sort order. The inter field sort order for pivot tables is defined simply by the order of the dimensions from left to right. For other chart types this can be manipulated in the Chart Properties: Sort dialog.

Specifying an offset greater than 1 lets you move the evaluation of expression to rows further up the current row. A negative offset number will actually make the above function equivalent to a below function with the corresponding positive offset number. Specifying an offset of 0 will evaluate the expression on the current row. Recursive calls will return NULL.

By specifying a third parameter n greater than 1, the function will return not one but a range of n values, one for each of n table rows counting upwards from the original cell. In this form, the function can be used as an argument to any of the special Chart Range Functions.

Examples:

sum( Sales ) / above( sum( Sales ))

above( sum( Sales ), 2 )

above( total sum( Sales ))

  

rangeavg (above(sum(x),1,3))returns an average of the three results of the sum(x) function evaluated on the three rows immediately above the current row.

talk is cheap, supply exceeds demand
Koniki
Contributor II
Contributor II

Above simply takes a value from the row Above the current row. It can be used to calculate an accumulating total.

suppose i have 

name:      sum( salary)    above(sum(salary))  

venkat     1000                    -

ramu        3000                 1000

rabga        2000                 2000

now we are using  with offset value

i want  above(sum(salary))-sum(salary) for 3 record then it gives 1000 as the value

so as per the requirment  we can do different ways

 

 

Iras
Contributor III
Contributor III

As per the explaination its sound good. But what If i want to have a subraction of average of first two rows - third row value i.e. based on your example I would like to do like this ((100+3000)/2) - 2000 in Qlik sense. 

Does below logic is correct ? 

((above(column(1),0)+ above(column(1),1))/2)-above(column(1),3)

If the below logic is not correct could you let me know. How I can do it ?