Splunk Search

wrong results for case statement with AND

sam1010
Explorer

I used this eval statement with AND conditions but I'm only getting result as "Public" even when the condition satisfies for value "Private" i.e. I'm only getting default result. Any idea of what's wrong with this statement?

| eval perm=case(block_public_acls=true AND block_public_policy=true AND ignore_public_acls=true AND restrict_public_buckets=true,"Private",1=1,"Public")

sam1010_1-1634196686147.png

 

0 Karma
1 Solution

marilyncugal
Engager

Check the type of the fields. 
e.g.  | eval type_of_field = typeof(block_public_acls)

If it is "String", then you can wrap the right side of the condition with quotation marks.

| eval perm=case(block_public_acls="true" AND block_public_policy="true" AND ignore_public_acls="true" AND restrict_public_buckets="true","Private",1=1,"Public")

View solution in original post

marilyncugal
Engager

Check the type of the fields. 
e.g.  | eval type_of_field = typeof(block_public_acls)

If it is "String", then you can wrap the right side of the condition with quotation marks.

| eval perm=case(block_public_acls="true" AND block_public_policy="true" AND ignore_public_acls="true" AND restrict_public_buckets="true","Private",1=1,"Public")

gcusello
SplunkTrust
SplunkTrust

Hi @sam1010,

use double quotes in all the conditions:

| eval perm=case(block_public_acls="true" AND block_public_policy="true" AND ignore_public_acls="true" AND restrict_public_buckets="true","Private",1=1,"Public")

Ciao.

Giuseppe

ITWhisperer
SplunkTrust
SplunkTrust

Have you tried putting "true" in double quotes?

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 ...