Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

aveeeeeee7en
Valued Contributor III

Bucket Creation

Hi Community

I have fields:

1) Division - OIS, PPP

2) CM_RT_Time - 0:00:42, 0:03:05, .............

3) Model Mapping - Big Machines, Small Machines

4) Flag - Metro, Remote-1, Remote-2

Out of these, I have to create Buckets. The Buckets are created on the basis of Hours.

I've created the Buckets using  AVG(CM_RT_Time) but facing some issues.

See the Snapshot for the requirement:

Bucket Creation.png

Need Script or Expression for it.

Regards

Aviral Nag

Tags (1)
5 Replies
sujeetsingh
Honored Contributor III

Re: Bucket Creation

What is the needed UI output you want

aveeeeeee7en
Valued Contributor III

Re: Bucket Creation

Somewhat Like this:

Gui.png

I need the Buckets to get changed on specific Selections.

aveeeeeee7en
Valued Contributor III

Re: Bucket Creation

Any Suggestion guys???????????

deepaktibhe
Valued Contributor

Re: Bucket Creation

Try like this

if(Hrs >= 0 and Hrs <= 2 , '0-2 Hrs',

if(Hrs >= 2 and Hrs <= 4 , '2-4 Hrs',',

if(Hrs >= 4 and Hrs <= 6 , '4-6 Hrs',)) as Hrs

Re: Bucket Creation

To create regular clusters you could use the function class(). Unregular clusters are also possible but the effort is higher because then it will be some if-loops within the function needed.

Easier is often to use a mapping with applymap(). Therefor you needed only a round function or a similar logic to create fixed values then a greater or less then isn't possible:

HourMap:

Mapping Load * Inline [

0, 0-2 Hrs

1, 0-2 Hrs

2, 2-4 Hrs

3, 2-4 Hrs

....

];

table:

Load *;

     applymap('HourMap', floor(Hrs), 'DefaultValue') as HrsCluster

....

Such mapping-tables are easily created in excel even if you have then 24 hrs.

- Marcus

Community Browser