April 3, 200223 yr 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
April 3, 200223 yr The calculation is your problem. Change your entire calculation to: Count(selfrelationship::fieldname) -bd
April 3, 200223 yr 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".
April 4, 200223 yr Author 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
April 4, 200223 yr 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.
April 5, 200223 yr Author 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.
April 5, 200223 yr Author 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.
April 5, 200223 yr Author 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
Create an account or sign in to comment