Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Carlaf_93
Creator II
Creator II

Class function

Godd morning,

i'm trying to create a classification. I would like to have those classes:

10<=x<15

5<=x<10 

3<=x<5

1<=x<3 

0<=x<1 

with the class function i'm able to create  a class with always a predefinited range:

class( var,10 ) with var = 23    returns '20<=x<30'

How can i have those classes?

 

Thanks

1 Solution

Accepted Solutions
Vegar
MVP
MVP

Try something like this:

Class:
load
  Start,
  num(Stop - 0.000001, '0') as Stop,
  Start & '<=X<' & Stop as Class
inline [
  Start, Stop
  0,1
  1,3
  3,5
  5,10
  10,15
];

Data:
LOAD
  recno()-1 as X
AutoGenerate 17;

LEFT JOIN (Data)
IntervalMatch(X)
LOAD Start, Stop Resident Class;

LEFT JOIN (Data)
LOAD Start, Stop, Class Resident Class;

DROP TABLE Class;

View solution in original post

2 Replies
Vegar
MVP
MVP

As far as I know, you can't do that classification  using Class(). You could however use IntervalMatch() to solve your problem. 

Vegar
MVP
MVP

Try something like this:

Class:
load
  Start,
  num(Stop - 0.000001, '0') as Stop,
  Start & '<=X<' & Stop as Class
inline [
  Start, Stop
  0,1
  1,3
  3,5
  5,10
  10,15
];

Data:
LOAD
  recno()-1 as X
AutoGenerate 17;

LEFT JOIN (Data)
IntervalMatch(X)
LOAD Start, Stop Resident Class;

LEFT JOIN (Data)
LOAD Start, Stop, Class Resident Class;

DROP TABLE Class;