Splunk Search

Doing calculations using eval command with fields generated by timechart command.

jvmerilla
Path Finder

Hi,

I'm doing some search query where I used timechart command that creates fields. Now, what I want to do is to some calculations with this fields using eval command but nothing happens.

Here's my query:

index="sample_data" sourcetype="management_sampledata.csv" 
| timechart count(Ticket_No) as Inflow
| append 
    [search index="sample_data" sourcetype="management_sampledata.csv" Status=Closed 
    | timechart count(Ticket_No) as Closed/Cancelled 
    | fillnull]
| timechart first(*) as *
| eval Backlog_Total = (Inflow-Closed/Cancelled)

And here's the result:
alt text

What I was expecting to happen is a new field named "Backlog_Total" will be created using the eval command.

I hope someone can help me with this.

Thank you.

Tags (3)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi

Can you please try this?

index="sample_data" sourcetype="management_sampledata.csv" 
 | timechart count(Ticket_No) as Inflow
 | append 
     [search index="sample_data" sourcetype="management_sampledata.csv" Status=Closed 
     | timechart count(Ticket_No) as "Closed/Cancelled"
     | fillnull]
 | timechart first(*) as *
 | eval Backlog_Total = (Inflow-'Closed/Cancelled')

I have just changed in Closed/Cancelled field.

Thanks

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi

Can you please try this?

index="sample_data" sourcetype="management_sampledata.csv" 
 | timechart count(Ticket_No) as Inflow
 | append 
     [search index="sample_data" sourcetype="management_sampledata.csv" Status=Closed 
     | timechart count(Ticket_No) as "Closed/Cancelled"
     | fillnull]
 | timechart first(*) as *
 | eval Backlog_Total = (Inflow-'Closed/Cancelled')

I have just changed in Closed/Cancelled field.

Thanks

0 Karma

jvmerilla
Path Finder

Hi @kamlesh_vaghela,

It works!

Thank you again. 🙂

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Glad to help you.
Can you please accept the answer to close this question and upvote any comment which helps you.

Happy Splunking

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...