Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results forย

Splunk Search

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results forย

- Community
- :
- Splunk Answers
- :
- Using Splunk
- :
- Splunk Search
- :
- How to round up a number and avoid infinite zeros?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark Topic
- Subscribe to Topic
- Mute Topic
- Printer Friendly Page

- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

adonio

SplunkTrust

โ05-11-2018
10:02 AM

I am trying to round UP numbers one decimal to the left whenever its, for example:

10510 ---> 11000

10499 ---> 10000

read the following answers, but cant apply those as they are rounding down, also, seems like the `ciel`

function is depreciated?

https://answers.splunk.com/answers/475056/how-to-round-up-a-field-value-which-contains-the-d.html

https://answers.splunk.com/answers/552707/how-to-round-a-number-to-hundreds-or-thousands.html

here is my search: WARNING! it might break your web browser:

```
| makeresults count=1
| eval data = "10510,20010.11,10999.99,10500,10499,10000,10001,501,21"
| makemv delim="," data
| mvexpand data
| eval rounded_1 = round(data, -1)
| eval rounded_2 = round(data, -2)
| eval rounded_3 = round(data, -3)
| eval using_floor = floor(data)
```

How can I avoid the zeros? see screenshot:

1 Solution

- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

somesoni2

SplunkTrust

โ05-11-2018
11:31 AM

The ceil or ceiling function but now we just have ceiling.

Your rounding_3 didn't work for me in Splunk 6.2x. I thought function sigfig would work but that also doesn't work past 2 decimal digits. I found the expression (workaround) I used in rounding_custom worked for me. Give this a try.

```
| gentimes start=-1
| eval data = "10550,20010.11,10999.99,10500,10499,10000,10001,501,21" | table data
| makemv delim="," data
| mvexpand data
| eval rounded_1 = round(data, -1)
| eval rounded_2 = round(data, -2)
| eval rounding_sigfig = sigfig(data*1.000)
| eval rounding_custom=round(data/1000)*1000
| eval using_floor = ceil(data)
```

- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

somesoni2

SplunkTrust

โ05-11-2018
11:31 AM

The ceil or ceiling function but now we just have ceiling.

Your rounding_3 didn't work for me in Splunk 6.2x. I thought function sigfig would work but that also doesn't work past 2 decimal digits. I found the expression (workaround) I used in rounding_custom worked for me. Give this a try.

```
| gentimes start=-1
| eval data = "10550,20010.11,10999.99,10500,10499,10000,10001,501,21" | table data
| makemv delim="," data
| mvexpand data
| eval rounded_1 = round(data, -1)
| eval rounded_2 = round(data, -2)
| eval rounding_sigfig = sigfig(data*1.000)
| eval rounding_custom=round(data/1000)*1000
| eval using_floor = ceil(data)
```

- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

adonio

SplunkTrust

โ05-11-2018
12:03 PM

up voting as i find this `round(data/1000)*1000`

very useful.

however, if have a 6 (or greater) digits number, the `rounding_custom`

wont work and seems like ill have to adjust the `rounding_custom`

rule accordingly.

thanks again

- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

somesoni2

SplunkTrust

โ05-11-2018
12:17 PM

Do you've example data for those 6 or higher digit with expected output?

- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

adonio

SplunkTrust

โ05-11-2018
01:07 PM

- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

somesoni2

SplunkTrust

โ05-11-2018
01:31 PM

So you want to dynamically round based on 2nd digit from left. Give this a try (should work for any length of data)

```
| gentimes start=-1
| eval data = "123456,1234567,87654321,987654321,123456789,10510,20010.11,10999.99,10500,10499,10000,10001,501,552,21,29" | table data
| makemv delim="," data
| mvexpand data | eval mf=pow(10,len(tostring(round(data)))-1)
| eval rounding_custom1=round(data/mf)*mf
```

- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

adonio

SplunkTrust

โ05-11-2018
06:24 PM

ill take it as an answer as it works. still puzzled why the `round(X, -3)`

wont work... any idea?

thanks again!