9 Replies Latest reply on Oct 30, 2016 2:42 PM by Veronica Simoes

    Group by Type

    Braden Smith



      I'm just getting started with Tableau public and I'm trying to create a visualization that compares type of response over years...so here is what my data has:

      Year     Category

      2016     2

      2016     2

      2016     1

      2015     2

      2015     1


      And I want to show that 66% of responses in 2016 were 2 and 50% in 2015 were 1 (obviously this is a micro subset of the data), preferably in a pie display....but when I add the "category" to the column or row it wants to add it all together? How can I get the count of number of "2" or "1" results in data per year? Thanks!

        • 1. Re: Group by Type
          Andrea Shome

          Hi Braden,

          You can convert the category field to a dimension and then just do your calculation on the number of records. Putting category and year as discrete dimensions should do this, then you can bring out number of records and just do a Quick Table Calculation (Percent of Total).


          I attached my approach - hope this helps!

          1 of 1 people found this helpful
          • 2. Re: Group by Type
            Lisa Li

            Hey Braden,


            You can also try making a calc like this?

            sum(if [Category]=1 then 1)


            sum(if [Category]=2 then 1)


            This way, you can drag year to rows, then double click those measures (this will show both in text).


            Hope this helps,



            CoEnterprise | Home

            • 3. Re: Group by Type
              Braden Smith

              Andrea, I tried to download it but it wouldn't allow me to open the workbook since it was not a Tableau Public file?


              But you're saying convert Category and year to discrete dimensions, do a table calc to get total number of records for category 1 and 2?

              • 4. Re: Group by Type
                Braden Smith

                Lisa, I just tried your approach and was able to get the data in a line chart with year and totals for the categories...but it won't allow me to use a pie chart? It's greyed out...It looks to me like I should have the correct number of measures and dimensions.

                • 5. Re: Group by Type
                  Rahul Verma


                  Do you want something like this?

                  Please let me know





                  • 6. Re: Group by Type
                    Lisa Li

                    Hey Braden,


                    I think i misunderstood what you were looking for. Are you looking for something like this:


                    Is Category a dimension for you? Can you make it a dimension without affecting your other charts/views? If no, I would suggest building the pie chart like so. To get percent of total, make a quick table calculation (percent of total) and compute it using Region.


                    Otherwise, please share an image of what you're referring to.


                    Hope this helps.


                    CoEnterprise | Home

                    • 7. Re: Group by Type
                      Braden Smith

                      Yeah that is more what I am looking for! I will try that and see if I can make something similar work!

                      • 8. Re: Group by Type
                        Braden Smith

                        Ok so I converted Category to a dimension but am struggling with the table calc...I currently have this.

                        COUNT([category])/sum(if [Category]=1 or [Category]=2 then 1 end)


                        Which currently gives me a even 50% pie chart, which is because I think I am only counting two categories...how can I get total number of occurrences in the numerator for categories 1 and 2?


                        All told there are five categories, but the only two which are significant are 1,2 right now. Here is a screenshot of the pie graphs I'm talking about!


                        Screen Shot 2016-10-30 at 12.21.58 PM.png

                        • 9. Re: Group by Type
                          Veronica Simoes

                          Hi Braden,


                          Take a look if that you expect.


                          Bests Veronica

                          2 of 2 people found this helpful