Hash and HashHash Comparison

Compare # and ## Operators

This article compares the main differences between the # Operator and ## Operator with some examples of where these differences can be seen in practice. For the sake of simplicity, all parameters in the examples below are based on whole numbers. Please refer to the individual articles about each operator for a full overview of available options.
To understand this logic, you also need to be familiar with the concepts of repeat counter and repeat context.
Repeat counter
identifies each repeat run by the value of the variable used in the repeat business rule.
For example, if we have a repeat span that is repeated three times, from 1 to 3, then variables collected in the first run will have the repeat counter "1", the variables collected in the second run will have the repeat counter "2" and the variables in the third run will have the repeat counter "3". When used inside the repeat, the RepeatCounter function will return the current value for the repeat run.
Repeat context
is used to identify different values of the same variable from different repeat runs. Repeat context consists of one or several repeat counters, presented in square brackets.
For our previous example where we repeat a span three times, the RepeatContext function will return the full repeat context for variables in each run as "[1]", "[2]", or "[3]". Where repeats are used within repeats, the full repeat context will use the repeat counters from each level of repeat, starting from the outermost and ending with the innermost repeat. For example, if we collect companies and for each company we collect directors, we will list the repeat counter identifying the company first and the repeat counter identifying the director next. For example, full repeat context "[1][3]" means we are referring to the third director of the first company.
Examples:
In the examples used in the table below we collect two companies and for each company we collect three directors.
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
# Operator
## Operator
Description
Returns the value of a particular repeat of a particular variable.
Returns the value of a particular repeat of a particular variable.
Relationship to repeat context
Relative to the repeat context you're in.
Absolute, unaffected by the repeat context you're in.
Parameter description
RepeatCounter expressed as a number or a string, or
Relative repeat context string with each RepeatCounter in square brackets, e.g. "[1][1]" (will be the same as the full repeat context if you are not inside of a repetition).
Note: If square brackets define spans, the context must be defined within a computable.
Full repeat context expressed as a list where each member of the list is the RepeatCounter starting from the highest level of repeat to the innermost repeat counter where the value is defined. For example, the full repeat context "[1][1]" translates to List( 1, 1).
Examples of parameters for getting lists of values
List( 1, 2, 3 )
List( "[1][1]", "[1][2]", "[1][3]" )
List( List( 1 ), List( 2 ), List( 3 ) )
List( List( 1, 1 ), List( 1, 2 ), List( 1, 3))
Use in Repeat context
If the repeat context is not relevant, the expression must be unrepeated as many times as the repeat context requires.
Where the RepeatCounter is used as part of the relative repeat context, it has to be concatenated to be expressed in the form "[1][1]".
In these scenarios, we recommend using ## instead of #.
Same as outside of repeat context
Get a Company outside of repeat context
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
First company value: {Company # 1}
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
First company value: {Company ## List( 1 )}
Get a Director outside of repeat context
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
First company's first director: {Director # "[1][1]"}
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
First company's first director: {Director ## List( 1, 1 )}
Get a list of Companies outside of repeat context
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
All companies: {Company # List( 1, 2 )}
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
All companies: {Company ## List( List( 1 ),List( 2 ) )}
Get a list of Directors outside of repeat context
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
All directors of company 1: {Director # List( "[1][1]", "[1][2]", "[1][3]" )}
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
All directors of company 1: {Director ## List( List( 1, 1 ), List( 1, 2 ), List( 1, 3 ) )}
Get a list of Directors inside the Company repeat context
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
Directors of each company: <
Repeat 2
{Director # List( 1, 2, 3 )}>
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
Directors of each company: <
Repeat 2
{Director ## List( List( RepeatCounter, ToString( 1 ) ), List( RepeatCounter, ToString( 2 )), List( RepeatCounter, ToString( 3 ) ) )}>
Note: All members of the list must be of the same data type. In example above, it must be either strings or integers. Putting numbers in quotation marks or turning RepeatCounter into integer would work as well.
Refer to a Company within another repeat
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
<
Repeat Shares
{Unrepeated(Company # 1)}>
In these scenarios, we recommend using ## instead of #.
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
<
Repeat Shares
{Company ## List( 1 )}>
Refer to a Director within another repeat
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
<
Repeat Shares
{Unrepeated( Director # [1][1] )}>
In these scenarios, we recommend using ## instead of #.
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
<
Repeat Shares
{Director ## List( 1, 1 )}>
Repeat Directors of one Company in a new repeat context, using RepeatCounter
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
<
Repeat 3
{Unrepeated( Director) # concatenate( "[1][",RepeatCounter, "]" )}>
In these scenarios, we recommend using ## instead of #.
<
Repeat 2
{Company}
<
Repeat 3
{Director}>>
<
Repeat 3
{Director ## List( ToString( 1 ), RepeatCounter )}>
or
<
Repeat 3
{Director ## List( "1" ), RepeatCounter}>
or
<
Repeat 3
{Director ## List( 1, ToInteger( RepeatCounter ) )}>
Note: All members of the list must be of the same data type. In example above, it must be either strings or integers.

Related content