1. build webform with a number component
2. make several submissions with different numbers for that component.
3. build a view showing submissions for that webform
4. add a relationship to the webform data of that component
5. add a field showing the raw data of that now-related component
6. build an exposed filter relating to that component with operator 'greater than'

please note that this does not do a numeric comparison.

it seems to be alphabetic? 99 is higher than 100. 5 is higher than 49.

There are two parts to this:

1) Casting submission data to numeric in views filters (and exposed filters)
2) Casting submission data to numeric in views sorting.

Comments

danchadwick’s picture

Category: Bug report » Feature request

Can you confirm that sorting and filtering (not exposed, but regular filtering) work? If so, then your view is set up correctly.

I suspect that the views support in webform does not implement the special processing that would be needed for an exposed filter. When working with raw data, realize that all values are stored as strings in the database. There is some support for casting these to numbers.

If my understanding is correct, patches are welcome. I haven't looked at it in a while. Could be easy. Or not. ;) You probably need to take care to avoid casting non-numeric data to a number. I suspect you get a SQL exception.

jannis’s picture

Thanks Dan.

I went ahead and did a non-exposed filter, and had the same result. It does a string comparison.

I've been using Webform 4 and Views 3 with a bunch of cool exposed filter modules (selective, dependent, autocomplete etc) everything 'just works' except this one thing.

I think it might have something to do with the webform data relationship? Do you know of way to create a relationship and force it to convert the string value to a number? Maybe make another relationship option called "Webform Submissions: Numeric Data"?

I'm not too concerned with non-number data in the db causing errors, the validation works great for kicking out bad data on the submission side.

Thanks again for your feedback. I can't seem to find any other folks reporting this issue.

danchadwick’s picture

My error. The regular (not raw) submission field contains the number versus string option. This pseudo-field doesn't support filtering or sorting.

It seems like a good idea to extend the Number/String option to the raw data. There might be complications. Don't know. Patches welcome.

pal4life’s picture

@Jannis,
I am curious how you are using webform submissions in views, everytime I have tried that it does not go as expected. Is there a particular link or example you followed so maybe I can look at it. This way I can also try to recreate this scenario.

Thanks.

danchadwick’s picture

Title: Can't do numeric comparison of webform submitted numeric data in views » Numeric comparison and sort of submitted data in views
Version: 7.x-4.4 » 7.x-4.x-dev
Issue summary: View changes
danchadwick’s picture

Status: Active » Fixed
StatusFileSize
new7.98 KB

This patch adds a different type of raw value for numeric data. You need to create a relationship to the specific node / component first, just as you would for regular (string) raw data.

This patch supports:

  1. Displaying the numeric data. It will be a floating point number, allowing floating point formatting.
  2. Filtering the data numerically -- i.e. 5 < 20. You can also use exposed filters. All filter operators are supported, although empty, not empty, and regular expression are of limited value.
  3. Sorting the data numerically. You can also expose the sort filters.
  4. More than one numeric value is supported by using additional relationships.

I have to admit this was a tough issue as it requires a fairly deep understanding of how field, filter, and sort handlers interact in views.

If you use the development version and have already run update.php since update 7423, you will need to clear all caches to rebuild the registry and flush the views cache. There is a new file containing the new views handlers, as was as update views definitions for the tables. If you are updating from webform 7.x-4.7 to 7.x-4.8 or higher, update 7423 and 7425 will flushed the needed caches.

Committed to 7.x-4.x.

danchadwick’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev
Status: Fixed » Patch (to be ported)

  • DanChadwick committed c87bebb on 7.x-4.x
    Issue #2449871 by DanChadwick: Numeric display, comparison and sort of...

  • fenstrat committed bb2bfbf on 8.x-4.x authored by DanChadwick
    Issue #2449871 by DanChadwick: Numeric comparison and sort of submitted...
fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
Status: Patch (to be ported) » Fixed

Committed and pushed to 8.x-4.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.