Using comparison sets in Set Analysis

The following figure is of a stacked bar chart, a standard way of comparing separate entities. Each value that you select is displayed as a segment in each bar by year:

Using comparison sets in Set Analysis

Using a comparative analysis lets you group the separate selections dynamically, so that you can compare them against each other. In the preceding example we can group together Plum and Apple versus Fig and Orange.

Getting ready

For the purpose of this recipe,we will make use of an inline data load which gives yearly sales information for different fruits. Load the following script in the Qlik Sense data load editor:

Data: 
LOAD * INLINE [
    Fruit, Year, Sales
    Apple, 2013, 63
    Apple, 2014, 4
    Cherry, 2014, 1150
    Cherry, 2013, 1180
    Fig, 2013, 467
    Fig, 2013, 374
    Fig, 2014, 162
    Orange, 2013, 131
    Orange, 2013, 145
    Orange, 2014, 102
    Pear, 2014, 489
    Pear, 2014, 782
    Plum, 2013, 148
    Plum, 2014, 412
]; 

DataIslandFruit: 
LOAD * INLINE [
FruitAlt
Apple
Cherry
Fig
Orange
Pear
Plum
];

How to do it…

  1. Drag a bar chart onto the content area and title it Comparison Analysis.
  2. Add Year as a dimension.
  3. Add the following expression and label it as Group 1 Sales:
    Sum(Sales)
  4. Add the following expression and label it as Group 2 Sales:
    Sum({<Fruit={$(=GetFieldSelections(FruitAlt))}>}Sales)
  5. Under Appearance | Colors and legend switch on the Show legend option.
  6. Create a Filter pane object and add the first dimension as Fruit. Label the dimension as Group 1.
  7. Add FruitAlt as the second dimension to the Filter pane and label the dimension as Group 2.
  8. The final chart should resemble one of the following images if you have already made the selections to test the comparative analysis.

The following is an example where no selections are made:

How to do it…

The following is an example where selections are made:

How to do it…

How it works…

The second table we loaded is what's known as a data island, this table is not connected to the rest of the data model in any way. However, we can use its contents in our Set Analysis expression to compare different groups of the same field.

The first expression is completely standard. The second expression gives the total sales where the Fruit field (part of the complete dataset) matches the values selected in the FruitAlt field (part of the disconnected data island). This method allows us to select groups of data for aggregation in our graph that we can not do normally by effectively breaking the association (green, white, and grey) using Set Analysis.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset