Lollipop Chart

Intermediate4 min readUpdated November 2026

This example recreates a yearly sales comparison with an SVG lollipop chart in Qlik: a current-year sales KPI, comparisons to a selectable baseline year and the previous year, a moving baseline line, and one lollipop per year.

Video

See the chart in Qlik

A short screen recording of the Lollipop Chart working in a Qlik Sense app: selections change the sales values and the baseline moves when a different baseline year is picked.

This is a recording, not a live Qlik connection — the sales figures shown in it are synthetic demo data.

Design inspiration: ‘16 Different Ideas to Visualize your KPIs (opens in a new tab)’ by Kajal Kadam on Tableau Public.

This is my own SVG and Qlik adaptation of the visual idea.

What the chart shows

  • Current year sales, based on the latest year in the dataset.
  • Percentage comparison to a selectable baseline year.
  • Percentage comparison to the previous year.
  • A horizontal baseline that moves when you pick a different baseline year.
  • One lollipop for every year in the Year dimension.
  • Country selections filter the sales values; Year selections do not remove years from the chart.

The sales figures are synthetic demo data, not real country sales. The Qlik script and expression below are for you to use and test in Qlik Sense. This page is not connected to a Qlik app.

Download qvf

Download the supplied Lollipop Chart Qlik app. Requires Qlik Sense to open .qvf files.

Tested with: Qlik Sense edition and version not yet confirmed.

Download sample data

Download the sales demo CSV with Country, Year, Sales and Unit fields to load into the SalesTrend table.

Set it up in Qlik

  1. 1Load the Country, Year, Sales and Unit fields into a table called SalesTrend.
  2. 2After loading SalesTrend, add the disconnected BaselineYearPicker table and the variables from the load script shown under this step.
    Lollipop Chart — Qlik load script

    Paste into the Qlik data load editor — see step 2 above.

  3. 3Add a Qlik filter pane using the BaselineYear field.
  4. 4Paste the SVG expression below into Qlik using either method from the SVG Basics lesson: Method 1, a Button object, or Method 2, an Image object.
  5. 5The baseline defaults to 2021 until exactly one baseline year is selected in the filter pane.
  6. 6Country selections change the sales values. Year filter selections do not remove years from the lollipop chart, because the marks ignore Year selections with {<Year=>}.

Qlik SVG expression

Multiline, joined with &, with percent-encoded colours.

Lollipop Chart — Qlik expression

Paste into the Qlik image expression editor — see step 4 above.

The same expression with a comment above each part, explaining what it does. For reading only — Qlik chart expressions do not accept comments, so paste the uncommented version above into Qlik.

Lollipop Chart — Qlik expression (commented walkthrough)

Reading only — paste the uncommented expression into Qlik (step 4 above).

Explain this code

Loading the disconnected baseline-year picker

BaselineYearPicker copies every Year into a new field, BaselineYear. It shares no field name with SalesTrend, so selecting a baseline year does not filter the sales data — it only tells the variables which year to compare against.

Finding the latest year and previous year

YearMax holds the highest Year in the data. Peek reads it into vCurrentYear, vPreviousYear is one less, and the helper table is dropped. These are fixed when the script reloads.

The baseline and KPI variables

vCurrentSales and vPreviousSales sum Sales for those two years. vBaselineYear and vBaselineSales use the selected BaselineYear when exactly one is selected, otherwise 2021. Because they are SET, Qlik evaluates them inside the chart, so country selections still apply.

Scaling and positioning the chart

vAnnualMax finds the largest yearly total, ignoring Year selections. vYearX spreads years evenly from x=18 to x=362. vYearY and vBaselineY map sales onto a 145-pixel tall area whose floor sits at y=280.

Drawing the baseline and lollipop marks

A 3-pixel blue line is drawn at vBaselineY with its label just above it. Concat(Aggr(…, Year)) then builds one stem line, one dot and one year label per Year, sorted ascending, and joins them into the SVG.

About Robert Mika

Qlik developer sharing practical SVG techniques

Follow on LinkedIn