Before you begin: In this document, only data sources are mentioned, but it applies to channels as well.
Calculating On Initial Data Set means the calculation is computed for each row of the database. Calculating On Final Data Set means the calculation is computed on data that has already been reduced through the aggregate function. Based on your calculation formula, TapClicks automatically determines where in the pipeline the calculation is computed, either before or after the data is reduced. However, there are times when you may want to override this default behavior. For this reason, the Post Aggregation option is available when you build a calculation in the Advanced Calculator.
The Post Aggregation options are:
- Auto: TapClicks uses its default logic. Based on the calculation formula, TapClicks determines whether the calculation is computed after aggregation (post-aggregation) or before aggregation.
- On Final Data Set: Overrides the automatic behavior. The calculation is computed after aggregation.
- On Initial Data Set: Overrides the automatic behavior. The calculation is computed before aggregation, for each database row.
| Note: If your calculation formula already contains a custom aggregate function, the Post Aggregation option cannot be used. |
Example 1: Calculate Click-Through Rate (CTR)
To see how this works, consider a simplified example using this database:
In this example, you create a widget grouped by campaign name and add a calculation that computes the click-through rate (CTR) as 100 * Clicks / Impressions. The standard SUM aggregate function is used when grouping clicks and impressions.
On Final Data Set Result
If the calculation is computed after aggregation (a post-aggregation calculation), the data is first grouped like this:
The calculation is then computed on the grouped data:
On Initial Data Set Result
If the calculation is computed before aggregation (a pre-aggregation calculation), it is first computed for each database row:
The AVERAGE aggregate function is then used when grouping the calculation data, which gives this result:
The two results are different, so whether the calculation is computed before or after aggregation matters. For CTR, On Final Data Set is the correct choice.
Example 2: Count Days With 100 or More Clicks
To measure campaign performance, you want to count the number of days where clicks are greater than or equal to (≥) 100. This example uses the same database and widget configuration, with a calculation defined using this formula:
| IF (Clicks >= 100) THEN 1 ELSE 0 END |
The SUM aggregate function is used in this case. With the calculation computed on the final data set, the result is:
This result is incorrect because the condition is evaluated against the total clicks for each campaign, not the clicks for each day. With the calculation computed on the initial data set, the calculation is first computed for each database row:
When the data is aggregated, the result is correct: