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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...