How to sort data in excel sheet with month names

Hey All,

I have an excel file with multiple sheets(5 sheets), which have user data and one of the column is “Month”. My task is to sort the sheets with “Month”.
Example
Username: David, Month: Jan, Bill: $10.99
Username: David, Month: Oct, Bill: $25.49
Username: Kelly, Month: Feb, Bill: $69.99
Username: Kelly, Month: Nov, Bill: $34.99
Username: Kelly, Month: Dec, Bill: $78.99

How do I achieve this task, please suggest.
Thanks and Happy Automation!

Hey!

Use sort data table activity to sort the column by ascending or descending

Reference:

Regards,
NaNi

Hey Nani,

I want to sort by Month names
Jan
Feb
Mar
Apr

Sort Ascending will print
Apr
Feb
Jan
Mar

Thanks, but this will not work for me :frowning:

Hi @Zeba ,

Could you show us this data in Excel. We would like to check how the data is presented.

we can set up a so called custom sorting, where we look on the position of the month in a month name array.

This month name we can retrieve from:
grafik

as @supermanPunch mentioned with the sample data we can help more individually

Hi!

Try this

Regards,
NaNi

I tried this, it didn’t work.
Thanks Nani!

1 Like

Here is test file for the data I want to sort by month names.
test.xlsx (13.7 KB)

Can you provide a sample please!

Hi @Zeba

You can try this

dt_Data.AsEnumerable.OrderBy(Function(r) Date.ParseExact(r("Month").ToString.Substring(0,3), "MMM", Nothing)).CopyToDataTable

image

The xaml file

SortByMonthNames.xaml (5.1 KB)

1 Like

It worked, Thank you so much!

can you please explain the function so that I understand it as well :slightly_smiling_face:

Hi @Zeba

For your reference

To understand LINQ, please go through the tutorials by @ppr

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.