Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
check out this: Buckets
Create a Bucket Like this and then use that Bucket as a Dimension with required expression?
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
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.
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.
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,
If(Distance>5 and Distance<=10, 3))) as code //in your load statement
Dimmension:
Load * inline [
Code, Desc
1, <1KM
2,<1-5KM
3, <6-10KM
];
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')))
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')))