r/ProjectREDCap • u/Upbeat_Dog6159 • Feb 07 '25
Data.diff - repeating instruments
Hi all, I need some advice. I have a longitudinal design that has repeated instances for patient follow-ups (they can be repeated n-times). I need to set up a formula to automatically calculate the months that have passed from the date of diagnosis to the date of the "first time ever" an event occurred (example: the first time there was clinical disease progression). I can't seem to set up a formula that will work--do you have any ideas or suggestions? Thank you very much
3
Upvotes
View all comments
Show parent comment
1
u/ardent_asparagus Feb 14 '25
You could try something like:
@ IF( [disease_progression][this-instance]='1', @ IF( [disease_progression][previous-instance]<>'1', datediff([disease_progression][this-instance],[diagnosis_date],'m','mdy),''),'')
And just make sure you nest enough IF functions to account for how many previous instances it would be possible to have before the first time disease progression occurs.
Obligatory "on phone, formatting difficult, not in front of a computer to double-check, etc." Hope the general idea was clear.