Dashboards & Visualizations

Merge two rows based on common field value

charan986
Engager

I've a table like below and I want to merge two rows based on the COMMONID

1.    JBID    JOBTYPE                     START_TIME             END_TIME          COMMONID
2.                                2020-03-10T06:30:00   2020-03-10T08:30:00   abc
3.   6398   Medium                                                                abc
4.   5649   Medium                                                                def
5.                                2020-03-10T08:30:00   2020-03-10T10:30:00   def
6.   5649   Medium                                                                ghi
7.                                2020-03-20T08:30:00   2020-03-20T10:30:00   ghi
8.                                2020-03-11T08:30:00   2020-03-11T10:30:00   jkl
9.   6383   Medium                                                               jkl
10.  7070   Medium                                                                mno
11.                                  2020-03-10T08:30:00    2020-03-10T10:30:00   mno
12.  11690  Medium                                                               pqr
13.                                  2020-03-12T06:30:00    2020-03-12T08:30:00   pqr
14.                                  2020-03-19T06:30:00    2020-03-19T08:30:00   stu
15.  6398   Medium                                                                stu
16.  6398   Medium                                                                vwx
17.                                  2020-03-10T06:30:00    2020-03-10T08:30:00   vwx

The resulting table should look like below

1.  JBID    JOBTYPE                                START_TIME             END_TIME          COMMONID
2.  6398    Medium                            2020-03-10T06:30:00   2020-03-10T08:30:00   abc
3.  5649    Medium                          2020-03-10T08:30:00 2020-03-10T10:30:00   def
4.  5649    Medium                          2020-03-20T08:30:00 2020-03-20T10:30:00   ghi
5.  6383    Medium                          2020-03-11T08:30:00 2020-03-11T10:30:00   jkl
6.  7070    Medium                          2020-03-10T08:30:00 2020-03-10T10:30:00   mno
7. 11690    Medium                          2020-03-12T06:30:00 2020-03-12T08:30:00   pqr
8.  6398    Medium                          2020-03-19T06:30:00 2020-03-19T08:30:00   stu
9.  6398    Medium                          2020-03-10T06:30:00 2020-03-10T08:30:00   vwx

How do I achieve this?

Labels (1)
Tags (1)
0 Karma
1 Solution

manjunathmeti
Champion

hi @charan986

You can do this using stats command:

<base search>| stats first(*) as * by COMMONID

View solution in original post

woodcock
Esteemed Legend

I typically do this:

... | stats list(*) AS * BY COMMONID

Just in case there are some duplicated lines.

0 Karma

to4kawa
Ultra Champion
....
| selfjoin COMMONID

manjunathmeti
Champion

hi @charan986

You can do this using stats command:

<base search>| stats first(*) as * by COMMONID

charan986
Engager

Thanks, it worked 🙂

0 Karma
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!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...