Create top 5 of selected options I would like to create a top 5 of selected options from a webform.

As users fil in the webform i would like to create a view with the top 5 selections of the list.
How can i do this with views?

Example: i have a webform with 5 options.

a,b,c,d,e

User get a dropdown to choose 1 or multiple options.

When 10 users have filled out the form these are the results

option a is chosen 4 times
option b is chosen 7 times
option c is chosen 2 times
option d is chosen 1 time
option e is chosen 9 times

How can i create a view that show this

Top 5 of selected options:
Option e
Option b
Option a
Option c
Option d

Kind regard Kevin
You can create a view with webform type. Then add a Global PHP field in header.

&lt;?php 
$nid=62;
$option1_count=0;
$option2_count=0;
foreach($results as $results1) {
    $each_submission=webform_get_submission($nid, $results1-&gt;sid);
    //print_r($each_submission-&gt;data);
    if($each_submission-&gt;data[1][0]==1) {
        $option1_count++;
    }
    if($each_submission-&gt;data[1][0]==2) {
        $option2_count++;
    }
}
$top=[$option1_count,$option2_count];
arsort($top);
?&gt;


I haven't tested this code but something like this should work.

EDIT:

You can make that code generic but if you don't want that then use grouping and aggregation in views and try Views Distinct

First add field Webform submission data:Value(your webform field) and set aggregation to yes. This will help.