Courseiva
Basic Searching and Transforming CommandsmediumMultiple ChoiceObjective-mapped

Filter Stats Results with where Command

An analyst runs the search `index=web | stats count by status | sort - count` and wants to show only status codes with count greater than 100. Which command should be added before the sort?

Quick Answer

Filtering on a field that stats itself creates, like count, has to happen after the aggregation has already run, because that field doesn't exist in the raw events at all, it's generated by the stats command as part of building its summary table. This is exactly why where count>100 belongs after stats count by status: the where command evaluates a condition against the fields present in the current result set, and by the time it runs in this pipeline, count is already a field on each row, one row per status code, that where can compare against 100. Placing the filter before stats wouldn't work, since count wouldn't exist yet at that point in the search. The where command is Splunk's general-purpose tool for this kind of post-aggregation filtering, distinct from the search command, which filters raw events before or independent of any transforming command. Any time a question describes wanting to keep only the aggregated rows that meet some numeric or comparison threshold, such as a count, sum, or average above or below a certain value, after a stats, chart, or timechart command has already run, that's the signal to reach for where placed immediately after the aggregating command in the pipeline.

⚠ Common exam trap

Splunk often tests the distinction between `search` (pre-aggregation filtering) and `where` (post-aggregation filtering), and candidates mistakenly use `search` to filter computed fields like `count` from `stats`, not realizing that `search` operates on raw events before transformation.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

where count>100

The `where` command is used to filter results based on a condition after statistical aggregation. In this search, `stats count by status` creates a field called `count`, and `where count>100` filters the results to show only status codes with a count greater than 100. The `where` command operates on the results of the `stats` command, making it the appropriate choice for post-aggregation filtering.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • eval count>100

    Why it's wrong here

    eval creates a field, does not filter.

  • search count>100

    Why it's wrong here

    search filters events before stats, not after.

  • where count>100

    Why this is correct

    where filters the stats results.

  • filter count>100

    Why it's wrong here

    filter is not a valid SPL command.

About these practice questions

This SPLK-1001 question is part of Courseiva's 502-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on SPLK-1001

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. An analyst runs: index=app sourcetype=log ERROR | stats count by host | where count > 5. What is the function of the where command in this search?

medium
  • A.Remove duplicate hosts
  • B.Filter events that contain ERROR before counting
  • C.Rename the count field
  • D.Filter the output of stats to show only hosts with count > 5

Why D: The `where` command filters the results of the `stats` calculation, keeping only rows where the `count` field exceeds 5. This is a post-processing filter applied after aggregation, not a pre-filter on raw events. The `where` command operates on the output of `stats`, not on the original events.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This SPLK-1001 practice question is part of Courseiva's free Splunk certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SPLK-1001 exam.