Using a parameter in a calculated field

I have survey data. I need to estimate a field that gives me a percent of responses of a dimension field (V1) that meet a condition. However, the denominator should change by a parameter. I need to have the data in percent because my samples are not equal in size, so using totals and counts would be misleading. I have the following code

(countIf (
{V1},
            {V1} = 'Condition 1' OR
            {V1} = 'Condition 2')
 )/ count(${PARAMETER}) * 100

For some reason, the calculated field gives me a result that is somewhat close, but not equal to results I get in R. The difference is enough to alter my conclusions. I don’t know what I’m doing wrong.

1 Like

The way you are doing things, count(${PARAMETER}) basically gives you the count of number of rows that you have in your dataset (irrespective of the value of ${PARAMETER}).

Your aim seems to be to divide everything by the value of ${PARAMETER}, so I think you need to change this to:

(countIf (
{V1},
            {V1} = 'Condition 1' OR
            {V1} = 'Condition 2')
 )/${PARAMETER} * 100
1 Like