Splunk Search

How to use conditional comparison of two field values from the same event to populate a third field

373782073
Explorer

Hi all

I am trying to use the eval case function to populate a new field based on the values of 2 existing fields that meet certain string value matching.

For example:
| eval ValueY=case(Status == StringValue_A) AND (Priority == StringValue_B)), "StringValue_C")
| table Status Priority ValueY

So as you can see the above is not working and was wondering if anyone has tried to do something similar so that the exact combination of StringValueA and StringValue_B can be used to define if StringValue_C is used to populate a third column on a table.

Hope it makes sense
Many thanks

1 Solution

373782073
Explorer

I found that the following worked.

| eval ValueY=case(
match(Status, "StringValue_A") AND Priority == "StringValue_B", "StringValue_C")
| table Status Priority ValueY

thanks anyway

View solution in original post

373782073
Explorer

I found that the following worked.

| eval ValueY=case(
match(Status, "StringValue_A") AND Priority == "StringValue_B", "StringValue_C")
| table Status Priority ValueY

thanks anyway

vnravikumar
Champion

Hi

Try like

| makeresults 
| eval col1="one",col2="two" 
| eval col3=if(col1=="one" AND col2=="two","matched","unmatched")

OR

| makeresults 
| eval col1="one",col2="two" 
| eval col3=case(col1=="one" AND col2=="two","matched",1=1,"unmatched")
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 ...