Splunk Search

How to Combine 2 rows

minihyo
Engager

Hi,

 I'm new to Splunk. I expect to combine 2 rows like this but dont know how

COL1COL2VALUE
c1c2Amy
c2c1Bob
c3c4Carol
c4c3David

 

Expected answer

NEWC3VALUE
c1 / c2

Amy

Bob

c3 / c4

Carol

David

 

Thanks

Labels (3)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this run-anywhere example.

| makeresults 
| eval _raw="COL1	COL2	VALUE
c1	c2	Amy
c2	c1	Bob
c3	c4	Carol
c4	c3	David" 
| multikv forceheader=1
```Above just defines test data```
| eval COL3=mvappend(COL1, COL2)
| eval COL3=mvjoin(mvsort(COL3),",")
| stats values(VALUE) as VALUE by COL3
---
If this reply helps you, Karma would be appreciated.

gcusello
SplunkTrust
SplunkTrust

Hi @minihyo,

please, try something like this:

| makeresults
| eval _raw="COL1	COL2	VALUE
c1	c2	Amy
c2	c1	Bob
c3	c4	Carol
c4	c3	David"
| multikv forceheader=1
| eval ppp1=COL1.",".COL2, ppp2=COL2.",".COL1
| makemv delim="," ppp1
| makemv delim="," ppp2
| eval ppp1=mvsort(ppp1), ppp2=mvsort(ppp2)
| eval ppp=mvindex(ppp1,0)."/".mvindex(ppp1,1)
| stats values(VALUE) AS VALUE BY ppp

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Application management with Targeted Application Install for Victoria Experience

  Experience a new era of flexibility in managing your Splunk Cloud Platform apps! With Targeted Application ...

Index This | What goes up and never comes down?

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

Splunkers, Pack Your Bags: Why Cisco Live EMEA is Your Next Big Destination

The Power of Two: Splunk + Cisco at "Ludicrous Scale"   You know Splunk. You know Cisco. But have you seen ...