I am trying to create a measure (LookML) that gives the average of funding over a three year window.
A sample of my data looks like this:
| year | person | funding |
|---|---|---|
| 2022 | Amy | 20,000 |
| 2022 | Josh | 15,000 |
| 2021 | Amy | 23,000 |
| 2021 | Josh | 11,000 |
| 2020 | Amy | 29,000 |
| 2020 | Josh | 10,000 |
I'd like the measure to produce resulting data like this:
| person | 3 year avg. funding |
|---|---|
| Amy | 24,000 |
| Josh | 12,000 |
The user would be able to pick the 3 year window using a filter, so the real data is between 1975-2023. I've tried this (below) but it's not worked.
measure: average_funding {
type: average
label: "Average funding"
sql: CASE WHEN ${year} >= CURRENT_DATE() -3 THEN ${funding} ELSE NULL END;;
}