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

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Quantify Your Splunk Investment Impact: Introducing Savings Metrics to Value Insights

Building on the foundation established in our initial Value Insights releases, we are introducing the Savings ...

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...