Finding the Percentage of a Group of Items / Total Items

390 Views Asked by At

This may sound very stupid, but my brain stuck and I can't get it Right.

What I have:

  1. 10 Categories in which a number of Items (Item1, Item2, Item3) are stored.
  2. In a Category there can be 0 or 100000 Items.

What I want:

Based on the item's in the Category, I want to find the Percentage every Category takes up.

These are the variables i have:

$category1_items    <- All items of an Individual Category
$all_items          <- All Items (#)
$all_categories     <- All Categories (#)

I need to calculate $category1_percentage (and of every other category) so that i can display the Percentage of each individual Category.

I can add any other variable i need.

Can someone help me ?

1

There are 1 best solutions below

0
On BEST ANSWER

$category1_items / $all_items $\cdot 100$