# Stats reports on a per-category basis?

**URL:** https://meta.discourse.org/t/stats-reports-on-a-per-category-basis/150000
**Category:** Data & reporting
**Created:** [April 30, 2020, 11:31pm UTC](https://meta.discourse.org/t/stats-reports-on-a-per-category-basis/150000 "2020-04-30T23:31:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![shooj](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@shooj](https://meta.discourse.org/u/shooj)
#### Post date: [April 30, 2020, 11:31pm UTC](https://meta.discourse.org/t/stats-reports-on-a-per-category-basis/150000/1 "2020-04-30T23:31:42Z")

</div>

Hi folks, wasn’t able to find this discussed previously.

Is there a way to generate reports (pageviews, topics, posts) on a per-category basis?

We created a new category that’s generating interest from our community, and we’d like to see its growth curve over time as we make people aware it’s there.

Would that be possible? Could that be done by 1) customizing the stock Discourse reports UI, or 2) by using analytics tools on my end to look at the Discourse database through the API?

---

<div class="post-metadata">

### Author: ![Grayden\_Shand](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/grayden_shand/32/166586_2.png) [@Grayden\_Shand](https://meta.discourse.org/u/Grayden_Shand)
#### Post date: [April 30, 2020, 11:54pm UTC](https://meta.discourse.org/t/stats-reports-on-a-per-category-basis/150000/2 "2020-04-30T23:54:25Z")

</div>

Check out the [Data Explorer plugin](https://meta.discourse.org/t/data-explorer-plugin/32566).

You can use this to generate reports from SQL queries, here’s a query that will capture some of what you want to track.

```plaintext
-- [params]
-- date :start_date = 2020-04-01
-- date :end_date = 2020-04-29

SELECT c.id category_id, COUNT(DISTINCT(t.id)) topics, COUNT(p.id) posts, sum(p.like_count) likes, sum(p.reads) reads
FROM categories c
INNER JOIN topics t ON (t.category_id = c.id)
INNER JOIN posts p ON (p.topic_id = t.id AND p.post_type = 1)
WHERE p.created_at BETWEEN :start_date AND :end_date
GROUP BY c.id
ORDER BY COUNT(p.id) DESC

```

You can share these reports with groups via the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) UI:  
[![](https://global.discourse-cdn.com/meta/original/3X/1/0/105d438ed47fd63e2a9ab3894cee18e90d9f305b.png) ](https://dl.dropboxusercontent.com/s/z2ftyw94t7l9nvp/Screenshot%202020-04-30%2019.53.20.png?dl=0)

And it will appear in the group page like this:  
[![](https://global.discourse-cdn.com/meta/original/3X/f/d/fda5dbeca6dad491a88c2134dc81cd5f8a2703ff.png) ](https://dl.dropboxusercontent.com/s/bzym022zq642dqx/Screenshot%202020-04-30%2019.52.13.png?dl=0)

---

<div class="post-metadata">

### Author: ![cogdog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cogdog/32/116536_2.png) [@cogdog](https://meta.discourse.org/u/cogdog)
#### Post date: [March 11, 2024, 6:02pm UTC](https://meta.discourse.org/t/stats-reports-on-a-per-category-basis/150000/3 "2024-03-11T18:02:10Z")

</div>

Thanks for this, it’s exactly what I needed (and also has me digging more into what I can query). I added to the SELECT statement to get the count of replies in a topic

```
 sum(t.reply_count) replies,

```
