‎2025 May 16 10:57 AM - edited ‎2025 May 16 10:57 AM
Hi, I am using activity get values (cells). This gives list of values. Using this variable and embedding it with ".length" it gives number of values. But how to count unique values? IRPA suggest things like ".count" or ".unique" but it gives empty result. I have also tried to use custom script like this one:
const arr = RunID;
function countUniqueArray(arr) {
const Result = [];
arr.forEach(item => {
if (!Result.includes(item)) {
Result.push(item);
}
});
return Result.length;
}
return(countUniqueArray(arr));
But issue is:
1) when RunID (returned values from excel) are passed directly, counting of unique values does not work and gives only total number of items correctly, but not unique values
2) when insted of RunID I hard code something like ["apple", "banana", "apple", "orange"] it works correctly and returns 3
So either change input to something like in 2) (but how) or use some javascript function directly in one of the steps.
Many thanks in advance.
Request clarification before answering.
ah, just found that devil in the detail - output has to be set in format like below:
Then it works in the script above. However I am still curious if this can be made easier? for stepX.returnedValues I see also function like "CountUniqueArray" however it also gives no result like {}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.