How To: Create User Defined Buckets
This how to will describe how to setup user defined buckets. The biggest difference with predefined buckets (last how to post) is the flexibility for the end-user who can choose a variable bucket width.
I will stick with the same example: a database contains a table with data of people. The table contains an age field. The thing we want to do is divide all ages in groups with a variable bucket width:
Copy paste the following load inline in script:
People:
LOAD * INLINE
[ Name, Age
John, 17
Jack, 20
Bill, 3
Jim, 4
Lis, 60,
Lia, 80
Lara, 2
Mara, 9
Wim, 8
Frans, 13
Stef, 12
William, 26
So, 27
];
Next create a variable so the end-user can choose the width. In Qlikview, click Settings and pick “Variable Overview”
Add a new variable and name it vBucketWidth
In the main sheet, create an input box. (Right Mouse, New Sheet Object, Input Box).
Add the variable vBucketWidth, give the Input Box a name and click ok.
Finally create a chart to display the buckets.( (Right Mouse, New Sheet Object, Chart)
Give the chart a title and click next.
=class(Age,vBucketWidth)
The class function creates buckets as big as the size of vBucketWidth. Click next.
Add the expression count(Name) and click finish. (This will count how many persons are in a bucket)
Enter a bucketWidth and have fun!






koala kare baby changing station said,
nice posts and nice site Great post man! Continue the good work!
William said,
your welcome!
Add A Comment