Use case: show the percentage of runners who finish the 5 km run in less than 35 minutes, less than 40 minutes, less than 45 minutes, and 45 minutes or above.
Here are the steps
1. Create a Compare Table
2. Clone "Count of Rows" column
3. Edit cloned "Count of Rows"
4. Select "Running Total" from f(x), you can add a header too
5. Switch to Query mode to calculate the percentage
Here is the original query
- q = load "run_result";
- q = group q by 'Bucket';
- q = foreach q generate q.'Bucket' as 'Bucket', count(q) as 'A';
- q = group q by 'Bucket';
- q = foreach q generate 'Bucket', first(A) as 'A', sum(sum(A)) over ([..0] partition by all order by ('Bucket')) as 'B';
- q = order q by 'Bucket' asc;
- q = limit q 2000;
Update row #5 to
q = foreach q generate 'Bucket', first(A) as 'A', sum(sum(A)) over ([..0] partition by all order by 'Bucket') as 'B', sum(sum(A)) over ([..0] partition by all order by 'Bucket')/sum(sum(A)) over([..] partition by 'all') as 'cumulative (%)';
6. Format "cumulative (%)" to Percent or Custom
7. Switch the chart mode and select line chart
8. Hide A and B from Y-Axis and done
With this chart, we can easily understand the percentage of runners who complete the run in less than 35 minutes, less than 40 minutes, less than 45 minutes, and 45 minutes or above.
No comments:
Post a Comment