Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
GuackGuack
Frequent Visitor

Identifying Inventory Quantity and Calculating Gross Margin in Dynamics SL Database

Currently, I only have access to the Dynamics SL database, and I need to identify the available inventory quantity for each product to calculate the gross margin. I have reviewed the main inventory tables such as ItemSite, INTran, LotSerMst, and other related tables, but I have found discrepancies between the recorded quantities and the transactions. For instance, the quantities in ItemSite.QtyOnHand often do not match the calculations derived from the transactions in INTran.

Additionally, some records in the IN10990_ItemSite table are empty or do not reflect the expected data. Furthermore, the transactions have different TranType values (such as RC, IS, II, etc.), which complicates identifying the inventory movements.

My goal is to calculate the available inventory quantity for each product (InvtID) by site (SiteID), as well as determine the gross margin using the costs (ItemCost) and sales prices (SlsPrc). In which table and field can I find the definitive data for the available inventory quantity for each product, and how can I ensure that I am using the correct information to accurately calculate the gross margin?

1 REPLY 1
Anonymous
Not applicable

Hi @GuackGuack ,

 

1)Identifying Available Inventory Quantity.

To calculate the available inventory quantity, I would suggest creating a calculated column or measure that sums the net quantity for each product (InvtID) and site (SiteID) by grouping the transactions. This method will allow you to account for different transaction types and provide a more accurate view of inventory levels.

IdentifyingInventoryQuantity = SUMX(FILTER(INTran,INTran[TranType] = "RC" || INTran[TranType] = "II"),INTran[Qty]) -
SUMX(FILTER(INTran,INTran[TranType] = "IS"),INTran[Qty])

 

2)Calculating Gross Margin

For calculating gross margin, you may want to use the following DAX formula. It subtracts the item cost from the sales price and divides the result by the sales price to calculate the percentage. This approach ensures that you handle cases where the sales price might be zero without resulting in errors.

GrossMargin = (SalesOrder[SlsPrc] - ItemCost[ItemCost])/SalesOrder[SlsPrc]

 

Best Regards,

Bof

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.