Book Image

QlikView for Developers Cookbook

By : Stephen Redmond
Book Image

QlikView for Developers Cookbook

By: Stephen Redmond

Overview of this book

QlikView has been around since 1993, but has only really taken off in recent years as a leader in the in-memory BI space and, more recently, in the data discovery area. QlikView features the ability to consolidate relevant data from multiple sources into a single application, as well as an associative data model to allow you to explore the data to a way your brain works, state-of-the-art visualizations, dashboard, analysis and reports, and mobile data access. QlikView for Developers Cookbook builds on your initial training and experiences with QlikView to help you become a better developer. This book features plenty of hands-on examples of many challenging functions. Assuming a basic understanding of QlikView development, this book provides a range of step-by-step exercises to teach you different subjects to help build your QlikView developer expertise. From advanced charting and layout to set analysis; from advanced aggregations through to scripting, performance, and security, this book will cover all the areas that you need to know about. The recipes in this book will give you a lot of the information that you need to become an excellent QlikView developer.
Table of Contents (19 chapters)
QlikView for Developers Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Brushing parallel coordinates


Parallel coordinates is a long established method of visualizing multivariate data. QlikView will display a parallel coordinate chart and a user can interact with the data, but sometimes it is useful to allow the user to "brush" the data, selecting different values and seeing those values versus the whole of the data.

We can do this by using two almost identical charts with one being transparent and sitting over the other.

Getting ready

We need to download some data for this from the United States Census QuickFacts website. Go to http://quickfacts.census.gov/qfd/download_data.html and download the first three files on offer:

Files

Description

DataSet.txt

Raw data

DataDict.txt

Information on the different metrics in the raw data

FIPS_CountyName.txt

List of the U.S. counties

Load the following script:

// Cross table the raw data into a temp table
Temp_Data:
CrossTable(MetricCode, Value)
LOAD *
FROM
DataSet.txt
(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

// Load the temp table into our data table.
// Only load county information.
// Only load RHI data (Resident Population).
Data:
NoConcatenate
Load
  fips,
  MetricCode,
  Value
Resident Temp_Data
Where Mod(fips, 1000) <> 0  // Only County
And MetricCode Like 'RHI*'; // Only RHI

// Drop the temporary table
Drop Table Temp_Data;

// Load the location information.
// Use LEFT to only load locations that match Data.
Location:
Left Keep (Data)
LOAD @1:5 as fips, 
     @6:n as Location
FROM
FIPS_CountyName.txt
(fix, codepage is 1252);

// Load the Metric information
// Use LEFT to only load metrics that match Data.
Metrics:
Left Keep (Data)
LOAD @1:10 As MetricCode, 
     Trim(SubField(SubField(@11:115, ':', 2), ',', 1)) as Metric, 
     @116:119 as Unit, 
     @120:128 as Decimal, 
     @129:140 as US_Total, 
     @141:152 as Minimum, 
     @153:164 as Maximum, 
     @165:n as Source
FROM
DataDict.txt
(fix, codepage is 1252, embedded labels);

How to do it…

To create a parallel coordinates chart with brushing, perform the following steps:

  1. Add a list box for Location onto the layout.

  2. Create a new line chart. Add Metric and Location as dimensions.

  3. Add the following expression:

    Avg({<Location={*}>} Value)
  4. Label the expression as %.

  5. Click on the + sign beside the expression and enter the following expression for Background Color:

    LightGray()
  6. On the Sort tab, set the sort for the Metric dimension to Load Order and Original as shown in the following screenshot:

  7. On the Presentation tab, turn off the Suppress Zero-Values and Suppress Missing options. Also, turn off the Show Legend option:

  8. On the Axes tab, turn on the Static Max option and set it to 101. Set the Primary Dimension Labels option to /. Turn on the Show Grid option under Dimension Axis:

  9. Click on Finish.

  10. Right-click on the chart and select Clone from the menu. Position the new chart so it exactly overlaps the first. Edit the properties.

  11. On the Expressions tab, modify the expression:

    Avg(Value)
  12. Click on the + sign beside the expression and change the Background Color property to:

    Blue()
  13. On the Colors tab, set the Transparency option to 100%.

  14. On the Layout tab, set the Layer option to Top. Set the Show option to Conditional and enter the following expression:

    GetSelectedCount(Location)>0
  15. Click on OK.

    Note

    Note that when you make a selection on the chart or in the list box, the selection is highlighted or "brushed".

How it works…

The transparent chart with the slightly different color and expression is the trick here. When a selection is made, our chart overlays the first chart and displays the "brush". The underlying chart will remain the same as we have a set that excludes selections in the Location field.

As far as the user is concerned, there is only one chart being displayed.

There's more…

Using transparent charts to overlay another chart is a great technique to use when the particular visualization is just not available in QlikView.

See also

  • The Creating a "Stephen Few" bullet chart recipe