These two little tips are not going to help you solve any major issues in your applications, or even directly improve the end application. They will however save you a chunk of time each time you use them. In fact, if you were not previously aware of them, your Qlik Life is about to change for the better.
Don’t Remove Dimensions, Over Type
I’m sure you’ve been in the situation where you have set your Pivot Chart up beautifully. The alignment is right, pivot dimensions are correct, format expressions on the text – all perfect. You then realise that you made one slight slip when first setting up the chart, and you picked the wrong one of two similar dimensions. No problems, you think, just remove the incorrect dimension and then add in the right one. A couple of double clicks later and all is fixed. Except…
What you will find is that all the effort that has gone in to alignment and setting of other properties has gone. Worst case scenario the dimensions are now in a different order and all your pivoting needs to be re-done. Five minutes later you are back where you were before needing to make the switch.
There is however a better way.
If you click the Edit button that sits beneath the list of Dimensions you can simply type in the new dimension.
This button is generally used for editing Calculated Dimensions, but simply typing a dimension name is also allowed. You do need to be careful not to turn this into a calculated dimension with a single field (although it will work, my assumption would be performance could be hit a bit). Type in the field name, resisting the temptation to start with an equals sign or to add square brackets on fields with spaces. The latter feels a bit alien – and breaks both auto-complete and syntax completion – but it is the best way.
When the dimension is changed like this all settings relating to that dimension, such as layout properties, are maintained. This technique works the same for any chart type. Unfortunately it will not help you with Table Boxes. I will pretty much always use this for swapping dimensions as it also has the advantage that you don’t have to pick from the list on the left.
Copy and Paste Expressions
When thinking about the way that over-typing dimension names, and how it retains formatting, it reminded me of another neat feature that not many people seem to be aware of.
If you right click on an expression name a small context menu appears. On this menu you will see a Copy option.
Now, obviously you could click into the Expression Definition, do a Ctrl+A to copy the expression text, create a new expression and then paste in the code – this makes sense as you inevitably need to tweak the code. However, when you Copy and then right click in the space under the Expression list and click Paste something really neat happens. Not only do you get a copy of the expression code, the new column that is created has exactly the same properties as the source expression. This includes column width, alignment, number format etc.. This saves you having to set the formats and alignment on each column and it is also the simplest way of ensuring equal column widths – as there is no way to highlight multiple columns and drag them to the same size, as in Excel.
I hope that these two techniques are as useful to you as they have proven to be to clients that I have demonstrated them to.
If you have any quick tips of your own that you would like to share please feel free to do so in the comments box below.