Get all records against one unique values

I need to get all the corresponding values of “City” against the “Country” in string.

Expected Output- str_Country = “India”, str_City= “Delhi”,“Mumbai”,“Kolkata”,“Chennai”.

1 Like

Hi

Hope the below steps would help you resolve this

  1. Use a excel application scope and pass the file path as input

  2. Inside the scope use a Read range activity and get the output as dt

  3. Now use a assign activity like this

dt = dt.AsEnumerable().Where(Function(a) a.Field(of String)(“Country”).ToString.Contains(“India”)).CopyToDatatable()

If you want you can pass even as a string variable like this instead of “India”

dt = dt.AsEnumerable().Where(Function(a) a.Field(of String)(“Country”).ToString.Contains(str_country.ToString)).CopyToDatatable()

  1. Now this dt will have only the records with country “India” or the string variable passed as input

  2. Then use a assign activity to get the list of city in it
    Str_City = String.Join(“,”,dt.AsEnumerable().Select(Function (a) a.Field(of string)(“City”).ToString).ToArray())

Cheers @mkm8587

2 Likes