ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Number of entries as a percentage

October 18, 2011 12:04pm

Subscribe [2]
  • #1 / Oct 18, 2011 12:04pm

    davewilkinson

    1 posts

    I have set up 6 categories and each entry from my ‘contacts’ channel will be in 1 of these categories. I’m trying to display information on the number of entries in each category as a percentage.

    e.g. if there are 100 entries in total, my category list would look something like this:

    Category 1: 50% ~ 50 of the 100 entries are filed under category 1
    Category 2: 40%
    Category 3: 0
    Category 4: 10%

    I’m able to loop through the categories and display all 6 of them, but the calculation has me baffled. Any ideas?

    I’m new to EE so I may have searched incorrectly. Sorry if this has already been discussed.

  • #2 / Oct 18, 2011 2:22pm

    John St-Amand

    865 posts

    You could likely use the Simple Math add-on to perform the percentage calculation for you based on the totals you pull for an individual category and the total entries.  Pass the add-on those variables and it would calculate them in-template.

    Hope that helps.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases