Splunk Enterprise

Remove field-value from multivalue

siv
Explorer

I have  this table for example 

Field1 | Field2

Value1 | value1 value2 value3 

Field2 is mv

I want to remove the value that already axits in field1 so the result be like this:

Field1 | Field2

Value1 | value2, value3 

 

I didnt see the mvfilter support this

Labels (1)
0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @siv 

How about 

| makeresults
| eval Field1="value1", Field2="value1 value2 value3"
| eval Field2=split(Field2," ")
| foreach Field2 mode=multivalue [| eval Field2=mvappend(Field2,IF(<<ITEM>>!=Field1, <<ITEM>>,null()))]

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma

PrewinThomas
Motivator

@siv 

You can consider using mvfilter as well.

| makeresults
| eval Field1="Value 1"
| eval Field2=split("Value 1,Value 2,Value 3", ",")
| eval Field2=mvfilter(match(Field2, "^(?!Value 1$).*"))


Regards,
Prewin
Splunk Enthusiast | Always happy to help! If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| foreach mode=multivalue Field2
    [| eval new=if(<<ITEM>>!=Field1,mvappend(new,<<ITEM>>),new)]
0 Karma

siv
Explorer

I think i tried that,

But i found a solution with mvmap and if match...

0 Karma

bowesmana
SplunkTrust
SplunkTrust

The simplest way is to use = rather than match, unless you need match. The problem with match is if your data contains anything that might be significant to the regular expression, e.g. if Value 1 is Va*ue, then that won't work well with match.

You can do it like this - example shows simple fields in Field1, 2 and 3 and then one with regex significant characters and shows Field6 works, but not Field7

| makeresults | fields - _time
| eval Field1="Value 1", Field2=split("Value 1,Value 2,Value 3", ",")
| eval Field3=mvmap(Field2, if(Field1=Field2, null(), Field2))
| eval Field4="Odd[Regex Chars?]Value 1", Field5=split("Odd[Regex Chars?]Value 1,Value 2,Value 3", ",")
| eval Field6_using_equals=mvmap(Field5, if(Field4=Field5, null(), Field5))
| eval Field7_using_match=mvmap(Field5, if(match(Field4,Field5), null(), Field5))

 

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...