For today I have a quick tip on creating a specific labelling for bar charts. This has come out of Workout Wednesday 2021 Week 44. Usually, labels are either at the end of the bar chart (automatic / right), at the end but inside the bar (left) or inside centered (center alignment).
But what if you want basically the label to be always on the opposite end of the bar beginning? i.e. if a bar is positive, the label should be on the left of the zero axis and if it is negative, it should be on the right?
This is what we get
This is what we want
So how do we do this? Remember, there are always several solutions and in this case, mine is completely different to what Candra McRae has used in her WoW 2021 W44 challenge.
The solution is pretty simple in my case. Create a dual axis with the measure you are using (in the above I used profit) and wrap it in a sign function which we then turn negative
//for dual axis -sign(SUM([Profit])
Synchronize axis and put label alignment to left on the secondary axis. On the main axis, you can remove the sub-categories and just add the value labels on automatic alignment.
And that’s it already, straight forward and pretty neat looking:
That’s my quick tip for today, I hope you find this useful.
As always, appreciate your feedback.
Until next time.