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

# Sales trends

> Long-horizon daily sales - units, revenue and discounts per variant over up to two years, for trends and year-over-year.

Long-horizon daily sales - units, revenue and discounts per variant over up to two years, for trends and year-over-year.

## Example

```sql theme={null}
FROM sales_history
  SHOW units_sold, total_revenue
  GROUP BY product
  ORDER BY units_sold DESC
```

## Metrics

| Metric              | Type     | Description                                                                                      |
| ------------------- | -------- | ------------------------------------------------------------------------------------------------ |
| `units_sold`        | Number   | Units sold in the selected period.                                                               |
| `total_revenue`     | Currency | Gross revenue from sales in the period.                                                          |
| `discount_amount`   | Currency | Money discounted in the period, including markdowns (where Shopify reporting data is available). |
| `avg_selling_price` | Currency | Average revenue per unit sold in the period.                                                     |

## Dimensions

| Dimension      | Description                                                                                                                                                                                 |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `product`      | Product with image, rendered as a single cell (variants roll up).                                                                                                                           |
| `sku`          | Variant SKU - splits a product-grain report into variant rows.                                                                                                                              |
| `variant`      | Variant title (e.g. "Small / Blue"), shown as a dash for products without options. Group by product too - on its own, variants sharing a title across different products fall into one row. |
| `vendor`       | Product vendor.                                                                                                                                                                             |
| `product_type` | Shopify product type.                                                                                                                                                                       |
| `tag`          | Individual product tag - a SKU appears under each of its tags (cross-tag totals overlap).                                                                                                   |

## Filters

| Filter                     | Type   | Description                                                                 |
| -------------------------- | ------ | --------------------------------------------------------------------------- |
| `collection`               | Number | Restrict to products in the selected collection(s).                         |
| `category`                 | Text   | Restrict to products in the selected category (matches sub-categories too). |
| `sales_channel`            | Number | Restrict to products published to the selected sales channel.               |
| `region_catalog`           | Number | Restrict to products in the selected region (market) catalog.               |
| `b2b_catalog`              | Number | Restrict to products in the selected B2B (market) catalog.                  |
| `company_location_catalog` | Number | Restrict to products in the selected company-location catalog.              |
| `vendor`                   | Text   | Product vendor.                                                             |
| `product_type`             | Text   | Shopify product type.                                                       |
| `sku`                      | Text   | Variant SKU.                                                                |

## Related datasets

* [Sales](/stockfulql/datasets/sales)
* [Returns](/stockfulql/datasets/returns)
* [Promotions](/stockfulql/datasets/promo)
