---
title: Summarize by Group
slug: summarize-by-group
docTags: 
createdAt: 2022-11-28T06:17:48.000Z
---

Groups by a key and then sumarrized the values present in a given key in JSON Objects within a list.

| Setting       | Description                                                                                                                    |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| value\_field  | Summarizes the value in this field. User substitution curls                                                                    |
| group\_fields | One or many fields that the value should be grouped by.<br />Use substitution curls in the list of fields. See example request |
| input         | List of JSON Objects                                                                                                           |



### API Definition

:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "https://orca.pathfix.com/functions/list/groupandsummarize",
  "name": "Sum JSON  Objects API",
  "method": "POST",
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [],
    "bodyDataParameters": [],
    "formDataParameters": []
  },
  "results": {
    "languages": [
      {
        "id": "28UsDqyeH3QRdmtVamSQT",
        "code": "{\n    \"output\": [\n        {\n            \"source\": \"facebook\",\n            \"sum\": \"6500\",\n            \"count\": \"2\",\n            \"avg\": 3250.0\n        },\n        {\n            \"source\": \"linkedin\",\n            \"sum\": \"3200\",\n            \"count\": \"1\",\n            \"avg\": 3200.0\n        }\n    ],\n    \"size_in_bytes\": 488.0\n}",
        "language": "200"
      },
      {
        "id": "yIX64DyIuDPJgBRFSfAWb",
        "code": "{\n    \"message\": \"error\"\n}",
        "language": "404"
      }
    ],
    "selectedLanguageId": "28UsDqyeH3QRdmtVamSQT"
  },
  "examples": {
    "languages": [
      {
        "id": "ENcJz9TStG38F0X-taA4x",
        "code": "{\r\n    \"input\": [\r\n        {\r\n            \"email\": \"bruce@pathfix.com\",\r\n            \"source\": \"facebook\",\r\n            \"other\":\"test\",\r\n\t\t\t\"date\":\"2022-01-25\",\r\n\t\t\t\"lead_value\":\"2000\"\r\n        },\r\n        {\r\n            \"email\": \"paul@pathfix.com\",\r\n            \"source\": \"facebook\",\r\n\t\t\t\"date\":\"2022-02-12\",\r\n\t\t\t\"lead_value\":\"4500\"\r\n        },\r\n        {\r\n            \"email\": \"chang@pathfix.com\",\r\n            \"source\": \"linkedin\",\r\n\t\t\t\"date\":\"2022-02-15\",\r\n\t\t\t\"lead_value\":\"3200\"\r\n        }\r\n    ],\r\n\t\"value_field\":\"{{lead_value}}\",\r\n\t\"group_fields\":[\r\n\t\t\"{{source}}\"\r\n\t]\r\n}",
        "language": "json"
      }
    ],
    "selectedLanguageId": "ENcJz9TStG38F0X-taA4x"
  },
  "description": "\nCall the following API:",
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  }
}
```
:::

















