Jump to content

This topic is 7284 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi

I am still pretty shaky in the area of calculations and the limits of what they can do. I'm wondering how to go about calculating a list of related values from another table field. I'm not sure if there is a way to loop through the values, or if I'll have to create a recursive function somehow...

Seems like if there is a way to write a loop, I could just run a loop with lookup(), but I dont think there is a way to loop in a calculation field.

Any suggestion? I really don't quite know where to start with it.

Also, I know somebody will probably suggest that I just create a value list on the related field, but my problem is that I need to be able to generate lists from different tables, not just one. So, I am pretty sure I have to calculate it, because the source field is variable.

Posted

Hi

I am still pretty shaky in the area of calculations and the limits of what they can do. I'm wondering how to go about calculating a list of related values from another table field. I'm not sure if there is a way to loop through the values, or if I'll have to create a recursive function somehow...

Seems like if there is a way to write a loop, I could just run a loop with lookup(), but I dont think there is a way to loop in a calculation field.

Any suggestion? I really don't quite know where to start with it.

Also, I know somebody will probably suggest that I just create a value list on the related field, but my problem is that I need to be able to generate lists from different tables, not just one. So, I am pretty sure I have to calculate it, because the source field is variable.

Posted

Hi

I am still pretty shaky in the area of calculations and the limits of what they can do. I'm wondering how to go about calculating a list of related values from another table field. I'm not sure if there is a way to loop through the values, or if I'll have to create a recursive function somehow...

Seems like if there is a way to write a loop, I could just run a loop with lookup(), but I dont think there is a way to loop in a calculation field.

Any suggestion? I really don't quite know where to start with it.

Also, I know somebody will probably suggest that I just create a value list on the related field, but my problem is that I need to be able to generate lists from different tables, not just one. So, I am pretty sure I have to calculate it, because the source field is variable.

Posted

My question is sufficiently similar it seemed appropriate to post it here - if not I apologize.

I want to enter a start date and a number of days and generate a return-delimited list I can operate on, thusly:

Date: January 1, 2005 ; Days: 5 =

1/1/05

1/2/05

1/3/05

1/4/05

1/5/05

this seems like it ought to be trivial AND common, and yet I have searched all over without success.

any help would be MUCH appreciated. (we have Developer, so could create custom function if necessary)

Posted

My question is sufficiently similar it seemed appropriate to post it here - if not I apologize.

I want to enter a start date and a number of days and generate a return-delimited list I can operate on, thusly:

Date: January 1, 2005 ; Days: 5 =

1/1/05

1/2/05

1/3/05

1/4/05

1/5/05

this seems like it ought to be trivial AND common, and yet I have searched all over without success.

any help would be MUCH appreciated. (we have Developer, so could create custom function if necessary)

Posted

My question is sufficiently similar it seemed appropriate to post it here - if not I apologize.

I want to enter a start date and a number of days and generate a return-delimited list I can operate on, thusly:

Date: January 1, 2005 ; Days: 5 =

1/1/05

1/2/05

1/3/05

1/4/05

1/5/05

this seems like it ought to be trivial AND common, and yet I have searched all over without success.

any help would be MUCH appreciated. (we have Developer, so could create custom function if necessary)

Posted

A calculation, recursive or not, cannot loop through related records, simply because there is no way to reference "related record #2". A reference to a related record in a calculation is always a reference to the FIRST related record, or, in an aggregate function, to ALL related records.

I believe your best choice is to create a value list based on the related field. If the related field is a variable, create a value list for each, then use a calculation to select the correct one.

The other option is a script, looping through the the records in the related table, comparing the current value to a temp global. If the value <> temp global, add the new value to the result, and update the temp global.

Posted

A calculation, recursive or not, cannot loop through related records, simply because there is no way to reference "related record #2". A reference to a related record in a calculation is always a reference to the FIRST related record, or, in an aggregate function, to ALL related records.

I believe your best choice is to create a value list based on the related field. If the related field is a variable, create a value list for each, then use a calculation to select the correct one.

The other option is a script, looping through the the records in the related table, comparing the current value to a temp global. If the value <> temp global, add the new value to the result, and update the temp global.

Posted

A calculation, recursive or not, cannot loop through related records, simply because there is no way to reference "related record #2". A reference to a related record in a calculation is always a reference to the FIRST related record, or, in an aggregate function, to ALL related records.

I believe your best choice is to create a value list based on the related field. If the related field is a variable, create a value list for each, then use a calculation to select the correct one.

The other option is a script, looping through the the records in the related table, comparing the current value to a temp global. If the value <> temp global, add the new value to the result, and update the temp global.

Posted

Good idea, about the value lists. Question, though.. how do I use a calculation to select the proper value list? That would solve my problem.

Posted

Good idea, about the value lists. Question, though.. how do I use a calculation to select the proper value list? That would solve my problem.

Posted

Good idea, about the value lists. Question, though.. how do I use a calculation to select the proper value list? That would solve my problem.

Posted

Example:

