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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
gpp007
New Member

date table

Hi all, 

 

I have two queries that i would to join... 

So first query is a table of 3 columns (Date, product, Quantity) and for this one i have everyday of a year

 

for the second query, i have 4 columns (Date, product, price, segment product) but only 4 point of data per year per product (it's a pricing policy/strtegy) 

 

my objective is to add the price columns to my first table, to be able to simply multiply my quantity by princing decided by corporate. 

 

Thanks a lot 

 

Let me know if i can be more precise

1 ACCEPTED SOLUTION

Hi @gpp007 ,

 

First create a column in query 2:

 

next period = 
var _next= CALCULATE(MIN('Table'[Date]),FILTER('Table','Table'[Date]>EARLIER('Table'[Date])&&'Table'[Product]=EARLIER('Table'[Product])))
Return
IF(_next=BLANK(),DATE(YEAR(MAX('Table'[Date])),12,31),_next)

 

Then create a measure as below:

 

_cost = 
CALCULATE(MIN('Table'[Price]),FILTER('Table','Table'[Date]<=MAX('Query 1'[Date])&&'Table'[next period]>=MAX('Query 1'[Date])&&'Table'[Product]=MAX('Query 1'[Product])))

 

 And you will find that the price has been added to query 1 according to period setting.

v-kelly-msft_0-1613029210588.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@gpp007 , a new column like

 

minx(filter(table2, table1[product] =table2[product] && table1[Date] = table2[Date]),table2[price])

 

or

minx(filter(table2, table1[product] =table2[product] && year(table1[Date]) = year(table2[Date])),table2[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

hi amitchandak

thanks for quick reply, i used your method, but it partially worked... the difficulty is to have a changing price between period, if i use your method, on my new column i only have the data i need at one date vs all date (in order to calculate turnover etc). 

Hi @gpp007 ,

 

First create a column in query 2:

 

next period = 
var _next= CALCULATE(MIN('Table'[Date]),FILTER('Table','Table'[Date]>EARLIER('Table'[Date])&&'Table'[Product]=EARLIER('Table'[Product])))
Return
IF(_next=BLANK(),DATE(YEAR(MAX('Table'[Date])),12,31),_next)

 

Then create a measure as below:

 

_cost = 
CALCULATE(MIN('Table'[Price]),FILTER('Table','Table'[Date]<=MAX('Query 1'[Date])&&'Table'[next period]>=MAX('Query 1'[Date])&&'Table'[Product]=MAX('Query 1'[Product])))

 

 And you will find that the price has been added to query 1 according to period setting.

v-kelly-msft_0-1613029210588.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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