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

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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...