Quicksight: Sum values from the unique fields where dimension is date range and show unique values for fields which are duplicating the rows when using the filter

I want to create a clustered bar combo chart where on:

  • x axis i have date range (date field)
  • bars i have active field (sum)

The goal is to sum over date range.
However, my dataset contains duplicate rows which are created by addition of group and division fields ( many-to-many relationship with owner_id field ).

I have approached this issue from two angles (please see image attached):
First approach:
In SQL I ranked the rows in order to identify duplicated rows created from addition of group and division fields and whenever rank is > 1 I replace duplicated values in the active field with 0.
Then in the QS visual layer I choose SUM on active field and on x axis we choose date field.
What happens: Ofc SUM works as expected BUT I have QS filter set up for group & division fields and whenever I choose group or division from the filter that WAS NOT in the row ranked as 1 (so it’s value for field active is equal 0 then I will always get 0 in the visual.
What I tried out:

  • SumIf calculated field → (sumIf(active,{rank} = 1) → this doesn’t work, if I then choose group or division in the filter which was not in the row ranked as 1 i will see no results in the visual.

Second Approach:
Instead of replacing duplicated values with 0 in the active field. I decided to keep them and I tried to create the calculated fields:

  • sumOver and max calculated field → sumOver(max(sum_active_over_date_range ) [date]) → this doesn’t work. If you then select MONTH drill up on date range (x axis), the value in the bar for a specific month will be a max value found for a day in the specific month. It doesn’t sum up values for whole month.
  • sumOver calculated field and max in the field well → sumOver({sum_active_over_date_range},[{date},{group_name},{division_name}],PRE_AGG) and then choose max in the field wells (bars) → this also doesn’t work, my results in the bars are incorrect (too high)

Hi Karolina - what if you tried sum(active)/count(active)?

Hi Jesse,

Thanks for your reply. Can you give me a bit more context why and how this would help me ?
If I sum(active) and divide by count(active) I will get incorrect output value.

Hi Karolina - sorry brain wasnt working the other day. We have a solution to this on the way. Ill reach out to you directly to discuss more. We are working on a feature that will help with this

1 Like

Ok nice.
Looking forward to hearing from you when the solution will be in GA.