# Selective Aggregation

In SuperTables you can use selective aggregation to aggregate only certain rows based on a condition. Selective aggregation instead of aggregating over all rows in a group, it aggregates based only on rows where a column  has valid values, by using a flag system that can be setup by the user to determine valid values. 1 for valid values and 0 for invalid values.

&#x20;To set up selective aggregation in SuperTables, follow these instructions:

1. **Prepare Your Worksheet**: Ensure your worksheet contains atleast one column with values (e.g., 1s for rows to aggregate and 0s for rows to leave unaggregated).
2. **Set the Column as a Dimension**: Configure this column as a dimension in Tableau, and set its data type to "String".
3. **Open SuperTables Configuration**: Navigate to the SuperTables configuration settings.
4. **Assign the Aggregation Flag Column**: Select the column you want to apply selective aggregation to, and set the "Column Flag" to the column with 1s and 0s.
5. **Set Aggregation Type**: For the measure you want to aggregate, choose the "Selective Aggregation" option under the aggregation type.
6. **Apply to Multiple Columns**: Repeat the steps for multiple columns if needed, following the same process.

The video below explains the whole process for 1 column but selective aggregation can be used with multiple columns.

<figure><img src="https://content.gitbook.com/content/e2zyseN6XFBaLs6YTcnd/blobs/0diO04YePTiHhoKMj7De/Tableau.gif" alt=""><figcaption></figcaption></figure>

{% file src="<https://content.gitbook.com/content/e2zyseN6XFBaLs6YTcnd/blobs/jLcxOSAGfwhFuiu3DG6W/Tableau.mp4>" %}
