Dashboards & Visualizations

## X axis per month with average

Explorer

Hi you all,

I'm very new on Splunk and I'm trying to learn the SPL code.

Pour le moment j'ai un graphique qui a dans l'axe X la date (JJ / MM / AAAA en désordre) et dans l'axe Y une valeur. Je veux savoir comment puis-je classer l'axe X dans l'ordre chronologique par mois et réaliser la moyenne de toute la valeur par mois?

For the moment I have a graphic that has the date in the X axis (DD/MM/YYYY in disorder) and Y axis the value. I want to know how can I sort the X axis in the chronogical order per month and realize the average of all the value per month ?

Labels (1)
• ### timechart

1 Solution
SplunkTrust

sample:

``````| gentimes start=1/1/2019 end=1/1/2020
| rename starttime as _time
| rename COMMENT as "this is sample, from here the logic."

| bin _time span=1month
| eval date=strftime(_time,"%d/%m/%Y")
| eval count=random() % 100
| stats avg(count) as count by _time date
| table date count``````

recommend

``````your search
| eval _time=strptime(DateJour,"%d/%m/%Y")
| bin _time span=1month
| eventstats avg(May) as avgMay by _time
| eval _time=strptime(DateJour,"%d/%m/%Y")
| sort _time
| eval criticalmin = -2 ,criticalmax = 2
| table DateJour May avgMay criticalmin criticalmax``````
SplunkTrust

sample:

``````| gentimes start=1/1/2019 end=1/1/2020
| rename starttime as _time
| rename COMMENT as "this is sample, from here the logic."

| bin _time span=1month
| eval date=strftime(_time,"%d/%m/%Y")
| eval count=random() % 100
| stats avg(count) as count by _time date
| table date count``````

recommend

``````your search
| eval _time=strptime(DateJour,"%d/%m/%Y")
| bin _time span=1month
| eventstats avg(May) as avgMay by _time
| eval _time=strptime(DateJour,"%d/%m/%Y")
| sort _time
| eval criticalmin = -2 ,criticalmax = 2
| table DateJour May avgMay criticalmin criticalmax``````
Explorer

Many thanks !!

Take the 2021 Splunk Career Survey

### Help us learn about how Splunk has impacted your career by taking the 2021 Splunk Career Survey.Earn \$50 in Amazon cash! Full Details! >

Get Updates on the Splunk Community!