Labeling a pie chart to replace the legend

Standard pie charts in QlikView suffer from a legendary problem – the legend. The problem is that the eye needs to move back and forth between the chart and the legend to help make sense of the data.

In this recipe, we are going to remove the legend and use the Dual function to replace it with text besides each segment that identifies the information.

Getting ready

Load the following script:

LOAD * INLINE [
    Country, Sales
    USA, 1000
    Mexico, 600
    Canada, 700
    UK, 900
    Germany, 800
];

How to do it…

These steps show you how to label a pie chart to replace the legend:

  1. Create a pie chart with Country as the dimension. Add the following expression:
    =Dual( if(Len(Only(Country))>0, Country, 'Others') & chr(10) & Num(Sum(Sales), ...

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.