Filtered row summary

Rows that aren't adequately aggregated to protect end-user privacy, or don't meet Ads Data Hub's other privacy checks, will be dropped from the results of a given query. You can configure a filtered row summary in analysis queries to return a single row containing constants and sums from dropped rows. This can help prevent discrepancies in your data totals, such as a total impression or total click count. A filtered row summary is enabled by default for new analysis queries created using the UI. Filtered row summaries don't apply to audience queries. Queries created using the API don't have a filtered row summary enabled by default.

Example

In the following example, the rows containing campaigns 124 and 125 would be filtered, as they don't meet the 50-user aggregation requirement.

Campaign ID Users
123 400
124 45
125 6

However, using a filtered row summary, the filtered data can be combined to meet the 50-user aggregation requirement. This example uses a sum to tally filtered data, and a constant to label the row:

  • A sum that aggregates filtered data from the Users column.
  • A constant (used to label the filtered row summary), set to "Filtered row summary" in the Campaign ID column.
Campaign ID Users
Filtered row summary 51
123 400

Automatic mode

We recommend using automatic mode. By default, Ads Data Hub automatically enables and configures a filtered row summary for new queries created using the UI. As you edit the query, Ads Data Hub will automatically adjust the configuration, based on the selected columns.

  • To view the automatically configured settings when viewing a report, click edit Edit. The configuration is read-only.
  • To disable automatic mode, click the Automatic toggle to the off position. The current configuration is retained and automatic mode is disabled. You must save your query to retain the change.
  • To enable automatic mode, click the Automatic toggle to the on position. You must save your query to retain the change.
  • To toggle automatic mode with the API, use generateFilteredRowSummaryAutomatically.

Manual mode

We recommend using automatic mode. To manually add a filtered row summary to a saved query, or after disabling automatic mode:

  1. In Ads Data Hub, open the Reports page.
  2. Click the name of the report you want to edit.
  3. Click edit Edit next to Filtered row summary automatically generated.
  4. Click the Automatic toggle to the off position. Note: When automatic mode is disabled, the current configuration is retained. Edit or delete these rules as needed.
  5. Aggregate a column using a sum. Note that if the sum falls below aggregation thresholds, the filtered row summary will be dropped.
    1. Click Add rule
    2. Enter the name of the column to aggregate in the Column name field.
    3. Select Sum from the Type list.
  6. Add a label for the filtered row summary using a constant. Your constant must be a valid data type for your chosen column.
    1. Click Add.
    2. Decide in which column of the filtered row summary you want the identifier to appear, then enter the name of that column in the Column name field.
    3. Select Constant from the Type list.
    4. Enter a helpful identifier for the row, such as "Filtered row summary", in the Specify constant field.
  7. Click Done.
  8. Click Save to commit your changes.

Manual mode with multiple tables

We recommend using automatic mode. If you are exporting multiple tables using the in-sql syntax introduced in Exporting multiple tables, then you can add a filtered row summary in the column options:

CREATE TABLE `myproject.mydataset.mytable` (
    campaign_id INT64 OPTIONS(merge_constant=0),
    ct INT64 OPTIONS(merge_type="SUM")
  )
OPTIONS(privacy_checked_export=true) AS
SELECT campaign_id, COUNT(*) AS ct GROUP BY campaign_id;
    

This will produce a result table with a filtered row summary where the campaign_id is 0 and ct will be the sum of rows that were filtered from the result due to privacy checks.

The available column options for filtered-row summary are:

  • merge_type="SUM": Outputs the sum of filtered values in the summary row.
  • Valid only for numeric types.
  • merge_constant=<value>: Sets a constant value in the summary row. Must have same type as the column.
  • columns with no specified option will have NULL in the summary row.

Only one of merge_type or merge_constant may be specified. Any rules for filtered row summaries apply here, too (i.e. if the sum falls below the aggregation thresholds, the filtered row summary will be dropped).