Below is a dataset I have
ID | Dept | Value
1 | 0 | 50.58
2 | 0 | 75.64
3 | 0 | 32.57
4 | 0 | 187.57
5 | 0 | 354.54
How would I go about splitting this down into 2 groups of Dept 1 and Dept 2 where the break down would be based on value. i.e. where value is as close as to exactly half of the total value.
In the above example IDs 1-4 would be in group 1 with a total of 346.36 and ID 5 would be in group 2 with a total of 354.54.
This is a very difficult question. There are lots of algorithms to do this “bin packing” solution (ie trying to equally split various sizes across various containers). This is essentially the same. Have a look at Fill volume algorithm for more information on it.
The short answer, it’s not easy, and at best you can only get an approximation to the best solution.