6 Replies Latest reply on Jul 26, 2018 8:31 AM by Mahfooj Khan

# Count of an Aggregate

Hi,  I'm a bit of a newbie on Tableau.  Can someone help

I have some data as follows

Company         Branch     Completed

Company A     Branch 1     Yes

Company A     Branch 2     Yes

Company B     Branch 3     No

Company B     Branch 4     No

Company C     Branch 5     Yes

Company C     Branch 6     No

I want to aggregate the data so i have only 1 line per Company which i have managed to do with Max function.  so

Company A          Yes

Company B          No

Company C          Yes

How do i do a count of Yes/No, i.e

Yes = 2

No = 1

Thanks

• ###### 1. Re: Count of an Aggregate

You can write an LOD expression for this
{ FIXED [Company],[Branch]: COUNT([Completed])}

Which will give you this

Thank you,

Soham

• ###### 2. Re: Count of an Aggregate

sorry Soham, i don't think i explained myself correctly.

I just want a count of how many Yes and How many No there are.  But with each supplier only appearing once, and Yes taking priority over No.

• ###### 3. Re: Count of an Aggregate

So what would  you like to display if there is 1 yes and 1 no  or 1 yes and 2 no`s ? how would you display 2 statuses on one line?

• ###### 4. Re: Count of an Aggregate

Hi,

Create a calculated field using below logic

Lets call it Company Choice:

{FIXED [Company]:MAX([Completed])}

Now drag Company field in rows shelf and then drag above calculated field after Company like this

Now your final output: Drag Company dimension to label and use COUNTD() on that to get the distinct count

You can create separate calculated field to get the count of company like this

COUNTD([Company]) and use this field on label.

Hope this will help.

Mahfooj

1 of 1 people found this helpful
• ###### 5. Re: Count of an Aggregate

Thanks Mahfooj, this worked for me.