Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
louise119
Creator III
Creator III

Floor function

How can I display the truncated value as a value with 1 or 2 decimal places?
I don't really understand how to use the floor function.

1 Solution

Accepted Solutions
N30fyte
Creator
Creator


@louise119 wrote:


I don't really understand the difference between floor() and round()...

 


Round() rounds up or down

Floor() always rounds down

Ceil() always rounds up

So floor(3.46,0.1) rounds down to the nearest single decimal place: 3.4

while round(3.46,0.1) rounds to the nearest single decimal place in either direction, which in this case is up, and gives 3.5.

ceil(3.46,0.1) rounds up to 3.5.

View solution in original post

7 Replies
Chanty4u
MVP
MVP

Try this 

Round(FieldName, 1)   //one decimal

 

Round(FieldName, 2).  // Two decimal

 

 Floor(FieldName * 10) / 10.    // One decimal

 

Floor(FieldName * 100) / 100.     // Two decimal 

 

 

 

louise119
Creator III
Creator III
Author

Thank you so much.

I tried. 
When I used the "Round([Field name],1)", I thought it would display values with 1 decimal place, but it displays integers.
I don't really understand the difference between floor() and round()...

test.png

louise119
Creator III
Creator III
Author

Should I use "Floor([Field Name],0.1)" when I express the 1 decimal.

N30fyte
Creator
Creator


@louise119 wrote:


I don't really understand the difference between floor() and round()...

 


Round() rounds up or down

Floor() always rounds down

Ceil() always rounds up

So floor(3.46,0.1) rounds down to the nearest single decimal place: 3.4

while round(3.46,0.1) rounds to the nearest single decimal place in either direction, which in this case is up, and gives 3.5.

ceil(3.46,0.1) rounds up to 3.5.

louise119
Creator III
Creator III
Author

Thank you so much!
I could understand.

N30fyte
Creator
Creator

In your first example (the screenshot of the table) you have floor([customer number]/3,1]

The step is 1 so floor() rounds down to the nearest single digit. For example:

floor(10/3,1)   gives 3, the next lowest to 3.3333333... in steps of 1

If you change the step to 0.1, floor() rounds down to the nearest decimal place. For example:

floor(10/3,0.1) gives 3.3, the next lowest to 3.3333333... in steps of 0.1

louise119
Creator III
Creator III
Author

Thank you so much:)!