Percentage Of Total For Each Row

Input collection: myFruit26

ItemQuantity
Apples30
Oranges12
Bananas27
Grapes22
Kiwis8


Output value: mySolution26

ItemQuantityPercentage
Apples3030.3%
Oranges1212.1%
Bananas2727.3%
Grapes2222.2%
Kiwis88.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%"))
);