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
GPH
Frequent Visitor

Return a value based on date start and date end

Need help please! 

 

I need to return a value based on a date range. I have two tables, one has the date (which i need to return the id) and the other has the date start and date end of the coresponding ids. I have made two smaller tables as an example. 

id table.PNGMy first table provides the date start and date end of each id. I need to populate the id column in the table below. 

 

date table.PNG

 

 

These tables are just mockups, I have a much larger tables (with more ids and dates) loaded into power bi already. I could do it in excel using a VLOOKUP but can not work out how to make it work in Power BI. 

 

Any help would be much appreciated! 

1 ACCEPTED SOLUTION
Johanno
Responsive Resident
Responsive Resident

If I name the first table to Intervals and the second to Dates you could try:

Id = 
CALCULATE(
       VALUES(Intervals[Id]);
       FILTER(
           Intervals;
           Intervals[Date_Start] <= EARLIER(Dates[Date])
           && Intervals[Date_End] >= EARLIER(Dates[Date])
       )
)

View solution in original post

2 REPLIES 2
Johanno
Responsive Resident
Responsive Resident

If I name the first table to Intervals and the second to Dates you could try:

Id = 
CALCULATE(
       VALUES(Intervals[Id]);
       FILTER(
           Intervals;
           Intervals[Date_Start] <= EARLIER(Dates[Date])
           && Intervals[Date_End] >= EARLIER(Dates[Date])
       )
)
GPH
Frequent Visitor

That is perfect! thankyou so much! 

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.