Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Class function with closed intervals?

Hi,

I managed to use the class function with a variable as interval.

I use only interval widths which looks good to the user.

0 - 25 ; 25 - 50 ; ... looks better than 0 - 23,46 ; 23,46 - 46,92 ...

So far so good.

But the class function returns half opend intervals [interval-start, interval-end[.

I think my user assume the behavior of closed intervals.

What I would like to do is:

Substranct the smallest unit from the interval-end and make it closed.

0 - 24,99 ; 25 - 49,99

If I could do it like that I have no data between the gap (thus use the smallest unit) and I have no overlapping data which I would have if only converting to closed intervals.

Is there a (easy) way to achieve this?

Thx in advance.

3 Replies
MVP
MVP

Re: Class function with closed intervals?

Alternative to using Class is to use if statements where you can create you own buckets:

If(Field >= 0 and Field <= 25, ...

If(Field > 25 and Field <= 50, ....

and son on...

Not applicable

Re: Class function with closed intervals?

with this manual creation it would be more difficult to use one variable calculated interval width (at least i guess it wouldn't be that easy).

but I will keep it in mind

Employee
Employee

Re: Class function with closed intervals?

You could also use

Dual(Floor(x,$(vBinWidth)) & '-' & (Floor(x,$(vBinWidth))+$(vBinWidth)-1),Floor(x,$(vBinWidth))) as Class

Here I have 1 as smallest unit, but you can of course use any number. vBinWidth is a variable containing the interval size.

HIC