bin span=1 will do this for you
| makeresults count=20
| eval duration=random() % 20
| eval count=random() % 20
| stats sum(count) as count by duration
| sort 0 duration
| makecontinuous duration
| bin duration span=1
bin span=1 will do this for you
| makeresults count=20
| eval duration=random() % 20
| eval count=random() % 20
| stats sum(count) as count by duration
| sort 0 duration
| makecontinuous duration
| bin duration span=1
| eval duration=(TASK_DURATION)/3600000|chart distinct_count(TASK_NUM) as task by duration| makecontinuous duration | bin duration span=1
I have used the query like this and i'm getting the following results. This is the result that i got
Use floor on the division otherwise you are charting by fractions of hours.
| eval duration=floor((TASK_DURATION)/3600000)
Thank you so much!! It is working fine.. I have one small query, if we have to make interval as 0-2, 2-4, 4-6... i have to change span=2 right? i tried and i am getting repeated values in the table.
You would have do it slightly differently
| makeresults count=20
| eval duration=random() % 20
| eval count=random() % 20
``` this bin groups duration in 2's for the stats - note the s after the 2 (this keeps the duration as numbers rather than strings of ranges) ```
| bin duration span=2s
| stats sum(count) as count by duration
| sort 0 duration
| makecontinuous duration
``` this bin converts the duration to a string range - note the removal of the s ```
| bin duration span=2
I have one doubt.. need one more help from you.. The x axis is showing ranges that are too high.. for example 200-202 which doesn't have data in the y axis. How can i limit the range of x axis?
Take out the makecontinuous
Thank you..
Since the bar graph is having a lot of values in x axis i'm trying to limit the values. I'm trying to group the values into 3. One which has duration less than 15, second one having duration between 15 to 25 and last one having duration greater than 25.
| eval red = if(duration>25,duration,0) | eval yellow = if(duration<=25 AND duration>15,duration,0) | eval green = if(duration<=15, duration, 0)
I have tried like this but i think this is not how its done. Do you have any idea on this. Can you please help me on this.
Thank you so much!