Calculating the lowest or highest value in a range
It is quite often useful for us to calculate the lowest or highest value in a range. There are possibilities to do this using AGGR
, but within a chart we can also make use of the Range functions along with some of the chart inter-record functions, such as Above
, Below
, Before
, After
, First
, Last
, and so on.
In this recipe, we are going to calculate the highest and lowest values in a range so that we can assign a relative color to them using the ColorMix1
function.
Getting ready
Load the following script:
LOAD * INLINE [ Country, Sales USA, 1100 Mexico, 650 Canada, 709 UK, 932 Germany, 800 France, 777 Australia, 537 Japan, 898 Russia, 687 ];
How to do it…
Follow these steps to find out how to calculate the lowest or highest value in a range:
Create a Block chart. Add
Country
as the dimension. Add the following expression:Sum(Sales)
Click on the + sign besides the expression and enter the following expression...