Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
kpradeep5610
Contributor III
Contributor III

Class Function

In Qlik Sense Web  in pivot chart , I want to display project allocation from 

0-10

10-20

-

-

90-100.

 

For that I'm using the class() , it shows me last line like 100 -110 , but I don't want to display this one 

my expression is :     Replace(Class([AAFD Allocation],10),'<= x <','-')

 
 
1 Solution

Accepted Solutions
Kushal_Chawda

If this is the fix buckets then better to create custom field in script if class function did not work as expected

Pick(Match(-1, 
[AAFD Allocation]>=0 and  [AAFD Allocation]<=10, 
[AAFD Allocation]>11 and  [AAFD Allocation]<=20, 
[AAFD Allocation]>21 and  [AAFD Allocation]<=30,
[AAFD Allocation]>31 and  [AAFD Allocation]<=40, 
[AAFD Allocation]>41 and  [AAFD Allocation]<=50, 
[AAFD Allocation]>51 and  [AAFD Allocation]<=60, 
[AAFD Allocation]>61 and  [AAFD Allocation]<=70,
[AAFD Allocation]>71 and  [AAFD Allocation]<=80, 
[AAFD Allocation]>81 and  [AAFD Allocation]<=90, 
[AAFD Allocation]>91 and  [AAFD Allocation]<=100),
'0-10','11-20','21-30','31-40','41-50','51-60','61-70','71-80','81-90','91-100') as Bucket,

View solution in original post

5 Replies
MayilVahanan

Hi 

Try like this

=Replace(Class(Row,10,'x',1),'<= x <','-')

Class function Def:

The class function assigns the first parameter to a class interval. The result is a dual value with a<=x<b as the textual value, where a and b are the upper and lower limits of the bin, and the lower bound as numeric value.

Class([AAFD Allocation],10) with v[AAFD Allocation]=100, its fall under 100-110. 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
kpradeep5610
Contributor III
Contributor III
Author

Hi,

In last line I am getting 91-101, but as I told I want to display the data like 

0-10

10-20

-

90-100

like this 

 

tresesco
MVP
MVP

This happens because, the upper limit in class() is (less than) and NOT <= (less that equal), therefore for last value 100, it becomes part of 100-110 class. You can tweak your expression like:

=Replace(Class(if([AAFD Allocation]=max( {1}total [AAFD Allocation]), [AAFD Allocation]-0.1,[AAFD Allocation]),10),'<= x <','-')

However, this is logically not right, i.e. - the classes would be overlapped in display. So I would not recommend this solution.🤔

Kushal_Chawda

If this is the fix buckets then better to create custom field in script if class function did not work as expected

Pick(Match(-1, 
[AAFD Allocation]>=0 and  [AAFD Allocation]<=10, 
[AAFD Allocation]>11 and  [AAFD Allocation]<=20, 
[AAFD Allocation]>21 and  [AAFD Allocation]<=30,
[AAFD Allocation]>31 and  [AAFD Allocation]<=40, 
[AAFD Allocation]>41 and  [AAFD Allocation]<=50, 
[AAFD Allocation]>51 and  [AAFD Allocation]<=60, 
[AAFD Allocation]>61 and  [AAFD Allocation]<=70,
[AAFD Allocation]>71 and  [AAFD Allocation]<=80, 
[AAFD Allocation]>81 and  [AAFD Allocation]<=90, 
[AAFD Allocation]>91 and  [AAFD Allocation]<=100),
'0-10','11-20','21-30','31-40','41-50','51-60','61-70','71-80','81-90','91-100') as Bucket,
AshrafTai
Contributor II
Contributor II

i think you are missing out on some numbers. in the below 11 is missed out

[AAFD Allocation]>=0 and  [AAFD Allocation]<=10, 
[AAFD Allocation]>11 and  [AAFD Allocation]<=20,