154
Views
10
Comments
Solved
Sort Table on the bases of Months order
Question
Application Type
Reactive

I have a table containing Month column...when I apply sort and when user click on the month column the table should sort according to the month wise...not alphabetic order... ex Jan, Feb ,march, so on....and also it should fetch the current month and display records having month column of current month first then again rest records month wise...


ex: sorting like Jan,Feb,March,,,

 If for ex: current month is Nov, then recording having Nov month should display first then records of dec, jan,Feb should appear

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP
Solution

For that you need to add a filter to exclude all records with the date older than the first date of the current month. Get the first date of the current month: NewDate( Year(Date), Month(Date), 1) 

So agggregate date >= NewDate( Year(Date), Month(Date), 1) 

You could also filter on year+month combination.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi Akshata,

For that you need to make sure to have the Month Number and the Year in your aggregate, then you can sort on year then month number, but display the month abbreviation. You can use the Year() and  Month() build in function in aggregates to extract the year and the month from a date.

Regards,

Daniel

UserImage.jpg
Akshata Patil

Thank You @Daniël Kuhlmann  I got it..but also i want to sort like Current month record should appear first then followed by december,Jan,Feb....so on...

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP
Solution

For that you need to add a filter to exclude all records with the date older than the first date of the current month. Get the first date of the current month: NewDate( Year(Date), Month(Date), 1) 

So agggregate date >= NewDate( Year(Date), Month(Date), 1) 

You could also filter on year+month combination.

UserImage.jpg
Akshata Patil

But I have Month column with the data Type as Text...so How do I do that...

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

I think this is the real problem, your entity should have the year and month numeric, then it would be easy to derive the month number.  Maybe this post will help you:
https://www.outsystems.com/forums/discussion/68981/get-month-integer-by-text-month-name/

But honestly,  for a good solution to your question, make sure in your entity you have the year and month number, or a date.

2025-04-17 05-42-16
Ajit Kurane

Hello Akshata,

Hope you are doing well.

You can refer below thread for your reference.

https://www.outsystems.com/forums/discussion/40947/sort-by-month-in-aggregate-on-a-date-attribute/

Regards,

Ajit kurane.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

yes it has the same info that I shared.

UserImage.jpg
Akshata Patil

Hi @Ajit Kurane  

Thanks for the reply...but my case is bit different...I have Month column with the data type as Text...so i want to sort it month wise..like Jan,Feb,March so on...and also I want the record having current month should appear first...

ex: Current Month is: November then Records with the month column November should appear first then followed it by Dec,Jan,Feb and so on...

2025-02-27 13-13-03
Poonam Agarwal

Hello Akshata

I have attached a file , i think it would be helpful for solution .

  Happy coding!

TestingApplications.oml
UserImage.jpg
Akshata Patil

This module is not working in my personal environment...its throwing the error Message

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.