- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have used below query to get distinct values:
stats values(gitRepo) AS serviceName BY buildNum
This gives correct values. Problem is I am not getting value for other fields. If I used eventstats all values are coming in the table output but it is getting wrong data.
eventstats values(gitRepo) AS serviceName BY buildNum
How do I fix this?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![493669 493669](https://community.splunk.com/legacyfs/online/avatars/456647.jpg)
Try this:
...| stats values(*) as * by buildNum
It will give all fields unique values by buildNum
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![493669 493669](https://community.splunk.com/legacyfs/online/avatars/456647.jpg)
Try this:
...| stats values(*) as * by buildNum
It will give all fields unique values by buildNum
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
awesome, it worked. Can you explain more about it? so that we can understand concept better. Also let me know Splunk reference documents for above solution.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![493669 493669](https://community.splunk.com/legacyfs/online/avatars/456647.jpg)
here * denotes wildcard
stats values(*) as *
will calculate all fields unique values
have a look at http://docs.splunk.com/Documentation/Splunk/7.0.3/SearchReference/Stats
stats
- Calculates aggregate statistics over the results set, such as average, count, and sum. This is similar to SQL aggregation. If stats is used without a by clause only one row is returned, which is the aggregation over the entire incoming result set. If you use a by clause one row is returned for each distinct value specified in the by clause.
eventstats
- Generate summary statistics of all existing fields in your search results and saves those statistics in to new fields. The eventstats command is similar to the stats command. The difference is that with the eventstats command aggregation results are added inline to each event and added only if the aggregation is pertinent to that event.
to better understand difference between stats and eventstats have a look at answer
https://answers.splunk.com/answers/139534/what-are-the-calculated-differences-between-stats-and-even...
![](/skins/images/53C7C94B4DD15F7CACC6D77B9B4D55BF/responsive_peak/images/icon_anonymous_message.png)