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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MarlenePirker
Helper I
Helper I

Stock Allocation

Hello, 

 

i have a question and I already tried a lot but It doesnt seem to work. 

I have this table created in excel: 

MarlenePirker_0-1697464735828.png

I want new columns. 
1: If below zero is 1 for one company for a product, then I want to check PER PRODUCT the Over/understock if there is a company that has overstock that could cover the understock from a company (this is what is shown in max overstock). What i want now is to check if the max overstock < Stock needed and if that is the case I want to take stock from other companies as well. And if company B needs all the available stock company D will not get anything. In the new columns I want to show the name of the company(ies) that have overstock to cover the understock of a company. 

 

2. I want a column with the new Over/understock value after allocation. 

 

It should look like this in the end: 

 

ProductCompany NameStockOrdersProductionStock - OrdersOver/UnderstockBelow zero Stock neededAllocation Comp1 Allocation Comp2Allocation Comp3New Over/Understock

ACompany A30430-13-13113Company B  0
ACompany B  2002000   7
ACompany C40200202000   20
ACompany D102030-102000   20
BCompany A15  151500   0
BCompany B 30 -30-30130Company A Company ECompany C0
BCompany C 26-2400   1
BCompany D20808-60-52152   -52
BCompany E5 751200   0

 

MarlenePirker_1-1697465300339.png

 

 

Hope thats clear since its a bit hard for me to explain. 

 

Thanks!

 

best regards, 

Marlene

 

1 REPLY 1
123abc
Community Champion
Community Champion

Step 1: Load the Data into Power BI

  1. Open Power BI Desktop.
  2. Go to "Home" > "Get Data" > "Excel," and select your Excel file.
  3. Select the worksheet containing your table and load the data.

Step 2: Create a New Column for Over/Understock

  1. In Power Query Editor, add a custom column that calculates the Over/Understock:

    • In Power Query Editor, go to the "Model" tab.
    • Click on "New Column."
    • Use the following formula for the "New Over/Understock" column:

[Stock] - [Orders]

 

Step 3: Allocate Stock from Overstock

  1. To allocate stock from overstock, you can create a new query that calculates the available overstock for each product and company.
  2. Merge this query with your main table based on the product and allocate the stock as needed.

Step 4: Create a New Column for Allocation

  1. In Power Query Editor, add a custom column that calculates the allocation based on your criteria. This may require some advanced M code to identify the companies with overstock to cover understock. The logic can be complex, depending on your specific requirements.

Step 5: Load Data into Power BI Model

  1. Once you've applied all the necessary transformations in Power Query Editor, load the data into the Power BI model.

Step 6: Create Visualizations

  1. In the Power BI report view, create visualizations based on the transformed data.

The exact M code for calculating allocation based on your criteria and merging with the main table will depend on the specifics of your data and requirements. This is a complex task and might require expertise in Power Query and DAX.

It's essential to have a good understanding of Power BI, Power Query, and DAX to achieve the desired result. You may need to consult with a Power BI expert or consider a custom development solution if your requirements are highly complex.

Remember to regularly refresh your data in Power BI to keep your visualizations up-to-date as your source data changes.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.