I see both COUNT and D_COUNT as options for aggregation. Which one should I use?
COUNT and D_COUNT, distinct count, are ways of aggregating data. Data aggregation is the process where a list of items is combined into one data point. For example, SUM is an aggregation where the listed values are added together.
COUNT counts the number of items being aggregated. D_COUNT counts the number of unique items there are being aggregated. Consider the list below.
Aggregated by COUNT on that list would give the result of 4 as there are four items. Aggregating that list by D_COUNT would give a result of 3 as two of the items are the same. The most common use for COUNT and D_COUNT in Explore is when aggregating ticket IDs. D_COUNT will make sure each ticket only shows up once, COUNT allows a ticket to be counted multiple times.
For more information on the different Explore aggregators, see the article: Choosing metric aggregators.
If a query has attributes in rows or columns, COUNT and D_COUNT are aggregated within each cell, not for the query as a whole. From the example above, imagine that "Cat," "Dog," and "Bird" are tags, and they are arranged on three tickets:
- Ticket 1: Cat
- Ticket 2: Cat, Dog
- Ticket 3: Bird
COUNT and D_COUNT for tickets both return 3 since there are three tickets. However, if tags are added under rows, the total changes:
- Cat: 2 tickets
- Dog: 1 ticket
- Bird: 1 ticket
The total is 4, even though there are only three tickets. This is because two unique tickets have the "Cat" tag. If a report has multiple rows or columns, it's possible for the sum of D_COUNT values to be higher than the D_COUNT without rows or columns.