Sort Months Chronologically and Not Alphabetically

Published on December 2, 2015

By default, Arcadia stores months as numbers. While you can always represent them in words, sorting them alphabetically in the visualization would mean the year starts with April instead of January. Of course, if that gets plotted on a graph, January moves after April and August ahead and messes up the analysis. But you may still want to show the names of the months rather than numbers.

In this post, I’ll show you how to display an alphabetical representation of months while sorting them chronologically on the dataset SFPD Reported Incidents for 2014 [data source].

Suppose I want to analyze the number of incidents for different quarters for the Central, Northern, and Southern regions. The following screen shows how it appears visually:


Though the months are sorted, I want to display them in words. For that, I will undertake the following steps:

  1. Change the Months on X axis applying the following expression.


The visualization shelves now look like this:


The months are unsorted; and if you try to sort them using the same field, the visualization will be sorted alphabetically.

  1. To solve for this issue, drop the numerical Month on the Tooltips shelf and sort it using this dimension.

Months are now sorted chronologically and are represented in words.


The same method can be used to sort weekdays; inherently, this trick is applicable on any numeric value to be sorted and represented otherwise.