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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
blommethomas
Frequent Visitor

Data allocation in retailer sales model

Dear PowerBI Community,

 

I'm trying to build a sales model for a company which sell to supermarkets.

The goal is to calculate the net profit made each week, with net profit = Volume Sold x Price - Promotional Costs

 

I'm using 3 tables, each with an example of the dataset:

 

Products

EAN CUNameBrandSegmentFormatPrice
123456Soap BarCleanMeBars400gr0.5
345678XL BarCleanMeBars670gr0.65

 

Sales

EAN CUWeekVolumeValue
12345615.00012.500
34567843.20017.000

 

Promotions

WeekBrandSegmentFormatCost
1CleanMeBarsnull2.000
4nullBars400gr3.500

 

Promotions can be on very specific segments or very broad ones:

  • Line 1 is a promotion on all 'CleanMe Bars' regardless of the size
  • Line 2 is a promotion on all '400gr Bars' regardless of the brand

I can easily link Sales & Products using EAN as a primary key.

 

But I'm struggling to connect the Promotions table:

I believe I should first create a calculated table which splits each promotion into a new row for every product involved.

For instance the promotion on 'CleanMe Bars' would need to be split over the 400gr and 750gr formats:

WeekEANCost
11234561.000
13456781.000

After which I can link the combination Week + EAN to the Sales table.

 

But I don't see how I can create this new table using DAX or PowerQuery. Can somebody help me?

 

Bonus: preferably the cost allocated to each product is weighted according to % of total sales during the specified week)

 

KR,
Thomas

 

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Assuming there will always be an entry (no blanks there) in the Segment column of the Promotions Table, we can first bring over Brand from the Products Table into the Sales Table and then based on Week and Brand columns in the Sales table and Promotion table, we can bring over Cost from the Promotions Table into the Sales Table.

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
kentyler
Solution Sage
Solution Sage

I think you should split your promotions table into one table for segment promotions and one for brand promotions. Then each promotion table will have its own relationship and can be linked to sales or products or both...depending on what you want to report on.

 

 

 





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Unfortunately this wouldn't make my model robust enough:

tomorrow I might want to split my promotions over a different variable (let's say size or flavour) and I would need to change the whole model.

 

What I'm looking for is a solution in Power Query (M language) but I struggle with the language semantics.

 

In pseudo-code I would need the following:

Promotions.AddColumn (list of EAN)

list of EAN = Contract.SelectRows(

if(Promotions.Brand is not null) Contract.Brand == Promotions.Brand 

AND if(Promotions.Segment is not null) Contract.Segment== Promotions.Segment

AND if(Promotions.Format is not null) Contract.Format == Promotions.Format

)

 

Afterwards I can split the List into new Rows using 'Split Columns' and I can continue working on my model

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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