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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Poojara_D12
Super User
Super User

Many To Many Relation Issue

Hello Members,

I have a scenario where I have a many to many relation issue which I have explained below, can anyone please help me with the solutions for the same?

Poojara_D12_0-1730802887235.png

As per above screenshot, I have 2 different tables : purchase and selling respetively. I have purchased similar products multiple time at a different purchase price. Both the table has QTY column. The QTY is been taken care of that if I have QTY left with the old purchase, I'll have to sell it first and then the other with HIGHER Purchase Price. 
The question is that if I want to find the selling price dynamically that what will be the way for it. For example, I got a order for 3 Iphone 13,and I'm left with 1 Iphone 13 whose Purchase Price is 150 and other 2 is the new one i.e.160. So How will I figure the P&L in this senario? PLEASE HELP. @Dangar332 @FreemanZ @shafiz_p @SachinNandanwar @Jihwan_Kim @lbendlin 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
1 ACCEPTED SOLUTION

Hi @Poojara_D12 ,

 

To calculate the P&L, as outlined in your requirements, we need to determine the timing of item sales relative to purchases. Since your sold quantities are lower than your purchase quantities, this results in an inventory balance at the end of the transactions above. There are various methods to value this inventory, including FIFO (First In, First Out), LIFO (Last In, First Out), and moving average. Each of these valuation methods requires a reference to the time dimension.

 

Best regards,

View solution in original post

3 REPLIES 3
DataNinja777
Super User
Super User

Hi @Poojara_D12 ,

 

I would start by creating a dimension table for the product (iPhone) and establishing a one-to-many relationship with your purchase and sales fact tables, rather than using a many-to-many relationship between two fact tables 😉.

Next, I’d like to confirm whether you have separate columns for purchase date and sales date. Your P&L will recognize the cost of goods sold (COGS) at the point of revenue recognition (when sales are made), as inventory (assets) remain on the balance sheet until sales are made.

Please let us know if there is a separate date field for the sales and purchase fact tables.

 

Best regards,

Hi @DataNinja777 
There is no seperate date field for the sales and purchase given from client, also there is no Lot Number column in sales or purchase table as well.

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

Hi @Poojara_D12 ,

 

To calculate the P&L, as outlined in your requirements, we need to determine the timing of item sales relative to purchases. Since your sold quantities are lower than your purchase quantities, this results in an inventory balance at the end of the transactions above. There are various methods to value this inventory, including FIFO (First In, First Out), LIFO (Last In, First Out), and moving average. Each of these valuation methods requires a reference to the time dimension.

 

Best regards,

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.