> For the complete documentation index, see [llms.txt](https://attr.sygnal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://attr.sygnal.com/sa5-data/advanced-use.md).

# Advanced Use

Some Tips for more advanced use

## Grouping & Group Counts

## Example

Scenario;

> You have a CMS collection of Locations, which each have a State. You want to show a list of States, with the count of Locations in each.&#x20;

Let's suppose you have setup this SA5 Data source.

<figure><img src="https://2168358812-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsBcvwQ6TdfCVq8IuMako%2Fuploads%2Fg9fJkKAZWdL47yB74iDA%2Fimage.png?alt=media&amp;token=c3886eee-77af-4129-936f-352e67d94fa1" alt=""><figcaption></figcaption></figure>

Once loaded, the data it will exist as a JavaScript Map in SA5's Datastore;

```javascript
ds.store.locations.data
```

You can transform that Map into a new map which contains Groups and counts, like this;

```javascript
// Get count of locations in each state
let result = new Map();
ds.store.locations.data.forEach(({ state }) => {
    result.set(state, (result.get(state) || 0) + 1); // increment state count
});
```

Now you can use your result Map however you like.&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://attr.sygnal.com/sa5-data/advanced-use.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
