1 Reply Latest reply on Mar 6, 2018 3:47 AM by Simon Runc

    How to create user input bins as parameter for histogram in tableau?

    Manoj Prahaladarao

      I have created a histogram with one measure

      Tableau allows me create input parameter only for bin size


      I want user to input number of bins(x), which will generate x equally sized bins


      Can you guys please help me with the formula for same?!

      (Bit urgent)

        • 1. Re: How to create user input bins as parameter for histogram in tableau?
          Simon Runc

          hi Manoj,


          So one way I thought of is like this...


          (btw I've broken this into several calculations to help the understanding, but could be nested into one if your final solution)


          First I've created a field which is Sales by Customer (this isn't important, it's just an example measure to use)

          [Sales by Customer]

          {FIXED [Customer Name]: SUM(Sales)}


          I then want to get the Range of these Values

          [Range of Values: Customer Sales]

          {MAX([Sales by Customer])} - {MIN([Sales by Customer])}


          and from this I can determine the Bin Size required, based in the "Number of Bins" input from a parameter

          [Bin Size Based on Input]

          [Range of Values: Customer Sales]/[Number of Bins]


          where [Number of Bins] is a parameter.


          Then we can use this, is a Manual Bin creation formula to create the Bins

          [Sales by Customer Bin]

          INT([Sales by Customer]/[Bin Size Based on Input])*[Bin Size Based on Input]


          I've had to keep this (on the canvas) as Continuous...as we don't get the "Show Missing Values" option, as it's not a Tableau Bin...and have also used the [Bin Size Based on Input] to size the Bars (with Left Alignment) so it's clear what the user is seeing.


          Hope that's what you were after and makes sense.