2 Replies Latest reply on May 3, 2016 8:05 PM by danielfarnan

# I have a database file wth say 100 records, some records have the same name. I can get the total of the same name (Count (SelfJoin_Rhododon::Name) - which gives me the total of same name (say7), what i need is the 1of7, 2of7, 3of7 etc. I need that count.

• ###### 1. Re: I have a database file wth say 100 records, some records have the same name. I can get the total of the same name (Count (SelfJoin_Rhododon::Name) - which gives me the total of same name (say7), what i need is the 1of7, 2of7, 3of7 etc. I need that cou

macho wrote:

gives me the total of same name (say7), what i need is the 1of7, 2of7, 3of7 etc. I need that count.

I think you should rephrase that, and/or give a practical example; I for one have no idea what that means.

• ###### 2. Re: I have a database file wth say 100 records, some records have the same name. I can get the total of the same name (Count (SelfJoin_Rhododon::Name) - which gives me the total of same name (say7), what i need is the 1of7, 2of7, 3of7 etc. I need that cou

This is easiest to achieve with a recursive custom function. Pass a parameter of the current record's primary key and the current recursive depth, starting with 1. The custom function will use the GetNthRecord function to grab the value of the related record's primary key; if it matches what is passed in then return the recursive depth.

Something like this:

DepthFunction ( _keyVal ; _max ; _depth ) =

Case (

_depth > _max ; -1 ;

GetNthRecord ( SelfJoin_Rhododon::<primary key field> ; _depth ) = _keyVal ; _depth ;

DepthFunction ( _keyVal ; _max ; _depth + 1 )

)

The _max value is in there so that we don't go through unnecessary recursion and perhaps error out by going too far.

You would call this function in your calculation field where you want the "out of" value to appear:

DisplayOutOf =

Let (

[

_outof = Count ( SelfJoin_Rhododon::Name ) ;

_result = DepthFunction ( <primary key field> ; _outof ; 1 )

] ;

Case ( _result = -1 ; "<Error>" ; _result & " of " & _outof )

)

(have as a text result rather than a number result)