Splunk Search

How to write a search to return a value from one of three columns in a CSV lookup based on a field?

irfans
Explorer

I am trying to write a lookup that will pull a value out from one of three different columns.

for example

Col_A, Val_A, Val_B, Val_C

I want to look up only one of the values depending on a field.

So if lookup_field = Val_B , I want to use Col_A and pull out value from Val_B column.

woodcock
Esteemed Legend

This does the same thing (I do not believe there is a way to do this exactly the way you described):

... | lookup myLookup Col_A OUTPUT Val_A Val_B Val_C | eval desiredValue=case(lookup_field="Val_A", Val_A, lookup_field="Val_B", Val_B, lookup_field="Val_C", Val_C) | fields - Val_*
0 Karma

somesoni2
Revered Legend

Can you post some sample data from the lookup?

0 Karma

alexandermunce
Communicator

This is a slightly complicated one - however if you can provide some sample data then there may be a more suitable way to approach the logic here.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...