Splunk Search

How to convert a crosstable into a list format to use as a lookup file?

HeinzWaescher
Motivator

Hi,

I would like to convert a crosstable into a list.

Date      | A | B 
01.01.2014| 5 | 2
02.01.2014| 5 | 2
03.01.2014| 8 | 9

The output should be:

col1       |col2| col3
01.01.2014 | A | 5
01.01.2014 | B | 2
02.01.2014 | A | 5
02.01.2014 | B | 2
03.01.2014 | A | 8
03.01.2014 | B | 9

Is there an easy way to do this? I tried out the transpose command, but without success.

BR

Heinz

Tags (4)
0 Karma
1 Solution

tom_frotscher
Builder

I think this might not be the best solution. But maybe this is a good starting point:

| inputlookup answers.csv | stats values(A) as col3 by Date | eval col2="A" | append [| inputlookup answers.csv | stats values(B) as col3 by Date | eval col2="B"] | rename Date as col1 | sort col1 | table col*

View solution in original post

somesoni2
Revered Legend

This should work

| inputlookup lookup.csv | untable Date col2 col3
0 Karma

HeinzWaescher
Motivator

unfortunately this command only accepts 3 arguments, but I will need more soon.

0 Karma

tom_frotscher
Builder

I think this might not be the best solution. But maybe this is a good starting point:

| inputlookup answers.csv | stats values(A) as col3 by Date | eval col2="A" | append [| inputlookup answers.csv | stats values(B) as col3 by Date | eval col2="B"] | rename Date as col1 | sort col1 | table col*

HeinzWaescher
Motivator

Thanks, this works! But I think it could be easier to prepare the flat list with excel & pivot before importing, when there will be more columns. This search needs an update every time a new column is added.

0 Karma

HeinzWaescher
Motivator

The "search" for the conversion would be

| inputlookup lookup.csv | ...

0 Karma

HeinzWaescher
Motivator

Hi Patrick,

there is no search 🙂 My goal is just convert an uploaded csv, which looks like the above example (a crosstable). I want to use it as a lookup file, therefore I need to flatten it. I can do it everytime with excel before uploading, but a Splunk solution would be much more comfortable.

0 Karma

ppablo
Retired

Hi @HeinzWaescher

It'll be helpful if you can paste your current search query that people can work with and tweak to get the result you want 🙂

Patrick

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...