Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
paulyeo11
Master
Master

How to round the last 2 decimal either 0.50 or 0.00 ?

Hi All

I need to make :-

71.15 to 71.50

83.34 to 83.5

95.54 to 95

Below is my expression :-

Ceil(

If( column(1)>10,Round( column(1)), column(1))

,0.5)

it does not work. hope some expert here can help me pls.

Paul

1 Solution

Accepted Solutions
Anonymous
Not applicable

if ( column(1) < 80 ,

  num(  ceil ( column(1),0.5) , '#.##') ,

  if ( column(1) < 90 ,

  num( Ceil( column(1),0.5) , '#.#')  ,

  num( Ceil(  column(1),0.5) , '#0') ) )

gives what your result for your 3 sample numbers.

But, as Alessandro says, your question is not clear, so I am not confident it is what you want.

View solution in original post

5 Replies
alexandros17
Partner - Champion III
Partner - Champion III

You are not applying the same logic to all your values,

the first two are rouded to the upper 0.5, the third to the lower;

which is the logic?

Anonymous
Not applicable

if ( column(1) < 80 ,

  num(  ceil ( column(1),0.5) , '#.##') ,

  if ( column(1) < 90 ,

  num( Ceil( column(1),0.5) , '#.#')  ,

  num( Ceil(  column(1),0.5) , '#0') ) )

gives what your result for your 3 sample numbers.

But, as Alessandro says, your question is not clear, so I am not confident it is what you want.

rbecher
MVP
MVP

Hi Paul,

I guess this is the right expression:

     If(column(1)>10, Round(column(1), 1, 0.5), column(1))

- Ralf

Astrato.io Head of R&D
rbecher
MVP
MVP

No, now I got it:

     If(frac(column(1))*10>5, floor(column(1)), Round(column(1), 1, 0.5))

This will round your examples right..

Astrato.io Head of R&D
paulyeo11
Master
Master
Author

Hi Bill

Thank you very much. Your script is very easy for me modify to what i want.

  if ( column(1) <10 ,

  num( ( column(1)) , '#.##')  ,

  num( Ceil(  column(1),0.5) , '#.#') )

Yes my question is confuse , but logically i want to round up 95.54 i want to round 96.00 and for small value less then 10 i don't want to round .

Paul