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!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...