Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Nirpanthan
Contributor III
Contributor III

Dimension Bucket

Add a computed "ACTIVITY LEVEL" dimension for customers in:

ACTIVITY LEVEL possible values:

  • High if avg pairs / day >= 3
  • Medium if avg pairs / day >=1 and < 3
  • Low if avg pairs / day >= 0.5 and < 1
  • V Low if avg pairs / day > 0 and < 0.5
  • Inactive if avg pairs / day = 0

To compute "avg pairs / day",

  • for Compute: nb of orders / nb of days in month
    over the last completed month
8 Replies
ali_hijazi
Partner - Master II
Partner - Master II

you need first to aggregate your calculation to a dimension or set of dimensions
aggr(

if(

nb_of_Orders / nb_of_days >= 3, 'High'

,if(nb_of_Orders / nb_of_days >=1 and nb_of_Orders / nb_of_days < 3 , 'Medium'

,if(nb_of_Orders / nb_of_days  >=0.5 and nb_of_Orders / nb_of_days <1, 'Low'

,...

)))

,month)

alternatively you can use the class function but the class function gives you results over fixe-size intervals

I can walk on water when it freezes
Nirpanthan
Contributor III
Contributor III
Author

i want to do it in the dimension level ... front end i am able to achieve ..

ali_hijazi
Partner - Master II
Partner - Master II

you mean in the script?
then you need to calculate the number of orders group by customer, month
then you do the average calculation per row (customer, month)
then put the if condition to classify the result as either high, medium, low,...

I can walk on water when it freezes
Nirpanthan
Contributor III
Contributor III
Author

Yes in the script level

Nirpanthan
Contributor III
Contributor III
Author

Can you give me syntax will be so useful 

i am totally strucked 

ali_hijazi
Partner - Master II
Partner - Master II

the script would be something like this:

t1:
Load Customer, Date, count(Order_id) as [Number of Orders], Floor(MonthEnd(Date)) - Floor(MonthStart(Date)) + 1 as [Number of days in Month]
resident your_table
group by Customer, Month(Date);

 

then:
t2:
load * , if(avg>= 3, 'High', if(avg>=1 and avg <3, 'Medium',if(avg>=0.5 and avg <1, 'Low'))) as Classification

load *, [Number of Orders] / [Number of days in Month] as avg
resident t1;
drop table t1;

hope this helps

I can walk on water when it freezes
ali_hijazi
Partner - Master II
Partner - Master II

but I personally prefer doing things on the UI and keep the script as much simple as possible

I can walk on water when it freezes
Nirpanthan
Contributor III
Contributor III
Author

Explained .. Still they want from the backend even i have done Master dimension...

I am loading the data once done will update .

Thanks in advance....