# Counting from Nothing – A Double Remix (or, Partitioning via Table Calculations v2)

Over on the Tableau forums Alexander Mou answered a thread on generating a count from sparse data, and the solution he came up with is found in his blog post Dynamic Histogram Over Time. In this post I’m diving into some details of what Alexander did, coming up with a couple of alternative remixes of that solution, and describing a couple of different ways to effectively partition a table calculation via another table calculation. Read on for details!

# Bins

Easy bin building:

– select a measure
– click on Show Me!
– pick the histogram

Tableau tries to create roughly 10 bins, adds a dimension for the bin to the dimensions list
can change bin size

### Alternate for Bins (allows for reference lines on a histogram):

– Create a calculated field such as: INT([Sales]/100)*100-IIF([Sales]<0,100,0)
– Put Number of Records on Columns, calculated field on rows.
– Then can have calculated fields like: TOTAL(AVG([Sales])), TOTAL(MEDIAN([Sales])), etc.
– Will need to set Compute using to the calculated field.

Some stuff on bins & blends (might need this to pull off getting the percentile)
http://reports4u.co.uk/2011/08/17/tableau-create-bins-from-a-measure-calculated-field-pt-2/
http://www.tableausoftware.com/support/forum/topic/creating-bin-dimension-aggregated-calculated-field
http://www.tableausoftware.com/support/forum/topic/aggregating-aggregate-histograms

From Joe Mako:

BYO Bin calc:

`INT([Value]/[Bin Size])*[Bin Size]-IIF([Value]<0,[Bin Size],0)`

Manually choosing the number of bins/binning a dimension by a measure:

http://kb.tableausoftware.com/articles/knowledgebase/numberofbins

[loop category=”wikicontent” tag=”bins,bin,histogram,histograms”]
[field title] – Added [field date]
[content]
[/loop]

### Related posts:

[loop tag=”bins,bin,histogram,histograms” exclude=”this” relation=”and” compare=”not” taxonomy=”category” value=”wikicontent”]