I am trying to create a view that is somewhat complex and I am struggling. Any assistance is appreciated.

Here is the setup based on the views CiviCRM module (although the problem I am having isn't unique to this module).

I need to get 2 different phone numbers from the phone table and display all of the contacts, regardless of whether they have both numbers. I have a relationship between the contact table and the phone table and can get all of the records that have BOTH a phone and fax, but I need to get all of the contacts and the phone and fax numbers if they exist.

I may be making this more complicated than it needs to be, but I just can't seem to make it work. Is it possible to do this with views?

Contact Table Phone Table
id contact_id
phone_type
phone_number

Comments

Letharion’s picture

Status: Active » Fixed

What you want is called "Group by". While there are definitely ways you can work this out anyway, group by isn't supported by Views 2. If you are willing to use dev versions of modules, take a look at 3.x-dev.

qjensen’s picture

I could also use the Views Group By module if grouping will resolve the problem. Can you help me understand how using grouping will make this work for me? I have only used grouping for very simple aggregate functions in the past and I am having some trouble understanding how to use it in this situation.

Thanks for your help,
Q

dawehner’s picture

Project: Views (for Drupal 7) » Views Group By
Version: 6.x-2.12 » 6.x-1.x-dev
Component: Views Data » Documentation

So move it to the views groupy module

qjensen’s picture

I wasn't necessarily looking for help with the groupby module, but more conceptually how using the sql group by construct would help me get the needed results. Now that this is in the View Group By queue, maybe someone can help me understand how this would work.

Thanks,

qjensen’s picture

Just to close this out, I realized that I couldn't solve this problem with grouping and I created a custom field handler to build a complex join that resolved the problem.

Status: Fixed » Closed (fixed)

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