SPLK-1001 practice question 13 of 30

Which stats command function provides a count of how many unique values exist for a given field in the result set?

Full set: 244 questions

Domain Using Basic Transforming Commands

Answer options
A: dc(field) Correct answer
B: count(field)
C: count-by(field)
D: distinct-count(field)
Correct Answer:
A. dc(field)
Explanation

The stats command in Splunk uses various functions to perform calculations on search results. To count the number of unique (or distinct) values for a specific field, the distinctcount() function is used. The dc() function is the officially documented and commonly used alias for distinctcount(). It iterates through the results and returns a count of how many different values appear for the specified field.

Why Incorrect

B. count(field): This function returns the total number of events that contain the specified field, not the count of its unique values.
C. count-by(field): This is not a valid stats function. The by clause is a part of the stats command syntax itself (e.g., ... | stats count by field), not a function.
D. distinct-count(field): This syntax is incorrect due to the hyphen. The correct function name is distinctcount(field), for which dc(field) is the accepted alias.

References

1. Splunk Enterprise Documentation

Search Reference

"stats command".

Section: Statistical and charting functions

Content: The documentation lists dc() as an alias for distinctcount(). It defines distinctcount() as the function that "Returns a count of the unique values of the field." This directly supports option A. The same section defines count() as returning "a count of the number of occurrences of the field

" which invalidates option B.

2. Splunk Enterprise Documentation

Search Reference

"Statistical and charting functions".

Section: Function list

Content: This page provides a comprehensive list of functions for commands like stats

chart

and timechart. It explicitly lists dc() as the alias for distinctcount() and confirms the absence of count-by() or distinct-count() (with a hyphen) as valid functions

thereby invalidating options C and D.

Scroll to Top