Splunk Search

How do I transpose a table grouped by the values in the first column?

andweng
New Member

I have a search that produces the following sample data:

ValueA    ValueB
A         1
A         2
A         3
B         1
B         4
B         5
C         2
C         3
C         4

I want to transpose ValueA as the columns and keep ValueB as the values such that I would have this:

A     B     C
1     1     2
2     4     3
3     5     4

It seems like it should be fairly straightforward and I've tried combinations of transpose, untable and xyseries but nothing quite seems to work. Thanks for the assistance!

Tags (2)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try like this

your current search giving fields ValueA and ValueB OR ends with | table ValueA ValueB
| eval temp=1 
| xyseries temp ValueA ValueB
| fields - temp

View solution in original post

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try like this

your current search giving fields ValueA and ValueB OR ends with | table ValueA ValueB
| eval temp=1 
| xyseries temp ValueA ValueB
| fields - temp
0 Karma

andweng
New Member

That worked with a tweak. Didn't realize I could just create a temporary value to pivot on. I needed matching values to pivot on so I had to add an accum and then xyseries on the accum value.

| eval Rank=1
| accum Rank
| eval Rank=((Rank-1)%10)
| xyseries Rank ValueA ValueB
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 ...