# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
New Contributor

## Pie Chart with one column and between values

I have a column "Distance" with values like

2.758

4.474

5.807

1.167

1.411

1.506

7.335

2.02

2.572

8.684

0.066

1.074

1.26

1.335

7.335

0.902

0.932

1.506

I want to create a pie chart as >1 km,   >2 km.    >5 km.    >10km   >20km

I suppose we have to use some between/range function. Please advise how can I achieve this.

Tags (1)
7 Replies Not applicable

## Re: Pie Chart with one column and between values

check out this: Buckets

Esteemed Contributor

## Re: Pie Chart with one column and between values

Create a Bucket Like this and then use that Bucket as a Dimension with required expression?

Buckets

like?

If(Distance>0 and Distance<=1, dual('<1KM',1),

If(Distance>1 and Distance<=5, dual('<1-5KM',2),

If(Distance>5 and Distance<=10, dual('<5-10KM',3)))) as NewDim

Honored Contributor II

## Re: Pie Chart with one column and between values

Hi Hatimtaj,

There are multiple ways of acheiveing this.

1) You can so it in the script load using an if statement to categorise it.

For time intervals check this:IntervalMatch

2) Use a class() function in the script: https://community.qlikview.com/thread/87214

Thanks,

Sangram.

New Contributor

## Re: Pie Chart with one column and between values

I have dragged a pie chart on sheet and in dimension added "Distance" and in measure fx I am writing this code

If(Distance>0 and Distance<=1, dual('<1KM',1),

If(Distance>1 and Distance<=5, dual('<1-5KM',2),

If(Distance>5 and Distance<=10, dual('<5-10KM',3))))

The result are still not correct. Not sure how to work with a single field values.

Honored Contributor II

## Re: Pie Chart with one column and between values

Instead you can use this. Would be easier to make buckets:

class(Distance,5) : this will break it into 0 <= x <= 5, 6<= x <= 10 ans so on.

Or else: in your script use this:

If(Distance>0 and Distance<=1, 1,

If(Distance>1 and Distance<=5, 2,

Dimmension:

Code, Desc

1, <1KM

2,<1-5KM

3, <6-10KM

]; Not applicable

## Re: Pie Chart with one column and between values

Hi Hatimtaj,

I have loaded the values from excel.

u can write like this in editscrpit,

if(Distance>0,if(Distance<=1,' <1 KM',if(Distance>1,if(Distance<=5, '<1-5 KM','<5-10 KM')))) as Racelength

and in the Pie Chart

In Dimension  Racelength

and in the Expression

Count(if(Racelength>0,if(Racelength<=1,'<1 KM'),if(Racelength>1,if(Racelength<=5, '< 1-5 KM'),'<5-10 KM'))) Not applicable

## Re: Pie Chart with one column and between values

Hi Hatimtaj,

I have loaded the values from excel.

u can write like this in editscrpit,

if(Distance>0,if(Distance<=1,' <1 KM',if(Distance>1,if(Distance<=5, '<1-5 KM','<5-10 KM')))) as Racelength

and in the Pie Chart

In Dimension  Racelength

and in the Expression

Count(if(Racelength>0,if(Racelength<=1,'<1 KM'),if(Racelength>1,if(Racelength<=5, '< 1-5 KM'),'<5-10 KM')))