Hello everyone,
I am doing an API call and it returns to me a list of numbers. Everything is working well, but I hit a wall.
I need to go through every item of the list and divide it by 100 then sum every entrance. But, I can’t seem to do it. The lists operator only allows me to use a division after summing all the numbers, but it is not enough for me.
Can someone help me?
Thanks
Aside from using some custom JavaScript, you can do this using the Format as Text operator…
Take the list of numbers
Format as Text
For each item, print: this number /100
User a comma delimiter
Split the output text by a comma (to give you a list of texts)
Convert each text into a number
Sum the list of numbers
Of course, you don’t actually have to do any of that, because summing the list of number first, and dividing the total by 100 will give you the same results as dividing each number by 100 and then summing them, so it’s much simpler to do that (although from your question you seemed to be under the impression that’s not the same thing?..)
2 Likes
Hello Adam,
Thanks for the quick reply, I will try it!
Actually, since I wanted to focus on the method of solving this i quite oversimplified what I need to do. Each number of the list is an amount of seconds used by some application and I need to divide it by 60 to get how many minutes it were used. Then, if its a “broken” minute number ( let’s say 1.2 minutes) I round it up.
I can’t sum before dividing because for this API, two sessions of 1.2 minutes are counted as 4 minutes, since they are rounded up separately. So I also have to use the same logic. The rounding part was the catch.
Thanks again for helping me, I will try it and get back to you!!
OK, I understand…
But the method I described should work here… use format as text, and perform whatever calculations you need to on each number.
Then, once the text has been split into a list, and that list of text been converter to a list of numbers, you can then sum the list.
Worked perfectly, @adamhholmes .
Thanks a lot!
1 Like