Using TOTAL to calculate the percentage of total and subtotal
TOTAL
is a useful qualifier that can be added to an aggregation function (such as Sum
, Count
, and Avg
) to tell QlikView to ignore the dimensions of a chart in the calculation. By default, it ignores all the dimensions, but we can be more specific and tell it to ignore some while respecting others.
In this recipe, we will calculate the percentage of total sales for each city, as well as the percentage of sales for each city within its own country.
Getting ready
Load the following script:
LOAD * INLINE [ Country, City, Sales USA, San Diego, 24567 USA, Dallas, 54962 USA, New York, 67013 USA, Boston, 45824 UK, London, 64002 UK, Birmingham, 44291 UK, Manchester, 40320 Germany, Berlin, 52912 Germany, Frankfurt, 61832 Germany, Munich, 35812 Japan, Tokyo, 42137 Japan, Yokohama, 55832 Japan, Osaka, 37643 ];
How to do it...
The following steps show how to use TOTAL
to calculate the percentage of total and the percentage...