questions on calculated / wrapped fields

LabKey Support Forum
questions on calculated / wrapped fields Ben Bimber  2010-06-30 07:31
Status: Closed
 
We have a number of study datasets. Each dataset has a date field. We also have a 'demographics' dataset that contains the birthday of each animal. For pretty much every dataset, it would be useful to have a calculated field called 'age at the time', which is a simple SQL expression taking the date field minus birthday.

LabKey supports the concept of aliasing a column. To date, I have used this to wrap either the Id or ObjectId columns and created a lookup to some new query. This query contained whatever calculated fields I wanted. Maybe I'm missing something, but I'm not entirely sure what other purpose aliasing a column would serve. This method sorta works, but is a little cumbersome (this behaves a little weird in the UI, which i can write about if you want), especially when all we want is to add a simple calculation.

Is there a more direct mechanism to add a calculated SQL expression as a column to a table in labkey?
 
 
jeckels responded:  2010-06-30 12:52
Hi Ben,

We don't have a way to directly attach a SQL expression as a new "virtual" column. We can discuss where this falls on your priority list for 10.3 or some other future release.

I added the column aliasing feature a while ago to enable joining in data from external tables, and it also works for custom queries like in your scenario. It was simpler to implement than adding columns directly, but isn't as appropriate in this case.

Thanks,
Josh
 
Ben Bimber responded:  2010-06-30 13:44
Josh,

thanks for the reply. some alternative mechanism for attaching virtual SQL is probably something we'd want to get to at some point, but there are a lot of pending items and i'm not sure exactly where it falls among them.