Getting Data In

How to compare values in 2 fields and column that show Success/Failure?

shreyasathavale
Communicator

I have 2 fields as below

Field1    Field2
abc          abc
def          jkl
ghi          wxy
jkl
pqr
wxy

I have to compare values in Field1 with all values in Field2 and return "Success" if both are same and "Fail" if both are not same.

Expected Result:

Field1    Field2     Result
abc          abc         Success
def          jkl            Fail
ghi          wxy          Fail
jkl                             Success
pqr                          Fail
wxy                          Success

Index is same with different sourcetypes

0 Karma
1 Solution

HiroshiSatoh
Champion

Try this!

(your search)|table Field1,Field2|eval Result="Fail"
| join type=left Field1 [search (your search) Field2=*|table Field2
       |rename Field2 as Field1|eval Result="Success"]

View solution in original post

0 Karma

skoelpin
SplunkTrust
SplunkTrust

This assumes you passed a transformational command like stats to get that table view of your metrics. If so, just append this on and make sure to replace Field1 and Field2 with your column names

| eval Result=if(Field1==Field2,"Success","Fail")
0 Karma

HiroshiSatoh
Champion

Try this!

(your search)|table Field1,Field2|eval Result="Fail"
| join type=left Field1 [search (your search) Field2=*|table Field2
       |rename Field2 as Field1|eval Result="Success"]
0 Karma

shreyasathavale
Communicator

Thanks @HiroshiSatoh , I tried this and it is working as expected!!!

0 Karma
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...