Hi,

How can I sort views rows by a date field which has multiple values?

My content type has a field type Date with multiple values. I'm trying to build a view using a sort criteria by this date field.
But views rows become duplicated (if a node has 3 date values, this node will appear 3 times). I tried setting query as DISTINCT, but no effect.
Aggregation does work fine with sort, but the field value only returns one value (doesn't matter multiple values settings).

Is there a solution?

thanks

Comments

tim.plunkett’s picture

Category: bug » support

Say you have two nodes, 3 values for each.

Node 1
Jan 19 2012
Mar 21 2012
May 22 2012

Node 2
Dec 18 2011
Feb 20 2012
Apr 22 2012

How would you sort these?

carvalhar’s picture

Actually i was trying to output this:
January / 2012
Node 1
Node 2
February 2012
Node 3
Node 4

and so on... its related to this solution:
http://drupal.org/node/317534

tim.plunkett’s picture

@carvalhar, but using the date values from my comment above, it would output

Dec 2011
Node 2

Jan 2012
Node 1

Feb 2012
Node 2

Mar 2012
Node 1

Apr 2012
Node 2

May 2012
Node 1

carvalhar’s picture

ok, here's my configuration of the main view:

[Fields]
my multiple date field => selected first time to display only month (custom date format)
my multiple date field (2) => selected second time to display only day (custom date format)
my multiple date field (3) => selected third time to display as the grouping field, aggregate all, group column by value, group columns by entity type and value, showing only 'month - year' (custom date format)
my node nid => used as argument for views embed field.
my embed view date list => i had to use Views Field Views to create a list of dates from a view as a embed view in a field. This view simply list all dates from a node nid argument.

[Advanced fieldset settings]
Use aggregation = YES
Distinct = YES

[Sort]
Sorted by my date field (3) with aggregate all results (ASC)

[Format]
Grouping field => my multiple date field (3)
Use rendered output to group rows => checked

That's my solution. And here's the page.

tim.plunkett’s picture

Looks great, what's the problem?

carvalhar’s picture

today nothing lol
at 02 january it was a problem...
but i couldn't find a way to do this without views embed field

tim.plunkett’s picture

Status: Active » Fixed

I'm calling this fixed. You had a complicated use case, and you found a solution. There is no generic way to solve this.

Status: Fixed » Closed (fixed)

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