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: 
Not applicable

Qlikview Class function

Hello All,

I have one question.

I have age wise sales and age is between 18 , 19 , 20, 21, 22, 23,- - - - - 57. and I need to create dynamic bucket based on the interval input by user in input box. but whatever input user select my bucket always start with minimum age (18) and end with maximum age(57) in our case.

I have tried Class function like  class( var,10,'x',Input Variable ) but some how the movement I select different input variable it change the first bucket and it start from different no not from 18(Min) value.

So I want to set the min and max limit of my bucket. Is there any way

Ist case: If my input value is =2

Output should be

18-20 = 4

21-23 = 6

24-26 = 8

28-30 = 10  and so on

2nd case : if my input value is 3

Output should be

18-21 = 5

22-24 = 7  whatever sales @data is entered.


2nd case : if my input value is 5

Output should be

18-22 = 9

23-27 = 12  whatever sales data is entered.

You can simple create sample data with 2 columns age and sales in excel.

That would be really helpful.

Thanks in advance.

1 Solution

Accepted Solutions
JonnyPoole
Former Employee
Former Employee

Lets say your class function is like this:

=class( Age, $(vRange),'x')

add a 4th argument which defines the offset or starting position. Use the min value of the selected Age range as the offset, or even the global (disregards selection) min value of the age as follows:

=class( Age, $(vRange), 'x', min( total Age) )

or

=class( Age, $(vRange), 'x', min( {1} total Age) )

View solution in original post

3 Replies
JonnyPoole
Former Employee
Former Employee

Lets say your class function is like this:

=class( Age, $(vRange),'x')

add a 4th argument which defines the offset or starting position. Use the min value of the selected Age range as the offset, or even the global (disregards selection) min value of the age as follows:

=class( Age, $(vRange), 'x', min( total Age) )

or

=class( Age, $(vRange), 'x', min( {1} total Age) )

Not applicable
Author

Thanks Jonathan Poole,

I have tested it and It is working fine for Starting Age.

Can we also set this for Maximum age ?. not sure if that is also possible ?

Thanks

JonnyPoole
Former Employee
Former Employee

So that the last interval ends on the maximum ?

I think so, but you would have to dynamically calculate what the starting/min would be in order to achieve that because the only parameter in the class function (4th parameter) that controls this takes the starting point.

Here is the function structure from the help:  class(expression, interval [ , label [ , offset ]])


So try changing:   =class( Age, $(vRange), 'x', min( total Age) )


To:


=class( Age, $(vRange), 'x', 

max(total Age)

-

ceil( (max(total Age) - min(total Age) )  $(vRange)  *5000

)


---> this will take the max age and subract as many vRange segments as is necessary to cover the full span of data, providing a starting point that is also an even vRange increment.