Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Karahs
Partner - Creator
Partner - Creator

Creating range in following format

hi all,

i have Some random Value and i need to create Range like -

0 - 0.1

0.2 - 0.3

0.4 - 0.5

0.6 - 0.8

0.8 - 1.0

I made Use of Class Function it gives me Following Output

0-0.1

0.1-0.2

0.2-0.3

i don not want repeated Values

Thanks,

4 Replies
sunny_talwar

You can use if statement to do it:

If(Value <= 0.1, '0 - 0.1',

If(Value <= 0.3, '0.2 - 0.3',

If(Value <= 0.5, '0.4 - 0.5',

If(Value <= 0.8, '0.6 - 0.8', '0.8 - 1.0'))))

For sorting trouble you can further add a dual function:

If(Value <= 0.1, Dual('0 - 0.1', 1),

If(Value <= 0.3, Dual('0.2 - 0.3', 2),

If(Value <= 0.5, Dual('0.4 - 0.5', 3),

If(Value <= 0.8, Dual('0.6 - 0.8', 4), Dual('0.8 - 1.0', 5)))))

Not applicable

I've been meaning to try using IntervalMatchfor this sort grouping

Am sure it would look nicer than nested IF (no idea if it would function any better!)

Anonymous
Not applicable

Intervalmatch() would not help you in creating random buckets like you asked, Either Class() or what Sunny T

suggested will work...

For more details check this as well?

Buckets

Not applicable

I like the CLASS and ROUND function - will make use of those!

I reckon ROUND is the best bet. I played around with:-

setting an Interval variable:

LET vInterval = 0.1;

Then adding the ROUND function into the load script (i used [iNum] as my number field)

ROUND(iNum-($(vInterval)/2),$(vInterval)) & ' to ' & (ROUND(iNum-($(vInterval)/2),$(vInterval))+($(vInterval)-($(vInterval)/10))) AS [iRound]

that creates groups as:

0.1 to 0.19

0.2 to 0.29

0.3 to 0.39 etc