3 Replies Latest reply on Aug 11, 2017 9:40 AM by Jim Dehner

# Calculation to sum counts of values from two columns

Admittedly I find the calculations in Tableau at times perplexing because something that I think should be easy seems to be difficult. I think the my roadblock is that I don't understand how the partitioning works. Here is what I am trying to do, I have values in two columns and I want a combined count of the number of items in Column 1 and Column 2. I can get the counts accurately when I do COUNT of each column but when I try to sum things I don't get the numbers I expect. I have created a sample workbook in Tableau 9.3.

On my Primary Correct and Secondary Correct sheets these each have the correct counts and obviously on the Primary Incorrect and Secondary Incorrect the counts are not right. On the incorrect sheets I am not 100% sure what is causing them to be incorrect. I understand that using the Primary Issue and Secondary Issue as the Row will result in different display values such as NULL being shown but why is this changing my counts? Based on the Summary on the Total Counts page the total number of records is correct however the line items are not.

How can I get the right counts combined into a single view?

Any help would be greatly appreciated.

• ###### 1. Re: Calculation to sum counts of values from two columns

After playing with some filters in Excel I think I am starting to understand why the counts look incorrect. For example, on Secondary Incorrect, Issue 1 only has a COUNT of 1 because if you filter the data on Primary Issue = Issue 1 there is only one Primary Issue with a Secondary Issue. That is all well and good but that is not what I want, I want to show that one issue is Issue 4 and to put a bean in the Issue 4 counter.

• ###### 2. Re: Calculation to sum counts of values from two columns

Hi

I'm not certain I understand what you want

I am on a different version of tableau and yo would not be able to open the workbook

this fixed formula will give you either of the 2 screen shots          { FIXED [Primary Issue], [Secondary Issue]: countd([Secondary Issue])}

Or

This one will insert the secondary issue name  it results in a dimension

if  { FIXED [Primary Issue], [Secondary Issue]: countd([Secondary Issue])} >=1 then [Secondary Issue] else "" end

Let me know if this helps

Jim

• ###### 3. Re: Calculation to sum counts of values from two columns

sorry

It struck me you wanted to count the combinations

so the formula is { FIXED [Primary Issue], [Secondary Issue]: count([Secondary Issue])}

and the viz becomes

Or this

Jim