shanti_18
(shane hyung)
January 29, 2024, 1:58am
1
Hello guys I have this datatable “WEIGHT”
I need to filter these data with those weight that only contains 250 lbs below and put it into another sheet.
My only problem is that I can’t filter it on the filter data table activity, because WEight data is “250 lbs”. it has the “lbs”
note: Weight value should be configurable
mkankatala
(Mahesh Kankatala)
January 29, 2024, 2:07am
2
Hi @shanti_18
→ Use Read range workbook activity to read the excel and store in a datatable variable called Input_dt.
→ Take an assign activity and give the below linq expression,
- Assign -> Out_dt = (From row In Input_dt
Where CInt(row("WEIGHT").toString.Split(" ").First) < 250
Select row
).CopytoDatatable()
→ Use Write range workbook activity to write the Output_dt variable to another sheet in the excel.
Check the below workflow for better understanding,
Input -
Output -
Hope it helps!!
vrdabberu
(Varunraj Dabberu)
January 29, 2024, 2:08am
3
Hi @shanti_18
In value sections give the value as 250 lbs
Regards
lrtetala
(Lakshman Reddy)
January 29, 2024, 2:08am
4
Hi @shanti_18
Can you try below query
dtFiltered = dtOriginal.AsEnumerable() _
.Where(Function(row)
If(row("Weight") IsNot Nothing AndAlso row("Weight").ToString().ToLower().Contains("lbs"),
CInt(row("Weight").ToString().ToLower().Replace("lbs", "").Trim()) <= 250,
False)
).CopyToDataTable()
Yoichi
(Yoichi)
January 29, 2024, 2:20am
5
Hi,
How about the following if there is possibility the result is empty?
arrDr =v dt_WeightPlyaers.AsEnumerable.Where(Function(r) System.Text.RegularExpressions.Regex.IsMatch(r("WEIGHT").ToString,"\d+") AndAlso CInt(System.Text.RegularExpressions.Regex.Match(r("WEIGHT").ToString,"\d+").Value)<250).ToArray()
note: arrDr is DataRow array type
Regards,
shanti_18
(shane hyung)
January 29, 2024, 2:21am
6
where can i find it?
you mean this ?
vrdabberu
(Varunraj Dabberu)
January 29, 2024, 2:47am
7
Hi @shanti_18
Yes if the in-weight variable contains the value of 250 then the filteration given by you is correct.
Regards
shanti_18
(shane hyung)
January 29, 2024, 2:48am
8
it’s not working brother.
vrdabberu
(Varunraj Dabberu)
January 29, 2024, 2:52am
10
Hi @shanti_18
Try giving the 250 lbs directly in the place of in-weight variable and also remove the second filteration and give a try bro
Regards
mkankatala
(Mahesh Kankatala)
January 29, 2024, 2:52am
11
We can’t do it with both of the Excel activities and datatables. It will throw the error for sure.
Instead of doing this use the workbook activities and linq expression it will take less time and work properly.
Download the below workflow and execute in your machine,
2024.xaml (17.3 KB)
Note - Change the name of the Excel file and sheet names.
Hope you understand!! @shanti_18
vrdabberu
(Varunraj Dabberu)
January 29, 2024, 3:03am
12
Hi @shanti_18
Try replicating the same process from the below xaml file. Change the excel file names and sheet names as required.
Sequence15.xaml (11.2 KB)
Input:
Output:
Workflow:
Filter Wizard:
Regards
vrdabberu
(Varunraj Dabberu)
January 29, 2024, 8:25am
14
Hi @shanti_18
Make the variable Weight
datatype as System.Int32 and you can pass that in Filter Datatable table wizard.
Regards
vrdabberu
(Varunraj Dabberu)
January 29, 2024, 8:36am
16
Hi @shanti_18
Please remove the variable and argument and re-initialize them and that might sort out the issue.
Regards
vrdabberu
(Varunraj Dabberu)
January 29, 2024, 8:37am
17
Hi @shanti_18
Check out the below workflow:
Sequence15.xaml (11.6 KB)
Regards
1 Like
shanti_18
(shane hyung)
January 29, 2024, 8:49am
18
alright got it bro, thank you so much.
I add variable that will handle my argument value.
vrdabberu
(Varunraj Dabberu)
January 29, 2024, 8:52am
19
If you got your solution for your query please mark my post as solution to close the loop or if you have any questions, let me know @shanti_18
Happy Automation!!
system
(system)
Closed
February 1, 2024, 8:53am
20
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.