1 Reply Latest reply on Feb 23, 2016 11:32 AM by pooja.gandhi

    % by product type and state.

    David Trueblood

      I have a two column text table.  The first column has state.  In the second column I want to calculate the percentage of a particular product type versus the overall number of products by that state.  For example:

       

      AZ has 5 Type 1 products and 25 total products.  I want my chart to look like:

       

      AZ 20% (representing the % of Type 1 products)

      CO 20%

      CA 15%

      etc..

       

      I know this should be a relatively easy thing to do but i cannot for the life of me figure this out.  I have been playing around with a calculate field and I am getting some very strange results. 

       

      For example, if I do a simple calculation like 1 / total products, Tableau is giving me the total number of products instead of the actual calculation of .04

       

      Any help would be greatly appreciated.  Thanks.

        • 1. Re: % by product type and state.
          pooja.gandhi

          David,

           

          Which version of Tableau are you using? If you are on 9.0 or higher you can do this with LODs: Something along these lines:

           

          { fixed [State], [Type] : sum(if [Type] = 'Type 1' then [Number of Records] end )} / { fixed [State] : sum([Number of Records]) }

           

          If this doesn't work or if you are not on version 9.0 or higher, I recommend attaching some sample rows of your data.