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 ...

Get QlikView for Developers Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.