First I did the calculation in the Long table, using Col Mean function with by variable (Study ID).
e.g. for the 0..3 days average:
Col Mean( If( :Day <= 3, :total SOFA score, . ), :StudyID )
The Problem is, that Linking is not working from the short table to the Long, because in the Long table the Study ID is not unique.
A Workaround is to generate a new Link ID in both tables, in the Long table it May be:
Char( :StudyID ) || "_" || Char( :Day )
and in the short table:
Char(:StudyID) || "_0"
Then we can refer from the short table to the Long (Always day 0, but it contains the correct aggregated Information).
And now you have the Information in your short table, dynamically connected by symbolic link.
Georg