Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
nicolas_martin
Partner - Creator II
Partner - Creator II

Problem with "ceil"

Hello,

When I write

ceil(0.29999999999999, 0.1)

I expect

0.3

--> OK

When I write

ceil(0.3, 0.1)

I expect

0.3

--> OK

When I write

ceil(ceil(0.29999999999999, 0.1), 0.1)

I expect

0.3

--> KO, QlikView gives me

0.4

Because

ceil(0.29999999999999, 0.1)

returns in fact

0.30[...]01

Why?

ps: the workaround

ceil(0.299999 * 10) / 10

works.

Labels (1)
1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See this blog post: Rounding Errors


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See this blog post: Rounding Errors


talk is cheap, supply exceeds demand
nicolas_martin
Partner - Creator II
Partner - Creator II
Author

I said

ps: the workaround

  1. ceil(0.299999 * 10) / 10 

works.

but in facts, when I'm dealing with interval match, it doesn't work.

I have some calculated scores.

I want to round them to the upper 1/10th and apply to them a label:

Interval:

LOAD * INLINE [

From, Start, Label

0, 0, None

0.1, 0.3, Few

0.4, 1, Many

1.1, , Too much

];

Values:

LOAD

  *,

  //ceil(A / B, 0.1) AS Value

  ceil(A * 10 / B) / 10 AS Value

;

LOAD * INLINE [

Id, A, B

1, 0, 10

2, 1, 10

3, 29999, 100000

];

IM:

IntervalMatch (Value)

LOAD

  From,

  Start

RESIDENT Interval;

For my Id "3", the score is "29999 / 100000", that is "0.29999" that should be rounded at "0.3" (upper 1/10th), so the Label should be "Few".

But as the round workaround doesn't returns "0.3" nor "0.4" (but "0.30...01"), my line #3 has no Label