Zeba
(Affy)
June 30, 2022, 6:24am
1
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
Zeba
(Affy)
June 30, 2022, 6:42am
3
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
Zeba:
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
Hi @Zeba ,
Could you show us this data in Excel. We would like to check how the data is presented.
ppr
(Peter)
June 30, 2022, 7:33am
5
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:
as @supermanPunch mentioned with the sample data we can help more individually
Zeba
(Affy)
June 30, 2022, 2:39pm
7
I tried this, it didn’t work.
Thanks Nani!
1 Like
Zeba
(Affy)
June 30, 2022, 3:00pm
8
Here is test file for the data I want to sort by month names.
test.xlsx (13.7 KB)
Zeba
(Affy)
June 30, 2022, 3:16pm
9
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
The xaml file
SortByMonthNames.xaml (5.1 KB)
1 Like
Zeba
(Affy)
June 30, 2022, 6:45pm
11
It worked, Thank you so much!
can you please explain the function so that I understand it as well
Hi @Zeba
For your reference
Retrieves a substring from this instance. This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.
To understand LINQ, please go through the tutorials by @ppr
1 Like
system
(system)
Closed
July 3, 2022, 6:51pm
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.