Skip to main content
Michael_Tarallo
Employee
Employee

Late last week I was working with a Qlik Sense client who wanted to classify a certain range of numeric data. Basically they described it as putting certain values into their own respective "buckets" defined by high and low values. Now when I hear "range of data" along with "classify" and "buckets" or even "grouping of data" I think of a histogram.

For the most part we know that a histogram is really nothing more than a bar chart that shows the distribution of numeric data. For example, say you want to know who your strongest customers are and you want to see how many and which customer orders have sales that fall in between a certain monetary range. We can make a bar chart act like a histogram by simply defining the bar chart’s dimension using the Class() function. Simply stated, Class() can be used to classify or group, a measure into bins defined with upper and lower limits.

The Class() function takes in a few arguments. The first argument is the actual "measure field name" you would like to count and the second argument is the interval you would like to bin by.  For example, let’s see how many customers have sales that fall within 0 and $1000. In my bar chart I define my dimension as class(Sales,1000), and for my measure I count the number of sales transaction using Count(Sales). In the final result you can see most of my sales consist of transactions that fell between 0 and $1000.

To see this in action watch this 60 second video on the topic.

Video Link : 4829

Dimension - class(Sales,1000)

Measure - count(Sales)

Final Result

For more chart functions like Class() be sure to visit our online help.

See the Qlik Sense sample provided in this post.

If using Qlik Sense Desktop please copy .qvf file to your C:\Users\<user profile>\Documents\Qlik\Sense\Apps and refresh Qlik Sense Desktop with F5. If using Qlik Sense Enterprise Server please import .qvf into your apps using the QMC - Qlik Management Console.

Regards,

Michael Tarallo (@mtarallo) | Twitter

Senior Product Marketing Manager
Qlik

Tags (1)
4 Comments
JonnyPoole
Employee
Employee

Don't forget to leverage the replace() function to further control those labels:

replace(class(Sales,1000),'<= x <','-')

labels such as  "0 <= x < 1000"   can easily be replaced with  "0-1000"

Untitled.png

589 Views
paulyeo11
Master
Master

nice and simple video

589 Views
Clever_Anjos
Employee
Employee

In my humble opinion, Class() function could be improved with 2 aditional parameters.

These parameters would set the sample outliers

Example:

class(Sales,1000,5000,30000)

this could return

< 5000

5000 <= x < 6000

6000 <= x < 7000

...

29000<= x < 30000

>30000

589 Views
paulyeo11
Master
Master

Hi Clever

Very good suggestion , if there are 3 parameter mean we can pre-define of row in the table , and can allow us set the max number. that will be very useful.

Paul

589 Views