There might be a simple solution. Can you post your Calc where you getting an error?
You can use a pareto chart to get the desired result.
I have attached a gif file to explain the same .
I have used the sample superstores data and what we can see from the final output is that 30% of the state are giving 80% of the sales.
Please let me know if you are not able to follow.