DFunctions() can be tricky to write due to the escaped quotation marks in the function. The parameters used must be written as text strings, but then comparing participants in groups requires calling the field value into the string. Below is an explanation of how to write DFunctions and how the quotation marks are escaped or how to write it using a full-text expression.
Standard Text String
The below function will return the count of all participants whose Gender and Contest match the considered participant.
DCount("[Contest]=" & [Contest] & " AND [Gender]=""" & [Gender] & """")
- The first yellow quote opens a string of text and the second yellow quote closes it.
- An ampersand is used to concatenate the yellow string of text with the value of [Contest].
- Since the value of [Contest] is a number and NOT a string of text, we do not need to surround the value with quotes. The resulting concatenated string is shown below if, for example, the considered participant was in contest 1.
[Contest]=1
- The first orange quote opens a new string of text and the second orange quote closes it.
- The first green quote escapes the second green quote leaving a single quote within the orange quote string. When evaluated, the resulting string between the orange quotes looks like this. (note, there is a space in front of AND)
AND [Gender]="
- An ampersand is used to concatenate the orange string of text with the value of [Gender]. The resulting concatenated string is shown below if, for example, the considered participant's gender was male.
AND [Gender]="m
- The first red quote opens a new string and the second red quote closes it.
- The first blue quote escapes the second blue quote leaving a single quote within the red quote string.
- When evaluated, the second green quote is paired with the second blue quote which encloses the value of [Gender]. The use of quotes around [Gender] is necessary because the value of [Gender] is a string and NOT a number.
- Once all strings are concatenated and the function is evaluated, the resulting string of text within the DCount() function would be this.
[Contest]=1 AND [Gender]="m"