Input collection: myFruit26
Item | Quantity |
Apples | 30 |
Oranges | 12 |
Bananas | 27 |
Grapes | 22 |
Kiwis | 8 |
Output value: mySolution26
Item | Quantity | Percentage |
Apples | 30 | 30.3% |
Oranges | 12 | 12.1% |
Bananas | 27 | 27.3% |
Grapes | 22 | 22.2% |
Kiwis | 8 | 8.1% |
Solution code:
//Create a collection
ClearCollect(myFruit26,
{Item: "Apples", Quantity: 30},
{Item: "Oranges", Quantity: 12},
{Item: "Bananas", Quantity: 27},
{Item: "Grapes", Quantity: 22},
{Item: "Kiwis", Quantity: 8}
);
//Calculate the percentage of total code
ClearCollect(mySolution26,
AddColumns(myFruit26,"Percentage",Text(Quantity/Sum(myFruit26,Quantity)*100,"[$-en-US]0.0%"))
);