Newbies mrchew Posted November 4, 2008 Newbies Posted November 4, 2008 I'm new to Filemaker though I have experience with MySQL. I have a very simple, one table database of stock quotes: Date Symbol Open High Low Close Volume ----------------------------------------------------------- 10/31/08 ABC 10 12 9 11 9990303 10/31/08 DEF 20 22 18 21 1909933 . . . I'm trying to create a calculated field that lists the trailing "moving" average for each stock based on the last 5, 10, 30 day: Symbol 5dayAVG 10dayAVG 30dayAVG------------------------------------------------------------------------- ABC 11 10 9 DEF 22 20 18 . . . In MySQL this is straightforward, you'd have code that looks approximately like: AVERAGE(SELECT close FROM quotes WHERE date is <=today...5 days ago AND symbol=this.symbol) AVERAGE(SELECT close FROM quotes WHERE date is <=today...10 days ago AND symbol=this.symbol) AVERAGE(SELECT close FROM quotes WHERE date is <=today...30 days ago AND symbol=this.symbol) Is there a way to do this in Filemaker? I'm struggling trying to figure out a way to do 'Find' queries as part of calculations. Scripting seems capable of running multiple queries but what I really need is these moving averages as calculated fields in the same table as the plain quotes. Any advice? Thanks, Chew
comment Posted November 4, 2008 Posted November 4, 2008 In Filemaker, this is a two-step process: first, you need to define a self-join relationship for each of the SELECT statements. Then you can have calculation fields to aggregate the related records.
Newbies mrchew Posted November 4, 2008 Author Newbies Posted November 4, 2008 Thanks, I'll investigate doing this. Chew
Recommended Posts
This topic is 5923 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now