- QlikView for Developers Cookbook
- Stephen Redmond
- 380字
- 2021-08-13 17:08:24
Creating a secondary dimension in a bar chart
Within QlikView, there is the possibility of displaying a secondary X-axis in a bar chart. This can be useful for displaying some hierarchical data, for example, year and month. In fact, it only really works where there is a strict hierarchy such as this. Each of the secondary values would exist in each of the primary values (as each month occurs in each year).
Getting ready
Load the following script:
CrossTable(Year, Sales) LOAD * INLINE [ Month, 2011, 2012, 2013 1, 123, 233, 376 2, 423, 355, 333 3, 212, 333, 234 4, 344, 423 5, 333, 407 6, 544, 509 7, 634, 587 8, 322, 225 9, 452, 523 10, 478, 406 11, 679, 765 12, 521, 499 ];
How to do it…
Follow these steps to create a bar chart with a secondary dimension:
- Create a new bar chart with
Year
andMonth
as dimensions and the expression:Sum(Sales)
Note
Note that this chart shows the monthly trend.
- Edit the chart and add a second expression with just a value of 0:
- A new legend will appear.
- Open the properties and go to the Presentation tab. Deselect the Show Legend option:
Note that all subvalues (months) are displayed under all the primary values (years).
- Edit the properties of the chart and go to the Axes tab. Set the Secondary Dimension Labels to the / option as shown in the following screenshot:
Note that the labels for the secondary dimension are now at an angle:
How it works…
QlikView will automatically add the secondary dimension to a bar chart when:
- There are more than two dimensions
- There are two dimensions and there are two or more bar expressions
If there are two expressions, the bars will automatically stack. By setting an expression with a value of 0, the second bars will not appear. However, we do need to remove the legend.
There's more…
This can be useful in a number of situations. However, as previously noted, the two dimensions must be in a strict hierarchy. If there are values that don't exist under all the primary dimensions, they will be represented under all of them anyway and that may not achieve the results that you were hoping for.
- 一本書學內部審計:新手內部審計從入門到精通
- 自愿審計動機與質量研究:基于我國中期財務報告審計的經驗證據
- Pentaho Business Analytics Cookbook
- Citrix XenApp? 7.5 Desktop Virtualization Solutions
- Mastering System Center Configuration Manager
- Metabase Up and Running
- 審計全流程實操從入門到精通
- 新編統(tǒng)計學
- Microsoft Dynamics NAV
- 企業(yè)并購審查中的相關市場界定:理論與案例
- 項目管理實務(第二版)
- 審計定價問題研究
- 圖解經濟博弈論(圖解經濟學叢書)
- 政府采購評審專家工作指南
- 房產稅征收對區(qū)域經濟的影響:以新都區(qū)為例