Splunk Search

Mulit lookup with same event-field, lookup-destfield and event-destfield

Lukas85
New Member

Hi All

I'm new on splunk and have following problem.

We need data from a table depending on the value of a variable. For this lookup is the right function i think. The special on that csv/file is the value can be in different columns. Return data will be always the same. 

The csv table has following structur: 

column1column2column3column4column5
441F205E77889 22558
441F204E779984455633669
442G20718899266557 
442  1122311559

 

it's possible there is no value inside a field in the table.  In case we won't found a match on column2 we search in column 4 and last in column6. 

I tried it as follow:

 

 

| lookup Inventar_SBB column2   as Test_field output    "column1" as "value1" , "column3" as "value2", "column4" as "value3", "column5" as "value4" 
| lookup Inventar_SBB "column4" as Test_field outputnew "column1" as "value1" , "column3" as "value2", "column4" as "value3", "column5" as "value4" 
| lookup Inventar_SBB "column5" as Test_field outputnew "column1" as "value1" , "column3" as "value2", "column4" as "value3", "column5" as "value4"

 

 

It looks like lookup function returns NULL in case there is no match.  With outputnew it won't overwrite the NULL value and with output it always overwrite my values with NULL  

I tried with different variable names for "value" in each lookup and compare it to NULL but this was also not working. 

Any idea what could be the workaround for this problem?

Thanks in advance for any help.

Labels (1)
0 Karma

efika
Communicator

Hi @Lukas85 ,

Read the full set of column and use the function coalesce ( "This function takes an arbitrary number of arguments and returns the first value that is not NULL.")

| makeresults 1 
| eval column2=NULL,column3=NULL, column4=11223,column5=11559
| eval result= coalesce(column2,column3,column4,column5)

 

 

0 Karma
Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...