Splunk Search

Transpose function is split multivalue to singlevalue of space delimiter

kbluech
Engager

Hi.
I am found that Transpose function is split multivalue to singlevalue of space delimiter.

< table >

AAA

BBB

CCC

< table | transpose >

AAA BBB CCC

Can I remain my multivalue?

0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

You could work around the issue like this:

| stats count | eval value = "foo" | eval multivalue = "foo bar" | makemv multivalue
    | foreach * [eval <<FIELD>> = mvjoin(<<FIELD>>, "#####")] | transpose | foreach row* [makemv "<<FIELD>>" delim="#####"]

First I create a dummy event with an mv field multivalue, that's where your transpose command would be. Now I use foreach to turn every mv field into a regular field, using a delimiter that may not exist elsewhere... do the transpose, and turn each row back into a mv field based on that delimiter.

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

You could work around the issue like this:

| stats count | eval value = "foo" | eval multivalue = "foo bar" | makemv multivalue
    | foreach * [eval <<FIELD>> = mvjoin(<<FIELD>>, "#####")] | transpose | foreach row* [makemv "<<FIELD>>" delim="#####"]

First I create a dummy event with an mv field multivalue, that's where your transpose command would be. Now I use foreach to turn every mv field into a regular field, using a delimiter that may not exist elsewhere... do the transpose, and turn each row back into a mv field based on that delimiter.

kbluech
Engager

Yes, It works.
Additionally, before the transposed multivalue that use head 1|table |transpose|makemv delim=" " "row 1". It's not working, but i was use head 1|chat list() over _time|transpose|makemv delim=" " "row 1".
Thank you martin.^^

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Well, the key reason for using foreach here is that you don't need to care about what fields actually are mv fields and how many rows you get after the transpose.

If you do know these things you could replace the foreach with one eval per mv field before the transpose and one makemv per transposed row X field after the transpose.

0 Karma

somesoni2
Revered Legend

Works perfectly fine with Splunk 6.x. Can we achieve the same in Splunk 5.0.5 version (foreach command is not available)?

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...