henrik_ahlgren Posted April 3, 2002 Posted April 3, 2002 I have a field that is a counter for a specific persons records in a file. This works fine so long you manualy create new records. The problem is when I import records then the value don't get any bigger then one (1). To count a persons records I use a self relationship and the following calculation in the field. code: If( fieldname <> ""; If( Count(Selfrelationship::fieldname <> ""; Count(Selfrelationship::fieldname)+1;"1");"") It counts the time a record with fieldname exists and put that + 1 in the counter field. Is there some smart way to solve a problem like this? At second thought the solvation dosen't have to be smart so long it works //Henkan
LiveOak Posted April 3, 2002 Posted April 3, 2002 The calculation is your problem. Change your entire calculation to: Count(selfrelationship::fieldname) -bd
goldraven Posted April 3, 2002 Posted April 3, 2002 Alternatively, you could create a calculated numerical field for each record where the result is always "1" and use the Sum function instead (ie. "Sum(selfrelationship::C_Constant)". By using this method, you never have to manually increase any field and even records that are imported will have a value of "1".
henrik_ahlgren Posted April 4, 2002 Author Posted April 4, 2002 quote: The calculation is your problem. Change your entire calculation to: Count(selfrelationship::fieldname) If I use this calculation the first record for this person will have no value. That will mess things up when I realy want a value in this field and has set the field to "Not empty". I haven't tried the other suggestion yet but although it seems to solve the problem with no value in the field will the second post realy get 2 as value? Or have I got it wrong that the Sum like Count only sees records that already exists and not the one I' creating? Maybe if I take Sum(selfrelationship::C_Constant) + 1, but I tried that with Count and it didn't work. I have to try that out later today. I'm happy for all suggestions. //Henkan
goldraven Posted April 4, 2002 Posted April 4, 2002 Henkan, If you utilize my suggestion the record will have a value of "1" in the C_Constant field the moment you create it, and therefore the Sum will count it.
henrik_ahlgren Posted April 5, 2002 Author Posted April 5, 2002 Rob thanks for your answer. I tested your calculation but I don't get a value into the field. It is empty after the import. What have I done wrong??? What I did was created a field, Calc1, which I equeld with 1. I set the calculation in my counterfield, Counter, to Sum(selfrelationship::Calc1). The selfrelationship is based on my foreign key.
henrik_ahlgren Posted April 5, 2002 Author Posted April 5, 2002 Forget the last post. I figured it out. The problem was that I didn't have the Count field as calculation fieldtype, it was numeric. When I changed it all works fine. Thanks again for your help Rob.
henrik_ahlgren Posted April 5, 2002 Author Posted April 5, 2002 On the other hand it didn't work like I thought it would. I can't store the value and FM says something about the reason could be because it referes to a relation field. This shouldn't be that hard to do, is it me that hasn't got the hold om FM yet? It proberly is
Recommended Posts
This topic is 8269 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