Awesome QlikView functions – Dual

  • Ctrl + Q + Q to create dummy Data model that comprises of three tables
  • If I put together three tables resultant table would be as below

1

  • For explanation sake I’m creating a stacked bar chart with one dimension (Dim1) and three expressions (Sum(Expression1) in similar way others).

2

  • Created above chart in straight forward way but a special requirement came on top of this. In place of summed up values in blocks, percentage (each block in a bar) needs to be displayed.

3

  • To implement this I used Dual function which has unique feature of showing up as both String and Number
  • String part I used for percentage calculation and Number part I used for actual aggregation

=Dual(Num((Sum(Expression1)/(Sum(Expression1)+Sum(Expression2)+Sum(Expression3)))*100,’#0.0#’)&’%’,Sum(Expression1))

  • One other setting you have to remember for making this work is Number format, it should be expression default.

4