Difficulty Level: Advanced. This post assumes a strong understanding of HubSpot tools and technical knowledge. Insutructions are given as guidelines and may require additional customisation.
Last Updated: May 19, 2022
Let's assume you have a HubDB table (ID 12345) with two columns:
In your code, you can use the orderBy
parameter to sort your table by a specific column (in this case, "date"), adding a minus symbol in front of it if you want to reverse the order. So your query parameters will either be "&orderBy=date"
or "&orderBy=-date"
Using the hubdb_table_rows function, this looks something like this:
See the Pen [Blog Post Example] Sort a HubDB query by date by Stephanie O'Gay Garcia (@stephanieogaygarcia) on CodePen.
Note: if you've somehow landed on this post looking for a way to sort the actual HubDB table, unfortunately, that's not possible as of the time of writing this post unless you do some hacky export/order on a spreadsheet/re-import. But be sure to upvote the idea here! In a recent update, HubSpot have said they're working on it so fingers crossed!
Written by: Stephanie O'Gay Garcia Last Updated: May 19, 2022I'd appreciate if you could take a moment to let me know how I can improve this article.
Hi! 👋 I'm a freelance HubSpot Website Developer based in Toronto (Canada). Give me a shout if you have questions about this post or there's anything I can help you with.
HubSpot is a full suite of Marketing, Sales and Services tools. Learn more here.
Note: as a HubSpot affiliate I will earn commission if you decide HubSpot's the right software for you! :)