Skip to main content Skip to complementary content

Bottom - chart function

Bottom() evaluates an expression at the last (bottom) row of a column segment in a table. The row for which it is calculated depends on the value of offset, if present, the default being the bottom row. For charts other than tables, the evaluation is made on the last row of the current column in the chart's straight table equivalent.

Syntax:  

Bottom([TOTAL] expr [ , offset [,count ]])

Return data type: dual

Arguments:  

Argument Description
expr The expression or field containing the data to be measured.
offset

Specifying an offsetn greater than 1 moves the evaluation of the expression up n rows above the bottom row.

Specifying a negative offset number makes the Bottom function work like the Top function with the corresponding positive offset number.

count

By specifying a third parameter count greater than 1, the function will return not one but a range of count values, one for each of the last count rows of the current column segment. In this form, the function can be used as an argument to any of the special range functions. Range functions

TOTAL

If the table is one-dimensional or if the qualifier TOTAL is used as argument, the current column segment is always equal to the entire column.

See: Defining the aggregation scope

Information noteA column segment is defined as a consecutive subset of cells having the same values for the dimensions in the current sort order. Inter-record chart functions are computed in the column segment excluding the right-most dimension in the equivalent straight table chart. If there is only one dimension in the chart, or if the TOTAL qualifier is specified, the expression evaluates across full table.
Information noteIf 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.

Limitations:  

Recursive calls will return NULL.

Examples and results:  

Example: 1

The table visualization for Example 1.

In the screenshot of the table shown in this example, the table visualization is created from the dimension Customer and the measures: Sum(Sales) and Bottom(Sum(Sales)).

The column Bottom(Sum(Sales)) returns 757 for all rows because this is the value of the bottom row: Divadip.

The table also shows more complex measures: one created from Sum(Sales)+Bottom(Sum(Sales)) and one labeled Bottom offset 3, which is created using the expression Sum(Sales)+Bottom(Sum(Sales), 3) and has the argument offset set to 3. It adds the Sum(Sales) value for the current row to the value from the third row from the bottom row, that is, the current row plus the value for Betacab.

Example: 2

In the screenshots of tables shown in this example, more dimensions have been added to the visualizations: Month and Product. For charts with more than one dimension, the results of expressions containing the Above, Below, Top, and Bottom functions depend on the order in which the column dimensions are sorted by Qlik Sense. Qlik Sense evaluates the functions based on the column segments that result from the dimension that is sorted last. The column sort order is controlled in the properties panel under Sorting and is not necessarily the order in which the columns appear in a table.

In the first table, the expression is evaluated based on Month, and in the second table it is evaluated based on Product. The measure End value contains the expression Bottom(Sum(Sales)). The bottom row for Month is Dec, and the value for Dec both the values of Product shown in the screenshot is 22. (Some rows have been edited out of the screenshot to save space.)

First table for Example 2. The value of Bottom for the End value measure based on Month (Dec).

Second table for Example 2. The value of Bottom for the End value measure based on Product (BB for Astrida).

Please refer to Example: 2 in the Above function for further details.

Example: 3

Result

The Bottom function can be used as input to the range functions. For example: RangeAvg (Bottom(Sum(Sales),1,3)).

In the arguments for the Bottom() function, offset is set to 1 and count is set to 3. The function finds the results of the expressionSum(Sales) on the three rows starting with the row above the bottom row in the column segment (because offset=1), and the two rows above that (where there is a row). These three values are used as input to the RangeAvg() function, which finds the average of the values in the supplied range of numbers.

A table with Customer as dimension gives the following results for the RangeAvg() expression.

 

Astrida

Betacab

Canutility

Divadip:

659.67

659.67

659.67

659.67

Monthnames:

LOAD * INLINE [

Month, Monthnumber

Jan, 1

Feb, 2

Mar, 3

Apr, 4

May, 5

Jun, 6

Jul, 7

Aug, 8

Sep, 9

Oct, 10

Nov, 11

Dec, 12

];

Sales2013:

crosstable (Month, Sales) LOAD * inline [

Customer|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec

Astrida|46|60|70|13|78|20|45|65|78|12|78|22

Betacab|65|56|22|79|12|56|45|24|32|78|55|15

Canutility|77|68|34|91|24|68|57|36|44|90|67|27

Divadip|57|36|44|90|67|27|57|68|47|90|80|94

] (delimiter is '|');

To get the months to sort in the correct order, when you create your visualizations, go to the Sorting section of the properties panel, select Month and mark the checkbox Sort by expression. In the expression box write Monthnumber.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!