Inventory Management & Demand Forecasting for E-commerce Sellers + Tutorial

A technical approach to inventory optimization.

This article caters to professionals who want to enhance their e-commerce operations, specifically in inventory management and demand forecasting. In this blog, we offer a practical guide on how linear regression models can be employed for SKU-level forecasting and integrate forecasted sales into a reorder alert system for inventory replenishment using Shopify data in Snowflake.

Why is inventory management & demand forecasting important to e-commerce sellers?

Demand forecasting can help retailers reduce stockouts by up to 50%. (Gartner)

E-commerce sellers face a challenging and time-consuming task when managing their inventory. If they understock, they risk losing sales and disappointing customers, while overstocking can lead to increased storage costs. Nevertheless, sellers can optimize their operations to meet customer demand and reduce the risk of overstocking or understocking by accurately predicting demand and implementing an efficient inventory management strategy.

Inventory management

Alert reorder time & quantity: Inventory management is critical in optimizing business operations by monitoring stock levels and determining the appropriate times and amounts for reordering. This process involves tracking inventory from the point of purchase to the sale of goods, enabling companies to respond effectively to trends and ensure sufficient stock to meet customer orders while providing timely alerts in case of potential shortages.

Save stock costs: Also, effective inventory management helps save costs, as holding excess inventory can tie up capital and negatively impact cash flow.

Satisfy Customers: From a customer satisfaction perspective, maintaining adequate stock levels ensures that customers receive the products they want without delays, essential for building and retaining a loyal customer base.

Demand forecasting

Demand forecasting is an integral component of effective inventory management. It involves using data analysis to predict the quantity of each item expected to be sold and the timing of those sales. By accurately estimating demand, businesses can make informed decisions regarding the procurement and allocation of inventory.

What are solutions for e-commerce sellers?

Demand forecasting model & visualization

Using linear regression, sellers can forecast the order quantity of each SKU.

Sellers can observe the actual and forecasted demand trend over time and by each SKU.

Sellers can monitor the performance of the forecasting model with R-squared. R-squared measures how much of the variance can be explained by our fit line. This will evaluate a number between 0 and 1, with 1 being a better-fitting line.

Inventory alert system

Sellers get an alert when it’s the day to reorder and know how many items should be replenished.

Step 1) Building & evaluating a linear regression model using your Shopify data in Snowflake

The linear regression is represented by:

y_est = mx + b


y_est – estimated y value

m – slope

x – x value

b – y-intercept

Once we use these formulas to have our line, we can evaluate how well it fits our data using R-squared. R-squared measures how much of the variance can be explained by our fit line.

R-squared = sum((y_est - y_bar)^2) / sum((y - y_bar)^2)

1.1 Create a date spine including past and future dates

1.2 Prepare sales by order month from Shopify data & forecast key derived from the order month

1.3 Calculate the slope and intercepts

Using the Snowflake functions REGR_SLOPE and REGR_INTERCEPT, we can quickly find the estimated slope and intercepts:

1.4 Make predictions!

1.5 Evaluate the model by R-square

Using the Snowflake function REGR_R2, we can have r-squared over time:

Step 2) Integrating forecasted sales into the inventory alert system

Reorder points strategy

This simplified reorder point graph shows you the relationship between your reorder point, stock level, and safety stock over a period of time. It helps you visualize your reorder point based on your sales trends.

Lead time: Time taken (in days) to fulfill the order

Maximum average usage: The number of sales made in an average day of that particular item

Daily average usage: The number of sales made in a day of that particular item

Safety stock: The amount of extra stock, if any, that sellers keep in their inventory to help avoid stockouts

Safety stock = Maximum average usage * Lead time

Reorder point (level): The specific level at which the stock needs to be replenished. In other words, it tells sellers when to place an order so they won’t run out of stock.

Reorder point = Daily average usage * Lead time + Safety stock

When Remaining stock <= Reorder point, it’s time to reorder the same amount of Reorder point. So that at the end of the order cycle, the remaining stock is equal to safety stock.

Alert Reorder Time & Quantity

Avg daily sales = monthly predicted sales/ days in a month

Inbound - In progress = Reorder point if it’s in Order Cycle

Inbound - Arrived = Reorder point if it’s the date receiving the order

Remaining stock = (Remaining stock – Actual sales + Inbound - Arrived ) of the previous day

The Need Order column is used to alert reorder time.

  • ”Yes” if Remaining stock <= Reorder point and Inbound - In progress = 0
  • “No” if Remaining stock > Reorder point or Inbound - In progress > 0

Demo Template: link


The integration of demand forecasting and inventory management is critical in ensuring that e-commerce companies operate efficiently and maintain customer satisfaction. Through the adoption of linear regression models and reorder alert systems, businesses can streamline inventory operations, reduce costs, and ultimately thrive in a competitive market.

Why rely on guesswork? Elevate your e-commerce strategy with Joon Solutions, where empirical data meets innovative analytics and AI. Our experts will empower you to streamline inventory, predict demand, and maximize revenue. Book a free 1:1 consultation and take the driver’s seat in navigating your business to unprecedented heights. Your data-driven success starts now.

Alice Bui
Like what you read? Share with a friend.

Contact Us!

Do you have a question or need more info? Please enter your information and describe your inquiry, and we’ll get back to you as soon as possible. Thanks!

Check out our Case Study!

We’d love to hear more from you. Tell us more about yourself and we’ll message you with our case studies as soon as we receive your message!