Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi
i have defined this variable:
set vGender = sum({$<gender_ID={1,2}>} %contact_counter)/sum({$<gender_ID={1,2}>} total %contact_counter)
now i want to use the same variable in this expression, where I split the field name, but i do not want to select the different values with a list box or any other sheet object:
=RangeMax(
(sum({$<gender_ID={1}>} %contact_counter)/sum({$<gender_ID={1,2}>} total %contact_counter))
,
(sum({$<gender_ID={2}>} %contact_counter)/sum({$<gender_ID={1,2}>} total %contact_counter))
)
please advice on this
thanks
felipe
On reconsideration, if your define vGender like this:
set vGender = sum({<gender_ID={$1}>} %contact_counter)/sum({<gender_ID={1,2}>} total %contact_counter)
This is now a parameterised macro and you would use it like this
=RangeMax($(vGender(1)), $(vGender(2)))
The original form would be
=$(vGender(1,2))
If that does not work, you might need to include an extra = in the set statement:
set vGender = =sum({<gender_ID={$1}>} %contact_counter)/sum({<gender_ID={1,2}>} total %contact_counter)
Jonathan
Felipe
Perhaps I misunderstood your requirements, but the simple answer is you cant. You have defined vGender, but what you need is different. Why not simply use another variable?
Jonathan
On reconsideration, if your define vGender like this:
set vGender = sum({<gender_ID={$1}>} %contact_counter)/sum({<gender_ID={1,2}>} total %contact_counter)
This is now a parameterised macro and you would use it like this
=RangeMax($(vGender(1)), $(vGender(2)))
The original form would be
=$(vGender(1,2))
If that does not work, you might need to include an extra = in the set statement:
set vGender = =sum({<gender_ID={$1}>} %contact_counter)/sum({<gender_ID={1,2}>} total %contact_counter)
Jonathan
thanks, first time i use this, it worked
i declared the vGender and then used as $(vGender(1)) and $(vGender(2)) for the rangemax()
I did not use the =$(vGender(1,2)) . what did you mean with the original ?
i check this in the manual , but i do not understand how it is used. What does the " $1 " or "$2", etc. means?
is it the first set of values of my first field and $2 the second set of values of the next field included in the expression?
for vGender(1,2) you meant with original, that i have for that variable, a list of two parameters? do i need to use this in the script?
thanks
felipe
A variable described this way behaves like a parameterised macro (or user defined function, if you prefer). The $1 refers to the first parameter, $2 to the second and so on. When the variables is evaluated, it uses the values passed in the brackets.
So
=$(vGender(1))
is the same as
=sum({<gender_ID={1}>} %contact_counter)/sum({<gender_ID={1,2}>} total %contact_counter)
And
=$(vGender(2))
is the same as
=sum({<gender_ID={2}>} %contact_counter)/sum({<gender_ID={1,2}>} total %contact_counter)
I assumed that because you stated vGender that way in your post that you might want to use it that way. So there is no reason to use $(vGender(1,2)). (It would not work anyway as the comma is the separator between two parameters and if it did it would always return 1).
Hope that helps
Jonathan
hi thanks
it is very clear
Felipe