Discussion Board for collaboration on QlikView Scripting.
Hi to all,
From qlikview help i knew how the ceil and floor functions works,but still i have some doubts in these two functions.
Ex1.ceil( 1.1 , 1 , 0.5 ) returns 1.5
ex2.Ceil(2.6, 0.25) returns 2.75
internally how ceil() works in above 2 examples
ex1.floor( 3.88 , 5 ) returns 0 ex2.floor( 1.1 , 1 , 0.5 ) returns 0.5 ex3.Floor(2.6, 0.25) returns 2.5
Internally how floor() works in above 3 examples.
Prior to this posting i had searched in the google,qlikview reference manual and in the book qlikview 11 for developers.But i didn't get any thing.
Can any one please helpme in the layman language as early as possible.
Thanks in advance.
Go to Solution.
ceil(x [ , base [ , offset ]])
Rounding of x upwards to the nearest multiple of base with an offset of offset. The result is a number.
ceil( 1.1 , 1 , 0.5 ) returns 1.5
Multiples of 1 are 0, 1, 2, 3, 4
If apply the offset 0.5, you get 0.5, 1.5, 2.5, 3.5, 4.5
The nearest higher number for 1.1 is 1.5 and so ceil returns 1.5
floor(x [ , base [ , offset ]])
Rounding of x downwards to the nearest multiple of base with an offset of offset. The result is a number.
floor( 3.88 , 5 ) returns 0
multiple of 5 are 0,5,10,15
In this list, the nearest lower number for 3.88 is 0 and so floor() returns 0
Hope this helps.
floor(), ceil() [and not to forget round()] all have the same possible arguments:
round( x [ , base [ , offset ]])
Rounding of x upwards or downwards to the nearest multiple of base with an offset of offset. The result is a number. If x is exactly in the middle of an interval, it is rounded upwards.
'x' is your input number. 'offset' is the number your intervals start from. base is the interval increment.
So ex2.floor( 1.1 , 1 , 0.5 ) creates intervals like [0.5, 1.5]; [1.5, 2.5]; [2.5, 3.5] ...
If your input is 1.1, the first interval is the matching one. floor() now returns the lower limit and ceil() the upper limit of the matching interval.
Hope this helps,
Good help from krishnamoorthy & swuehl .
... but with QV 11 SR2 64-bits there is a problem with Round and Floor, both not working as expected.
See Support cases 00170986 & 00170987.
I could write a little trick but of course have other problems behind!!!
As per your logic ,
Multiples of 2 are 0,2,4,6,8
If apply the offset 8 you get 8,10,12....
output will be 8 .
But i'm getting 6. Do you know why ? Am i missing anything ??
Thanks and Regards
The intervals are not only created by using positive integral numbers as factor for the increments, but also negative. So intervals start not only from 0,2,4,6,8,... but from ...-4, -2,0,2,4,6 ....
So 6 is indeed the nearest interval upper limit to 5.3.
Thanks and Perfect ..