Hello ,
I am trying to use filter data table wizard where one of the condition is the Amount column should be always greater than $10 or in other words it should not pick up any amount which is less than 10 dollar. When I am trying to put this filter its not working as expected
@dutta.marina
Instead of using filter datatable use linq query to get appropriate output
rlgandu
(Rajyalakshmi Gandu)
July 2, 2024, 12:51pm
3
@dutta.marina
Send the sample excel so that it will be easy to provide you the FilterDatatable expression
Hi @dutta.marina
After read range.
Use an assign activity
And write range
filteredDataTable = dt.AsEnumerable().
Where(Function(row) row.Field(Of Boolean)("Overall Status") = True AndAlso
row.Field(Of String)("Opportunity ID") <> "Oppty" AndAlso
row.Field(Of String)("Stage Name") = "Signed" AndAlso
row.Field(Of String)("RPA Close Eligible") = "True" AndAlso
row.Field(Of String)("Amount") > "$10.00").
CopyToDataTable()
@dutta.marina ,
As per screenshot here is how you can use LINQ for filtering this data.
io_dt_TransactionData.AsEnumerable().Where(Function(row) _
row.Field(Of Boolean)("Overall Status") = True AndAlso _
Not String.IsNullOrEmpty(row.Field(Of String)("Opportunity ID (Oppty)")) AndAlso _
row.Field(Of String)("Stage Name") = "Signed" AndAlso _
row.Field(Of Boolean)("RPA Close Eligible") = True AndAlso _
row.Field(Of Decimal)("Amount") > 10.0).CopyToDataTable()
Thanks,
Ashok
mkankatala
(Mahesh Kankatala)
July 2, 2024, 12:53pm
6
Hi @dutta.marina
You can try the below linq expression,
- Assign -> dt_output = dt_Input.AsEnumerable().Where(Function(X) CDec(X("Amount").ToString().Split("$"c).Last()) > 10).CopyToDataTable()
Hope it helps!!
Anil_G
(Anil Gorthi)
July 2, 2024, 1:12pm
7
@dutta.marina
First of all check the values in the locals pane if it is coming as integer or a dollar value…if dollar value then you cannot use filter datatable you need to go with linq…if integer then dont with dollar sign and inverted comma directly give 10 in filter datatable
Cheers
@ashokkarale
getting the cast error
io_dt_TransactionData.AsEnumerable().Where(Function(row) _
row.Field(Of Boolean)(“Overall Status”) = True AndAlso _
Not String.IsNullOrEmpty(row.Field(Of String)(“Opportunity ID (Oppty)”)) AndAlso _
row.Field(Of String)(“Stage Name”) = “Signed” AndAlso _
row.Field(Of Boolean)(“RPA Close Eligible”) = True AndAlso _
row.Field(Of Decimal)(“Amount”) > 10.0).CopyToDataTable()
@dutta.marina ,
Check the datatype of your datatable columns and change type of fields accordingly.
Thanks,
Ashok
rlgandu
(Rajyalakshmi Gandu)
July 2, 2024, 1:33pm
10
@dutta.marina
dt.AsEnumerable().
Where(Function(row) row.Field(Of String)("Overall Status") = "True" AndAlso
row.Field(Of String)("Opportunity ID") <> "" AndAlso
row.Field(Of String)("Stage Name") = "Signed" AndAlso
row.Field(Of String)("RPA Close Eligible") = "True" AndAlso
CDec(row.Field(Of String)("Amount").Split("$"c).Last()) > 10).
CopyToDataTable()
@Anil_G
I have tried different methods but getting cast value error for LINQ
@dutta.marina
Can you share the input file
So that we will see the datatype formats the columns and give an appropriate sol
@pravallikapaluri
If I click the Amount cell . I checked by clicking Information Tab in excel and Type itreturned 2 which means its not a number string
@dutta.marina
Okay.If all the columns are of string datatype
Below query will work
filteredDataTable = dt.AsEnumerable().
Where(Function(row) row.Field(Of String)("Overall Status") = "True" AndAlso
row.Field(Of String)("Opportunity ID") <> "Oppty" AndAlso
row.Field(Of String)("Stage Name") = "Signed" AndAlso
row.Field(Of String)("RPA Close Eligible") = "True" AndAlso
row.Field(Of String)("Amount") > "$10.00")
CopyToDataTable()
1 Like
@pravallikapaluri
Yea I made similar changes the running the bot .will update
@pravallikapaluri
I am getting as The source contains no DataRows: Is it because there is no data based on filter conditions
Anil_G
(Anil Gorthi)
July 3, 2024, 4:46am
18
@dutta.marina
Using > "$10.00" will never work…as said first check the values in locals panel or attach the file here we can check
When you use inverted comma it is a string and you also have $ which again cast cannot convert to integer
Cheers
@Anil_G
Attached the excel file . The values are string. The below query is not working for me
io_dt_TransactionData.AsEnumerable().
Where(Function(row) row.Field(Of String)(“Overall Status”) = “True” AndAlso
row.Field(Of String)(“Opportunity ID (Oppty)”) <> “” AndAlso
row.Field(Of String)(“Stage Name”) = “Signed” AndAlso
row.Field(Of String)(“RPA Close Eligible”) = “True” AndAlso
row.Field(Of String)(“Amount”) > “$10.00”).CopyToDataTable
Opportunity Quote.xlsx (628.5 KB)
system
(system)
Closed
July 6, 2024, 11:57am
20
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.