Splunk Search

How to split count by product by another value?

maxmukimov
Explorer

Hi,  I have the following query: 

 

| bin _time span=1d | stats count as ProductCount by applysourcetype, product, _time   

| where _time=relative_time(now(), "-d@d") or _time=relative_time(now(), "-8d@d")   

| eval when = if(_time=relative_time(now(), "-d@d"), "(Yesterday)", "(7 Days Ago)")  

| eval "Products Ordered {when}" = ProductCount    

| fields - _time ProductCount  when

| stats  values(*) as * by product , applysourcetype

 

 

and I'm getting following output: banana.PNG

How can make product filed one row for unique product? 

Labels (3)
0 Karma

s2_splunk
Splunk Employee
Splunk Employee
| mvexpand product

at the end of your search should do the trick. mvexpand docs here.

0 Karma

maxmukimov
Explorer

Getting the same results when I added

| mvexpand product
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| stats list(*) as * by product
0 Karma

maxmukimov
Explorer

got this 

banana1.PNG

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

One unique product per row - which is what you said. If this is not what you wanted, perhaps you can give an example of what you were expecting?

0 Karma

maxmukimov
Explorer

From original query I’m getting something like this :

1.PNG

I want to get something like this:

 

2.PNG

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The standard table view doesn't merge cells across rows. Using stats list(*) as * by product should at least group the fields into multi-value lists which is close to what you want.  If you still want separate rows for the counts, with blank entries in the product column for subsequent rows for the same product, you could use some CSS to hide them. This is a little fiddly to do but possible.

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 ...