Forum Discussion
Marcottech
10 months agoRegular Visitor
Add a column from a different query for which the value is determined by both a match and a date
Hi, I have 2 different tables, each in a different query. 1. A table that defines the date a time for which some events (Adverse Events) occured to some people (Subject) from different group popu...
- 10 months ago
Hi Christian,
Not sure if you want Power Query or DAX or what the relationships in your model look like, but as a first draft, DAX, try this...
First Dosing for Subject = CALCULATE( MIN(Dosing[Collection Time]), FILTER( Dosing, Dosing[Study] = 'Adverse Event'[Study] && Dosing[Subject] = 'Adverse Event'[Subject] && 'Adverse Event'[Is this a Pre-dose AE?] = "No" ) )Last Dosing Before AE = CALCULATE( MAX(Dosing[Collection Time]), FILTER( Dosing, Dosing[Study] = 'Adverse Event'[Study] && Dosing[Subject] = 'Adverse Event'[Subject] && Dosing[Collection Time] <= 'Adverse Event'[Start Time] && 'Adverse Event'[Is this a Pre-dose AE?] = "No" ) )This was done quickly, may need to tweak the calculation a bit.
KNP
Super User
10 months agoHi Christian,
Not sure if you want Power Query or DAX or what the relationships in your model look like, but as a first draft, DAX, try this...
First Dosing for Subject =
CALCULATE(
MIN(Dosing[Collection Time]),
FILTER(
Dosing,
Dosing[Study] = 'Adverse Event'[Study] &&
Dosing[Subject] = 'Adverse Event'[Subject] &&
'Adverse Event'[Is this a Pre-dose AE?] = "No"
)
)
Last Dosing Before AE =
CALCULATE(
MAX(Dosing[Collection Time]),
FILTER(
Dosing,
Dosing[Study] = 'Adverse Event'[Study] &&
Dosing[Subject] = 'Adverse Event'[Subject] &&
Dosing[Collection Time] <= 'Adverse Event'[Start Time] &&
'Adverse Event'[Is this a Pre-dose AE?] = "No"
)
)
This was done quickly, may need to tweak the calculation a bit.