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
Allisond
Advocate II
Advocate II

Date from another table btwn 2 dates on a row on a second table

Good Morning,

 

I am struggling with a problem regarding admission events occurring between weight measurements in a row making that row invalid.  I want a way to identify those rows or remove those rows. 

 

I have 2 Tables

 

Table 1

PatientIDEventDate
123401/01/01
234501/03/04
123405/02/01
789002/15/02

 and

Table 2

PatientIDMeasurementDatePriorMeasurementDate
123412/12/0109/12/01
123407/01/0111/01/00
789008/01/0109/01/01

 

I am needing either a column to identify each row that does/does not   have any "event date" in between the measurementdate and priormeasurementdate     or      I need a table returned with only those rows that DO NOT have an event occuring between the MeasurementDate and PriorMeasurementDate.    

 

So for the above, Row 1 for 1234 would be kept, but Row 2 for 1234 would not.   The patient would have been readmitted in between those dates making that row invalid.

 

I have tried a calculated column:

CALCULATE
(VALUES('Events Data'[Event Date]),
FILTER   ('Events Data',          'Weights'[PatientID] = 'Events Data'[patid]
                                               && 'Census Events Data'[Event Date] >= Weights_20190901[Previous.Measurement Date]
                                               && 'Census Events Data'[Event Date] <= Weights_20190901[Measurement Date])
)
 
but getting an error "A table of multiple values was supplied where a single value was expected" which I totally get, but have no idea how correct for.    Any help would be Greatly Appreciated.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Allisond , you can measure like

 

CALCULATE
(max('Events Data'[Event Date]),
FILTER ('Events Data', max('Weights'[PatientID]) = 'Events Data'[patid]
&& 'Events Data'[Event Date] >= max('Weights'[Previous.Measurement Date])
&& 'Events Data'[Event Date] <= max('Weights'[Measurement Date]))
)

 

Can you share output in table format?

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Allisond , you can measure like

 

CALCULATE
(max('Events Data'[Event Date]),
FILTER ('Events Data', max('Weights'[PatientID]) = 'Events Data'[patid]
&& 'Events Data'[Event Date] >= max('Weights'[Previous.Measurement Date])
&& 'Events Data'[Event Date] <= max('Weights'[Measurement Date]))
)

 

Can you share output in table format?

Thank you!!! It seems to work beautifully.

 

Just to make sure, using this formula, If I have multiple event dates and multiple wt measure windows will using "MAX" only pull the most recent event or the MAX event date occurring within the dates window?   With my understanding of MAX - which may be off for sure......  MAX would only pull the most recent date?

 

Event:    1/4/20                      1/20/20

Wt:         1/6/20                     1/18/20

Prior Wt: 1/1/20                     1/22/20

 

Both rows would need to pull the respective event dates that fall within the window of wt to prior wt.  

 

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