Dashboards & Visualizations

add cumulative line on bar chart

matansocher
Contributor

Hi,

I have a report that shows the number of hours worked for each employee.
Can I add a cumulative line, to show the cumulative for all employees?

The code I am using:

    index=snow dv_state="Clos*" 
    | dedup number 
    | rex field=dv_u_total_time_spent "(?<DAYS>\d+)\s*Day" 
    | rex field=dv_u_total_time_spent "(?<HOURS>\d+)\s*Hour" 
    | rex field=dv_u_total_time_spent "(?<MINS>\d+)\s*Minute" 
    | eval DAYS = if((isnull(DAYS)), 0, tonumber(DAYS)) 
    | eval HOURS = if((isnull(HOURS)), 0, tonumber(HOURS)) 
    | eval MINS = if((isnull(MINS)), 0, tonumber(MINS)) 
    | eval numberOfHours = round(((DAYS*8) + HOURS + (MINS/60)),0)
    | chart sum(numberOfHours) AS "Number Of Hours" by dv_assigned_to
    | sort -"Number Of Hours"

This is the result now:
alt text

I need a line that starts from the left side (ddaniel) in 400, and than moves to 750 (slavag) and so on.
Its not by time, so is this possible to add that cumulative line?

Thanks

0 Karma
1 Solution

HiroshiSatoh
Champion

try this!

<cumulative>

 index=snow dv_state="Clos*" 
     | dedup number 
     | rex field=dv_u_total_time_spent "(?<DAYS>\d+)\s*Day" 
     | rex field=dv_u_total_time_spent "(?<HOURS>\d+)\s*Hour" 
     | rex field=dv_u_total_time_spent "(?<MINS>\d+)\s*Minute" 
     | eval DAYS = if((isnull(DAYS)), 0, tonumber(DAYS)) 
     | eval HOURS = if((isnull(HOURS)), 0, tonumber(HOURS)) 
     | eval MINS = if((isnull(MINS)), 0, tonumber(MINS)) 
     | eval numberOfHours = round(((DAYS*8) + HOURS + (MINS/60)),0)
     | chart sum(numberOfHours) AS "Number Of Hours" by dv_assigned_to
     | sort -"Number Of Hours"
     | accum "Number Of Hours" as cumulative

<total>
|addcoltotals labelfield=dv_assigned_to label=TOTAL

View solution in original post

HiroshiSatoh
Champion

try this!

<cumulative>

 index=snow dv_state="Clos*" 
     | dedup number 
     | rex field=dv_u_total_time_spent "(?<DAYS>\d+)\s*Day" 
     | rex field=dv_u_total_time_spent "(?<HOURS>\d+)\s*Hour" 
     | rex field=dv_u_total_time_spent "(?<MINS>\d+)\s*Minute" 
     | eval DAYS = if((isnull(DAYS)), 0, tonumber(DAYS)) 
     | eval HOURS = if((isnull(HOURS)), 0, tonumber(HOURS)) 
     | eval MINS = if((isnull(MINS)), 0, tonumber(MINS)) 
     | eval numberOfHours = round(((DAYS*8) + HOURS + (MINS/60)),0)
     | chart sum(numberOfHours) AS "Number Of Hours" by dv_assigned_to
     | sort -"Number Of Hours"
     | accum "Number Of Hours" as cumulative

<total>
|addcoltotals labelfield=dv_assigned_to label=TOTAL

matansocher
Contributor

the accum line was what I needed.
Thanks a lot!

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

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

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...