SumOver Distinct Values

First create a calculated field for the year like this:
year = truncate(‘YYYY’, {budget_period})

Looking at the data, it’s clear that there are duplicates but you want your sum to be 100 + 250 + 12000 + 1000 + 1900 = 15250.

First you need a way to exclude the duplicates:
min({total_leader_budget_year}, [{leader}, {year}])

This is basically telling Q to take the min of {total_leader_budget_year} for every combination of {leader} and {year}.

Then wrap this min in a sum to get your final result:
sum(min({total_leader_budget_year}, [{leader}, {year}]))

3 Likes