Filter by column and create new sheet

Hi,

I have this excel file as shown below:
image

I need to filter the excel by the “Country” column and create a new sheet in the same excel for each unique country as such:

Can anyone help please?
Thanks!

Hi @Yudhisteer_Chintaram1

You can try like this

  1. Read the input excel sheet and store in dt1 variable

  2. Get the list unique country names from Country column using below assign activity

countries= dt1.AsEnumerable().Select(Function(r) r(“Country”).ToString).ToArray.Distinct

Now use excel application scope pointing to the filepath where u need output excel sheet.

inside that try this

a. use a for each activity to loop through each item in countries variable (for item in countries)

inside that try this:

  1. filter the dt1 on country column with condition , Country=item and store output in a variable dtoutput
  2. write dtoutput to a sheet using write range specifying the name of sheet as item

Try this appraoch and let me know

Thanks & Regards,
Nived N

1 Like

Hi @NIVED_NAMBIAR ,

Thanks for replying. What should the type of my country variable be?

Thanks!

It should be string , i hope u are talking about country collection variable right?

1 Like

Sorry. The countries variable which I should assign to dt1.AsEnumerable().Select(Function(r) r(“Country”).ToString).ToArray.Distinct

yes it string array varaiable type String

1 Like

Hi,

I added a .xaml, you can check it out.

FilterColumn.xaml (8.3 KB)

Regards,
MY

1 Like

Thanks a lot!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.