I have a long list of zip codes and a total units within each zip code. I want to create groups of zip codes where the totals add up to a certain number.
In the example table below, the zips and counts are in no particular order. But I want to start adding up the counts cumulatively until they reach the magic number of 43 and then that would represent Group A. Then start the cumulative count over again until the total reaches 43 and then that is Group B. And so forth. The Column marked "43" is a sample of my desired result.
Thanks all.
In the example table below, the zips and counts are in no particular order. But I want to start adding up the counts cumulatively until they reach the magic number of 43 and then that would represent Group A. Then start the cumulative count over again until the total reaches 43 and then that is Group B. And so forth. The Column marked "43" is a sample of my desired result.
Thanks all.
Zip | Count | 43 | |
30526 | 8 | Group A | |
38212 | 13 | Group A | |
38430 | 8 | Group A | |
13476 | 19 | Group B | |
78768 | 9 | Group B | |
70158 | 3 | Group B | |
63321 | 10 | Group B | |
29800 | 6 | Group C | |
70909 | 1 | Group C | |
64779 | 10 | Group C | |
87976 | 16 | Group C | |
57904 | 10 | Group C | |
88979 | 19 | Group D | |
60494 | 19 | Group D | |
70390 | 8 | Group E | |
17882 | 15 | Group E | |
65415 | 1 | Group E | |
97033 | 4 | Group E | |
57637 | 11 | Group E | |
41411 | 18 | Group F | |
91239 | 8 | Group F |