---
title: inventory_by_location
description: >-
  Reference for the ShopifyQL `inventory_by_location` table. Every metric and
  dimension, paired with worked example queries.
api_version: 2026-07
source_url:
  html: >-
    https://shopify.dev/docs/api/shopifyql/latest/schemas/inventory/inventory_by_location
  md: >-
    https://shopify.dev/docs/api/shopifyql/latest/schemas/inventory/inventory_by_location.md
api_name: shopifyql
---

# inventory\_​by\_​location

The `inventory_by_location` [schema](https://shopify.dev/docs/api/shopifyql/latest/schemas) captures how much of each item you hold at each location, as point-in-time snapshots. Use it for stock, value, and availability views by item and variant.

### Use cases

* **Stock on hand**: Group [`ending_inventory_units_at_location`](#inventorybylocationmetric-propertydetail-endinginventoryunitsatlocation) by [`product_variant_id`](#inventorybylocationdimension-propertydetail-productvariantid) to break on-hand units down by variant.
* **Net change**: Compare [`starting_inventory_units_at_location`](#inventorybylocationmetric-propertydetail-startinginventoryunitsatlocation) and [`inventory_units_net_change_at_location`](#inventorybylocationmetric-propertydetail-inventoryunitsnetchangeatlocation) to trace how stock at a location shifted over the interval.
* **Stock duration**: Show [`days_in_stock_at_location`](#inventorybylocationmetric-propertydetail-daysinstockatlocation) and [`days_out_of_stock_at_location`](#inventorybylocationmetric-propertydetail-daysoutofstockatlocation) for each [`inventory_item_id`](#inventorybylocationdimension-propertydetail-inventoryitemid) to see how long items sit in or run out of stock at a location.
* **Value by product**: Report [`ending_inventory_value_at_location`](#inventorybylocationmetric-propertydetail-endinginventoryvalueatlocation) and [`ending_inventory_retail_value_at_location`](#inventorybylocationmetric-propertydetail-endinginventoryretailvalueatlocation) by product or variant to see where inventory capital is tied up.

Examples

### Examples

* ####

  ##### Description

  Rank variants at each location by \`days\_of\_inventory\_remaining\_at\_location\` ascending, keeping only those with fewer than 14 days of stock left. This example uses \[\`HAVING\`]\(/docs/api/shopifyql/latest/syntax/having) \`ending\_inventory\_units\_at\_location > 0\` to drop variants that are already out of stock.

  ##### ShopifyQL

  ```shopifyql
  FROM inventory_by_location
    SHOW ending_inventory_units_at_location,
      days_of_inventory_remaining_at_location, days_out_of_stock_at_location
    GROUP BY inventory_location_name, product_variant_id
    HAVING days_of_inventory_remaining_at_location < 14
      AND ending_inventory_units_at_location > 0
    SINCE -30d UNTIL today
    ORDER BY days_of_inventory_remaining_at_location ASC
    LIMIT 200
  VISUALIZE days_of_inventory_remaining_at_location TYPE horizontal_grouped_bar
  ```

* ####

  ##### Description

  Rank the product variants that aren't selling by \`ending\_inventory\_value\_at\_location\`, the capital tied up at each location, highest first. This example uses \[\`HAVING\`]\(/docs/api/shopifyql/latest/syntax/having) \`inventory\_units\_net\_change\_at\_location = 0\` to keep only variants with no movement over the last 90 days, your clearance or relocation candidates.

  ##### ShopifyQL

  ```shopifyql
  FROM inventory_by_location
    SHOW days_in_inventory_at_location, ending_inventory_value_at_location,
      ending_inventory_units_at_location, inventory_units_net_change_at_location
    GROUP BY inventory_location_name, product_variant_id
    HAVING days_in_inventory_at_location > 90
      AND inventory_units_net_change_at_location = 0
    SINCE -90d UNTIL today
    ORDER BY ending_inventory_value_at_location DESC
    LIMIT 100
  VISUALIZE ending_inventory_value_at_location TYPE horizontal_bar
  ```

* ####

  ##### Description

  Track weekly \`ending\_inventory\_retail\_value\_at\_location\` across last quarter, with \`starting\_inventory\_units\_at\_location\`. This example uses \[\`WITH TOTALS\`]\(/docs/api/shopifyql/latest/syntax/with#total-columns) to add a total for last quarter beside the weekly rows.

  ##### ShopifyQL

  ```shopifyql
  FROM inventory_by_location
    SHOW ending_inventory_retail_value_at_location,
      starting_inventory_units_at_location, first_day_in_inventory_at_location
    TIMESERIES week WITH TOTALS
    DURING last_quarter
    ORDER BY week ASC
  VISUALIZE ending_inventory_retail_value_at_location TYPE line
  ```

* ####

  ##### Description

  Track weekly \`days\_in\_stock\_at\_location\` across this quarter, each week compared to the quarter before. This example uses \[\`COMPARE TO previous\_period\`]\(/docs/api/shopifyql/latest/syntax/compare-to) to benchmark your date range against the equal-length period right before it.

  ##### ShopifyQL

  ```shopifyql
  FROM inventory_by_location
    SHOW days_in_stock_at_location
    TIMESERIES week WITH PERCENT_CHANGE
    DURING this_quarter
    COMPARE TO previous_period
    ORDER BY week ASC
  VISUALIZE days_in_stock_at_location TYPE bar
  ```

***

## Metrics

Counts and calculations that let you track key business indicators. Metrics show up as the columns when queried.

Metrics you can use when querying `FROM inventory_by_location`.

* **days\_​in\_​inventory\_​at\_​location**

  **DAY\_DURATION**

  The number of days in your selected period when the inventory item had a stock record at the inventory location.

* **days\_​in\_​stock\_​at\_​location**

  **DAY\_DURATION**

  The number of days in your selected period that ended with more than zero units at the inventory location.

* **days\_​of\_​inventory\_​remaining\_​at\_​location**

  **DAY\_DURATION**

  Forecasted number of days of inventory remaining at the specified location

  `Days of inventory remaining (at location) = ending inventory units (at location) / inventory units net change (at location) per day`

* **days\_​out\_​of\_​stock\_​at\_​location**

  **DAY\_DURATION**

  The number of days in your selected period that ended with zero or fewer units at the inventory location.

* **ending\_​inventory\_​retail\_​value\_​at\_​location**

  **MONEY**

  The retail value is reported in your store's currency.

  `Ending inventory retail value (at location) = ending inventory units (at location) * product variant price`

* **ending\_​inventory\_​units\_​at\_​location**

  **INTEGER**

  Units at the end of the given period at the specified location

* **ending\_​inventory\_​value\_​at\_​location**

  **MONEY**

  The cost value is reported in your store's currency.

  `Ending inventory value (at location) = ending inventory units (at location) * inventory item cost`

* **first\_​day\_​in\_​inventory\_​at\_​location**

  **DAY\_TIMESTAMP**

  The first day in your selected period when the inventory item had a stock record at the inventory location. Use [`first_day_in_inventory_at_location`](#inventorybylocationmetric-propertydetail-firstdayininventoryatlocation) with [`last_day_in_inventory_at_location`](#inventorybylocationmetric-propertydetail-lastdayininventoryatlocation) to show the date range covered for each item and location.

* **inventory\_​units\_​net\_​change\_​at\_​location**

  **INTEGER**

  The net movement in units at the inventory location during your selected period. Use [`inventory_units_net_change_at_location`](#inventorybylocationmetric-propertydetail-inventoryunitsnetchangeatlocation) with [`starting_inventory_units_at_location`](#inventorybylocationmetric-propertydetail-startinginventoryunitsatlocation) and [`ending_inventory_units_at_location`](#inventorybylocationmetric-propertydetail-endinginventoryunitsatlocation) to show the opening and closing unit counts for the period.

  `Inventory units net change (at location) = starting inventory units (at location) - ending inventory units (at location)`

* **last\_​day\_​in\_​inventory\_​at\_​location**

  **DAY\_TIMESTAMP**

  The last day in your selected period when the inventory item had a stock record at the inventory location. Use [`last_day_in_inventory_at_location`](#inventorybylocationmetric-propertydetail-lastdayininventoryatlocation) with [`first_day_in_inventory_at_location`](#inventorybylocationmetric-propertydetail-firstdayininventoryatlocation) to show the date range covered for each item and location.

* **starting\_​inventory\_​units\_​at\_​location**

  **INTEGER**

  Units at the start of the given period at the specified location

### DAY\_DURATION

A duration measured in days.

```ts
```

### MONEY

A monetary amount representing currency values such as prices, revenue, costs, and discounts.

```ts
```

### INTEGER

A whole number without decimal places, used for counts, quantities, and other discrete numeric values.

```ts
```

### DAY\_TIMESTAMP

A date value truncated to day precision.

```ts
```

***

## Dimensions

Attributes of your data that let you look more granularly at aspects of the data. Group and filter by dimensions to shape the rows your query returns.

Dimensions you can use when querying `FROM inventory_by_location`.

* **day**

  **DAY\_TIMESTAMP**

  The day an inventory snapshot applies to.

* **inventory\_​group\_​id**

  **IDENTITY**

  Shopify identifier for the inventory group

* **inventory\_​item\_​id**

  **IDENTITY**

  The unique Shopify identifier for the inventory item. Use [`inventory_item_id`](#inventorybylocationdimension-propertydetail-inventoryitemid) to break results down by inventory item or to filter to a specific inventory item. Use it with [`product_variant_sku`](#inventorybylocationdimension-propertydetail-productvariantsku) or [`product_variant_title`](#inventorybylocationdimension-propertydetail-productvarianttitle) to show readable labels.

* **month**

  **MONTH\_TIMESTAMP**

  The month an inventory snapshot applies to.

* **product\_​id**

  **IDENTITY**

  The unique Shopify identifier for the product, which can include multiple variants. Use [`product_id`](#inventorybylocationdimension-propertydetail-productid) to group stock for the same product or to filter to a specific product. Use [`product_id`](#inventorybylocationdimension-propertydetail-productid) with [`product_title`](#inventorybylocationdimension-propertydetail-producttitle) to show a readable label.

* **product\_​variant\_​id**

  **IDENTITY**

  The unique Shopify identifier for the product variant. Use [`product_variant_id`](#inventorybylocationdimension-propertydetail-productvariantid) to break stock down to a specific variant or to filter to one variant. Use [`product_variant_id`](#inventorybylocationdimension-propertydetail-productvariantid) with [`product_variant_title`](#inventorybylocationdimension-propertydetail-productvarianttitle) or [`product_variant_sku`](#inventorybylocationdimension-propertydetail-productvariantsku) to show readable labels.

* **quarter**

  **QUARTER\_TIMESTAMP**

  The quarter an inventory snapshot applies to.

* **shop\_​id**

  **IDENTITY**

  The unique Shopify identifier for your store. Use [`shop_id`](#inventorybylocationdimension-propertydetail-shopid) with [`shop_name`](#inventorybylocationdimension-propertydetail-shopname) to show readable store labels.

* **week**

  **WEEK\_TIMESTAMP**

  The week an inventory snapshot applies to.

* **year**

  **YEAR\_TIMESTAMP**

  The year an inventory snapshot applies to.

* **inventory\_​location\_​id**

  **IDENTITY**

  Shopify identifier for the inventory location

* **inventory\_​location\_​name**

  **STRING**

  Name of the inventory location

* **shop\_​name**

  **STRING**

  Name of your store

* **inventory\_​cost\_​is\_​recorded**

  **BOOLEAN**

  Whether the inventory item has a cost saved in Shopify, with values `true` and `false`.

* **inventory\_​is\_​tracked**

  **BOOLEAN**

  Whether Shopify tracks inventory adjustments for the inventory item, with values `true` and `false`.

* **inventory\_​item\_​cost**

  **MONEY**

  The cost recorded for one unit of the inventory item, in your store's currency.

* **product\_​status**

  **STRING**

  The product's current publishing state, with values Active, Archived, Draft, Suspended, and Unlisted.

* **product\_​title**

  **STRING**

  Display name of the product that your customers see

* **product\_​type**

  **STRING**

  Type (category) that you've assigned to the product

* **product\_​vendor**

  **STRING**

  Vendor of the product

* **product\_​collection**

  **STRING**

  Collection associated with the product

* **product\_​collections**

  **ARRAY\<STRING>**

  Set of collections associated with the product

* **app\_​product\_​creation**

  **STRING**

  The app that created the product, shown as an app name.

* **product\_​tag**

  **STRING**

  Tag associated with the product

* **product\_​tags**

  **ARRAY\<STRING>**

  Set of tags associated with the product

* **product\_​variant\_​abc\_​grade**

  **STRING**

  The ABC grade assigned to the product variant based on its share of revenue. A-grade variants account for about 80% of revenue, B-grade for 15%, and C-grade for 5%.

* **product\_​variant\_​sku**

  **STRING**

  SKU of the product variant

* **product\_​variant\_​title**

  **STRING**

  Display name of the product variant

### IDENTITY

A unique identifier for a Shopify resource such as a customer, product, or order.

```ts
```

### MONTH\_TIMESTAMP

A date value representing the start of a month.

```ts
```

### QUARTER\_TIMESTAMP

A date value representing the start of a fiscal quarter.

```ts
```

### WEEK\_TIMESTAMP

A date value representing the start of a week.

```ts
```

### YEAR\_TIMESTAMP

A date value representing the start of a year.

```ts
```

### STRING

A sequence of characters representing text data.

```ts
```

### BOOLEAN

A true or false value representing binary states.

```ts
```

### ARRAY

A list of values. The element type appears inside angle brackets, such as ARRAY\<STRING>.

```ts
```

***

## Related schemas

* [`inventory`](https://shopify.dev/docs/api/shopifyql/latest/schemas/inventory/inventory): Store-wide inventory totals without location breakdown.
* [`inventory_transfers`](https://shopify.dev/docs/api/shopifyql/latest/schemas/inventory/inventory_transfers): Stock moves between locations that resolve stockouts.
* [`inventory_shipments`](https://shopify.dev/docs/api/shopifyql/latest/schemas/inventory/inventory_shipments): Incoming shipments arriving at each location.
* [`inventory_adjustment_history`](https://shopify.dev/docs/api/shopifyql/latest/schemas/inventory/inventory_adjustment_history): Manual adjustments at each location.

***
