KNOWLEDGE BASE

How To Control the Number of Bins using the Parameter


Published: 20 Jun 2023
Last Modified Date: 21 Jun 2023

Question

How to control the number of bins instead of the size of bins by the parameter?

Before:
User-added image

After:
User-added image

 

Environment

  • Tableau Desktop

Answer

1. Create the following parameter:

User-added image

2. Create the following calculated field [Profit bin]:

IF [Profit]>=0 THEN 

(INT([Profit]/
  ROUND({(MAX([Profit])-MIN([Profit]))/[Profit Bin Amount]})
))

ELSE 

(INT([Profit]/
  ROUND({(MAX([Profit])-MIN([Profit]))/[Profit Bin Amount]})
)-1)

END

*(ROUND({(MAX([Profit])-MIN([Profit]))/[Profit Bin Amount]}))

3. Drag [Profit bin] to [Columns] and convert it to dimension

4. Drag [Orders (Count)] to [Rows]

5. Use the parameter [Profit Bin Amount] to change the amount of bins

See the attached sample workbook. 
Did this article resolve the issue?