Hi
I have a data table(varDT) with 20 columns, let’s say the column names are a, b, c, d, e, f, g,… etc.,
I have an array of column names from the asset as {“b” , “d”, “f”} and now I want to filter the above datatable(varDT) in such a way that it should contain only the columns b, d and f.
Can someone support me with the approach to get this done.?
modify the asset value (Asset Datatype: Text) to: ["b" , "d", "f"]
this will represent a string array as JSON String
read the asset value - strJsonFilter
Assign activity:
arrColFilters | String Array =
Newtonsoft.Json.Linq.JArray.Parse(strJsonFilter).ToObject(Of String())
Assign Activtiy:
dtFiltered =
YourOriginDataTableVar.DefaultView.ToTable(False, arrColFilters )
An alternate method…
Change the Asset to just be a comma delimited list: b,d,f
Assign Activtiy: varDT = varDT.DefaultView.ToTable(False,Split(varAsset,“,”))
(I never understand why people always create second variables to assign to. You can just reassign back to the original variable.)
@Harsha_Vemula
Can you check and close the topic by:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.