Sorting Month
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi! I want to find a cleaner way to sort my data by month (starting January) other than having a column I added labeled month_num (which works but is unappealing? Would someone be able to assist?
- Labels:
- Date Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @soulton ,
There are a bunch of date/time functions available.
https://help.alteryx.com/20223/designer/datetime-functions
So when you deal with dates, you may first consider converting it to Date type.
Once you get the Date type data, you can use it for sorting, and easily convert the format in your favorite style.
The workflow I posted to your previous question is one of the example. (attached again.)
Good luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Here's what I do with regards to sorting months:
Since there are always 12 months in a year - I know that is fixed. Just add a Text Input tool with the months sorted according to January, February, March, April, etc., and then use Record ID tool to rank them 1 to 12.
Join the months with your data, and then Sort the RecordID ascending. Once that is done, use a Select tool to remove both the Joined month and the RecordID.
Your final output will look clean!
Hope this helps.
Best,
Cal
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi, @soulton
.
IMHO, your approach is solid - getting the DateTimeMonth (Month_Num).
Every other approach might be different, but the outcome will be the same - to achieve a sortable field by Integer, Double (because Text would put April before Jan, etc.)
Kindly consider using a Select Tool prior to output to only keep the fields that you need.
I hope you find this helpful - Cheers!
![](/skins/images/9AF25434D4F136B28264A96CA92E8A93/responsive_peak/images/icon_anonymous_message.png)