Count how many times a value appears

I have a column with different ages. I want to count the amount of time that the ages appear. E.g. a list of [12, 14, 28, 12, 14], I want to return with the values 12 = 2 times, 14 = 2 times & 28 = 1.
Any help?

Hola Alexander!

Try with it

I’d be curious about the larger context. How is your array generated in the first place, what do the numbers represent, and what will you do with the results?

Actually, I just re-read your question. Amazing how you can read something once and only take part of it in. Anyway…

If these ages are all in a single column, all you need to do is:

  • Add a multiple relation column that matches your age column with itself
  • Add a rollup column that does a count via the multiple relation column
1 Like

I also suffer this little problem often by reading some curious cases over here :woozy_face:

I have used your method. However, it doesn’t seem to work when I put it in a chart. Because I only have 2 users that are 17, but they have seemed to multiply by 2.

Yes, if you’re using the original Age column as the X-Axis on your chart, that is the expected result.

What you would need to do is massage your data a little to create a new column that only contains the unique ages. You can do that as follows:

  • Add a RowID column to your table
  • Add a Single Value column that takes the first RowID via the relation column that you created earlier.
  • Now create an if-then-else column:
    – If Single Value RowID is RowID, then Age

The result of the if-then-else column should be that you get an Age value in some rows, but not all, and there should be no duplicates.

And now you can use the if-then-else column as the X-Axis source of your chart.

1 Like

Can you help me with another thing? I’m trying hard to convert data from a website to google Sheets. I have tried a lot of things, and I want to know if it is possible. Click the link for more info.
If you succeed, I will be SO gratefull.

Link to the question: Website to google sheet - #3 by Alexander_Rubino