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!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...