This content has been marked as final.
Show 2 replies
-
1. Re: How to create N classes with the same number of elements ?
Esther AllerJan 21, 2016 3:14 PM (in response to Batiste Roger)
1 of 1 people found this helpfulHi Batiste,
I created evenly sized bins using an IF THEN statement that compares the index value of a number to total number of items. The following instructions will create a histogram of [Sales] in the sample data set Superstore with evenly sized bins:
- Create a calculated field with a name like "Bin Size" with a calculation similar to the following:
WINDOW_SUM( COUNT( [Sales] ))
/
10 - Create a calculated field with a name like "Evenly sized bins" with a calculation similar to the following:
IF INDEX() < [Bin Size]
THEN "Group 1"
ELSEIF INDEX() < [Bin Size] * 2
THEN "Group 2"
ELSEIF INDEX() < [Bin Size] * 3
THEN "Group 3"
ELSEIF INDEX() < [Bin Size] * 4
THEN "Group 4"
ELSEIF INDEX() < [Bin Size] * 5
THEN "Group 5"
ELSEIF INDEX() < [Bin Size] * 6
THEN "Group 6"
ELSEIF INDEX() < [Bin Size] * 7
THEN "Group 7"
ELSEIF INDEX() < [Bin Size] * 8
THEN "Group 8"
ELSEIF INDEX() < [Bin Size] * 9
THEN "Group 9"
ELSE "Group 10"
END - Drag [Evenly Sized Bins] to the Columns shelf
- Drag [Sales] to the Rows shelf
- Right-click on Sales on the Rows shelf and select Measure > Count
- In the Analysis menu, uncheck Aggregate Marks
I hope this answers your question!
- Create a calculated field with a name like "Bin Size" with a calculation similar to the following:
-
2. Re: How to create N classes with the same number of elements ?
Batiste Roger Jan 22, 2016 5:56 AM (in response to Esther Aller)Awesome !
Still a bit more complex than it should (I'm sure it will ship in a future version), but completely fine.