Let ( [

list1 = ValueListItems ( Get(FileName) ; "yourFirstListName" ) ;

list2 = ValueListItems ( Get(FileName) ; "yourSecondListName" ) ;

list3 = ValueListItems ( "ExternalFileName" ; "ExternalListName" ) ;

theList =

Case (

selectorField = "List One" ; list1 ;

selectorField = "List Two" ; list2 ;

selectorField = "List Three" ; list3 ;

"no list has been specified"

)

] ;

theList

)

Posted

Example:

Let ( [

list1 = ValueListItems ( Get(FileName) ; "yourFirstListName" ) ;

list2 = ValueListItems ( Get(FileName) ; "yourSecondListName" ) ;

list3 = ValueListItems ( "ExternalFileName" ; "ExternalListName" ) ;

theList =

Case (

selectorField = "List One" ; list1 ;

selectorField = "List Two" ; list2 ;

selectorField = "List Three" ; list3 ;

"no list has been specified"

)

] ;

theList

)

Posted

Example:

Let ( [

list1 = ValueListItems ( Get(FileName) ; "yourFirstListName" ) ;

list2 = ValueListItems ( Get(FileName) ; "yourSecondListName" ) ;

list3 = ValueListItems ( "ExternalFileName" ; "ExternalListName" ) ;

theList =

Case (

selectorField = "List One" ; list1 ;

selectorField = "List Two" ; list2 ;

selectorField = "List Three" ; list3 ;

"no list has been specified"

)

] ;

theList

)

Posted

I said "cannot be limited to a predefined maximum".

Otherwise, you can use a repeating field, or LeftValues ( compute a range of 2000 ; n), or any such.

Of course, I have since learned that a custom function has its own maximum of 10,000 iterations, so perhaps the difference is merely quantitative. And with up to 32,767 repetitions, repeating field looks like the winner on this one.

Posted

I said "cannot be limited to a predefined maximum".

Otherwise, you can use a repeating field, or LeftValues ( compute a range of 2000 ; n), or any such.

Of course, I have since learned that a custom function has its own maximum of 10,000 iterations, so perhaps the difference is merely quantitative. And with up to 32,767 repetitions, repeating field looks like the winner on this one.

Posted

I said "cannot be limited to a predefined maximum".

Otherwise, you can use a repeating field, or LeftValues ( compute a range of 2000 ; n), or any such.

Of course, I have since learned that a custom function has its own maximum of 10,000 iterations, so perhaps the difference is merely quantitative. And with up to 32,767 repetitions, repeating field looks like the winner on this one.

Posted

Yep, lots of ways to skin a cat.

Oops, sorry Fluffy. blush.gif

A lot of my workarounds were rendered obsolete with the Get(CalculationRepetitionNumber) function in FM7. I haven't gotten around to using it for anything yet, so I still tend to think in terms of FM6 limitations.

Posted

Yep, lots of ways to skin a cat.

Oops, sorry Fluffy. blush.gif

A lot of my workarounds were rendered obsolete with the Get(CalculationRepetitionNumber) function in FM7. I haven't gotten around to using it for anything yet, so I still tend to think in terms of FM6 limitations.

Posted

Yep, lots of ways to skin a cat.

Oops, sorry Fluffy. blush.gif

A lot of my workarounds were rendered obsolete with the Get(CalculationRepetitionNumber) function in FM7. I haven't gotten around to using it for anything yet, so I still tend to think in terms of FM6 limitations.

Posted

Ok, comment. That little snippet worked great for fetching the list I want.

Now, I have a new problem related to that. I want to be able to show that list in a pop-up list in a field on my layout. I tried creating a fourth value list that will show the values of my field with the calculation in it. Unfortunately value lists can only be created from indexed fields, and you cannot index a calculation field that references other fields.

It's a connundrum. Is there another way to show the values in a popup besides what I was trying to do?

I'm thinking I might not be able to solve this problem at all.

Posted

Ok, comment. That little snippet worked great for fetching the list I want.

Now, I have a new problem related to that. I want to be able to show that list in a pop-up list in a field on my layout. I tried creating a fourth value list that will show the values of my field with the calculation in it. Unfortunately value lists can only be created from indexed fields, and you cannot index a calculation field that references other fields.

It's a connundrum. Is there another way to show the values in a popup besides what I was trying to do?

I'm thinking I might not be able to solve this problem at all.

Posted

Ok, comment. That little snippet worked great for fetching the list I want.

Now, I have a new problem related to that. I want to be able to show that list in a pop-up list in a field on my layout. I tried creating a fourth value list that will show the values of my field with the calculation in it. Unfortunately value lists can only be created from indexed fields, and you cannot index a calculation field that references other fields.

It's a connundrum. Is there another way to show the values in a popup besides what I was trying to do?

I'm thinking I might not be able to solve this problem at all.

Posted

Perhaps you could change the calculated value list into a text field with auto-enter calculation (replace).

This might work for you or not, depending on what you're trying to achieve. After all, you are trying to break the rules here. There is a reason why FMP won't let you create the fourth VL. You might be able to fool it, but it also might backfire.

Posted

Perhaps you could change the calculated value list into a text field with auto-enter calculation (replace).

This might work for you or not, depending on what you're trying to achieve. After all, you are trying to break the rules here. There is a reason why FMP won't let you create the fourth VL. You might be able to fool it, but it also might backfire.

This topic is 7284 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.