# members_grouped_count (records)

| Required permit | Rate limit tokens cost |
| --- | --- |
| Reporting:Api:Report:MembersGroupedCount | 2 |

This report allows you to get information about simply aggregates counts in your loyalty club (community).

## Fields

### community_id

| Type | Filterable | Readonly |
| --- | --- | --- |
| Integer | <Icon icon="material-outline-done"/> (via `X-Customer` header) | <Icon icon="material-outline-done"/> |

ID of community.

### grouping_type

| Type | Filterable | Readonly |
| --- | --- | --- |
| Enum | <Icon icon="material-outline-done"/> | <Icon icon="material-outline-done"/> |

Indicates aggregation group type.

This field is an enum, possible values are:
* optin_channel
* optin_subchannel
* optin_platform
* birth_year_group
* consent_true
* consent_false
* marketing_true
* marketing_false
* subunit_id
* group_id
* favorite_store
* country
* gender

### grouping_value

| Type | Filterable | Readonly |
| --- | --- | --- |
| String | <Icon icon="material-outline-done"/> | <Icon icon="material-outline-done"/> |

Indicates aggregation group value.

### members_count

| Type | Filterable | Readonly |
| --- | --- | --- |
| Integer | <Icon icon="material-outline-highlight_off"/> | <Icon icon="material-outline-highlight_off"/> |

Count of members in given aggregation group.

### updated_at

| Type | Filterable | Readonly |
| --- | --- | --- |
| Time | <Icon icon="material-outline-highlight_off"/> | <Icon icon="material-outline-highlight_off"/> |

Time when last change of members_count was done.

Note that it may be not the same as last time of member's update.

## Query without aggregations

Query returns list of member counts groups.

```json
{
    "records": [
        {
            "community_id": 235,
            "grouping_type": "optin_channel",
            "grouping_value": "default",
            "members_count": 159,
            "updated_at": "2024-08-14T05:56:40.098000Z"
        },
        {
            "community_id": 235,
            "grouping_type": "optin_platform",
            "grouping_value": "other",
            "members_count": 633,
            "updated_at": "2024-08-14T05:56:40.098000Z"
        },
        {
            "community_id": 235,
            "grouping_type": "country",
            "grouping_value": "NO",
            "members_count": 680,
            "updated_at": "2024-08-14T05:56:40.098000Z"
        }
    ],
    "pagination": {
        "next_page_info": null
    },
    "result_type": "records"
}
```

## Aggregations

### by_grouping_type_and_value

Member count aggregated by grouping_type and grouping_value.

This aggregation can be only useful when you want to sum counts between multiple loyalty clubs.

#### Returned fields

| Key | Type | Description |
| --- | --- | --- |
| grouping_type | Enum | See in `Fields` |
| grouping_value | String | See in `Fields` |
| members_count | Integer | Count of members |

#### Example query response

```json
{
    "records": [
        {
            "grouping_type": "optin_channel",
            "grouping_value": "default",
            "members_count": 159
        },
        {
            "grouping_type": "optin_platform",
            "grouping_value": "other",
            "members_count": 633
        },
        {
            "grouping_type": "country",
            "grouping_value": "NO",
            "members_count": 680
        },
    ],
    "pagination": {
        "next_page_info": "CNOW-AE"
    },
    "result_type": "records"
}
```