Count the number of times each value is in a column

Count the number of times each value is in a column

chris.cavagechris.cavage Posts: 46Questions: 12Answers: 0
edited March 2016 in Free community support

I have a datatable that has a column called 'Category'. There may be hundreds of rows. The category column only has 4 possible categories.

I want to count how many times each category is present across the whole table and store them in separate variables.

So if 'Repair' is in the column 100 times, then $repair_count = 100;
if 'Service' is in the column 50 times, then $service_count = 50;

I want to do this without having the user filter/search the column. I want to display the counts outside the table.

I've search to no avail for a clue!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    This is called "binning" - the alphabet search shows one possible way to do it. Basically you need to loop over the data and just have a counter for each option.

    Allan

This discussion has been closed.