##### Page tree

Release 9.2

Contents:

This example illustrates how you can use conditional calculation functions.

Functions:

ItemDescription
SUMIF Function Generates the sum of rows in each group that meet a specific condition.
COUNTDISTINCTIF Function Generates the count of distinct non-null values for rows in each group that meet a specific condition.

Source:

Here is some example polling data across 16 precincts in 8 cities across 4 counties, where registrations have been invalidated at the polling station, preventing voters from voting. Precincts where this issue has occurred previously have been added to a watch list (`precinctWatchList`).

totalReginvalidRegprecinctWatchListprecinctIdcityIdcountyId
73124y111
74329y211
8740 321
9830 421
62229 532
6930 632
77537y742
102549y842
78713 953
3420 1053
34239y1163
38728y1263
58259 1374
2440 1474
9406y1584
9014y1684

Transformation:

First, you want to sum up the invalid registrations (`invalidReg`) for precincts that are already on the watchlist (`precinctWatchList = y`). These sums are grouped by city, which can span multiple precincts:

Transformation Name `New formula` `Single row formula` `SUMIF(invalidReg, precinctWatchList == "y")` `cityId` `'invalidRegbyCityId'`

The `invalidRegbyCityId` column contains invalid registrations across the entire city.

Now, at the county level, you want to identify the number of precincts that were on the watch list and were part of a city-wide registration problem.

In the following step, the number of cities in each count are counted where invalid registrations within a city is greater than `60`.

• This step creates a pivot aggregation.

Transformation Name `Pivot columns` `countyId` `COUNTDISTINCTIF(precinctId, invalidRegbyCityId > 60)` `1`

Results:

countyIdcountdistinctif_precinctId
10
22
32
40

The voting officials in counties 2 and 3 should investigate their precinct registration issues.

See Also for EXAMPLE - SUMIF and COUNTDISTINCTIF Functions:

• Page:
• Page:

This page has no comments.