Splunk Search

Query to find events with more than 2 values for a specific field compared to another field

john_byun
Path Finder

I'm trying to create a query to show me all users who have purchased more than 1 type of product.

Each event has a "user" field and a "product" field.  I only want to see the users that have purchased more than 1 type of product.

"| stats count by user product" 

This shows me all user and product combinations, but don't know how to filter all events where a user only purchased one type of product.

I feel that it should be a very simple query, but can't seem to figure it out.

Labels (5)
Tags (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @john_byun,

Please try below;

| stats dc(product) as count by user
| where count>1

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

scelikok
SplunkTrust
SplunkTrust

Hi @john_byun,

Please try below;

| stats dc(product) as count by user
| where count>1

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

john_byun
Path Finder

Perfect!  Thanks for your help.

0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

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

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...