locked
Grouping a listview by lookup columns RRS feed

  • Question

  • Hello!

    I have a list that has two lookup columns. My customers have asked to have this list group items by the two lookup fields. However, when I try to do that under filter/group settings in SharePoint designer, the two lookup fields don't show up as an option!

    Is there a way to group the list items by the two lookup columns?

    Thanks!

    -Spaz
    Thursday, October 22, 2009 3:25 PM

Answers

  • Another option may be to have multiple list view web parts on the page. Each of these web parts would point to a different view where the view was filtered on a specific lookup field, thereby giving a "kind of grouping" effect



    • Marked as answer by THTolleson Tuesday, October 27, 2009 8:49 PM
    Tuesday, October 27, 2009 3:35 PM

All replies

  • Hi Spaz,

     

    You can use SharePoint UI to create a new list view by clicking “Settings”à “Create View”à “Standard View”. Then under “Group By” you can choose the first lookup column name and the second lookup column name to be grouped.

     

    Please let me know if I misunderstood you, thanks.

     

    Lu Zou

    Monday, October 26, 2009 7:11 AM
  • Hey, Lu!

    I understand what you mean. The strange thing is - I can filter by the lookups columns, but I can't group by the lookup columns because they aren't listed in the pull-down menu! I can see them in filter, but not in group.

    Please let me know if there is a setting for me to change.

    Thanks!

    -Spaz
    Monday, October 26, 2009 5:25 PM
  • Hi Spaz,

    When you defined the lookup column, do you have the "Allow multiple values" checkbox checked? If so, you will probably not be able to group on that column.

    Hope this helps

    Paul.

    Monday, October 26, 2009 8:13 PM
  • Hi Spaz,

    When you defined the lookup column, do you have the "Allow multiple values" checkbox checked? If so, you will probably not be able to group on that column.

    Hope this helps

    Paul.


    +1 You can definitely group by lookup columns but only if they only allow one value.  If you allow multiple values, then you can't group whether it's a lookup column or not.  However, you can still filter.
    SharePoint Architect || My Blog
    Monday, October 26, 2009 8:22 PM
  • Ah, ok. Now, that could prove problematic for us. We're creating a Shared Document Library for ALL of our work products. Documents may be used on multiple projects and have multiple meta tags, but the users will definitely need to filter, group and sort their lists based on these metatag columns that are lookups with multiple options.

    Any advice on how we can pursue this?

    Thanks!

    Tom
    Tuesday, October 27, 2009 3:18 PM
  • You'll need to have multiple columns then - as many as the max # of projects that a doc can be associated with.  Each column will have the same dropdown list and be named something like Projects1, Projects2, etc.  Same column copied X number of times.  That way, if a doc is to be associated with more than one project, then it's a separate piece of metadata for each associated project.  Frumpy, but if you do that and only allow one project selection per column, then you can group to your heart's content but only up to 2 layers deep.  To go beyond this, you'll need to write some funky code or find a 3rd-party web part or JQuery that can overcome these limitations.
    SharePoint Architect || My Blog
    Tuesday, October 27, 2009 3:28 PM
  • Another option may be to have multiple list view web parts on the page. Each of these web parts would point to a different view where the view was filtered on a specific lookup field, thereby giving a "kind of grouping" effect



    • Marked as answer by THTolleson Tuesday, October 27, 2009 8:49 PM
    Tuesday, October 27, 2009 3:35 PM
  • Hmmm. I'm not crazy about either of those options, but Paul's suggestion does get me thinking in the right direction - using the interface as a sorting/grouping tool on its own.

    Clayton's idea would certainly work, but the list of items in the list that the lookup sources will constantly change, and so the need to create and delete columns would have to be figured into the maintenance of the product, and I'm probably going to avoid that.

    Thanks for all your suggestions, guys! I really appreciate the advice!

    -Spaz
    Tuesday, October 27, 2009 8:49 PM
  • You wouldn't have to change the columns.  You could create a list with the options and then create these columns as lookup columns.  That way, whenever the items in the list change, the selectable column data changes.  Very little maintenance that way, and it can be done by a non-admin who has Contributor rights on the list.  Food for thought...
    SharePoint Architect || My Blog
    Tuesday, October 27, 2009 11:00 PM
  • Hi Clayton

    Here I'm passing single value in look up columns, but still behaviour of the result is in following format. Here 4 cols are grouping .

    col1: <a href="https://extranet.joneslanglasalle.com/sites/APClientDemo/Services/AP/sandbox/_layouts/listform.aspx?PageType=4&ListId={4CAFBAAD-0F6D-4DC7-9C7A-EF390222243E}&ID=1&RootFolder=*">portfolio</a>
     expand col2: <a href="https://extranet.joneslanglasalle.com/sites/APClientDemo/Services/AP/sandbox/_layouts/listform.aspx?PageType=4&ListId={24CAADF1-BBD8-455E-8073-CD835FAA9886}&ID=1&RootFolder=*">c2</a>
      expand col3: <a href="https://extranet.joneslanglasalle.com/sites/APClientDemo/Services/AP/sandbox/_layouts/listform.aspx?PageType=4&ListId={8E54050D-09E4-4447-8BD6-ADF822E130C4}&ID=1&RootFolder=*">c3</a>
       expand col4: <a href="https://extranet.joneslanglasalle.com/sites/APClientDemo/Services/AP/sandbox/_layouts/listform.aspx?PageType=4&ListId={A437B2DD-D14A-4ABD-B2D8-9541DB2953A4}&ID=1&RootFolder=*">c4</a>

    Note:Instead of lookup columns if we use other column(ex: choice,single line..) expected results are coming

    Please advice



    Regards


    • Edited by Niyazuddin Monday, May 7, 2012 10:19 AM
    Monday, May 7, 2012 10:15 AM
  • Hi Spaz,

    You can Grouping a listview by lookup columns with below steps.

    1. Open .aspx page in sharepoint desginer.
    2. Select Sort/Group from the Ribbon.
    3. Add one of the column to the right side panel.
    4. Check Group By option and click OK.
    5. Save the form with changes
    6. Now it will render with content with Groupby Column.
    7. Check the CAML query for GroupBy coulmn in .aspx and replace with lookup column.
    8. Save the form with new changes.

    Above steps will work for lookup with multiple values also.

    Happy Coding!!

    Regards,

    N.Srinivas

    Friday, May 11, 2012 5:59 PM