Flexmonster Aggregations Made Simple
One of the most powerful features of our pivot table is a wide variety of aggregations. You have two options for applying aggregations: via UI or code. Let’s look at the advantages and disadvantages of both of these methods:
- UI: here, you can do it easily, even if you have no prior coding experience. All you need to do is go to Fields on the Toolbar and set it up. Also, it’s quite intuitively understandable for users.

- Code: at first sight, it may seem complicated, but in reality, it isn’t. In the slice part of the report, you need to include measures, and after it, set all required parameters.
slice: {
…
measures: [
{ uniqueName: "title", aggregation: "count" },
{ uniqueName: "title", aggregation: "distinctcount" },
…
]
},
Let's take a look at the hands-on example for better understanding!
Have you heard about Goodreads? If you enjoy reading, then probably yes. So, today we will explore the “Goodreads-books” dataset. I built an easy-to-use dashboard where rows are displayed by the author of the book, the publisher that published it, and the exact title of each book. Additionally, I added some styling there, and now I think that if Goodreads were to add analytics, this is exactly how it would probably look. Moreover, Flexmonster offers 10 built-in themes, allowing you to select the one that best suits your needs. Haven't found the one? Not a big deal, you can create your own.
And look! In this dataset is my favourite book series, “Harry Potter” by J.K. Rowling. I'm sure you've all definitely heard about the boy who grew up to change the fate of the entire wizarding world. So, let’s learn more about it!

First, I want to check how many books by J.K. Rowling are in our dataset, but we have two aggregations for this: count and distinct count. But what is the difference? It’s pretty easy to explain:
- Count: shows how many times this author’s books appear in the dataset. If the book was republished with some fixes or exclusive covers, this number can include the same book more than once.
- Distinct count: indicates the number of unique books this author has in the dataset. Each book is counted only once, even if it appears multiple times because of other publishers.
Both of them are pretty easy to set in the code inside the measures section:
measures: [
{ uniqueName: "title", aggregation: "count" },
{ uniqueName: "title", aggregation: "distinctcount" },
…
],

We can notice that these amounts are the same, so there are no book repetitions. But not all authors show the same results. For example, we can see that the value of count and distinct count are different for Adam Hochschild, because his book “Bury the Chain” was published by Macmillan and Mariner Books:

Okay, let’s get back to J. K. Rowling’s books. Now I want to evaluate her popularity. For this, I will use sum and average aggregations.
- Sum: shows the total number of users’ voices
- Average: counts the average rating given by users.

By the way, have you ever wondered what the shortest and longest books written by J. K. Rowling are? And on average, how many pages do they have? For this, we will use min, max, and median aggregations.
But wait, wait, I guess you have a question: “Why median and not average?” The thing is, the diapason of pages can be quite big, for example, from 100 to 1000. The average can be misleading if there are very short or very long books. Median shows the middle value, which tells us what a typical book length is.
So, the median gives a better idea of how long a regular J. K. Rowling book usually is.

But how popular are her books in comparison with all other books on Goodreads? Percent aggregation will help us to compare. It shows the portion of all votes in the dataset that went to J.K. Rowling’s books. This way, we can quickly understand how much attention her books are getting compared to others.

And for sure, these aren’t all the aggregation options we have for you. For more advanced analytics, we recommend checking our aggregations documentation.
So go ahead, experiment with aggregations and switch up your perspective. Just a few clicks or lines of code can transform raw numbers into powerful insights, meaningful trends, and show hidden patterns.