Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Generate range


Mr_Scripter

Recommended Posts

Hi, I need a calc solution to generate a range of numbers. Lets say we have a number field containing "10" and another containing "3". I need the result of the field to list (separated by returns); 10, 11, 12. Both fields are variable.

 

Is this possible?

 

thanks for any assistance on this grin.gif

Link to comment
Share on other sites

This is a recursive calculation, which would require Developer 7. However, for this purpose you can do nicely with a repeating calculation field =

 

Let (

i = Get ( CalculationRepetitionNumber ) - 1 ;

Case ( i

)

 

where StartNumber is 10 and n is 3 in your example.

 

Make the result same type as the matching field on the opposite side. Define the field with enough repetitions to cover your worse case scenario.

Link to comment
Share on other sites

thanks for that! sorry - i should have mentioned that i am in fact working with Developer blush.gif does this mean i can dispense with the repeating field?

Link to comment
Share on other sites

You can - although I often find it more convenient to work with than a custom function.

 

If you prefer, you can use this CF:

 

Range ( start ; counter )

 

Case ( start ; start & ¶ & Case ( counter - 1 > 0 ; Range ( start + 1 ; counter - 1 ) ) )

 

 

---

The result in this case MUST be Text, of course.

Link to comment
Share on other sites

Ok, life just got a little more "interesting" wink.gif

 

I now find I need to incorporate a fixed string into the recursion. So the result, instead of 10, 11, 12 etc, would be 1/9/05_10, 1/9/05_11, 1/9/05_12 and so on.

 

I got the custom function working just fine and have tried to incorporate the fixed string but it only seems to work on the first iteration and even then it strips the "_" and the "/". I'm a bit stuck for time and could do with a pointer. Thanks, comment for your help - it really is appreciated! cool.gif

Link to comment
Share on other sites

You can either build that into the CF, or substitute it in afterward. The substitute would look like this:

 

Substitute ( ¶ & Range ( Start; counter) ; ¶; ¶ & getastext(date) & "_" )

 

Though, since this is for FM7, its probably not necessary to build concatonated keys in this multi-key. You can simply add additional criteria to the relationship.

Link to comment
Share on other sites

The expression (start + 1) implicitly converts start into a number.

Try instead:

 

Range ( start ; counter )

 

Case ( start ; start & ¶ &

Case (

counter - 1 > 0 ;

Range ( SerialIncrement ( start ; 1 ) ; counter - 1 )

)

)

 

or use a multi-criteria relationship as per Ender's suggestion.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...

Important Information

Terms of Use