3 Replies Latest reply on Sep 1, 2016 6:59 AM by Andrew Watson

# Aggregation by Sum and Count

Hi,

I am having data that look like this:

type,value,year

"K",0,2014

"K",1,2015

"M",0,2014

"M",1,2014

"M",1,2015

"P",0,2014

"P",0,2015

"T",1,2014

"T",0,2015

I am making KPI / spark lines similar to this video How to Show KPIs & Sparklines in the Same Graph - YouTube

So, I need the sum of value and count of the value grouped by type to produce an output similar to this image below.

So for each "type" field, I will have the sum of "value", count of "value" and the line graph for seeing the trend over the years.

But as you can see, only the Sum of value field is displayed and I cannot bring in the grouped count when I use a similar calculated field.

Thanks,

Subha

• ###### 1. Re: Aggregation by Sum and Count

Your SUM is a window_sum currently and your COUNT is just a standard count. Change your count formula to be a window_sum and it'll work. Try this formula: WINDOW_SUM(SUM([Number of Records]))

1 of 1 people found this helpful
• ###### 2. Re: Aggregation by Sum and Count

Thanks for the quick reply. I got the answer I was looking for

I was using WINDOW_COUNT instead of WINDOW_SUM and so it didn't work. I am curious as to why WINDOW_SUM works when I am just looking for the "count" of the number of records?

I have done similar things in R,SQL but being a tableau-newbie I found it confusing that the command SUM works to calculate the actual COUNT.

• ###### 3. Re: Aggregation by Sum and Count

Counting the number of records is the same as summing the number of records. The number of records is just a 1 against each record so summing this is exactly the same as counting.

Sent from Samsung Mobile

1 of 1 people found this helpful