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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
andreiaf
Contributor
Contributor

Quartiles QlikSense

Hello, I am quite new to Qliksense, I have a dataset and I would like to slice this dataset similar into quartiles/quintiles in order to rank my Costumers by varA. I want to know in which quartile/quintile my costumer belongs to according to my varA.

I have the following code in the chart :

 if(varA<= fractile(Total varA,0.20), 1,
if( varA <= fractile(Total varA, 0.40), 2,
if( varA <= fractile(Total varA, 0.60), 3,
if( varA <= fractile(Total varA, 0.80), 4, 5)))))

That works. I have something similar to this: 

Costumer 1      VarA              Quintile 

1                            a                      Q1

2                            b                       Q2

3                            c                        Q4

... 

However I would like to do it the the script. Is it possible? 

Labels (5)
3 Replies
Almen
Creator II
Creator II

Should work just like that.  Only have to add group by.

andreiaf
Contributor
Contributor
Author

Hello Almen, 

Thank you for your reply. 

It doesn't, I have the following error message: 'Aggregation expressions required by GROUP BY clause.'. 

I've tried to replace 'Total' by sum() but have another error message saying that nested aggregation is not possible...

Almen
Creator II
Creator II

That's why I wrote you have to add group by.

It would look like this:

Table:
LOAD
Costumer,
varA,
 if(varA<= fractile(Total varA,0.20), 1,
if( varA <= fractile(Total varA, 0.40), 2,
if( varA <= fractile(Total varA, 0.60), 3,
if( varA <= fractile(Total varA, 0.80), 4, 5))))) as Quantile
From Source group by varA, Costumer;