Custom (re)ordering of legend/bar segments in Einstein Analytics

Vanmoofer
2 min readMar 14, 2019

--

Recently I tacked with the problem of ordering the legend/bar segments in Einstein Analytics and this is how I solved it.

Problem:

Using the Einstein Analytics user interface, I could sort bar segments of a stacked column chart in asc/desc order or keep it unsorted. However, I needed to sort them in a custom fashion like in the image.

Apparently, its possible by using custom SAQL and with final touches using the extended meta data a.k.a XMD.

Solution:

Then you need to add a similar code like the following into the SAQL code:

Check the code : http://bit.ly/2CuBRfh

After this step, the legend is going to show its contents with numbers in front. To fix this using the eXtended Meta Data (XMD) .json file.

Go ahead download the XMD.json file after clicking “edit” dataset. As seen in the screenshot below, click “download” to get the latest .json file.

Now you need to edit the “dimensions” part like in the example code below. Define the member and label fields, if you want to override the color as well then also color too.

Next step is to replace the XMD .json file. Click the ‘replace‘ button and upload the updated file.

Check the code : http://bit.ly/2CuBRfh

Niceness! Now you have an ordered/coloured legend/bar segments in the stacked column chart and no more misleading/confusing numbers in front the legend elements.

About VanMoofer: Blending technology and design for e-mobility is the motivation of this blog. If you want to know more about new perspectives and ideas in this context, subscribe to VanMoofer on Medium, follow us on Instagram and Twitter. You can also check suitable VanMoof-Gear and if you like support us with a cup of a coffee ☕️.

🚲 Last but not least, if you consider buying an S3/X3, use the following discount code during checkout and get €100/$100/£95 off on VanMoof accessories & PoM services: ADV-Y78Q-4S9G-HEM7

Visit our website: vanmoofer.com

--

--

Vanmoofer
Vanmoofer

Written by Vanmoofer

vanmoofer.com · The driving force behind this blog is the blending of technology and design in the realm of e-mobility.

No responses yet