As mentioned in the below screenshot, I am having the table and the primary numbers in the tabular format, EXACTLY as shown in the figure.
Suppose I have the values of the start and end range as following:
- strStart = April 2021
- strEnd = March 2021
I need to have a filtered datatable where I can have the values as below:
Please let me know if we have any solution to this?
Kindly help experts: @prasath17 @Palaniyappan
Thanks and Regards,
dt.AsEnumerable.Where(Function(x) IsNumeric( x(“Test”).ToString.Trim)).CopyToDataTable
Can you try this LINQ query for filtering only numeric values?
I hope this will work for you
He doesn’t only want numeric values, he wants the numeric values after the specified month.
Assuming exactly the data you have shown here, you’d need to read the sheet into a datatable. Then loop through the datatable and with proper logic look for strStart. Then after you’ve gotten strStart, you continue looping and stick the values into an array until you find strEnd.
Another option would be to read it into a datatable then loop through looking for strStart and strEnd. When you find each one, you put its row index into a variable ie startIndex (INT32) and endIndex (INT32). Then you can pass startIndex+1 and endIndex-1 to the Read Range activity to read back in just the values you want as rows in a secondary datatable.
However, I should point out that this is one of those times I look at the source data and ask the question…can we get it in a better format? For example, if you could get it as two columns it would be better - column 1 is Month and Year, column 2 is value.
startIndex (Int32) =
dtData.AsEnumerable.toList.FindIndex(Function (x) x("Primary Number").toString.trim.Equals("March 2021"))
dtData.AsEnumerable.toList.FindIndex(Function (x) x("Primary Number").toString.trim.Equals("April 2021"))
dtResult | DataType: DataTable =
dtData.AsEnumerable.Skip(startIndex + 1).Take(endindex - startindex - 1).CopyToDataTable