Splunk Search

Lookup return same value if not found

sarumjanuch
Path Finder

Hi is there any way to return same value if not found in lookup table? i.e.
I have file

users.csv

code,name
100,jhon
200,jane

and for exmple when i am doing lookup and send for example code 300, i don have it in my table, and it will become NONE, but i want lookup to return 300.

Thank you.

Tags (2)

rmdfrb
Explorer

You can use coalesce()

From the docs:
"This function takes an arbitrary number of arguments and returns the first value that is not null."

eg:

... | lookup users.csv name as name OUTPUT code as code_lookup | eval code=coalesce(code,code_lookup)

This will leave the code field as it was if it existed in the event before, but fill it with the lookup value if it was null.

somesoni2
Revered Legend

I believe its other way around

| lookup users.csv code as codeFromSearch OUTPUT name as name | eval name=coalesce(name,codeFromSearch)

0 Karma
Get Updates on the Splunk Community!

Unleash the Power of Splunk MCP and AI, Meet Us at .Conf 2025, and Find Even More New ...

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

Observability Professionals: Build Resilience and Visibility with These .conf25 ...

  If you're focused on performance, availability, and full-stack visibility, the Observability track at ...

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...