hcl-bot
February 18, 2008, 7:26am
1
I have a field VoteVoter which contains a list of votes and voters concatenated thus: 01 Fred Smith:02 John Brown, etc.
I am using @transform to strip out the numbers and am then using @sum to add them up for a total vote.
My code is:
@Transform (VoteVoter;“VoteVoter_No”;@TextToNumber (@Left (VoteVoter;2)))
For some reason this returns:
1
2
1
2
so my sum ends up at 6 rather than 3. Obviously I can work around this by halving the result but it seems inherently wrong.
Any ideas what is going on here? Thanks.
hcl-bot
February 18, 2008, 8:38am
2
Subject: @transform returns a double set of results
When using @Transform , the second argument is the internal argument name, so you should have something more like:
@Transform (VoteVoter;“x”;@TextToNumber (@Left (x;2)))
ir if you really want your longer name
@Transform (VoteVoter;“VoteVoter_No”;@TextToNumber (@Left (VoteVoter_No;2)))
Otehrwise, you are not using each element but rather the whole array, which is why you get repeated results.
hcl-bot
February 18, 2008, 11:21am
3
Subject: RE: @transform returns a double set of results
And by the way, @TextToNumber and @Left work on lists, so you could just write:
@Sum (@TextToNumber (@Left (VoteVoter;2)))
This does iterate thru the list three times instead of twice, but since the iterations are happening in C code, it’s probably a lot faster and it’s certainly simpler.
hcl-bot
February 19, 2008, 6:54am
5
Subject: @functions and lists
Yes - it seems that most @functions work on lists even if the help does not say they do. This seems to be the root cause of the problem I had
hcl-bot
February 19, 2008, 7:57am
6
Subject: RE: @functions and lists
If information is missing from the help, please use the feedback link, which appears on the bottom of each help page, to request it be added. Thanks.