
Setup
To build this chart you will need to structure your query with the cohorts as the rows and the time passed as the pivot. A calculation is used to pull the cohort size out of the pivot. Additional calculations are necessary to figure out how to color each cell. Weโll also need the column totals enabled. The following table explains each field used in the example, including the calculation formulas.| Col | Name | Description or formula | Purpose |
|---|---|---|---|
| A | Monthly cohort | query field | A row for each cohort, sorted with the oldest at the top |
| B | Users Count | query field | Count of users in the cohort (inside pivot) |
| C | Customers | =PIVOTOFFSET(B1, 0, 0) | First column of users count is the size of the cohort |
| D | Sales | query field | Total sales for the cohort (inside pivot) |
| E | Sales (row max) | =MAX(PIVOTROW(D1)) | Maximum sales value for the row - set total calculation to maximum |
| F | Sales (row non-zero min) | =IFERROR(MINIFS(PIVOTROW(D1), PIVOTROW(D1), โ>0โ), 0) | Minimum non-zero value for the row. If row is all zeros, will set to 0. Set total calculation to minimum |
| G | pct | =(D1 - F_TOTAL) / (E_TOTAL - F_TOTAL) | how close to the max value is the current cell - will be a value between 0 and 1 where 0 is the overall min sales value, 1 is the overall max value |
| H | bucket | =IF(G1 <= 0.167, โbucket1โ, IF(G1 <= 0.333, โbucket2โ, IF(G1 <= 0.5, โbucket3โ, IF(G1 <= 0.667, โbucket4โ, IF(G1 <= 0.833, โbucket5โ, โbucket6โ))))) | string to identify bin for coloring |
- column D - Sales - to be
maximum - column E - Sales (row max) - to be
maximum - column F - Sales (row non-zero min) - to be
minimum
