Dashboards & Visualizations

Change timechart x-axis to quarters?

POR160893
Builder

Hi,

I have a timechart and the timeline on the X-axis must be in terms of quarters, i.e. like FY24Q1, FY24 Q2 etc.

Currently, this is my query:
(BASE SEARCH) | timechart span=1q count | eval Quarter=strftime(_time,"%Y") . "Q" . ceil((strftime(_time,"%m")+1)/3) | rename count as "Event Count" | fields Quarter, "Event Count"

However, I am receiving the following error:
Error in 'eval' command: Type checking failed. '+' only takes two strings or two numbers.

What can I do to solve this?


Thanks as always!

Labels (4)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The strftime function returns a string.  The error is complaining that eval can't add a number to a string.  Try this to convert the strftime output to a number.

 

| eval Quarter=strftime(_time,"%Y") . "Q" . ceil(tonumber(strftime(_time,"%m")))+1/3)

 

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

POR160893
Builder

When I used your suggestion as follows:
[BASE SEARCH]
| timechart span=1q count
| eval Quarter=strftime(_time,"%Y") . "Q" . ceil(tonumber(strftime(_time,"%m"))+1)/3)
| rename count as "Event Count" | fields Quarter, "Event Count",

 

I receive the following error:
Error in 'eval' command: The expression is malformed.

What can I do?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I misplaced a parenthesis.  Please try my revised answer.

---
If this reply helps you, Karma would be appreciated.
0 Karma

POR160893
Builder

So, at the moment, your updated query gives me this:

POR160893_0-1677683220101.png

The above query is as follows:
[BASE SEARCH]
| timechart span=1q count
| eval Quarter=strftime(_time,"%Y") . "Q" . ceil((tonumber(strftime(_time,"%m")))+1/3)
| rename count as "Event Count" | fields Quarter, "Event Count"

However, I need the individual days to be show WITH what ever quarter the day falls in.. So one timeline whose Year/Month/date and an overarching time to show what Quarter it falls.
Is this possible?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Timecharts support a single timeline on the X-axis.  Consider filing an enhancement request at https://ideas.splunk.com

Another thing to consider is using annotations to denote the quarters.  An annotation is a vertical line in the graph that marks when something happened.  It's not exactly what you're looking for, but may help.  See https://docs.splunk.com/Documentation/Splunk/9.0.4/Viz/ChartEventAnnotations for more information.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...

Index This | When is October more than just the tenth month?

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

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...