Hi All, i have a scenario that where i want to segregate excel based on rows count including duplicates and i should not split my same record into 2 excel new sheets.
Input : If my input comes like this
FIRST NAME
Stacy
Stacy
Stacy
Tan
Tan
Stan
Stan
Stan
Vick
Vick
Vick
Zin
Output should be : 2 excel files each contains 6 rows
1st File :
FIRST NAME
Stacy
Stacy
Stacy
Stan
Stan
Stan
2nd File :
FIRST NAME
Vick
Vick
Vick
Zin
Tan
Tan
Note : Output should not come like this :
FIRST NAME
Stacy
Stacy
Stacy
Tan
Tan
Stan
Stan
Stan
Vick
Vick
Vick
Zin
Stan have 3 records so it should go for single excel. It should not split into 2 excel files. If there are no records to combine 6 at the time we can but in scenario we should not split like same record into 2 files half in 1 new excel and another half in another new excel.
You can find the code below.
Basically you can create a dictionary to keep names and their counts. And with for each add names to a list of first table names until sum of current counts of names passes the half of total sum. Finally you can filter your datatable by the list that you created to hold the names that belonges first table. BlankProcess18.zip (642.3 KB)
Hi @Emre_Ayyildiz If i keep multiple rows of data it is not working. My input rows are not constant, it will change every time.
Can you please check below file once. In ** Output Sheet** i have mentioned my requirements.
It’s like matter of Combinatorial optimization such as Knapsack problem or Bin packing problem.
In general, more detailed condition is necessary to write logic. For example, what if the combination does not result in 6 records? etc. (Case of 5 records, 3records, 2records and 2 records)
Hi @Yoichi this code is working but it’s not giving as accurate to make its grouping only some records and it’s skipping few. If you get time look this once