# 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: 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](https://docs.carto.com/carto-user-manual/maps/widgets/..#widget-behaviour).


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
