> ## 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. |
| `barcode` | Variant barcode (GTIN/UPC/EAN/ISBN), grouping under a blank value when none. |
| `category` | Shopify product category (full taxonomy path). |
| `collection` | Shopify collection - a SKU appears under each collection it belongs to (cross-collection totals overlap), grouping under a blank value when it is in none. |
| `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. |
| `product_title` | Text | Product title. |
| `sku` | Text | Variant SKU. |
| `barcode` | Text | Variant barcode. |

## Related datasets

* [Sales](https://docs.stockful.app/stockfulql/datasets/sales.md)
* [Orders](https://docs.stockful.app/stockfulql/datasets/orders.md)
* [Returns](https://docs.stockful.app/stockfulql/datasets/returns.md)
* [Promotions](https://docs.stockful.app/stockfulql/datasets/promo.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.