The answer is that the eval command must be placed before stats because of Splunk’s order of operations. In the search pipeline, stats consumes raw event data and outputs only the fields it explicitly retains—here, status and count—so any subsequent eval trying to create a new field like status_category from status will still work technically, but the first stats is unnecessary and disrupts the intended flow. The correct approach is to apply eval first to categorize the raw status values, then use stats count by status_category to aggregate by the new field. On the SPLK-1002 exam, this tests your understanding of search-time field creation and pipeline sequence, a common trap where candidates mistakenly think stats can run before field transformations. Remember the memory tip: “Eval before stats, or your new field gets the axe.”
SPLK-1002 Practice Question: Creating Reports, Dashboards and Visualizations
This SPLK-1002 practice question tests your understanding of creating reports, dashboards and visualizations. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
Exhibit
Refer to the exhibit.
```
index=web sourcetype=access_combined
| stats count by status
| eval status_category = case(status>=200 AND status<300, "2xx", status>=300 AND status<400, "3xx", status>=400 AND status<500, "4xx", status>=500, "5xx")
| stats count by status_category
```
Refer to the exhibit. The search is expected to produce a count of HTTP status codes grouped into categories. However, the results show a column 'status' instead of 'status_category'. What is the problem?
Refer to the exhibit.
```
index=web sourcetype=access_combined
| stats count by status
| eval status_category = case(status>=200 AND status<300, "2xx", status>=300 AND status<400, "3xx", status>=400 AND status<500, "4xx", status>=500, "5xx")
| stats count by status_category
```
A
The first 'stats count by status' is unnecessary; the eval should be applied first, then stats.
Applying stats before eval loses the original status values for categorization, resulting in incorrect grouping.
B
The eval command references a field 'status' that does not exist after the first stats.
Why wrong: After first stats, the field 'status' exists as the grouping field.
C
The second stats command should be 'stats count by status'.
Why wrong: That would not group by category.
D
The eval command should use 'if' instead of 'case'.
Why wrong: Both if and case are valid; case is appropriate here.
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The first 'stats count by status' is unnecessary; the eval should be applied first, then stats.
Option A is correct because the search pipeline first uses `stats count by status`, which consumes the raw `status` field and outputs only the `status` and `count` fields. The subsequent `eval` command then tries to create `status_category` from `status`, but `status` still exists after the first `stats` (it is the group-by field). The real issue is that the `eval` should be placed before the first `stats` so that the categorization happens on the raw `status` values, and then `stats count by status_category` can aggregate by the new field. The first `stats` is unnecessary and disrupts the intended flow.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
✓
The first 'stats count by status' is unnecessary; the eval should be applied first, then stats.
Why this is correct
Applying stats before eval loses the original status values for categorization, resulting in incorrect grouping.
Related concept
Read the scenario before looking for a memorised answer.
✗
The eval command references a field 'status' that does not exist after the first stats.
Why it's wrong here
After first stats, the field 'status' exists as the grouping field.
✗
The second stats command should be 'stats count by status'.
Why it's wrong here
That would not group by category.
✗
The eval command should use 'if' instead of 'case'.
Why it's wrong here
Both if and case are valid; case is appropriate here.
Common exam traps
Common exam trap: answer the scenario, not the keyword
Splunk often tests the order-of-operations pitfall where candidates assume `eval` can create a new field from a field that exists before `stats`, forgetting that `stats` transforms the data structure and only retains specified fields.
Detailed technical explanation
How to think about this question
In Splunk's search processing pipeline, commands are executed left to right in the order they appear. The `stats` command is a transforming command that collapses events into a table, discarding all fields not used in the aggregation or group-by. If `eval` is placed after `stats`, it can only reference fields that survived the `stats` output. A common real-world scenario is categorizing HTTP status codes (e.g., 2xx, 3xx, 4xx) before aggregation; placing `eval` first ensures the new field is available for grouping, avoiding the need to re-extract or re-calculate.
KKey Concepts to Remember
Read the scenario before looking for a memorised answer.
Find the constraint that changes the correct option.
Eliminate answers that are true in general but not in this case.
TExam Day Tips
→Watch for words such as best, first, most likely and least administrative effort.
→Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A practitioner preparing for the SPLK-1002 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.
What to study next
Got this wrong? Here's your next step.
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
Creating Reports, Dashboards and Visualizations — This question tests Creating Reports, Dashboards and Visualizations — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: The first 'stats count by status' is unnecessary; the eval should be applied first, then stats. — Option A is correct because the search pipeline first uses `stats count by status`, which consumes the raw `status` field and outputs only the `status` and `count` fields. The subsequent `eval` command then tries to create `status_category` from `status`, but `status` still exists after the first `stats` (it is the group-by field). The real issue is that the `eval` should be placed before the first `stats` so that the categorization happens on the raw `status` values, and then `stats count by status_category` can aggregate by the new field. The first `stats` is unnecessary and disrupts the intended flow.
What should I do if I get this SPLK-1002 question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
This SPLK-1002 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-1002 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.