JSON View Formatting - Count total number of items in SP list

Copper Contributor

ApprovalHistoryList_JSON_Formatting.PNGHi, I want to modify the groups footer of a custom view that is grouped by a metadata column named Response/Actionv2. In the Totals section of the view settings I enabled Count for this column, which now displays the number of items (rows) for each of the groups. However, I would like to use this number in the JSON formatting to calculate and display the proportion (in percentage %) of total number of decisions. As you can see in the code below, I've included the static number 31, but I'd like to be able to dynamically reference the total number of items in the list? Basically, do you have an idea on how to implement this formula: (@columnAggregate.value / TOTAL NUMBER OF ITEMS) * 100

 

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "groupProps": {
    "hideFooter": false,
    "footerFormatter": {
      "elmType": "div",
      "children": [
        {
          "elmType": "div",
          "attributes": {
            "iconName": "CalculatorPercentage"
          },
          "style": {
            "color": "=if(@columnAggregate.type == 'Count' && @columnAggregate.value < 50, '#d13438', '#107c10')",
            "font-weight": "600",
            "margin-top": "10px"
          }
        },
        {
          "elmType": "div",
          "style": {
            "color": "=if(@columnAggregate.type == 'Count' && @columnAggregate.value < 50, '#d13438', '#107c10')",
            "font-weight": "600",
            "margin-top": "10px",
            "font-family": "Segoe UI"
          },
          "txtContent": {
            "operator": "*",
            "operands": [
              100,
              {
                "operator": "/",
                "operands": [
                  "@columnAggregate.value",
                  31
                ]
              }
            ]
          }
        }
      ]
    }
  }
}

 

 

1 Reply

Unfortunately, I learned that it's not currently possible in List Formatting. We can only have access to the total count in the list footer but won't be able to reference it inside the group footers... See the original answer on sharepoint.stackexchange.com here.