Splunk Dev

How do I compare numerical values in a multivalue field to another field?

abulco01
Explorer

Suppose I have some numerical field A, and some numerical multivalue field, mv_B.

Suppose I want to find all values in mv_B that are greater than A.

I envision something like the following:

search...
| eval mv_Results=mvfilter(mv_B > A)

However, this does NOT work. The documentation states the following:

mvfilter(X)
This function filters a multivalue field based on an arbitrary Boolean expression X. The Boolean expression X can reference ONLY ONE field at a time.

Hence, the above code will not work, but the following code would.

search...
| eval mv_Results=mvfilter(mv_B > 10)

In short, what is the best way to accomplish this task? I've tried searching the community answers to no avail. Is there a practical solution?

0 Karma
1 Solution

vnravikumar
Champion

Hi @abulco01

Please try

| makeresults 
| eval a="23" 
| eval b="22,23,24,24,25" 
| makemv delim="," b 
| mvexpand b 
| eval result=if(b>a,b,null()) 
| stats values(a) as a list(b) as b values(result) as result

View solution in original post

0 Karma

vnravikumar
Champion

Hi @abulco01

Please try

| makeresults 
| eval a="23" 
| eval b="22,23,24,24,25" 
| makemv delim="," b 
| mvexpand b 
| eval result=if(b>a,b,null()) 
| stats values(a) as a list(b) as b values(result) as result
0 Karma

abulco01
Explorer

Hello @vnravikumar

Thanks for the reply! Is there any way to accomplish this without the use of mvexpand?
The reason I ask is because, if I have multiple multivalue fields m1, m2, ... mn which I need to compare against, the number of rows will grow rapidly.

0 Karma

Nassima_0
New Member

Hello,

I have the same need ( comparing a multivalued numercial field with a single value ) but without using the command mvexpand.

is there any other solution ?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...