> For the complete documentation index, see [llms.txt](https://docs.carto.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.carto.com/carto-user-manual/maps/widgets/category-widget.md).

# Category widget

A Category Widget summarize and compare categorical data using proportional bar lengths to represent values. The longer the horizontal bar, the greater the value it represents.

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-12876d6e642492718657864ddafae73f0634014b%2Fimage.png?alt=media" alt=""><figcaption><p><em>Category Widget in Builder for United Kingdom insights</em></p></figcaption></figure>

### Widget Data

When configuring the Category Widget, you can either perform a simple `COUNT` operation over your define category field or you can perform an aggregated operation using `AVG`, `MAX`, `MIN`, or `SUM` on your define numeric field for each of the specified categories. For example, you can calculate the SUM population for each land use category.

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-bd1a8b5fad8283c55e62e3c7a8ae525ab3c9d77f%2Fimage.png?alt=media" alt=""><figcaption><p><em>Performing an aggregation operation with Category widget</em></p></figcaption></figure>

For more complex and custom calculations, you can select the *custom aggregation* option to create your own SQL Expression. With this option, you can use a wide range of SQL functions, operators and syntax using single or multiple columns from your data source.

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-aa039df8c3512b2f545e5474b675c036013a2b4e%2Fimage.png?alt=media" alt=""><figcaption><p><em>Custom aggregation using SQL Expression</em></p></figcaption></figure>

### Widget Display

From **Display options**, you can adjust the **formatting** of the values displayed. You can also use the **Order by** option to sort values **alphabetically** (ascending or descending) or by **value** (ascending or descending), including aggregated values. The default is **value descending**.

Additionally, you can add notes that support [Markdown syntax](https://www.markdownguide.org/basic-syntax/) to provide further context to users.

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-a3f567452de49b4cad603e674ecdef22992e851c%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Widget Behavior

Within the "Behavior" section, you can define how your widget operates by choosing between **"Viewport" or "Global" modes**.

You can also enable or disable the widget’s filtering capability using the **cross-filtering** toggle icon. When enabled, the widget can filter itself and other components connected to the **same data source** or across **multiple sources** if they share the same property.

Learn more about widget behavior [here](/carto-user-manual/maps/widgets.md#widget-behaviour).


---

# 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://docs.carto.com/carto-user-manual/maps/widgets/category-widget.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.
