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
Anonymous
Not applicable

Price on a given date

Master Data Table is called ( "PriceMD")

[SKU]    [Price]   [Customer]   [Price Effective From Date]

123               10                      1000               1 Jan 2020   

123             10                     1000              1 Jan 2021

124              20                     1000             1 Jan 2021

125              21                    1000                1 Jan 2021

126               21                     2000                 1 Jan 2021

123               10                      1000               1 Jan 2020             

...

...

 

 

Sales Table ("ConsolidatedSales")

[SKU Sold]     [Sold to Cust]     [Sold On]       [Price on Date]

123                1000                    5 Jan 2020      ??

126                2000                    5 Jan 2021    ??

...

...

 

Can someone please guide me by writing a PQ to add a custom column called [Price on Date] calculated from master data.

 

There are nearly 10 million rows in  "ConsolidatedSales" . I am not sure on what will be the most effiencent way to handle the the task at hand.

 

Thanks in advance.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Create a new column in ConsolidatedSales

 

new column =
var _date = maxx(filter(PriceMD,PriceMD[SKU] = ConsolidatedSales[SKU] && PriceMD[Customer] = ConsolidatedSales[customer] && PriceMD[Price Effective From Date] <=ConsolidatedSales[Sold On] ),PriceMD[Price Effective From Date])
return
maxx(filter(PriceMD,PriceMD[SKU] = ConsolidatedSales[SKU] && PriceMD[Customer] = ConsolidatedSales[customer] && PriceMD[Price Effective From Date] =_max ),PriceMD[price])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Many thanks Amit. This appears to be working.

 

I am assuming the _max variable is a typo and should be _date?

 

 

new column =
var _date = maxx(filter(PriceMD,PriceMD[SKU] = ConsolidatedSales[SKU] && PriceMD[Customer] = ConsolidatedSales[customer] && PriceMD[Price Effective From Date] <=ConsolidatedSales[Sold On] ),PriceMD[Price Effective From Date])
return
maxx(filter(PriceMD,PriceMD[SKU] = ConsolidatedSales[SKU] && PriceMD[Customer] = ConsolidatedSales[customer] && PriceMD[Price Effective From Date] =_max ),PriceMD[price])

amitchandak
Super User
Super User

@Anonymous , Create a new column in ConsolidatedSales

 

new column =
var _date = maxx(filter(PriceMD,PriceMD[SKU] = ConsolidatedSales[SKU] && PriceMD[Customer] = ConsolidatedSales[customer] && PriceMD[Price Effective From Date] <=ConsolidatedSales[Sold On] ),PriceMD[Price Effective From Date])
return
maxx(filter(PriceMD,PriceMD[SKU] = ConsolidatedSales[SKU] && PriceMD[Customer] = ConsolidatedSales[customer] && PriceMD[Price Effective From Date] =_max ),PriceMD[price])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.