inventory
The inventory schema captures point-in-time snapshots across all your inventory items and products, totaled across locations. Use it for stock, inventory value, sell-through, movement, and availability views when you don't need a per-location breakdown.
Anchor to Use casesUse cases
- Unit movement: Compare
starting_inventory_units,inventory_units_sold, andending_inventory_unitsfor a snapshot interval to split stock sold from stock remaining. - Sell-through: Group
sell_through_ratebyproduct_idorproduct_variant_idto report product-level inventory movement. - Cost vs. retail: Show
ending_inventory_valueandending_inventory_retail_valuetogether to compare stock cost against retail price. - Stock duration: Pair
days_of_inventory_remainingwithinventory_units_sold_per_day.
ShopifyQL
Examples
Track monthly sell-through against last quarter
Description
Compare monthly `sell_through_rate` this quarter against the previous quarter. This example uses [`WITH PERCENT_CHANGE`](/docs/api/shopifyql/latest/syntax/with#percent-change-columns) to add a period-over-period column beside the stock levels.
ShopifyQL
FROM inventory SHOW ending_inventory_value, ending_inventory_units, inventory_units_sold, sell_through_rate, days_out_of_stock TIMESERIES month WITH PERCENT_CHANGE, TOTALS DURING this_quarter COMPARE TO previous_period ORDER BY month ASC VISUALIZE sell_through_rate TYPE stacked_areaRank tracked variants by inventory value
Description
Rank the top 100 tracked variants by `ending_inventory_value` last month. This example uses a [`WHERE`](/docs/api/shopifyql/latest/syntax/where) clause to keep only variants with recorded cost data.
ShopifyQL
FROM inventory SHOW ending_inventory_units, ending_inventory_value WHERE inventory_cost_is_recorded = true AND inventory_is_tracked = true GROUP BY product_title, product_variant_title, product_variant_sku, inventory_item_cost WITH TOTALS DURING last_month ORDER BY ending_inventory_value DESC LIMIT 100 VISUALIZE ending_inventory_value TYPE tableTrack weekly inventory health last quarter
Description
Track weekly retail value on hand, days of stock remaining, and units sold per day for tracked inventory across last quarter. This example uses [`WHERE`](/docs/api/shopifyql/latest/syntax/where) `inventory_is_tracked = true` to keep only variants with inventory tracking turned on.
ShopifyQL
FROM inventory SHOW days_of_inventory_remaining, inventory_units_sold_per_day, ending_inventory_retail_value WHERE inventory_is_tracked = true TIMESERIES week WITH TOTALS DURING last_quarter ORDER BY week ASC VISUALIZE ending_inventory_retail_value TYPE lineTrack weekly inventory units by product
Description
Track weekly `ending_inventory_units` by `product_id` across last quarter. This example uses [`GROUP_TOTALS`](/docs/api/shopifyql/latest/syntax/with#group-total-columns) to add a per-week total across products beside the per-product bands, with `LIMIT 20` capping the returned rows.
ShopifyQL
FROM inventory SHOW ending_inventory_units GROUP BY product_id WITH TOTALS, GROUP_TOTALS TIMESERIES week DURING last_quarter ORDER BY week ASC LIMIT 20 VISUALIZE ending_inventory_units TYPE stacked_bar
Anchor to MetricsMetrics
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.
- Anchor to days_in_inventorydays_
in_ inventorydays_ in_ inventory DAY_DURATIONDAY_DURATION The number of days from the item's first inventory snapshot in your selected period through its last.
- Anchor to days_in_stockdays_
in_ stockdays_ in_ stock DAY_DURATIONDAY_DURATION The number of days in your selected period when ending stock was above zero.
- Anchor to days_of_inventory_remainingdays_
of_ inventory_ remainingdays_ of_ inventory_ remaining DAY_DURATIONDAY_DURATION A forecast of how many days your ending stock could last at the current sales pace. If no units sold in the selected period, then no forecast is returned.
Days of inventory remaining = ending inventory units / inventory units sold per day- Anchor to days_out_of_stockdays_
out_ of_ stockdays_ out_ of_ stock DAY_DURATIONDAY_DURATION The number of days in your selected period when ending stock was zero or below.
- Anchor to ending_inventory_retail_valueending_
inventory_ retail_ valueending_ inventory_ retail_ value MONEYMONEY The retail value of stock on hand at the end of your selected period, in your store's currency. It uses each variant's price and the ending unit count. Untracked items, items without a price, and items with zero or negative ending stock contribute 0.
Ending inventory retail value = ending inventory units * product variant price- Anchor to ending_inventory_unitsending_
inventory_ unitsending_ inventory_ units INTEGERINTEGER Inventory units at the end of the given period
- Anchor to ending_inventory_valueending_
inventory_ valueending_ inventory_ value MONEYMONEY The cost value of stock on hand at the end of your selected period, in your store's currency. It uses the item's recorded cost and ending unit count. Untracked items, items without a recorded cost, and items with zero or negative ending stock contribute 0.
Ending inventory value = ending inventory units * inventory item cost- Anchor to first_day_in_inventoryfirst_
day_ in_ inventoryfirst_ day_ in_ inventory DAY_TIMESTAMPDAY_TIMESTAMP The first day in your selected period when the item appears in inventory snapshots.
- Anchor to inventory_units_soldinventory_
units_ soldinventory_ units_ sold INTEGERINTEGER Quantity of inventory units sold in a given period
- Anchor to inventory_units_sold_per_dayinventory_
units_ sold_ per_ dayinventory_ units_ sold_ per_ day FLOATFLOAT Inventory units sold per day in the given period with a record of the inventory item
Inventory units sold per day = inventory units sold / days in inventory- Anchor to last_day_in_inventorylast_
day_ in_ inventorylast_ day_ in_ inventory DAY_TIMESTAMPDAY_TIMESTAMP The last day in your selected period when the item appears in inventory snapshots.
- Anchor to percent_of_inventory_soldpercent_
of_ inventory_ soldpercent_ of_ inventory_ sold PERCENTPERCENT The share of starting stock sold during your selected period, shown as a percentage. If starting stock is zero or below, then no percentage is returned.
Percent of inventory sold = inventory units sold / starting inventory units- Anchor to sell_through_ratesell_
through_ ratesell_ through_ rate PERCENTPERCENT The share of available units that sold during your selected period, shown as a percentage.
Sell-through rate = inventory units sold / (inventory units sold + ending inventory units)- Anchor to starting_inventory_unitsstarting_
inventory_ unitsstarting_ inventory_ units INTEGERINTEGER Inventory units at the start of the given period
DAY_DURATION
Length of time measured in days
MONEY
Currency amount such as a price, revenue, cost, or discount
INTEGER
Whole number without decimal places, used for counts and quantities
DAY_TIMESTAMP
Date with the time of day removed
FLOAT
Number stored as an approximation, used for measurements and rates
PERCENT
A percentage value represented as a decimal, where 0.25 represents 25%.
Anchor to DimensionsDimensions
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.
- Anchor to daydaydayDAY_TIMESTAMPDAY_TIMESTAMP
The day an inventory snapshot applies to.
- Anchor to inventory_item_idinventory_
item_ idinventory_ item_ id IDENTITYIDENTITY - Anchor to monthmonthmonthMONTH_TIMESTAMPMONTH_TIMESTAMP
The month an inventory snapshot applies to.
- Anchor to product_idproduct_
idproduct_ id IDENTITYIDENTITY - Anchor to product_variant_idproduct_
variant_ idproduct_ variant_ id IDENTITYIDENTITY - Anchor to quarterquarterquarterQUARTER_TIMESTAMPQUARTER_TIMESTAMP
The quarter an inventory snapshot applies to.
- Anchor to shop_idshop_
idshop_ id IDENTITYIDENTITY - Anchor to weekweekweekWEEK_TIMESTAMPWEEK_TIMESTAMP
The week an inventory snapshot applies to.
- Anchor to yearyearyearYEAR_TIMESTAMPYEAR_TIMESTAMP
The year an inventory snapshot applies to.
- Anchor to inventory_cost_is_recordedinventory_
cost_ is_ recordedinventory_ cost_ is_ recorded BOOLEANBOOLEAN Whether the inventory item has a cost saved in Shopify, with values
trueandfalse.- Anchor to inventory_is_trackedinventory_
is_ trackedinventory_ is_ tracked BOOLEANBOOLEAN Whether Shopify tracks inventory adjustments for the inventory item, with values
trueandfalse.- Anchor to inventory_item_costinventory_
item_ costinventory_ item_ cost MONEYMONEY The cost recorded for one unit of the inventory item, in your store's currency.
- Anchor to shop_nameshop_
nameshop_ name STRINGSTRING Name of your store
- Anchor to product_statusproduct_
statusproduct_ status STRINGSTRING The product's current publishing state, with values Active, Archived, Draft, Suspended, and Unlisted.
- Anchor to product_titleproduct_
titleproduct_ title STRINGSTRING Display name of the product that your customers see
- Anchor to product_typeproduct_
typeproduct_ type STRINGSTRING Type (category) that you've assigned to the product
- Anchor to product_vendorproduct_
vendorproduct_ vendor STRINGSTRING Vendor of the product
- Anchor to product_collectionproduct_
collectionproduct_ collection STRINGSTRING Collection associated with the product
- Anchor to product_collectionsproduct_
collectionsproduct_ collections ARRAY<STRING>ARRAY<STRING> Set of collections associated with the product
- Anchor to app_product_creationapp_
product_ creationapp_ product_ creation STRINGSTRING The app that created the product, shown as an app name.
- Anchor to product_tagproduct_
tagproduct_ tag STRINGSTRING Tag associated with the product
- ARRAY<STRING>ARRAY<STRING>
Set of tags associated with the product
- Anchor to product_variant_abc_gradeproduct_
variant_ abc_ gradeproduct_ variant_ abc_ grade STRINGSTRING 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%.
- Anchor to product_variant_skuproduct_
variant_ skuproduct_ variant_ sku STRINGSTRING SKU of the product variant
- Anchor to product_variant_titleproduct_
variant_ titleproduct_ variant_ title STRINGSTRING Display name of the product variant
IDENTITY
Unique identifier for a Shopify resource such as a customer or order
MONTH_TIMESTAMP
Date for the start of a month
QUARTER_TIMESTAMP
Date for the start of a fiscal quarter
WEEK_TIMESTAMP
Date for the start of a week
YEAR_TIMESTAMP
Date for the start of a year
BOOLEAN
Value that is either true or false
STRING
Text made of letters, numbers, or symbols
ARRAY
A list of values. The element type appears inside angle brackets, such as ARRAY<STRING>.
inventory_by_location: Same data broken down by location for stockout and stale-stock analysis.inventory_adjustment_history: Manual and automated stock adjustments that explain inventory changes.inventory_shipments: Incoming shipment data for what's replenishing stock.inventory_transfers: Stock moves between locations that affect on-hand totals.