# Grouped Running Totals

**URL:** https://community.omni.co/t/grouped-running-totals/63
**Category:** Workbooks
**Tags:** calcs, formulas
**Created:** [May 15, 2024, 5:22pm UTC](https://community.omni.co/t/grouped-running-totals/63 "2024-05-15T17:22:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![colin](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.omni.co/colin/32/112_2.png) [@colin](https://community.omni.co/u/colin)
#### Post date: [May 15, 2024, 5:22pm UTC](https://community.omni.co/t/grouped-running-totals/63/1 "2024-05-15T17:22:39Z")

</div>

Running totals are one of the most common reporting use cases, but can be tricky when exploring across multiple dimensions. This article presents a quick pattern for running totals inside sub-groups, with and without pivots.

Let’s take a data set with two dimensions, `traffic_source` and `gender`, and a single measure, `count`:

 ![Screenshot 2024-05-15 at 10.17.42 AM](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/ac826563f40f0fb423030feda28e1fef89f64964.png)

If we naively add a `running_total` the data will aggregate across both male and female, but we may want to understand the trends inside each.

The simplest option is to pivot our data set and then add a quick calculation for running total:

 ![Screenshot 2024-05-15 at 9.14.25 AM](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/66308fa9b35148617538d40b816ed66a77d07322.png)  
 ![Screenshot 2024-05-15 at 9.14.14 AM](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/fd6d2506849f23e757e47dceaef4903df61a53c6.png)

Be using clever calculations, we can also do the same calculation in the denormalized data set. Here we will use a moving `SUMIF` to calculate the `SUM` below a given field. We can subtract this from the total to then calculate a moving average, `=SUMIF(B:B, B1, C:C) - SUMIF(B1:B100, B1, C1:C100) + C1`. Note how the SUMIF is moving row-by-row in the second image, while the base total remains locked to the full series:

 ![Screenshot 2024-05-15 at 9.13.59 AM](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/d33bdb7c1f00136ab3565f9342e9431e2af84c11.png)

 ![Screenshot 2024-05-15 at 10.22.27 AM](https://canada1.discourse-cdn.com/flex004/uploads/omni/original/1X/3dd7ef5729bab6a44522782258a0edc45fcc8591.png)
