Wednesday, November 7, 2012

Highlight the Trend

Because I went to the Derek Zoolander Center For Kids Who Can't Read Good And Wanna Learn To Do Other Stuff Good Too, I can now teach you really, really, ridiculously good Qlikview tricks.


This one's no different. It's a good way to cut through the clutter of a chart that displays a large number of lines.

Line charts are great tools for showing trends over time. Your user can easily visualize whether the data is getting better or worse by the shape of the chart. They are not good for charting distinct categories. A good example of a bad idea is to use a line chart to show sales by territory. A proper example is to chart sales over time, split up by city.

Unfortunately, it's easy for line charts to become useless if there are too many categories. It's impossible to have that 'ah ha' moment if you can't easily spot the relevant data. Don't chart a bunch of territories and give them all random colors!



A much better way is to take advantage of Qlikview's associative logic to highlight a single line to compare it against the shape of the other items in the category. This example uses the Adventureworks database and charts sales by city over time.


Selecting a single city makes it stand out and gives the user something to see. 'Paris has similar spikes to other cities in France, but they are much more pronounced.'

Step One

Create your chart, limit your data to something relevant to the user, and then use an intersection in your set analysis. The intersection will let you click on a city to 'activate' it, but not have the others go away like they normally would with a list box selection.



Step 2

Add an expression attribute to let the user control the color of the line.



In the Background Color, use an If statement.



Step 3

On the Presentation tab, add a 'Text in Chart' to use as a subheading.



Make sure to properly locate it in your chart by using Ctrl-Shift.

That's it. Now, when you select a city, its line will be green and every other line will be grey.

Limitations
  • Only one City can be highlighted at a time
  • If multiple Cities are selected, all lines will be grey
  • If no City is selected, all lines will be grey
  • The highlighted City may be hidden behind other lines


With a little imagination, you can adapt this technique to other Qlikview objects. And don't forget when you judge me, I'm a coal miner, not a professional film or television actor. And don't you judge me.

3 comments:

  1. Very nice job ! You can highlight multiple cities at a time using the following expression for background color :

    If(SubStringCount('$(=GetFieldSelections([City]))',[City]) > 0,
    Green(),
    ARGB(150, 225, 225, 225))

    ReplyDelete