__STYLES__
A medium-sized Manufacturing Company produces electronic components. They have a wide range of products and maintain an inventory of raw materials, work-in-progress (WIP), and finished goods. The company has been experiencing issues with inventory management, including stockouts, excess inventory, and increased carrying costs. The management team wants to conduct an inventory analysis to identify areas for improvement and optimize their inventory management practices.
The primary objectives of the inventory analysis are as follows:
A clean and organized Excel sheets that shows key trends to help optimize the inventory management
https://www.kaggle.com/datasets/bhanupratapbiswas/inventory-analysis-case-study
Descriptive
The screenshots for the generated tables are available below.
To optimize the production streamline, we need to identify the problems in production. This is achieved by analyzing the level of demand for each brand.
The following steps demonstrate how I conducted the analysis:
1- I joined the BeginInv and EndInv tables together using the InventoryID, I named the new table Over Production Table and summed the total amount the company manufactured and stored for each brand at the beginning (startonHand) and the end(EndOnHand) of 2016 .
2- Moreover, I calculated the difference between the two quantities to get the additional amount that the company produced (diffUnits) and sorted them according to this difference.
--Over Production Table
WITH OverProductionTable as (
SELECT B.store, B.City, FirstOnHand, EndOnHand, FirstOnHand - EndOnHand AS Unitsdiff
FROM InvBeg B
LEFT JOIN InvEnd E ON B.InventoryId = E.InventoryId
)
SELECT store, City ,SUM(FirstOnHand) AS StartUnits, SUM(EndOnHand) AS EndUnits, Sum(ISNULL(Unitsdiff, FirstOnHand)) AS Unitsdiff
FROM OverProductionTable
GROUP BY store, City
1- To summarize purchases table, I used Sum() function to calculate the total amount of units that were bought in each store for each product and their total cost. I did the same thing for the sales table.
-- Purchases Summary
select Brand,sum(Quantity) QuantityBought,sum(Dollars) TotalCost from Purchases
group by Brand
order by TotalCost desc
-- Sales Summary
select Brand,sum(SalesQuantity) QuantitySold, sum(salesDollars) TotalRevenue from sales
group by Brand
order by QuantitySold desc
2- After I generated Purchases Summary table and Sales Summary table, I joined them using full outer join. The reason for this is their are some items that were bought but not sales, these are the raw materials that were used in production. Similarly, many goods in sales tables were not available in the purchases table, as these were the manufactured products, So I used full outer join to include all the data in one place.
select ISNULL(P.InventoryId,S.InventoryId) InvId, ISNUll(P.Store,S.Store) Store, ISNULL(P.Brand,S.Brand) Brand,
isNull(P.QuantityBought,0) QuantityBought, isNull(S.QuantitySold,0) QuantitySold
from PurchasesSummary P
Full outer Join SalesSummary Son P.InventoryId=S.InventoryId
3- To reorganize the table and combine all the common data in one column instead of two, I populated the InventoryID, store and Brand data from sales table into purchases data if these fields has NULL values in the Purchases table.
4- Then, I replaced all the NULL values in the totalBought and totalSold column with 0.
5- Finally after generating the final Summary report for bought and sold items. I added another column called to calculate the difference between the bought and sold units for each item to see how many units remained in the inventory.
--Final Summary
with Summary as(
select Brand , Sum(QuantityBought) TotablBought, Sum(QuantitySold) TotalSold
from PSSummary
group by(Brand)
)
select Brand , TotablBought,TotalSold, TotablBought-TotalSold as remaining
from Summary
order by remaining