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

Lookup start date and end date from another table

Hi, 

 

I got two tables, a calendar table (A) and table showing products' start and end dates (B). How can I get the result as shown in table C below (first date in the list would be current date and last date from the Product table, all dates in between should be listed)  

 

Calendar (A) 

Date

1/1/2020

1/2/2020
1/3/2020...

 

Product table (B)

ProductStart DateEnd Date
A6/1/20209/30/2020
B9/1/20209/30/2020
C1/1/202112/31/2021

 

Result (C)

DateProduct 1 Product 2 Product 3
6/7/2020Anullnull
6/8/2020Anullnull
...   
9/1/2020ABnull
...   
1/1/2021nullnullC
...   
12/31/2021nullnullC

 

Best regards,

 

Chris

1 ACCEPTED SOLUTION

the measure works fine for me. Have you put your fields in the right place? Date is from Calendar, Product is from Product. No linkage.

 

Annotation 2020-06-07 115329.png

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

Pseudo code here

 

var d= max(date)

var Res = calculate(max([product]),[product start date]<=d,[product end date]>=d)

return res

 

This will result in the product name if in range, and BLANK if not.

 

EDIT: actual code here:  Note: no relationships between the tables!

 

 

live = 
var d = max('Calendar'[Date])
return CALCULATE(max('Product'[Product]),'Product'[Start Date]<=d,'Product'[End Date]>=d)

 

 

Anonymous
Not applicable

Hi Ibendlin,

 

and thanks for your input. I tried your measure, but it does only return one product for a specific date even though there might be several products with the same starting date? What am I doing wrong? 

 

However, I was thinking of how to solve this in M as a new table and not DAX as I need to make some further calculations to the data once I get this first step sorted out.

 

Best Regards,

 

Christer 

the measure works fine for me. Have you put your fields in the right place? Date is from Calendar, Product is from Product. No linkage.

 

Annotation 2020-06-07 115329.png

Anonymous
Not applicable

Now I got it to work after seeing your formula. This solution will work, thanks a lot!

 

Chris

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