8 Replies Latest reply on Oct 16, 2018 2:08 PM by Tyson Andrews

    Two Parameter Donut Chart Help

    Tyson Andrews

      Hello,

       

      I am building a dynamic donut chart, but need to lump anything under 2% of the total pie into an 'other' category. I am running into issue where the legend doesnt line up with the pie color. I have two parameters I need to use. Below are the calcs I am using.  I can't attach a workbook right now as it would take a lot of scrubbing, but if needed to I will do that. Dummied up data, attached below is a sample .twbx

       

       

       

      Parameters -
           'Selected Month'  - List of months

           'Pie Variables'  - To select what donut you want to see, either 1 (Device), 2  (Country) or 3 (Source.)

       

       

      Calcs -

           'Pageview Param' - IF [Selected Month] THEN [Pageviews] END

       

            'Detail for Pie' - IF [Pie Variables] = 1 THEN [Device Category]

                     ELSEIF  [Pie Variables] = 2 THEN [Source / Medium]

                     ELSE [Country]

                      END

       

      'Pie Master Calc' -

                                    IF [Pie Variables] = 1 THEN

                                        ({ INCLUDE [Detail for Pie] : SUM([PARAM Pageviews])}) / ({EXCLUDE [Detail for Pie] : SUM([PARAM Pageviews])})

                                    ELSEIF  [Pie Variables] = 2 THEN

                                        ({ INCLUDE [Detail for Pie] : SUM([Pageview Param])}) / ({EXCLUDE [Detail for Pie] : SUM([Pageview Param])})

                                    ELSE

                                        ({ INCLUDE [Detail for Pie] : SUM([Pageview Param])}) / ({EXCLUDE [Detail for Pie] : SUM([Pageview Param])})

                                    END

       

       

      'Pie Color - Master'  -

                                         IF [Pie Variables] = 1 THEN

                                             (IF AVG([Pie Master Calc]) < .02 THEN "Other"

                                         ELSE ATTR([Device Category])

                                         END)

                                         ELSEIF  [Pie Variables] = 2 THEN

                                             (IF AVG([Pie Master Calc]) < .05 THEN "Other"

                                         ELSE ATTR([Source / Medium])

                                         END)

                                         ELSE

                                             (IF AVG([Pie Master Calc]) < .03 THEN "Other"

                                         ELSE ATTR([Country])

                                         END)

       

       

       

       

      Thank you,

      -Tyson

        • 1. Re: Two Parameter Donut Chart Help
          ShivaRam Chennapragada

          Tyson, I have a similar logic I use to group items into 'Others' category and works for me, I've modified yours accordingly see if it works for you.

           

            IF [Pie Variables] = 1 THEN

                                                 (IF ({FIXED [Device Category]: AVG([Pie Master Calc]) })< .02 THEN "Other"

                                             ELSE ATTR([Device Category])

                                             END)

                                             ELSEIF  [Pie Variables] = 2 THEN

                                                 (IF ({FIXED [Source / Medium]: AVG([Pie Master Calc]) }) < .05 THEN "Other"

                                             ELSE ATTR([Source / Medium])

                                             END)

                                             ELSE

                                                 (IF ({FIXED[Country]: AVG([Pie Master Calc]) }) < .03 THEN "Other"

                                             ELSE ATTR([Country])

                                             END)

          • 2. Re: Two Parameter Donut Chart Help
            Tyson Andrews

            Hi ShivaRam,

             

            I first want to thank you so much for your time!

             

            I am getting a  "Cannot Mix Aggregate and non-aggregate comparisons or results in 'IF' expressions" error. I'm not really sure why?

             

            Thank you!

            -Tyson

            • 3. Re: Two Parameter Donut Chart Help
              ShivaRam Chennapragada

              Tyson- Change the position of AVG like this,

              (IF AVG({FIXED [Device Category]: [Pie Master Calc] })< .02 THEN "Other"  ELSE ATTR([Device Category]) END)

              or

              (IF AVG({FIXED [Device Category]:SUM( [Pie Master Calc] )})< .02 THEN "Other"  ELSE ATTR([Device Category]) END)

               

              and do this to other IF statements as well and see if it works.

              • 4. Re: Two Parameter Donut Chart Help
                Tyson Andrews

                ShivaRam,

                 

                Thank you for your reply.

                 

                The first Iteration had the LOD must be aggregate, and the second still has the issue of not grouping them.

                 

                Thanks,

                -Tyson

                • 5. Re: Two Parameter Donut Chart Help
                  ShivaRam Chennapragada

                  Any possibility that you could mock up some data and attach a packaged workbook?

                  • 6. Re: Two Parameter Donut Chart Help
                    Tyson Andrews

                    Hi ShivaRam,

                     

                    I dummied up some data and attached a .twbx

                     

                    I am still having the issue where the legend is not bucketing into the 'other' category.

                     

                     

                    Thank you!

                    -Tyson

                    • 7. Re: Two Parameter Donut Chart Help
                      ShivaRam Chennapragada

                      Tyson,

                       

                      Everything just returns 1, I'm not sure how to test it. But I've modified the calc and labeled it "Tableau Forum Test - SR". Try this with your Live data and see.

                       

                      Best,

                      Shiva.

                      • 8. Re: Two Parameter Donut Chart Help
                        Tyson Andrews

                        Thank you!

                         

                         

                        It looked like pie master was working so I dropped the fixed avg  on  Forum test - SR - 1st this (count) to -

                         

                        CASE [Pie Variables] WHEN 1 THEN

                         

                         

                                                           (IF [Pie Master Calc] < .02 THEN "Other"

                                                           ELSE [Device Category]

                                                           END)

                                                           WHEN 2 THEN

                                                          (IF [Pie Master Calc] < .05 THEN "Other"

                                                           ELSE [Source / Medium]

                                                           END)

                                                          WHEN 3 THEN

                                                          (IF [Pie Master Calc] < .03 THEN "Other"

                                                           ELSE [Country]

                                                           END)

                         

                         

                        END

                         

                         

                        And it worked. Appreciate your time!

                        Thank you!