Get Data Per Week within a Month

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Get Data Per Week within a Month

L1 Bithead

Hello, I would like to ask how to retrieve dat per-week within a month. My current query is like:

 

config timeframe = 30d
| dataset = incidents
| bin creation_time span = 7d

.....

but i don't think its working  properly, could you please help me to fix or improve it 🙂

 

Thank You....

1 accepted solution

Accepted Solutions

L4 Transporter

config timeframe = 30d
| dataset = incidents
| alter week_start = date_floor(creation_time, "w")
| comp count() as incidents_per_week by week_start
| sort asc week_start

 

 

And here the details:

 

  • config timeframe = 30d: This sets the overall search window to the last 30 days.

  • dataset = incidents: Specifies that you're querying the incidents dataset.

  • | bin creation_time span = 7d as week_interval: This is the core for "per-week". It groups all incidents by their creation_time into distinct 7-day bins. The as week_interval assigns a readable name to the timestamp representing the start of each 7-day period.

  • | aggregate count() as incident_count: After binning, this counts how many incidents fall into each week_interval bucket.

  • | sort by week_interval asc: (Optional) This just orders your results from the oldest 7-day period to the newest.

 

Best Regards,
Suresh

View solution in original post

1 REPLY 1

L4 Transporter

config timeframe = 30d
| dataset = incidents
| alter week_start = date_floor(creation_time, "w")
| comp count() as incidents_per_week by week_start
| sort asc week_start

 

 

And here the details:

 

  • config timeframe = 30d: This sets the overall search window to the last 30 days.

  • dataset = incidents: Specifies that you're querying the incidents dataset.

  • | bin creation_time span = 7d as week_interval: This is the core for "per-week". It groups all incidents by their creation_time into distinct 7-day bins. The as week_interval assigns a readable name to the timestamp representing the start of each 7-day period.

  • | aggregate count() as incident_count: After binning, this counts how many incidents fall into each week_interval bucket.

  • | sort by week_interval asc: (Optional) This just orders your results from the oldest 7-day period to the newest.

 

Best Regards,
Suresh
  • 1 accepted solution
  • 330 Views
  • 1 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!