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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
APEREZ2
Advocate I
Advocate I

How to define if date is in a range

Hi,

I have the following problem. I need to relate the table of prices:

StartingPriceEndPriceProductUnit Price
2021-03-012021-05-22Apple Tree1.24
2021-05-232021-07-31Apple Tree1.54
2021-08-012022-04-01Apple Tree1.80
2021-03-012021-05-22Bonsai 2
2021-05-232021-07-31Bonsai 1.86
2021-08-012022-04-01Bonsai 1.79

With the sales tables, that contains an structure like this:

ProductQuantitySales Date
Apple Tree1232021-03-22
Bonsai2342021-05-09
Apple Tree1002022-01-22

How can I relate the two tables to obtain the Unit Price of each order. Because on Excel for me it's clear that with EndPrice column and XLOOKUP could be work, but on Power Query no.

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Use below formula in a custom column in second table. First table is PriceTbl.

Table.SelectRows(PriceTbl, (x)=> x[StartingPrice]<=[Sales Date] and x[EndPrice]>=[Sales Date] and x[Product]=[Product]){0}[Unit Price]

  

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

Use below formula in a custom column in second table. First table is PriceTbl.

Table.SelectRows(PriceTbl, (x)=> x[StartingPrice]<=[Sales Date] and x[EndPrice]>=[Sales Date] and x[Product]=[Product]){0}[Unit Price]

  

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.