How To: Create User Defined Buckets

Posted by William on 24/07/2009 under How To | 2 Comments to Read

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”

bucket1

Add a new variable and name it vBucketWidth

bucket2In the main sheet, create an input box. (Right Mouse, New Sheet Object, Input Box).

bucket3Add the variable vBucketWidth, give the Input Box a name and click ok.

bucket4

Finally create a chart to display the buckets.( (Right Mouse, New Sheet Object, Chart)

bucket5Give the chart a title and click next.

bucket6Add a calcultated dimension:

=class(Age,vBucketWidth)

The class function creates buckets as big as the size of vBucketWidth. Click next.

bucket7

Add the expression count(Name) and click finish. (This will count how many persons are in a bucket)

bucket8

Enter a bucketWidth and have fun!

bucket9

Add A Comment

Get Adobe Flash player