Window versus running functions

We have briefly discussed the WINDOW functions already. There's also another type of function, called the RUNNING function. The WINDOW functions have specific partitions, that is, they measure either the whole table, pane, or cell, or from a specific number of previous or future values. Alternatively, the RUNNING function compares all the values before the current value in the partition.

In the following example, we graphed the average percentage of the GDP that was from high-tech exports by region and by year in the World Development Indicators data source. This is a simple spark bar graph. We have hidden the header for the y axis in this graph.

We created a calculated field that, for each year, tests whether the average High Tech Exports as a percentage of the GDP is equal to the running maximum, that is, is the value for any year higher than all the years before it. The results are true and false, as shown in the following screenshot:

Window versus running functions

The RUNNING_MAX function, which is one of several RUNNING functions, does not have the start and end offsets like the WINDOW functions. However, you still need to address it.

A note on addressing

The following table calculation computes across the pane. You can also set it to Compute using Year. Year is the field along the x axis. Addressing the table calculation across the pane tells it to compute across the x axis and then to use other fields on the visualization, such as Region, as the partition or group. So, this field is addressed across year, and the calculation is performed for each Region.

Add the Region field to the Color shelf in the visualization and then format the true values so that they are blue, and format the false values so that they are orange, as shown in the following screenshot:

A note on addressing
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset