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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started


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


Sales Table


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] )


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

It worked perfect! Thanks a lot!!

Helpful resources


Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.