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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors