Advance with Assist: Sorting with MONTH in Reverse

Data

Advance with Assist: Sorting with MONTH in Reverse

Advance with Assist shares quick solutions to common challenges encountered by the InterWorks Assist on-demand team.

Question: I thought this would be easy and just a check somewhere, but I can’t figure out how to reverse the order of the colors. As new months are added, they go to the left. I want them on the right. What is the magic sauce?

sorting months in Tableau in reverse

Well, this person was right—it is just a button to select. But understanding what Tableau is doing here is important.

To sort this the way the client is requesting, you need to right-click on the MONTH(Date) pill on Color and click Sort. By default, Tableau selects Ascending. By changing to Descending, the months will be in order from left to right:

sorting months in Tableau in reverse

sorting months in Tableau in reverse

Now, another question comes up: January is the first month, but alphabetically February is before January, so why does this work? The answers are in how Tableau handles dates. When a date is recognized, Tableau gives the full hierarchy of the date for use in the Tableau visualizations. But what is really happening?

Let’s look at the exact same date hierarchy, but we’ll make it a calculated field instead of Tableau’s date hierarchy. Below, I’ve created a calculated field just like the date hierarchy pill:

sorting months in Tableau in reverse

Now, when we add this to the Label card, we can see that MONTH returns the month number. January = 1, February = 2, and so on:

sorting months in Tableau in reverse

Tableau’s date hierarchy gives the month name or date part rather than the month number or date value. In the background, though, the date value or number is what Tableau is using for the sorting.

More About the Author

Dustin Wyers

Analytics Consultant / Assist Lead - East
Advance with Assist: Connectionless Failure Error in Tableau Server Question: I’ve published my data source to Server and set the refresh schedule, but the refresh keeps failing with the error message ...
Advance with Assist: Ungroup Column Headers That Have Concatenated Question: I’m building a simple report for my manager. As I add new fields into the report, the first few dimensions that I’ve added ...

See more from this author →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK