Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Offset in Class()

Hello Qlikers,

Can somebody help me to find out how Offset works in Class() Function??

=Class(10,5,'X',3)

How this 3 will be used in calculation while calculating expression?

17 Replies
sunny_talwar

So I guess that your range either needs to start with offset value or end with it. I tried this:

Table:

LOAD Age,

  Class(Age, 5, 'X') as Class,

  Class(Age, 5, 'X', 1) as Class1,

  Class(Age, 5, 'X', 2) as Class2,

  Class(Age, 5, 'X', 3) as Class3,

  Class(Age, 5, 'X', 4) as Class4;

LOAD Ceil(Rand()* 99) as Age

AutoGenerate 1000;

Output:

Capture.PNG

For 1 the range start at 1, but for 2, 3, 4, it ends at the offset value. So it would depend how your underlying field data is If there were values like -1, then I would have assumed that for range 1 also it would have started like -4<=X<1

Kushal_Chawda

as You have given the offset '3' (Bucket will start from 3 if values are between 3 to 😎 else for Age 1 which is not falling in 3 so. 1-3 =-2. hence -2 to 3

Anonymous
Not applicable
Author

So, how QV decide where to start with offset value and where to end with offset value?

MK_QSL
MVP
MVP

For

Class(Age, 5, 'X', 1) as Class1

it is indeed start with -4 <=X < 1 but because you don't have 0 age, it's now showing...!

Use,

LOAD Floor(Rand()* 99) as Age

Instead of Ceil(Rand()* 99) as Age

tresesco
MVP
MVP

Offset moves the limits of interval. In Class(10,5,'X'), 5 is interval lenght and the intervals becomes like: 0-5, 5-10, 10-15, 15-20... When you put addition offset like: Class(10,5,'X' ,3), the interval starts from 0+3 to 5+3 .... i.e. 3-8, 8-13, 13-18...

Hope this helps .

sunny_talwar

Since the lowest observation is 1 there is no point doing -4<=X<1 as nothing will be included in it. So it starts from 1<=X<6. But for other options such as offset 3, it would include 1 within -2<=X<3 so it starts from there.

MK_QSL
MVP
MVP

If no offset, the first range with Start with 0

If offset, the first range will end with that offset integer...

SIMPLE !

ahbzshk07
Contributor III
Contributor III

hello Balraj!

Consider your example as

=Class(var,5,'X',3)

we see that the offset value is 3. So among all the class interval values (depending on var), 3 has to be the either limits (lower & upper) of two of the class intervals.

Now you have interval range of 5.


With these data, you get the base class interval values i.e. a set of {-2,1,0,1,2} when upper limit is 3. => i.e. -2 <= x < 3

and {3,4,5,6,7} when lower limit is 3. => 3 <= x < 7



Now that you have got the base range, you can get other class intervals on similar line.

If var=1, o/p will be 2 <= x < 3

If var=7, o/p will be 3 <= x < 7

If var=8, o/p will be 8<= x < 13


and yes, in your example var=10. so it falls in the range of 8<= x < 13


I hope this is helpful.

Regards.