Splunk Search

How to use AND in an eval case function?


I need a way of using AND in the eval function case.

For Example:

...mysearch | eval Path = case(Path=="my/path" AND Action=="check", "Yours is available", Path=="your/path" AND Action=="didnotcheck", "Mine is available" )

This did not work for me, so it seems I am doing something wrong. Thanks in advance

Tags (3)
0 Karma


Maybe your path contains special characters, try using match and just specifying part of your path to see if that works. If that's the case then try replacing the match with the "==" and escaping the special characters with a backslash. I would also include a default condition (1==1) in case none of the others match and also create a variable with a different name (like NewPath) to avoid overwriting your Path variable while you are still testing this and in order to see what's going on:

| eval NewPath = case(
    match(Path,"my path") AND Action=="check", "Yours is available",
    match(Path,"your path") AND Action=="didnotcheck", "Mine is available" 
    1 == 1, "Others"
0 Karma


How to use the AND is not wrong. Please tell me the contents of the mistake of the search results.

< search results>
Path=="my/path" AND Action=="check" : Path="Yours is available"
Path=="your/path" AND Action=="didnotcheck" : Path="Mine is available"
else :Path=NULL

Do you have field names and path match? For example,
"... Mysearch | dedup Path, Action"
What a result of?

0 Karma


I would like to capture this cases in a field so that I can pipe it to stats. That's why I used case and eval

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!