Making Custom Bins With Measures For Discover
So I have a measure that I want to use to make bins. Discover is able to have me create bins by rank, value, category, size, parameter, etc. Still, is there a way for me to create bins by custom values?
For example,
lets say I have this grid with dimension name and measure age
Name Age
Stacy 10
John 20
Mary 30
Richard 40
.
.
.
and so forth
If I do something like bin by rank with 2 bins, I'll get
Name Bin by Age
Stacy 10-20
John 10-20
Mary 30-40
Richard 30-40
.
.
.
and so forth with 2 bins called "10-20" and "30-40".
But what I want to do instead is
Name Bin by Age
Stacy 10 to 20
John 10 to 20
Mary 30 to 40
Richard 30 to 40
.
.
.
where it takes all of the ages measures and finds out which ones are <20 and gives them the bin called "10 to 20" (and I can change this custom name and the condition (<20) whenever I want) and does the same thing for >20 and puts it in the "30 to 40" bin.
And this custom Bin by Age should be a blue chip not an orange chip.
8 replies
-
Hi ,
You can create a custom column and using the case function split the Age attribute into custom bins.For example, I created this custom column:
case( [customerProfile].[Age] < 10, "0 - 10", [customerProfile].[Age] < 20, "10 - 20", [customerProfile].[Age] < 30, "20 - 30", "30+" )
Which outputs like this in the grid:
-
Hi ,
Is it possible to implement that above but lets say age are considered measures and not a model attribute. So the custom columns has element blocks but there are only model attribute, numeric and text parameter options and the model attribute only takes hierarchies that are my dimensions (blue chip). I am unable to select any measure (orange chip) in custom columns.
-
We do this all the time. The binning effectively takes any value column and introduces it as an attribute. Create a new custom column (or virtual column in the model) and use Imbar's suggestion to create manual bins on any numeric column. This takes each transactional item and puts it into a grouping, like below. You can then slice and dice as normal with this attribute and you're done.
If you want to get really clever, parameterize your logic, so the user can change the bin sizes. It complicates things a little, but produces a dynamic bin.
case( [fact].[sales] < 10, "0 - 10", [fact].[sales] < 20, "10 - 20", [fact].[sales] < 30, "20 - 30", "30+" )
Here is an example on one of the sales samples:
case( [transactions].[Quantity] < 5, "0 - 5", [transactions].[Quantity] < 8 && [transactions].[Quantity] >= 5, "5 - 8", "8+" )