4 Replies Latest reply on Mar 1, 2013 6:50 AM by christian.vonhehn

# percent of total by peroid

Hi Tableau Community,

this might be a simple question, if so please just refer me to appropiate post (I couldn't find any).

I have a caluclated field that converts a Boolean expression of my data ('Y' & 'N') into numbers so I get a count

[# of XYZ]:      IF [XYZ]="Y" THEN 1 ELSE 0 END

Now I would like to display [# of XYZ] as percentage of all records for a given month. Either doing it manually or with a slightly modified Quick Tabel Calculation I cannot get to work. For example, product B has 6 records total for Feb2013, 4 of those are XYZ or 66%.

The example workbook & data is attached.

Any help is appreciated. Thank you!

• ###### 1. Re: percent of total by peroid

Christian,

When you post a workbook, it is must simpler to post a .twbx file instead of a .twb.  .twbx will automatically include the data set.  That being said, I created the following calculation which seems to do what you want.

SUM( [# of XYZ] ) / COUNT( [XYZ] )

Let me know if this helps.

Thanks,

Associate Consultant

Mariner, LLC

http://breaking-bi.blogspot.com

• ###### 2. Re: percent of total by peroid

you are right on! Thanks a bunch.

This was the first time I attached a workbook, in the future I will post a .twbx file. Thanks for the pointer.

If I may ask a quick follow up question: I was trying to work with [Number of Records] as a denominator, e.g.

SUM( [# of XYZ] ) / SUM ([Number of Records] ), which clearly was wrong and didn't work. Where could I learn more about how to use the functions (especially SUM, COUNT, TOTAL, etc.) correctly? They are all briefly explained online, but I still struggle with the correct use.

• ###### 3. Re: percent of total by peroid

Christian,

These functions are passed directly to the underlying SQL.  I wish I knew of a good place to learn exactly how they work.  You can look for SQL beginner guides if you want.  What I would recommend is, go to http://www.tableausoftware.com/about/blog and sniff around for some people's blogs who may have posted something like that.

On a more forward note, I think I will create a blog post either today or tomorrow about the basic functions.  If you want, you are welcome to read it (I link it in my signature).

Thanks,

Associate Consultant

Mariner, LLC