5 Replies Latest reply on Jan 25, 2017 9:01 AM by Yuriy Fal

    Fixed number of bins in a histogram in Tableau 10

    Christian Schwehm

      Hi all,

       

      I really like tableau, but I just do not succeed in two things:

       

      1. I want to have a parameter that defines the number of bins Tableau should use in a histogram, I just get the option to select the size of each bin. Is there a way to get a slider to select the number of bins?

      2. Is ist possible to have a parameter to exclude the top and bottom x percent of data from the histogram, so that you do not have to bother to much about outliers?

       

      A Workbook is attached :-)

       

      Thanks for your help !!

        • 1. Re: Fixed number of bins in a histogram in Tableau 10
          Stoyko Kostov

          Hi Christian,

           

          1. For your Number of bins question, my suggestion is not elegant. You can go the following way:

          • Define a calculated field BinSize as follows - ({FIXED:MAX([Werte Faktor 1])}-{FIXED:MIN([Werte Faktor 1])})/[Bins]
            • Note that it uses LOD to ensure MAX and MIN are calculated for the entire data, not per current partition.
          • Define a parameter BinSizeParam of type Float, choose List for allowable values, and then use the "Add from Field" button to add the BinSize you computed above. Find it under the second data source - EQ...
          • Use this parameter to define the Werte Faktor 1 (Partition): set the bin size to BinSizeParam.
          • The problem with this suggestion is that if you change the [Bins] parameter, this change doesn't cascade to BinSizeParam. You would need to manually recompute , editing the definition of the parameter BinSizeParam. Then it would automatically update Werte Faktor 1 (Partition).

           

          2. For the exclusion of the outliers, I have the following suggestion. I assume the measure you want to use for discarding outliers is COUNT(Werte Faktor 1).

          Define a calculated field named ExcludeOutliersWerteFaktor1 with the following definition:

           

          IIF({FIXED [Werte Faktor 1 (Partition)]:COUNT([Werte Faktor 1])}>=

          (1-[Exclude top/bottom x percent]/100)*{FIXED:MIN({FIXED [Werte Faktor 1 (Partition)]:COUNT([Werte Faktor 1])})}

          +[Exclude top/bottom x percent]/100*{FIXED:MAX({FIXED [Werte Faktor 1 (Partition)]:COUNT([Werte Faktor 1])})}

          AND {FIXED [Werte Faktor 1 (Partition)]:COUNT([Werte Faktor 1])}<=

          (1-[Exclude top/bottom x percent]/100)*{FIXED:MAX({FIXED [Werte Faktor 1 (Partition)]:COUNT([Werte Faktor 1])})}

          +[Exclude top/bottom x percent]/100*{FIXED:MIN({FIXED [Werte Faktor 1 (Partition)]:COUNT([Werte Faktor 1])})}

          ,true,false)

           

          This may be complicated to comprehend, but here's the logic. You want your counts to fall in the following interval - (1-x)*min+x*max through x*min+(1-x)*max, where x is the percentage range and min, max are the absolute min and max on your scale. The LOD expressions are needed so that computations are carried either across the board, or within the partition.

           

          For example: {FIXED [Werte Faktor 1 (Partition)]:COUNT([Werte Faktor 1])}) calculates the count per partition, and the outside LOD, with empty FIXED clause, calculates the MIN or MAX across all partitions, respectively.

           

          Once you have this calculated field defined, drag it to Filter, and choose "True". This will discard the outliers from the chart.

           

          I'm attaching the workbook I produced. Hope this helps - let me know if you have more questions.

          1 of 1 people found this helpful
          • 2. Re: Fixed number of bins in a histogram in Tableau 10
            Christian Schwehm

            Hello Stoyko,

             

            thanks for your great answer :-)

             

            Regards

            • 3. Re: Fixed number of bins in a histogram in Tableau 10
              Yuriy Fal

              Hi guys,

               

              I'd like to suggest a slight variation of the above.

              It allows to change # Bins dynamically.

               

              Please find the attached.

              Hope it could help a bit.

               

              Yours,

              Yuri

              1 of 1 people found this helpful
              • 4. Re: Fixed number of bins in a histogram in Tableau 10
                Christian Schwehm

                Hi Yuriy,

                 

                I think you just forgot the workbook - as I do not see it :-)

                 

                Curious to see your suggestion!!

                • 5. Re: Fixed number of bins in a histogram in Tableau 10
                  Yuriy Fal

                  Hi Christian,

                   

                  To see the workbook, you'd like to go

                  to the thread page in the Forums --

                  by the link named View the full discussion.

                   

                  There is no attachments in email.

                   

                  Yours,

                  Yuri