Knowledge Management

How to Transpose Group of Columns in Rows?

mxh7777
Path Finder

Hello,
I'd like to transpose a table results by grouping by columns.

Here is my table

time1 event1 time2 event2 time3 event3
01/01/2022 titi 02/01/2022 toto 04/01/2022 tata

 

I'd like to transpose this structure in this way

time content
01/01/2022 titi
02/01/2022 toto
04/01/2022 tata

 

I didn't find a way to solve this

Thans in advance

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

One way might be something like this

| eval row=mvrange(1,4)
| mvexpand row
| foreach event*
    [| eval content=if(row=<<MATCHSEG1>>,<<FIELD>>,content)]
| foreach time*
    [| eval time=if(row=<<MATCHSEG1>>,<<FIELD>>,time)]
| table time content

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

One way might be something like this

| eval row=mvrange(1,4)
| mvexpand row
| foreach event*
    [| eval content=if(row=<<MATCHSEG1>>,<<FIELD>>,content)]
| foreach time*
    [| eval time=if(row=<<MATCHSEG1>>,<<FIELD>>,time)]
| table time content

mxh7777
Path Finder

Hi @ITWhisperer 

Thanks for this perfect  solution !!

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...