Creating dimensionless bar charts in Qlik Sense®

A bar chart is usually defined with one or two dimensions and a measure. However, we need to have dimensionless bar charts while designing KPIs on the dashboards and also in certain other scenarios. By default, Qlik Sense will not allow this. However, there is a workaround that is discussed in the following sections.

Getting ready

We will make use of the same application that we developed for the KPI recipe. The application has got the following script loaded, which gives information on the Sales and Target values for four countries. In addition, we will add a new column called as Dummy.

Make sure to save and load the script once the Dummy field is added:

LOAD * , 1 as Dummy INLINE [
Country, Sales, Target
USA, 10000, 8500
UK, 7000, 9500
Germany, 5000, 4500
Japan, 6000, 6000
];

We want to display the overall sales for the company and change the color of the bar based on the threshold value.

How to do it…

  1. Go to the App overview and create a new sheet.
  2. Name the sheet as Dimensionless Bar Chart and open it.
  3. Go to the Edit mode by clicking on How to do it….
  4. From the Assets panel, drag across the How to do it… object on the sheet.
  5. Go to the Master ItemsHow to do it… in the Assets panel and create a dimension with the name Dummy as shown:
    =Valuelist('Dummy')
  6. In the chart under Dimensions, use the just created master dimension Dummy as the dimension.
  7. Add the measure as Sum(Sales) and label it as Sales.
  8. Under Appearance, click on Presentation and make the chart as Horizontal and switch on the Value Labels.
  9. Under Appearance, click on General and add Company Sales as the chart Title under the General properties.
  10. Under Appearance, click on Colors and legend. Switch off auto colors and select By expression under the drop-down menu.
  11. Add the following color code expression:
    If(Sum(Sales)>Sum(Target),RGB(0,255,0),RGB(255,0,0))
  12. Make sure that The expression is a color code is checked.
  13. Go to the labels and click on the Title option under How to do it… and select None.
  14. Under How to do it…, switch off the Auto range and select Min/max under custom. Set the min value to 0 and the max value to 30000.
  15. The final chart looks like the following:
    How to do it…
  16. Create a Filter pane object with Country as the dimension. Now select different countries and view the results.

How it works…

Qlik Sense doesn't allow dimensionless bar charts. So, we need to create a Dummy dimension that has only one single field value. Further when we select none under the How it works… labels and title option, it hides this field value from the axis, thus serving the purpose. The color code used for the bars will turn the bar red if the sales for a country are less than or equal to the target values:

How it works…

There's more…

We can use the Dummy dimension directly from our source data instead of creating a master dimension in the frontend. Another approach is to use a calculated dimension =1 and name it Dummy. All the approaches will yield the same result. To make the chart more informative one can add reference lines for the target.

See also

  • Adding Reference Lines to trendline charts
..................Content has been hidden....................

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