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: 
kevbrown
Creator II
Creator II

Interval Banding

I need to create bandings in my bar chart however all the intervals are different. For example. I have a field that i want to count and put into bandings of - 1,2,3,4,5,6,7, 8-14, 15-21, 22-28, 29 days - 6 months, 6 months - 12 months and > 12 Months

How do i do that?

Kev

1 Solution

Accepted Solutions
Not applicable

Kevin,

This can be achieved using IF statement or Interval Match.

IF Statement:

If(FieldName)<=BandValue1,'BandValue Name1',

      If(FieldName)<=BandValue2,'BandValue Name2',

                If(FieldName)>BandValue3,'>BandValue Name3'))) as [BandingField],

Use logical operator depending on you requirement.

Interval Match:

[Banding Table]:

LOAD * INLINE [

    Banding Group, Start, End

Use Band range values here

];

IntervalMatch(FieldName)

load

Start,End

Resident [Banding Table];


Regards,

Sridhar

View solution in original post

6 Replies
datanibbler
Champion
Champion

Hi,

you can use the IntervalMatch() function for that.

Look it up in the help_file.

It's actually a two-step approach:

- First you LOAD a little inline_table holding your intervals (with the IntervalMatch() prefix)

- Then you can join those intervals to your actual fact table.

=> Then you can use the interval as a dimension in a barchart or whatever.

HTH

buzzy996
Master II
Master II

u can define based on ur conditions  one if else case in ur script and label as entire if else statement under one label and u can use that label as ur dimension in ur bar chart.

Not applicable

hi,

Resolved it by using an if condition in the load script

Not applicable

Kevin,

This can be achieved using IF statement or Interval Match.

IF Statement:

If(FieldName)<=BandValue1,'BandValue Name1',

      If(FieldName)<=BandValue2,'BandValue Name2',

                If(FieldName)>BandValue3,'>BandValue Name3'))) as [BandingField],

Use logical operator depending on you requirement.

Interval Match:

[Banding Table]:

LOAD * INLINE [

    Banding Group, Start, End

Use Band range values here

];

IntervalMatch(FieldName)

load

Start,End

Resident [Banding Table];


Regards,

Sridhar

kevbrown
Creator II
Creator II
Author

Thanks, the IF statement works. Just a quick question.  For 1,2,3,4,5 it works fine. What if I want banding for 8 days to 14 days for example.  So I'd have 1,2,3,4,5,6,7, 8-14 etc

Kev

Not applicable

Kevin,

use the below statement:

If(Ceil(FieldName)>=8 and Ceil(FieldName)<=14, '8-14BandValue Name')  as  [BandingField]

use Ceil function if necessary.

Regards,

Sridhar