x

# Lollipop Chart

Stephen Few is undoubtedly an expert in the field of data visualization.

He has an uncanny ability to articulate his viewpoints on how to use charts to tell a compelling data story.

Obviously, he is not a fan of dessert or candy charts, such as pies or donuts.

In this article, he has eloquently argued against another pretty candy chart — Lollipop chart.

Lollipop chart may not fit the bill for the visualization best practices, but it’s hard to argue against its aesthetic appeal!

### QlikView Lollipop Chart

I thought of creating a Lollipop chart in QlikView not so much to show a pretty graph, but rather to show the power of AGGR function along with an obscure yet useful function: GetObjectField.

### What is the Lollipop Chart?

Lollipop is another form of a bar chart. The only difference is that it has a dot at the end of the line. It is useful when you have bars of similar length, since, visually, these bars clutter space and are hard to read.

A diverging lollipop tells a compelling data story for comparative analysis, as depicted above.

### How-to Guide: Diverging Lollipop Chart

To create maximum and minimum sales vertical lines, I have used AGGR() function with a TOTAL qualifier.

AGGR() is a powerful aggregation function.

Imagine a two-step process when you use AGGR() function.

Step 1: Aggr() creates a virtual cube in the memory. This cube has a list of dimensions and measures akin to a virtual table.

Step 2: The virtual table allows you to perform additional aggregation such a maximum sales value or a minimum sales value.

TOTAL qualifier comes handy when you want to disregard the chart dimensions. Since we need max and min sales values from a list of products or customers, we can use TOTAL qualifier along with the AGGR() expression.

Here’s the kicker.

If you want to use a cyclic group as a dimension, you can use getObjectField function with a dollar-sign expansion.

#### max(total aggr(\$(vSales), \$(=GetObjectField(0,’CH02′))))

Here, vSales is a variable that stroes expression

#### sum({“\$(=max(Year))”}UnitPrice * Quantity)-sum({“\$(=max(Year)-1)”}UnitPrice * Quantity)

I am using this variable to show both the line and the bubble of the Lollipop chart.

The last step is to sort the chart by Y-axis value in the descending order.

That’s, in a nutshell, the high-level process to create a diverging Lollipop chart in QlikView!

-Shilpan