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