Splunk Search

Why am I unable to convert my addcoltotals value of MB to TB using eval?

dean1
New Member

Hello Splunk Ninjas

I'm trying to convert my addcoltotals of MB to TB using the eval statement which does not work....

index=myindex sourcetype=mysourcetype | table Cluster, Capacity_MB | addcoltotals  label=TOTALS labelfield=Cluster | eval  TOTALS = round(TOTALS/1024,2)

Thanks!

0 Karma
1 Solution

javiergn
Super Champion

Hi,

Your labelfield=Cluster means that's the name of the field that it's going to store the string "TOTALS".
TOTALS is not a field, it's a value. The field is Capacity_MB.

Therefore if you just want to apply it to that particular row in your table you can do it this way:

| eval Capacity_MB = if(Cluster == "TOTALS", round(Capacity_MB/1024,2), Capacity_MB)

Hope that makes sense.

Thanks,
J

View solution in original post

javiergn
Super Champion

Hi,

Your labelfield=Cluster means that's the name of the field that it's going to store the string "TOTALS".
TOTALS is not a field, it's a value. The field is Capacity_MB.

Therefore if you just want to apply it to that particular row in your table you can do it this way:

| eval Capacity_MB = if(Cluster == "TOTALS", round(Capacity_MB/1024,2), Capacity_MB)

Hope that makes sense.

Thanks,
J

dean1
New Member

Excellent - That worked - Thank you!

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...