Splunk Search

Why does addcoltotals not display decimal totals?

andrewtrobec
Motivator

Hello,
I've noticed that the addcoltotals command doesn't display decimals if the total contains a decimal. Run anywhere code:

| makeresults
| eval decimal = 1.5
| eval whole = 1.5
| append [ | makeresults
| eval decimal = 1
| eval whole = 1.5]
| addcoltotals

I'm using Splunk 6.4.1 and my results are:

decimal,whole
1.5,1.5
1,1.5
2,3.0 (here it truncates to a single decimal place for the decimal field)

Is there something I'm missing?
Regards,
Andrew

0 Karma
1 Solution

harishalipaka
Motivator

hi @andrewtrobec

try like this

| makeresults
 | eval decimal = 1.5
 | eval whole = 1.5
 | append [ | makeresults
 | eval decimal = 1
 | eval whole = 1.5]
 |eval decimal=round(decimal,2)  |eval whole=round(whole,2) |addcoltotals
Thanks
Harish

View solution in original post

harishalipaka
Motivator

hi @andrewtrobec

try like this

| makeresults
 | eval decimal = 1.5
 | eval whole = 1.5
 | append [ | makeresults
 | eval decimal = 1
 | eval whole = 1.5]
 |eval decimal=round(decimal,2)  |eval whole=round(whole,2) |addcoltotals
Thanks
Harish

harishalipaka
Motivator

Hi @andrewtrobec
Did you get that.
If my answer helped you please accept answer or up vote

Thanks
Harish
0 Karma

andrewtrobec
Motivator

This is a good workaround, thank you!

0 Karma

richgalloway
SplunkTrust
SplunkTrust

It looks like addcoltotals is using the lowest level of precision of the values it's adding. Since '1' has zero digits of precision, that's what is used for the result.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...