Hi,
I have a config file for sorting columns. Data looks like;
ColumnName | SortingRule
Column1 ASC
Column2 DESC
Column3 ASC
I have to read config, then use a for each row, and sort columns. When i do this like below;
It sorts one by one. We don’t want that. How can i achieve this?
Thanks.
@balupad14 Have any thougths?
@ercan.nebiler Not sure what is the Output that you expect , based on that we can provide a solution.
Srini84
(Srinivas)
July 8, 2020, 8:18am
3
@ercan.nebiler
Without using for each row, you can use as below
dt_Sort = From x In dt_Sort.AsEnumerable() Order By convert.Tostring(x(“Column1")),convert.ToString(x(“Column2”)) Select x).CopyToDataTable
Using Invoke Code:
dt_Sort.DefaultView.Sort = (“Column1_name ASC, Column2_name ASC”)
dt_Sort = datatableVar.DefaultView.ToTable
Hope this works
Thanks
4 Likes
Hi thanks for your answer.
Like i said i have a config file. Dt_Config
And a target file: Dt_Target
I will sort multiple columns. Which is dynamic. When i do this like image above, it sorts one by one. So it sorts first column. Then second. But first sort is becoming invalid. Because we sorted the other column. Clear now?
Hi can’t hardcode this. It’s have to be dynamic. There can be 3 columns, next week can be 5 columns.
balupad14
(Balamurugan)
July 8, 2020, 9:11am
6
Hi @ercan.nebiler ,
Take a look this thread with example
Thank you
Balamurugan.S
Thanks for your answer.
How can i make “create table” activity’s range dynamic?
Hi @balupad14 ,
I almost made the sorting with your help. But there is a problem.
I sorted this column DESC, But it’s not seeing these as numbers i guess. What do you suggest about it?
Thanks
General, i am creating this excel with excel application scope.
hbpe
(Peter Hansen)
November 20, 2020, 12:55pm
11
You can use the previously mentioned approach using Invoke Code in a dynamic way as the Sort property on DataView takes a string.
“Column1_name ASC, Column2_name ASC”
You can read the config file and concatenate each sorting rule into a single string, then set it on the Sort property.
Sero2077
(Sero)
August 23, 2021, 1:45am
12
working beautifully! thanks
2 Likes