> 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="/files/7vrGUzK5NzKQgtg4G1IT" 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="/files/cyXm3B3dZ2FVtlx1LW2l" 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="/files/PQuDmQppTpp71jO2IhPV" 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="/files/VDLFq5z8xA9hxFx26fML" alt=""><figcaption></figcaption></figure>

### Widget Behavior

Within the "Behavior" section, you can define how your widget operates: choose between **"Viewport" or "Global" modes**. Additionally, you can make your widgets **collapsible**, allowing you to hide them when needed.

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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.carto.com/carto-user-manual/maps/widgets/category-widget.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
