Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
aveeeeeee7en
Specialist III
Specialist 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

5 Replies
sujeetsingh
Master III
Master III

What is the needed UI output you want

aveeeeeee7en
Specialist III
Specialist III
Author

Somewhat Like this:

Gui.png

I need the Buckets to get changed on specific Selections.

aveeeeeee7en
Specialist III
Specialist III
Author

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

deepakqlikview_123
Specialist
Specialist

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

marcus_sommer

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