How to Sort by Date in Tableau
Setting up a new chart in Tableau should be simple, but then it happens: you drag your date field into the view and see your months sorted alphabetically as April, August, December. This frustrating and common issue happens because Tableau sometimes treats dates as text labels instead of points on a timeline. This article will show you several ways to fix it, from quick manual adjustments to permanent automated solutions, so your dates always appear in the correct chronological order.
Why Tableau Sorts Dates Alphabetically
Before fixing the problem, it helps to understand why it happens in the first place. The main reason for incorrect date sorting in Tableau is the distinction between Discrete (blue pills) and Continuous (green pills) fields.
Discrete vs. Continuous Dates
When you drag a date field onto your Rows or Columns shelf, Tableau gives you several options for how to display it (Year, Quarter, Month, etc.). You'll notice that these options are often split into two groups.
- Continuous (Green): The options in the bottom half, like MY(Order Date), result in a green pill. Tableau treats these as a continuous axis or timeline. If you choose the continuous MONTH, you get a single axis that flows from January through December and into the next year. These almost always sort correctly because they are part of an unbroken timeline.
- Discrete (Blue): The options in the top half, like DATENAME 'month', result in a blue pill. Tableau treats these as separate, distinct categories or labels. When you choose the discrete MONTH, you get a distinct header for each month: "January," "February," "March," etc. Because these are treated like text labels, Tableau’s default behavior is often to sort them alphabetically.
This alphabetical sorting is why you see "April" before "February." Tableau isn't looking at them as parts of a year, it's just sorting text strings. The rest of this guide focuses on how to tell Tableau to properly sort those blue, discrete date parts.
Method 1: The Quick Fix - Manual Sorting
Sometimes you just need a quick-and-dirty fix for a single chart. Manual sorting is the fastest way to reorder your date parts into the correct sequence. This is best for static views or situations with a few, unchanging values (like the 12 months of the year).
Let's say you have your sales data displayed by month, and it's sorted alphabetically.
Step-by-Step Instructions:
- Drag your Month pill (e.g.,
MONTH(Order Date)) to the Columns or Rows shelf. Ensure it's a blue, discrete pill. - Click the small dropdown arrow that appears on the right side of the pill.
- From the context menu, select Sort...
- A dialog box will open. Under "Sort by," you'll see a few options. Select Manual.
- You'll now see a list of your months in their current alphabetical order. Simply click and drag the items in the list until they are in the correct chronological order (January, February, March, etc.).
- Once you're done, close the dialog box. Your chart will instantly update with the corrected sort order.
When to use this method: Manual sorting is great for one-off charts, simple dashboards, or when you need an unconventional order that doesn't follow a standard rule. However, it's not dynamic. If new data with new values appears, you'll have to manually sort it again.
Method 2: The Best Practice - Sort by Field
For a more dynamic and automated solution, the "Sort by Field" option is your best friend. This method tells Tableau to sort one discrete field (like the month name) based on the values of another field that is inherently chronological (like the month number or the original date).
Almost any date part can be sorted this way. Let's stick with the month example.
Step-by-Step Instructions:
- Place your discrete month field on the Rows or Columns shelf. For example, use the field created by the calculation
DATENAME('month', [Your Date Field]). You'll see it is sorted alphabetically. - Click the dropdown arrow on the blue month pill and select Sort...
- In the Sort dialog box, change the "Sort by" option from "Data Source Order" to Field.
- Under "Field Name," click the dropdown and select the original, underlying date field from your data source (e.g.,
Order Date). - For "Aggregation," you can choose Minimum or Maximum. For sorting dates, either one works perfectly. Tableau will look at all the records for "April," find the minimum (or maximum)
Order Dateassociated with them, and use that value for sorting. Since every date in April comes after every date in March, the sort order will be correct. - Ensure the "Sort Order" is set to Ascending.
- Click "OK." Your chart is now sorted chronologically.
The beauty of this method is that it's dynamic. If your data updates to include a new year, the sorting will still work without any manual intervention. This same logic applies to sorting weekdays (e.g., DATENAME('weekday', [Date]) sorted by DATEPART('iso-weekday', [Date])) or quarters.
Method 3: Creating Custom Sort Orders with a Calculated Field
What if your business doesn't follow a standard calendar? Many companies operate on a fiscal year that starts in a month other than January — say, July. In this case, you want your charts to begin with July and end with June. Neither manual sorting nor the standard "Sort by Field" will achieve this easily. This is where a calculated field comes into play.
The goal is to create a new field that assigns a numerical sort order to each month based on your fiscal calendar.
Example: Sorting by a Fiscal Year Starting in July
Step 1: Create the Calculation
- In the Data pane, click the dropdown arrow at the top and select Create Calculated Field.
- Name your new field something descriptive, like "Fiscal Month Sort."
- Enter the following logic. This formula uses a
CASEstatement to assign the number 1 to July, 2 to August, and so on.
CASE MONTH([Order Date])
WHEN 7 THEN 1
WHEN 8 THEN 2
WHEN 9 THEN 3
WHEN 10 THEN 4
WHEN 11 THEN 5
WHEN 12 THEN 6
WHEN 1 THEN 7
WHEN 2 THEN 8
WHEN 3 THEN 9
WHEN 4 THEN 10
WHEN 5 THEN 11
WHEN 6 THEN 12
ENDClick "OK" to save the calculation. You now have an invisible numeric field that you can use to sort your month names.
Step 2: Apply the Custom Sort
- Once again, place your discrete month field (
DATENAME('month', [Order Date])) on the Rows or Columns shelf. - Click the dropdown arrow on the pill and open the Sort... dialog.
- Set "Sort by" to Field.
- For "Field Name," find and select your newly created calculated field, "Fiscal Month Sort."
- The default aggregation will likely be Sum. This is fine. Since each month has only a single sort value (e.g., July is always 1), the sum, average, min, or max will all return the same result.
- Make sure the order is Ascending.
Your chart will now be sorted according to your fiscal calendar, starting with July. This technique is extremely powerful for any kind of custom sorting, whether it's for product categories, sales territories, or non-standard date arrangements.
Method 4: Save Time by Setting the Default Sort Order
After you've gone through the trouble of correctly sorting your Month field, you probably don't want to repeat the process every time you create a new visualization. Tableau allows you to set the default sort order for any field in your data source, saving you valuable time and ensuring consistency across your workbook.
Step-by-Step Instructions:
- Find your discrete date field in the Data pane on the left side of the screen. Make sure this is the field you'll be using in your visualizations (e.g., the
DATENAME('month', [Order Date])field, which might be a calculated field you created). - Right-click on that field.
- In the context menu, navigate to Default Properties > Sort...
- You'll now see the familiar Sort dialog box. Set up your desired sort behavior using any of the methods we've covered. For months, the most robust option is "Sort by Field" using the minimum of the underlying date field. Or, if you need a fiscal sort, use the custom calculated field you created.
- Click "OK."
That's it! Now, any time you drag that specific date field into any new view in your workbook, it will automatically apply the chronological sorting you just defined. This is a huge efficiency booster for anyone who builds reports regularly.
Final Thoughts
Sorting dates correctly in Tableau is a fundamental skill that moves you past the frustrating default behaviors. By understanding the difference between discrete and continuous dates and using methods like manual sorting, sorting by field, custom calculations, or setting default properties, you can take full control of your visualizations and ensure your data tells a clear, chronological story every time.
Mastering these small but important steps is often what separates an effective dashboard from a confusing one. At Graphed, we’ve eliminated these tedious hurdles entirely. Instead of clicking through sort menus and writing custom calculations, you can just ask in plain English for what you want to see. Need a chart of sales by fiscal month starting in July? Just ask, "Show me a bar chart of our monthly Shopify sales for the last fiscal year," and Graphed instantly builds the report with your dates sorted correctly — all connected to your live data, no configuration required.
Related Articles
What SEO Tools Work with Google Analytics?
Discover which SEO tools integrate seamlessly with Google Analytics to provide a comprehensive view of your site's performance. Optimize your SEO strategy now!
Looker Studio vs Metabase: Which BI Tool Actually Fits Your Team?
Looker Studio and Metabase both help you turn raw data into dashboards, but they take completely different approaches. This guide breaks down where each tool fits, what they are good at, and which one matches your actual workflow.
How to Create a Photo Album in Meta Business Suite
How to create a photo album in Meta Business Suite — step-by-step guide to organizing Facebook and Instagram photos into albums for your business page.