I see in this issue for 6.x ( https://www.drupal.org/node/348374 ) there was some discussion on adding the ability to filter the analysis page based on submitted data (...think pivot tables in Excel), but I can't see a way to do this in 7-4.x. Is there any way to filter analysis data?
What I'm trying to accomplish:
For example I have 100 "survey" submissions from folks all over the country. It would be very useful to filter the analysis page by State/Province (one of the questions asked in the survey) — This way I can run a report for those people who selected "New York" and analyze the submissions for new yorkers.. — or even dive deeper and apply multiple filters like: "New York" + "Favourite Colour: Blue" + "Walk to work" — would show me the analysis page with only those submissions who have those three qualities... etc.
Anyone else accomplish this kind of analysis?
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | webform-filter_analysis_data-2450163-10.patch | 20.6 KB | danchadwick |
| #9 | webform-filter_analysis_data-2450163-9.patch | 18.81 KB | danchadwick |
Comments
Comment #1
wOOge commentedComment #2
danchadwick commentedShould be possible with views. For small datasets, try the views pivot table module. The views crosstab module is faster on large datasets but only works on simple sql. Use raw data fields.
Comment #3
wOOge commentedThanks for the quick response @DanChadwick — I tried both Views Pivot, and Views Crosstab but they are both very heavy on the configuration side just to get a simple table of data, and even then it's not very configurable as each desired "perspective" on the data has to be "hardcoded" into the setup of the view.
I feel like I'm getting closer with
Core Views+ Views Aggregator Plus — then mimicking the Webform Analysis page by creating a view with a tonne of attachments (one for each question in the survey) — then have exposed filters for each of the questions so that as I manipulate the exposed filters, the myriad of attached views tables update....however displaying just 2 tables taxes the server quite a bit (there are only 800 submissions, hosted on a Linode).Webform seems to have some kind of faster way to build the Analysis page — would be great to tap into that system with some kind of webform version of exposed filters (where the filters are just the questions + values in the webform).
Thoughts?
Comment #4
danchadwick commentedMy thoughts are that this is going in the opposite direction of where I see webform going. I have eliminated all the hard-coded tables other than analysis by creating views and enhancing the views integration to support that. Analysis is much harder, but eventually I'd like to see views handle it.
If one had substantial development time or money, I'd like to see the techniques in Views Crosstab rolled into a webform-specific handler(s) and plug-in(s). These would adapt to the components in the webform (like the current results field which expands to display all components as additional fields). Challenging, but the right direction, I think.
I think then that each component would have view which would analyze the data, each of which could be overridden on a component type or webform node + component id way.
I've marked this as postponed because it will take a patch from a contributor or some serious sponsorship to achieve it.
Comment #5
danchadwick commentedClosing for lack of activity. Please feel free to re-open if there is progress toward using Views for analysis.
Comment #6
kevin morse commentedI require this functionality as well. Looking back through the closed issues for this module it seems many others have requested this in the past.
I was considering writing a module to expose a filter on the hard coded Analysis page but it sounds like you are opposed to adding any new features to it and want it removed.
Can you please clarify?
I can't imagine it would be very difficult to add a filter by date or filter by submission number to the already hard coded Analysis page but doing a complete rewrite of it just to add that functionality seems way too difficult for someone without a serious amount of time.
Comment #7
danchadwick commentedIf each person writes his/her own filter on the analysis, it helps that one person. If someone takes on the task of using Views for the analysis, then it enables every site builder to be able to customize the analysis as they desire. I've already done this for the submission tab, table tab, and the administrative list of webforms.
There is a Views Crosstab module which attempts (not super successfully) to add crosstabs (which is what the analysis is) to any view. I'm pretty sure that if the problem space is reduced to the webform_submissions and webform_submissions_data tables, that it should be possible to do this. Someone with the skills or funding needs to step up and make this happen, though.
Make sense?
Comment #8
danchadwick commentedRe-opening this. I'm thinking that one could write a view which simply limits the submissions to the set of submissions desired.
function webform_results_analysis contains a parameter for an array of sid's, but it isn't currently used by webform. This array is passed to each component's analysis function.
It would be pretty easy to use a view to generate this list of sids, and display the view's exposed filter. The problem, however is that an array of sid's will become inefficient at about 10,000 submissions, and probably not viable above 100,000 (for memory alone, if not time). In my testing, I found that IN has O(n^2) performance.
So what I think we want to do is either join the view's query or extract the filters out of a view (which might be tricky if they are on other tables, such as user or webfrom_submissions_data.
Comment #9
danchadwick commentedHere's a patch for testing. I have not yet tried the analysis filtering on every component. Non-core components will need updating. Clear the cache after patching so the view will be recognized.
You will find a new view (webform_analysis, human name Webform Analysis). You can clone this view. Append _NID or _CONTENTTYPE to limit the view to a particular node or content type). For example, to customize the analysis of node 12, name the view webform_analysis_12.
Add whatever exposed filters you want to the view. Be SURE the view doesn't duplicate any data. It should display one sids. You can add relationships to filter on data in the webform. You can filter by user directly.
Let me know how it works for you. Getting this to work was quite a bit harder than you'd think. :)
Comment #10
danchadwick commentedUpdated patch. I missed adding the join to number components and I improved some comments.
Committed to 7.x-4.x and 8.x.
Comment #12
danchadwick commentedNote: Clear the cache to cause the view to be recognized.