# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
LINKEDIN LIVE: Democratizing data to enhance customer-centricity. JULY 29TH REGISTER TODAY
cancel
Showing results for
Did you mean:
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?

3 Replies
MVP

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
Author

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

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

Tags
Community Browser