Filter Datatable using Variable valule

In Currently Filter Datatable need to pass a value to apply a filter.
But required variable to be passed a variable for Row filter and Column.
Instead of Select Query, which will be helpful.

We can get all the variables there @sureshj, so that we can pass the variable to the filter wizard directly

image

1 Like

@HareeshMR

I have tried it’s not working while passing the variable.
Could you please help me with that.
Thanks,
Suresh J

Hi @sureshj

I moved the category because the feature request is not clear here yet.

Could you provide some information about your Studio version?

Please find the Filter activity and Select method,
Could you please help with this.
Here Filter Datatable throws empty but select method throws value.
Filter.xaml (10.5 KB)

And my studio version is 2019.7.0
Thanks,
Suresh J

Strange indeed, it looks like a bug. Works correctly when you set an = sign instead of Contains.

Actually, for it to work then you need to pass your variable as an INT:
image

1 Like

@loginerror

It will work if you assign inside the Filter Datatable. And if we declare as int also it’s not working,
while passing a variable in the Value Field.
Please find the XAML file above for your reference.

Thanks,
Suresh J

Yes, this is how it works:
image

And this is how it doesn’t
image

Thank you for spotting it. I registered the bug for someone from our team to have a closer look.

I would suggest using the working solution until it is fixed :slight_smile:

@loginerror
Thanks you response
My requirement is to pass a variable instead of direct value.
While iterating using For each I will pass a variable in the Value field.
Instead of Select query, Filter Datatable should support variable too.

Thanks,
Suresh J

@sureshj
I faced multiple scenarios like this and in such cases I shit to LINQ. In your case a statement coul look like:
DataTableVar.AsEnumerable.Where(Function ( r ) CInt(r.Item(“YourColumnNameOrIndex”).toString) = 1).CopyToDataTable

Shifting to LINQ can have the option, that you will get more control. Kindly note: If the Where function is returning no result rows, then CopyToDataTable will raise an exception.

@loginerror
I encountered often scenarios in which the comparators failed e.g. isEqual “=”. Not only in Filter Table, Join Table as well. I had a feeling that operators are applied on object level and not on value level. However it is only feeling and nothing is confirmed or proven

@ppr
Thank for replying.
My point is Filter Datatable activity needs to support variable in the Value field, instead of defined Value.

Thanks,
Suresh J

DataTableVar.AsEnumerable.Where(Function ( r ) CInt(r.Item(“YourColumnNameOrIndex”).toString) = YourIntVariable).CopyToDataTable

1 Like

It does support the variable, see this sample:

My point was that it doesn’t work with Contains, you can only check it using the equal sign =.

1 Like

@ppr

I have solution for this, I required the same thing in Activity also.

Thanks,
SureshJ

@loginerror
Yes sure it supports, no question. But in several scenarios the result is not as expected it is filtering to empty result instead to filter out the rows

1 Like

I didnt get you but You can use the LINQ statement from above within a assign activity
Assign activity to: yourDatatableVarFilteredOrOrigin
Expression: LINQ Statement from above

@loginerror

Yes, I agree it will support we can pass the variable but in several scenarios the result is empty.
If u see my working Above through empty I changed it to int also.

Thanks,
Suresh J

@ppr

I have used the Statement, I got the result also please find the above workings.
I need filter Datatable should work the same. instead of a statement.

Thanks,
Suresh J

Sorry I didnt get you

Just so we are on the same page, please run this slightly modified process of yours to see it works as expected with a variable and without empty output:
sureshj_modified.zip (2.5 KB)

However, the observed bug (I think) is that it doesn’t work with the Contains and only returns non-empty output when you use the = condition for the Filter Data Table activity :slight_smile:

1 Like