Newbies CBL Posted December 23, 2004 Newbies Posted December 23, 2004 I have a database of bills and expenses that I record every month. I have the various bills in a portal with the date they are due and the amounts. What I would like to be able to do is to select only certain rows (or ID's) from the portal and then get a summary of the amounts from all of those rows only. Then, I would like to take this total and divide it by 3 to get a new total. Can anyone help me with this?
RalphL Posted December 23, 2004 Posted December 23, 2004 Welcome to the Forum, Without knowing your table structure, I will have to make a guess. Add a number field in the related table. Auto enter 0 in this field. Write a script like this. If [NewField = 0] Set field [NewField, 1] Else Set field [NewField, 0] End If Commit record Add a button in the portal row that preforms the following script. Go to relaated record [Relationship] Preform Script [new script] Refresh window Make a new relationship to the related table. This relationship should include the dates (first and last days of month) aand the new field. Use the Sum function with this relationship to get the total for the selected rows. If this doesn't help you, post a sample of your file and I will make the changes to get this to work.
-Queue- Posted December 23, 2004 Posted December 23, 2004 A simpler script for changing the value of NewField: Set Field [NewField; Abs(NewField - 1)] Commit Records/Requests
Newbies CBL Posted December 23, 2004 Author Newbies Posted December 23, 2004 Thank you for your quick reply. I am new to this so I may need a little more explanation. First, what is the SetField doing in the script? Is it making some entries equal to 1 instead of 0? If so, how does this help? Won't it make each line equal to 1 since they are all auto entered as 0? Or does this allow me to select which entries become 1 or 0? Second, when I create the relationship to another table, how to I relate it to the beginning and end of the months? Do I have to manually type in the beginning and ending dates of each and every month? Thanks again for your help.
Newbies CBL Posted December 23, 2004 Author Newbies Posted December 23, 2004 Also, the SetField won't let me enter it the way that you suggested on either example. It says that it is missing an operator value. I am using FileMaker 7 if that helps.
-Queue- Posted December 23, 2004 Posted December 23, 2004 Actually, I don't think you need the Go to Related Record step. A button in a portal will act on only the current portal row (related record). So your script only need be Set Field [relationship::NewField; Abs(relationship::Newfield - 1)] Commit Records/Requests This will change the selected portal row's NewField to 1 or zero, appropriately. You could also put the related NewField in the portal and format it as a checkbox using a value list of 1. Then you wouldn't need a script at all. The new relationship should be the same as your original one, with the addition of a calculated number field equal to 1 being mapped to the related NewField. That way it will include only the related records with NewField marked as 1 for your Sum calculation.
-Queue- Posted December 23, 2004 Posted December 23, 2004 The semicolon in the Set Field step separates the target field, relationship::NewField, from the calculation to specify, Abs(relationship::NewField - 1). It should not be included in the actual calculation.
Søren Dyhr Posted December 23, 2004 Posted December 23, 2004 We had a very similar problem up her in this thread, which solved it for version 6, so something needs to be done different: http://www.fmforums.com/threads/showflat...true#Post134856 --sd
Newbies CBL Posted December 25, 2004 Author Newbies Posted December 25, 2004 Thanks for your quick reply. This is going to help me tremendously. I have one more question to make sure I understand this right. Let's say that I do set the NewField equal to 1 for certain rows. At that point, what would the sum function look like to get a sum of all the specific amounts in the selected rows?
-Queue- Posted December 26, 2004 Posted December 26, 2004 Sum(NewRel::Amount), where NewRel is the duplicate relationship with the additional mapping from a calculation of 1 to NewField.
Recommended Posts
This topic is 7273 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