> ## Documentation Index
> Fetch the complete documentation index at: https://docs.uselayers.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Weighted groups

> Blend several attributes and metrics into one sort score with auto-normalized weights, per-attribute direction, and composable soft boost or User Affinity.

## Overview

A **weighted group** blends several attributes and metrics into a single sort score so collection pages can balance multiple signals at once. Each feature you add contributes a configurable share of the final score, and you choose whether higher or lower values are better on a per-attribute basis.

Use a weighted group when no single attribute captures what you want to rank by — for example, when you want to balance sales performance with freshness, or recency with margin. A weighted group reflects a strategy ("60% sales, 40% new arrivals") rather than a strict hierarchy.

## How weighted groups work

Inside the group you add **expressions** (attributes and metrics). For each expression you set:

* A **weight**, expressed as a share of 100. Layers automatically normalizes weights so they sum to 100 — dragging one slider rebalances the others proportionally, so the share you see is the share each feature actually contributes.
* A **preference** (attribute expressions only): **Higher is better** or **Lower is better**. Metric expressions default to higher is better.

For each product, Layers normalizes every feature's value across the current result set to a 0–1 range, signs it by your preference, multiplies by the weight, and sums the terms into one score.

Result-set scoping means the normalization adapts to whatever the shopper is looking at. A "freshness" feature is compared against the products in the active collection or search, not against your entire catalog — so the blend stays meaningful inside small collections.

The group's **Final Sort Direction** controls how products are ordered by the resulting score. Most weighted groups use descending (highest blend score first); set it to ascending only when you want the lowest blend score on top.

## When to use a weighted group

A weighted group is the right tool when you want to combine signals into one ranking rather than apply them in priority order. Reach for it when:

* One metric isn't enough — for example, "best-selling **and** new".
* You want to soften a single dominant signal by mixing in a secondary one.
* You want to expose a blended ranking as its own storefront sort option (for example, "Best match").

If instead you want products matching a condition to *cluster* at the top or bottom, use [priority rules](/platform/sorting/priority-rules). If you want to *lift* matching products into view without clustering, use [soft boost](/platform/sorting/soft-boost).

## Configuration

In the sort order editor, click **Add Expression** and choose **Weighted Groups**. A new group is created with one feature row to start.

### Add expressions to the group

Use the picker to add attributes or metrics. Each row supports:

* **Feature** — the attribute or metric to contribute.
* **Preference** (attributes only) — Higher is better or Lower is better.
* **Weight** — the share of the blend, on a slider out of 100.

You can remove a feature row at any time; the remaining weights rebalance to keep the total at 100. A group can contain a single feature, though the blend is most useful with two or more.

### Group settings

The group header has a **settings** (gear) icon that opens a sheet with:

* **Final Sort Direction** — Descending (default, highest score first) or Ascending.
* **Conditions** — optional contextual conditions that gate the entire group. When the conditions don't match the current request, the whole weighted group is skipped and the next expression in the sort order takes over.

The header also shows a **Blend preview** on hover: a donut visualization of how the configured weights divide up the final score, with each feature colored to match its row.

### Compose with soft boost or User Affinity

A weighted group is a first-class base in the sort pipeline, so you can layer modifiers on top of its score:

* Drop a **soft boost** below the weighted group to lift products matching a condition within the blended ranking.
* Drop **User Affinity** below the weighted group to personalize the blend for each shopper.

The modifiers attach to the weighted score the same way they would attach to a single attribute or metric. This lets you build sort orders like "blend 70% sales + 30% margin, then softly lift in-stock products" without rebuilding the blend itself.

## Observability

Weighted groups participate in the same instrumentation as other sort types:

* **Score breakdown** — open the **Lab** view for a product to see the active feature contributions and their normalized values.
* **Annotations** — sort effect annotations show when the weighted group drove a product's position.

See [Preview and annotations](/platform/sorting/preview) for the full set of tools.

## Best practices

* **Start with two features.** Bigger blends are harder to reason about; add a third feature only when it noticeably changes the ranking.
* **Keep weights meaningful.** A feature weighted under \~10% rarely changes the order — either raise it or drop it.
* **Pick the right preference.** Use Lower is better for fields like price when shoppers want cheaper items first, or distance for store-locator sorts.
* **Use conditions to scope the blend.** If a blend only makes sense for a subset of traffic (a market, a channel), set group conditions instead of duplicating sort orders.
* **Preview before publishing.** Open the [sort order preview](/help/sort-orders/preview-sort-order) and compare a collection with and without the group to confirm the blend produces the order you expect.

## See also

* [Sort orders](/platform/sorting)
* [Priority rules](/platform/sorting/priority-rules)
* [Soft boost](/platform/sorting/soft-boost)
* [User Affinity](/platform/sorting/user-affinity)
* [Preview and annotations](/platform/sorting/preview)
* [Create a sort order](/help/sort-orders/create-sort-order)
