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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Syndicate_Admin
Administrator
Administrator

Calculate Profitability with sales and costs table with different dates

Hello! I'm a few days ago with this matter, and I do not know how to solve it!

I have a sales table with the amounts sold per month, and another of purchases with the purchases made each month. To know the profitability of the month, yes I have the sales and quantities sold belonging to each month, but not for all the products I have purchases that same month, so that it does not cost me $ 0 for that period, I need to take the cost of the last purchase, not of the whole table but before the month I am consulting.

If anyone can help me, thank you very much! 🙏

Shopping table

Natalia0710_0-1680095792357.png

Sales Table

Natalia0710_1-1680095943681.png

2 REPLIES 2
amitchandak
Super User
Super User

@Syndicate_Admin , Please create a new column in the sales using purchase, please change column name as as per need

 

New column in sales  =

var _max = maxx(filter(purchase, Purchase[Item] = sales[item]  && Purchase[date] <=sales[date]) ,Purchase[date] )

return

maxx(filter(purchase, Purchase[Item] = sales[item]  && Purchase[date] = _max ) ,Purchase[Price] )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

It worked perfect! Thanks a lot!!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.