Hey up,
I have recently been trying to figure out crosstabs, found this, did the job pefectly in my example. When I took it into the real data we wanted to use I noticed that it wasn't returning the results I wanted.
I return up to 6 grouped values for my columns which are numeric values, and then return a NID for each of them, the rows show up fine, but it will only return one value (with the correct data), which is the highest value, so if I request a column for 1, 15 and 23, I will only get results for 23, and the other columns do not appear. When I made the 6 grouped values text and not integers, the rest of the columns showed up correctly and all is working fine.
When I swap the data round to use NID as columns, again, it will only show the column for the highest numbered NID.
If you need any more information just give me a shout.
Cheers
Dan
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | views_crosstab-field_alias_conflict_total-2019563-7.patch | 3.55 KB | danchadwick |
| #4 | views_crosstab-numeric_column_results-2019563-4.patch | 849 bytes | danchadwick |
| #1 | test-view.txt | 3.06 KB | porridj |
Comments
Comment #1
porridj commentedhere is an example view that is broken
Comment #2
eft commentedCan you recreate the problem on a fresh install with dummy data or some other means? I don't have enough experience to figure it out from your exported view.
Comment #3
porridj commentedHey, that view has been created for a fresh install, but you'll need the views_crosstab module installed and also I used the devel module to generate content. Once you have imported the view, you will see that it doesnt look odd (because i must have forgotten to turn on aggregation before I exported!) so if you turn on the aggregation and group content type you should see, a list of nodes accross the top, with a 1 or a 0 in the content type line, then the count at the end. Instead what you actually see is just the highest number node id accross the top and all the others are missing. If you then change the crosstab settings so that the columns are the content types and the rows are the node ids, you will see that it works properly.
The problem only seems to happen when trying to use numbers as the columns.
Let me know if you need more explanation.
Cheers
Dan
Comment #4
danchadwick commentedThe fix is trivial. The regular expression used to create a column alias uses only letters A-Za-z. If the values in the column field are numeric, then the expression aliases are not unique. Also, the actual alias returned by add_field is ignored. The second change fixes the problem for all column field values, but I fixed it explicitly for numeric fields because the column value expressions have meaningful names.
Marking this as major because it prevents functioning for a major set of use cases. Renaming title to show correct failure mode (column field, rather than row field containing numeric values).
Comment #5
danchadwick commentedLooking at the code a bit more, the optional total column is susceptible to the same bug. Also, if the [2126443] is committed, then the awkward double-if can be cleaned up too:
Because this issue intersects with the can't-export issue, it might be best to tend to this after the export issue is committed.
Comment #6
danchadwick commented#4 committed to 7.x-1.x. #5 still open.
Comment #7
danchadwick commentedCommited to 7.x-1.x