Format list view with JSON or filter view to hide groupings with a single child item

Copper Contributor

We're trying to figure out how to add some custom JSON to a modern list view. The intent is to group list items by a column. Then suppress the group if it has only a single child item. What you're left with are groupings with 2 or more child items. We can't seem to get the syntax right. Also, the group in the list view settings keeps getting cleared to "None". We read somewhere it's possible when incorrect JSON is added it will clear out grouping settings for a list view, but we're usure. We're certain it keeps getting reset to none, but aren't certain of the cause. We thought something like the following might work, but it doesn't seem to:

 

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "groupProps": {
    "headerFormat": {
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "display": "=if(@group.count > 1, 'block', 'none')"
      }
    }
  }
}

 

Another possible solution to this would be to use the list view filtering. However, we can't seem to get that working either. We tried the following to filter out list items that only had one instance of a value in the same column we're grouping by so that only items with two or more instances of the same value would be included in the view:

 

When a column: License Plate Number (Indexed) is equal to:

 

=COUNTIF([License Plate Number],[License Plate Number])>1

 

Also note that this list has about 7,000 items in it, but we're also including a date filter in the list view that should have it below the 5,000 threshold. 

 

Thanks for any tips you can send our way ;)

 

1 Reply

@SJHBham I don't think you will be able to hide complete grouping including list items under grouping using JSON view formatting.

 

So, you have to try it using list view filters only. However, you cannot check the column values from another rows/list items in calculated column formula. Calculated column formula can check the values for current row/list item only.


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs