Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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?

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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?

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.