Splunk Enterprise

How to use eval command to determine if there is more than one value in a stats table field?

dwcooley01
Engager

Hello Everyone. I'm trying to find a way to use the eval command to determine whether or not a field in my stats table has more than one value.  Here is the scenario......I have two columns - IP Address in column A and userID in column B. The userID field may have more than one value. I'd like to evaluate the UserID field in each line to determine if there is more than one UserID listed. If there is, I'd like the eval command to place a value of 1 in column C, and if only one userID, to place a value of 0 in column C. Any help would be very appreciated.

Thanks!

Labels (1)
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Use the mvcount function to find out how many values are in a multi-value field.

| eval columnC = if(mvcount(userID)=1, 0, 1)

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Use the mvcount function to find out how many values are in a multi-value field.

| eval columnC = if(mvcount(userID)=1, 0, 1)

 

---
If this reply helps you, Karma would be appreciated.

dwcooley01
Engager

Perfect. Thanks for the reply.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to July and August Tech Talks, Office Hours, and Webinars!

Dive into our sizzling summer lineup for July and August Community Office Hours and Tech Talks. Scroll down to ...

Edge Processor Scaling, Energy & Manufacturing Use Cases, and More New Articles on ...

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

Get More Out of Your Security Practice With a SIEM

Get More Out of Your Security Practice With a SIEMWednesday, July 31, 2024  |  11AM PT / 2PM ETREGISTER ...