Hi,
I have an array with numbers, I want to count how often the number 5 is stored in it, does anyone know the syntax?
thanks,
Rich
Request clarification before answering.
Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with you directly:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK I solved this myself using a loop, which loops round and increments the element number in the array up to the size of the array, and a counter which increments each time the condition is met:
while loopcount <10
do (loopcount:=loopcount +1;
If SelfArray1[loopcount] = 5 then counter:=counter +1);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As long as all of the values in the array are one digit, Jason's formula will work. It will not work correctly if there are multiple-digit values with a 5 somewhere in the string of digits (e.g., the value 55 will cause the formula to count 2 fives)...
You might be able to change it to something like
(LEN(ToText({@Array},"00000000.0")) - LEN(REPLACE(ToText({@Array},"00000000.0"),"00000005.0",""))) / 10
HTH,
Carl
Hi Jason,
Sorry, I think I am mising something really basic here,
I have an Array created in a subreport declared:
shared numbervar array RespondentArray1;
there is then various code which poulates it depending on which IF conditions are met as it cycles through the records.
In my main report I want to count the occurneces of say the number 5. But I was expecting to drop the array name only (RespondentArray1) into where you have {@Array}. But I get an error if I do that. The formula where the array is declared and populates is in a subreport.
Can you please advise of what I should be replacing in your code?
My looping would work, but I dont think it is very efficient especially as I have lots of counts to do on various numbers,
thanks,
Richard.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.