0

Similar to the example here: Example: Color coded group header with aggregate

I am trying the group header text in the list view to show the number of tasks that are NOT 'Completed' in the 'Status' choice column.

enter image description here

Here's my JSON, can someone help me out with this?

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "groupProps": {
    "hideFooter": true,
    "headerFormatter": {
      "elmType": "div",
      "style": {
        "flex-wrap": "wrap",
        "display": "flex",
        "box-sizing": "border-box",
        "padding": "4px 8px 5px 8px",
        "border-radius": "6px",
        "align-items": "center",
        "white-space": "nowrap",
        "overflow": "hidden",
        "margin": "1px 4px 4px 1px"
      },
      "attributes": {
        "class": "ms-bgColor-neutralQuaternary"
      },
      "children": [
        {
          "elmType": "div",
          "children": [
            {
              "elmType": "span",
              "style": {
                "padding": "5px 5px 5px 5px",
                "font-weight": "500"
              },
              "txtContent": "@group.fieldData.displayValue"
            }
          ]
        },
        {
          "elmType": "div",
          "forEach": "iterator in @currentField",
          "children": [
            {
              "elmType": "div",
              "style": {
                "display": "=if([$iterator.columnDisplayName] == 'Status' && [$iterator.value] != 'Completed', 'flex', 'none')",
                "flex-direction": "row",
                "justify-content": "center"
              },
              "children": [
                {
                  "elmType": "div",
                  "txtContent": "=' pending tasks: ' + Number(@group.count - Number([$iterator.value]))",
                  "style": {
                    "font-weight": "500"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

1 Answer 1

0

The @group object provides access to the grouped column's data, display name and item count.

If you want to show the number of tasks that are not 'Completed' in the 'Status' choice column, it's necessary to group by the choice column.

If you group by another column instead of the choice column, it's not possible to get the count via @group.

--------------------Update-----------------

Per my test, It seems that the error prevent aggregate from working, we suggest you open a service request to Microsoft.

enter image description here

2
  • Thanks for your reply @Juile_MSFT but in Example: Color coded group header with aggregate view is grouped on City and then group headers formatted with group aggregates. I am unable to understand how they have changed City header text based on Approved column - and what is aggregates?
    – harry777
    Aug 12, 2021 at 9:01
  • Thanks for the link, and I have updated the reply.
    – Julie_MSFT
    Aug 13, 2021 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.