Splunk Search

How to merge multiple query in single output

twh1
Communicator

I have 5 query merged in single output. In statistics tab I am getting expected values. But in visualization tab when i am selecting bar chart for this table, first column value is displaying on x-axis as field name as x-axis label which should display as bar chart.
I have attached the screenshot. In this bottom table we can see 5 fields but in legend we can see only 4. Carecredit is showing as x-axis label.

Expected Result: All 5 field count in bar chart.

Note: I am getting correct result if I am using timechart rather than stats command.

0 Karma
1 Solution

niketn
Legend

@twh1... this exact scenario has been explained as a use case in Splunk documentation for transpose command. https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transpose

Your data is missing first column to show aggregate fields like row 1 is Device and row 2 is Count. If possible you should refactor your five queries to get these two aggregate by and aggregate type fields. Otherwise you can just pipe the following and you should be able to pull the Count of various Devices

| transpose column_name="Count"
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

twh1
Communicator

I tried the below option and got the expected result.

.....| table _time CareCredit SYPI WKS Orange Samsung

0 Karma

niketn
Legend

@twh1... If you required time as one of the fields to be displayed you can actually use timechart or in stats add by _time clause. There is no need of an additional pipe with table. Based on your query seemed like you just needed 5 columns.

Anycase... glad you found your answer.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

woodcock
Esteemed Legend

Add this to the end of your search:

| eval PutXAxisLableTextHere=" "
| table PutXAxisLableTextHere *
0 Karma

niketn
Legend

@twh1... this exact scenario has been explained as a use case in Splunk documentation for transpose command. https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transpose

Your data is missing first column to show aggregate fields like row 1 is Device and row 2 is Count. If possible you should refactor your five queries to get these two aggregate by and aggregate type fields. Otherwise you can just pipe the following and you should be able to pull the Count of various Devices

| transpose column_name="Count"
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

koshyk
Super Champion

what is your timechart parameters?
You might be just doing a | stats count

but rather do "by"
| stats count by your_product_field

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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...