Splunk Search

with the same search conditions, I cannot make eval if function to return true...

leonjxtan
Path Finder

For some use case, I need to make a new true/false field.

Below condition returns 11 events in my data sample:
| from datamodel:"SomeDataModel.SomeDataSet" |search LocalField1=ABC AND CalculatedField2!=0

But if I write it with Eval and if functions like below, it returns no event:
| from datamodel:"SomeDataModel.SomeDataSet" |eval truefalseField1=if((LocalField1=ABC AND CalculatedField2!=0),true,false)
|search truefalseField1=true

How can I make the 2nd search also return same (11) events? Could you please help?

Thanks.

Tags (1)
0 Karma

rjthibod
Champion

The values true and false are not recognized values. You have to use either the strings values "true" and "false" or use numbers 1 and 0.

For example

| from datamodel:"SomeDataModel.SomeDataSet" |eval truefalseField1=if((LocalField1=ABC AND CalculatedField2!=0),1,0) | search truefalseField1=1

0 Karma

leonjxtan
Path Finder

found reason why. It is that only when in eval statement, the CalculatedField2 failed to return any value. but in the first statement, the calculated field worked fine.

0 Karma

leonjxtan
Path Finder

this is actually splunk-enterprise question, but after I click the Splunk Enterprise button and then click the “Post Your Question” button, it gives me error: The following topics are not present in the system, and you don't have permissions to create new ones: splunk-enterprise

0 Karma

clara-fication
Super Champion

have you tried putting everything in quotations that isn't a number?

| from datamodel:"SomeDataModel.SomeDataSet" |eval truefalseField1=if((LocalField1="ABC" AND CalculatedField2!=0),"true","false") 
|search truefalseField1="true"
Solution Clara-fied!
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

How Splunk AI Assistant Is Transforming Investigations: Insights from .conf26

At .conf26 in Denver, I spent much of my time in conversation with Splunk customers about Splunk AI Assistant. ...

Make Your Machine Data AI-Ready in Splunk

Every team is getting ready for AI agents.   Thursday, November 12, 2026  |  11AM  PST / 2PM EST   ...

Splunk Asynchronous Forwarding Explained

Splunk asynchronous forwarding is often misunderstood as simply setting autoLBVolume. That is not quite right. ...