Group By Content Type in Modern Lists and Libraries

IMO, this should be an easier thing to do. It’s a VERY common request from my clients, and for years we’ve had to hack this together. There are currently two UserVoice items about it that I can find – here and here – but not nearly enough votes to get on the radar of the product team. You can help me fix that, right? Vote early, and vote often!

Ideally, in the modern view, we should be able to simply click on Group by Content Type in the UI. No joy there. We get that option for virtually every other column type – including the dread Managed Metadata column!

No big deal, right? We’ll just go into the view settings and add the grouping. Nope. Never was going to happen. Content Type is missing from the list of columns in the dropdown.

 

Luckily, in the second of those UserVoice items, a wonderful person named Eric Ivarsson gives us the trick we need to make this work. I worry about tricks like this because they could always stop working, but this one seems to have worked for a while now (at least a year), so I’m willing to use it and recommend it.

If you simply add this query string to the end of your view:

?groupBy=ContentType

you will get a view which groups by Content Type. You don’t even have to be displaying the Content Type column for this to work. If you have other groupings in place YMMV, but it accomplishes the main requirement here.

Make sure the “B” in groupBy is capitalized, or it won’t work.

You can then save the view from the UI, and even use the same view name. The setting will become embedded in the view (somehow) and you’ll be all set.

Again, if you use this trick, please vote up the two UserVoice items so that we can stop using it.

Similar Posts

28 Comments

  1. Do you know how I can do the following using this trick?:
    First group by: field1
    Then group by: ContentType

    So a nested group by

    1. Did you ever get an answer to this? I am also trying to do a nested group including Content Type

      1. Things have gotten a bit better. You can group by Content Type right in the UI without any monkey business with the URL. But AFAIK, there’s not a way to group by Content Type and another column through the UI.

        M.

  2. Thanks for this, Marc!

    I’m experiencing a huge lag for “Group By” option in a View that I don’t find in the Classic Experience on the same site. I wonder how much of this is the overhead required by using the React Framework or unoptimized JavaScript.

    I’m working on a Proof-of-Concept in a free O365 E3 Dev License with over 450 documents. I’m hoping that the lag is due to potentially less resources given to the Dev environment, but I don’t think so. As it is, this is not usable for User Adoption. I will be forced to use Folders. :(

    Is there a User Voice for the lag for the Group By functionality?

    1. @Joe:

      In my experience, the Group By behavior is quite quick, though I have seen a few other issues which I know the product team is working on. Do you see the same lag if you’ve saved the view and reload it? Anything else you can share about the characteristics of the metadata?

      M.

      1. I experience serious lag when going to a view that is grouped by Content Type in SharePoint Online. It would help the load time if I was able to collapse the view, but I can’t seem to figure out a way to do that. I can make the tweak via SPD, but when I go back to the library, it is indeed collapsed, but the Content Type values are not being displayed correctly.

        Instead of
        Content Type: Dog
        Content Type: Cat

        It looks like this:
        Content Type: 0x0101002AD9B1B04CB1F346860B4CFC1AC786EC0037AAA6307566DD47…
        Content Type: 0x010100628FD3F3572F354BBADD9C4096C3763500604FA37DB33CCD42…

        Any ideas how to get this view to default to collapsed?

  3. I was trying to group by Content Type for a list view in a webpart as part of a document set home page. Using SharePoint Designer (SP2010), I discovered I was able to group by Content Type by making a simple adjustment to the CAML query used to create the view.

    1. @Jeff:

      This post is about modern Document Libraries, where the underlying technology has changed significantly from SharePoint 2010. Glad you were able to solve your problem, though.

      M.

  4. This doesn’t work in 365. What does work is to create a view with one of the existing groupby choices then edit the view in designer. Change the groupby bit to

  5. Thanks Marc! This is a great workaround for functionality our business continues to request and Microsoft has ignored for years. I was able to setup the view grouped by Content Type but it is not sorting the groups alphabetically. Do you know how I could add sorting to the GroupBy?

      1. It did successfully group by Content Type but I would also like it to show the groups sorted by Content Type name. Right now the groupings (top level) appear to be sorted by the Content Type guid or some other value. When editing the view I do not see Content Type as an option for sorting. Thanks again and I appreciate the quick reply!

          1. I’ve confirmed there is no other Sort applied within the View Settings. I am attempting to use this as the default view for a document set, so perhaps that changes how it would sort. I appreciate your help and will just need to find an alternate solution.

              1. Document sets are now supported in modern, but they look just like a ‘normal’ library view and no longer allow the custom welcome page. Essentially just a default view inside a “folder” and provides access to the document set properties from the information panel when inside the document set. Feels a bit like a step back. And as you mentioned, they are a different animal. Your suggestion worked so far as to group the files by content type but something else must be driving the sort order within a document set. Again, thanks for the help!

  6. Hi Marc,

    Thanks for your post. It helped me a lot.

    Do you also have a way to sort on content type? For me, sorting seems to works. The sorting is consistent, but not alphabetically. It is like it sorts on the id of content type.

    Any advice?

    Kind regards

  7. I just found out that it is possible to group by content type in Modern UI. Other cool stuff like “Pin to filters pane” is possible. Was this feature published silently? Did I miss something?

  8. The Issue with this approach that I have seen is that you can create the view but if you tried to change anything in this view, the view falls over by loosing your group by settings, and then you have to recreate the view again. I think this is why its not a fully supported method, although it is very useful. So clients should use it sparingly and ensure that any lost settings are added back after editing the view. You will also need to re save the view again using the same steps that have been posted.

      1. In On-Prem 2016, you can’t group by Content Type unless you modify the view setting in Designer. Even after doing that, as stated by two users above, the Content Type groups do not appear in alpha order – any idea how to fix anyone?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.