Salesforce and other SMB Solutions are coming soon. ×

# Generate range

## 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

##### Share on other sites

1. Which FMP version?

2. What is the intended use of the result?

##### Share on other sites

FMP 7 - intended use for result is dynamic multikey

##### 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.

##### Share on other sites

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

##### 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.

##### Share on other sites

Thank you, thank you, thank you, thank you!!!!

##### Share on other sites

Ok, life just got a little more "interesting"

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!

##### 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.

##### Share on other sites

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

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.

#### Archived

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

• ### Images

• By Soliant Consulting,
• By Soliant Consulting,
• By Soliant Consulting,
• ### Forum Statistics

• Total Topics
33.7k
• Total Posts
141.6k
×
×
• Create New...