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
AW1976NOVA
Post Patron
Post Patron

DAX: Return value if date from one table is between two date fields in another table

Hi Power BI friends,

 

I have three excel tables in my Power BI report:

  • ‘DC to Home’
  • ‘PC’
  • ‘Member ID’

 

Both tables have the field [Member ID] as the Primary Key.  The ‘Member ID’ table only has the [Member ID] field.

 

The ‘DC to Home’ table has two date fields:

  • [NextAdmit]
  • [Discharge Date]

 

The ‘PC’ table has one date field:

  • [Qstn Resp Date]

 

I would like to create a measure that essentially does the following:

 

New Measure = IF’DC to Home’[NextAdmit] is > ‘PC’[QSTN Resp Date] AND ‘DC to Home’[Discharge Date] < ‘PC’[QSTN Resp Date] THEN … return the ‘PC’[QSTN Resp Date] … for the ‘Member ID’[Member_ID] ELSE “N/A”.

 

Here is a visual of the relationship map:

76.PNG

 

Here is an example of ‘DC to Home’:

Member ID         NextAdmit        Discharge Date

0001                     9/1/2020          9/1/2020

0002                     7/7/2020          7/5/2020

0003                     5/3/2020          4/1/2020

 

Here is an example of ‘PC’:

Member ID         Qstn Resp Date       

0001                               

0002                     7/6/2020         

0003                     4/2/2020

 

If the New Measure was working correctly, I’d expect the results of a table visual to be:

Member ID        New Measure         

0001                   N/A

0002                   7/6/2020

0003                   4/2/2020

 

Is there anyway to build this out as a measure so I can use it in a table visual?

 

 

 

Thank you!

2 REPLIES 2
Pragati11
Super User
Super User

Hi @AW1976NOVA ,

 

So what are you currently getting? (which you are saying is wrong)

Please share a screenshot and also share the measure calculation that you are currently using.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Hi,

 

I've never written this sort of measure before so I do not really know where to begin.  I usually try to build in Power Query but for my purpose here it needs to be in DAX which I'm not familiar with.

 

I tried to be as descriptive as possible.  Do you need more background on what I'm trying to do with the measure?

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