Splunk Search

Check to see if value is in a field if not get from next field

MeMilo09
Path Finder

Hello,

How can I check to see if value is in one field first, if not check the next field?

I have so far the below, it works, but I would like to use an if statement to check if team_name is in Blue first and if not then get the team_name from Red.

| eval Team_Color=case(team=“Blue”, team_name OR team=“Red”, team_name)

any advice on how to use if statement instead of case? 

Labels (2)
0 Karma
1 Solution

dave_null
Path Finder

Yeah just nest them:

 

| eval Team_Color=if(<check 1>, <value if check1 true> , if( <check 2> , <value if check2 true>, <value if both false>))

E.g. 

 

| eval Team_Color = if(team="Blue", team_name, if(team="Red",team_name, ""))

View solution in original post

dave_null
Path Finder

Yeah just nest them:

 

| eval Team_Color=if(<check 1>, <value if check1 true> , if( <check 2> , <value if check2 true>, <value if both false>))

E.g. 

 

| eval Team_Color = if(team="Blue", team_name, if(team="Red",team_name, ""))

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...