I created a new view, based on Users. Than I made the relationship "User: Profile", so I will be able to add fields from the profiles. The output of the view shows all user, as expected, but they appear as many times as there are profiles attached to these users. Example: I've got two Profile2 profiles attached to users. Result: the users appear twice in the view. I've then added a third Profile2 profile, and than the users appear 3 times in the view. This only happens for the users where those profiles are populated. So a user with only 2 profiles populated appears only twice.
Setting "Distinct" in Query settings solves this problem.
All this happens before I even added fields from those profiles to the view. But when I add fields from the profiles, the "Distinct" setting doesn't work, and the users appear as many times as there are profiles. Also the extra setting "Pure Distinct" doesn't help.
I'm using the latest versions of all the modules in my Drupal installation. Am I doing something wrong, is this a bug, or... Any help?
Thanks,
Mike.
Comments
Comment #0.0
sportel commentedtypo correction
Comment #1
fagothat's how views works.
Comment #2
sportel commentedHi fago,
Thanks for your helpfull reply.
And, sorry for my stupid and unnecessary issue. But please allow me to ask a stupid question then: this might be how views works, but I can't imagine this is how people would like it to work. So, has anyone got a solution for this? How can I create a view from users with fields from multiple profiles, without the users showing up more than once?
Thanks,
Mike
Comment #2.0
sportel commentedanother typo
Comment #3
crantok commentedEdit: Don't do the following. See #6 instead.
This worked for me...
Comment #4
joachim commentedHacking your view at the render stage does not seem like a good idea to me!
You need to restrict the relationship to a particular profile type.
Comment #5
crantok commentedWell, yeah, it's probably a bad idea, but I don't see a much better method for aggregating data from 2 profile types.
I can't merge the profiles in to one because they are each editable by a different set of people. To make life easy for the admins, fields from both profiles are shown on the same view. I could make them use two views or, I suppose, write my own custom page. (What I'd really like to do is to write my own SQL query and then throw the result at views for presentation.)
Comment #6
joachim commentedAdd the same relationship twice, restricting it to a different profile type each time. It's really simply once you know how, and no awful hacking is required!
Comment #7
crantok commentedAh! I see. Thank you Joachim. That worked for me. Is that knowledge recorded anywhere other than in the issue queue? If not, is there an obvious place that I should put it?
Comment #8
joachim commentedI think it's in the documentation pages for the module. If it's not, feel free to add it!
Comment #9
joachim commentedIt's on this page: https://www.drupal.org/node/2027157 but it could maybe do to be clearer. If you have time to work on expanding that text, maybe adding step-by-step instructions, please do :)
Comment #10
crantok commentedI reworded that. I hope it's a little clearer. It is more likely to catch the keywords I was searching for.
Comment #11
joachim commentedThat's much better. Thanks!
Comment #12
crantok commentedGlad I could help :)