How do I calculate multiple percentages based off a key?

Comments

3 comments

  • Avatar
    Kevin Keech

    Hi Wofi,

    Can you give the following a try?


    ("finished their work" or "failed their work")
    | parse regex "(?<status>finished|failed) their work"
    | json field=_raw "arg0.details.person.name" as name
    | if(status="finished", 1, 0) as finished
    | if(status="failed", 1, 0) as failed
    | sum(finished) as finished, sum(failed) as failed, count as total by name
    | (finished/total)*100 as pct_finished

    What this does is puts a 1 or 0 into a "finished" or "failed" column. We can then use those to sum up the number of finished v. failed per user and then it's just the simple math against the total count per user to get the percentage. 

    I hope this will help with getting the values your looking for. 

    0
    Comment actions Permalink
  • Avatar
    Wofi Team

    Yep, that works like a charm!

    Thank you!

    0
    Comment actions Permalink
  • Avatar
    Kevin Keech

    Awesome. I noticed I had a small error in the field label for the "finished" field and have fixed that in my original post. 

    0
    Comment actions Permalink

Please sign in to leave a comment.