Reporting

Multivalue field if more than one value output yes

Mary666
Communicator

Hello Splunk Community, 

 

I have a multivalue field that outputs "No" after applying if eval statement. I would like to have it output yes if there is more than 1 value for that field.  

I believe its my eval command that needs to be fixed: | eval Result=if(Doc=DocId, "Yes", "No")

(index="XYZ" ) OR (index="123" )
| eval Doc=if(level="RecordCount", DocId,"no_level") 
|fillnull DocType value=NA

|eval Result=if(Doc=DocId,"Yes","No")

| stats values(Doc) values(level) values(RecordCount) values(Result) by DocType
docTypevalues(DocId)values(level)values(RecordCount)values(Result)
PDF12345, no_levelsubmitted1No (this should say yes)
Labels (1)
0 Karma
1 Solution

renjith_nair
Legend

Alright!

Just use max(Result) as Result instead of values(result)

Lexicographically,  Y is greater than N and hence Yes will be chosen by max.

👍if it helps

---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

renjith_nair
Legend

As per your last search result  level = submitted (see values(level))

So in your first eval statement, i.e

| eval Doc=if(level="RecordCount", DocId,"no_level")

 Doc = no_level since level is not RecordCount but submitted

So in the second eval statement,

|eval Result=if(Doc=DocId,"Yes","No")

no_level  =  Doc is No

Not sure, if I miss something in between but Splunk seems to be right here .

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

Mary666
Communicator

@renjith_nair  Thanks for helping me out. I did try your suggestion |eval Result=if(Doc=DocId,"Yes","No"). However the issue that I have is the last values(Result) column displays yes and no and not just yes.  So my results look like this. I only need it to say yes where values(Doc) has a series of numbers known as the DocId field, but in this case I have value(Doc) with no_level and DocId, which in turn gives me a yes and a no result. I just need it to say yes where DocId is present regardless of there being the no_level value.  

DocTypevalues(Doc)values(level)values(RecordCount)values(Result)
pdfno_level submitted0No
csv12345
no_level
submitted
12345
0,1No, Yes 
0 Karma

renjith_nair
Legend

Alright!

Just use max(Result) as Result instead of values(result)

Lexicographically,  Y is greater than N and hence Yes will be chosen by max.

👍if it helps

---
What goes around comes around. If it helps, hit it with Karma 🙂

Mary666
Communicator

@renjith_nair  Thank you! you don't know how helpful this was for me 😊

renjith_nair
Legend

@Mary666 

You are welcome! Glad it worked. Appreciate a 👍 for the solution by clicking on the karma 🙂

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...