Dashboards & Visualizations

How to get the calender week from the date?

anooshac
Communicator

Hi Everyone,

I want to plot a chart according to the calendar week. I plotted a timechart like this,

 

|timechart span=7d distinct_count(Task_num) as Tasks by STATUS

 

But this doesn't give the exact calendar weeks. Also i am keeping this charts data to last 3 months.

Anyone have idea how to plot a bar chart based on calendar week? instead of date i want to see the data for current calendar weeks of last 3 months.

I got from the splunk community on how to get the Calendar week. But i am not to plot a graph out of it.

| eval weeknum=strftime(strptime(yourdatefield,"%d-%m-%Y"),"%V")

 

 

Labels (3)
Tags (2)
0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

maybe you could try to get data by adding this into your base search ?

earliest=-3mon@w+d latest=@w+d

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Untested, but try the chart command.

| eval weeknum=strftime(strptime(yourdatefield,"%d-%m-%Y"),"%V")
| chart dc(Task_num) as Tasks over weeknum by STATUS

 

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

anooshac
Communicator

Mt date field is _time. When i use this query i'm getting as no results found.

| eval weeknum=strftime(strptime(_time,"%d-%m-%Y"),"%V")
| chart dc(Task_num) as Tasks over weeknum by STATUS

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

_time is already in epoch form so it does not need to be (and cannot be) converted using strptime.

| eval weeknum=strftime(_time, "%V")
| chart dc(Task_num) as Tasks over weeknum by STATUS
---
If this reply helps you, Karma would be appreciated.
0 Karma

anooshac
Communicator

Thank you so much.. I totally forgot that it is already in epoch format.

0 Karma
Get Updates on the Splunk Community!

Splunk Lantern | Getting Started with Edge Processor, Machine Learning Toolkit ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Enterprise Security Content Update (ESCU) | New Releases

In the last month, the Splunk Threat Research Team (STRT) has had 2 releases of new security content via the ...

Announcing the 1st Round Champion’s Tribute Winners of the Great Resilience Quest

We are happy to announce the 20 lucky questers who are selected to be the first round of Champion's Tribute ...