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

Check if record from table A falls within a date range in table B

I have a table that I'll call Event.

 

  • Event
    • date
    • person_id

 

I have another table called Biography.

 

  • Biography
    • start_date
    • end_date
    • person_id
    • title

 

Every Event row should be associated with one and only one Biography entry (but a single person_id may have multiple Biography entries associated with it, i.e., George Washington: The Early Years, and George_Washington: The Later Years can be separate Biography entries, but they must cover non-overlapping years). I want to add a calculated column to the Event table that will hold the title of the Biography entry to which it corresponds by checking that the person_id is equal and that the Event date falls between the start_date and end_date of the Biography entry.

 

How do I do this? I've tried a number of formulas but can't seem to get it quite right.

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column in the Events Table

 

=CALCULATE(FIRSTNONBLANK(Biogaphy[title],1),FILTER(Biography,Biography[start_date]<=EARLIER(date)&&Biography[end_date]>=EARLIER(date)&&Biography[person_id]=EARLIER(person_id)))

 

If this formula does not work, then share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column in the Events Table

 

=CALCULATE(FIRSTNONBLANK(Biogaphy[title],1),FILTER(Biography,Biography[start_date]<=EARLIER(date)&&Biography[end_date]>=EARLIER(date)&&Biography[person_id]=EARLIER(person_id)))

 

If this formula does not work, then share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

That worked. Thank you! I guess the EARLIER function was what I needed.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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