Solving the Writing Out to Months in Order Issue
- Dawn Harrington
- Sep 17
- 2 min read
I've had a use case in Alteryx that has been driving me crazy for a while. If you need to export to multiple sheets in an Excel workbook for your client for the months of the year, Alteryx does it in Alphabetical order. So April will be next to August etc.
How do you get them in Month order? You could write them out in 1, 2, 3 etc. But you need to have the leading zero or Alteryx will have 1, next to 11, 12 in that order.
Here is an example data source. I use the Change File/Table Name option and use the Month column to export the sheets to the corresponding Month name.

As you see in the Workflow results, Alteryx created a Excel sheet in the Excel workbook for April, then August etc in Alphabetical order.

Here is the example Excel sheet open:

I want January first, then February and so on in order. So how do I do this in Alteryx?
You could use the DateTime Tool to force Alteryx to recognize your Month column as a month format.

You can then add a Formula tool and create the following formula in a new column called Revmonth
Datetimeformat([NewMonth],'%m')

I then combine this Revmonth column with an underscore and the Month column. I also then add the C:\FILEPATH in front of it like this:
'C:\Users\NAME\OneDrive\Desktop\SampleFile2.xlsx|||'+[Revmonth]+'_'+[Month]
I then select the Change Entire File Path in the Output tool and select Filepath as the file name.

So the final file will have the different months on different tabs in order as shown below;

In my experience, the DateTime tool can easily wipe out and it doesn't remember the format.
My suggestion is to just use the Formula tool for everything. I put them in three different formulas, the order below. You can combine them if you wish, this is just the way I did it.
New Month
DatetimeParse([Month],'%B')
Revmonth
Datetimeformat([NewMonth],'%m')
Filepath
'C:\Users\NAME\OneDrive\Desktop\SampleFile2.xlsx|||'+[Revmonth]+'_'+[Month]
Then do the steps again for the Output tool as specified above.
It returns the same results but with one less tool in your workflow.

Comments