Summation of values in an array

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Is there an expression to add up all of the values in a column or row of an array without typing out each position individually?

    What I've been doing so far was:
    Set Global Value A
    >ValueAtXY ("Array", 1, 1) + ValueAtXY ("Array", 1, 2) + ValueAtXY ("Array", 1, 3)

    .. And so on. I'm sure there's a shorter way to write that out, am I correct?

  • Yeah, you should use loops

    on "start sum" condition
    (>>> set Global Value A to 0) if you want to reset the value each time you perform the calculation
    >>> start loop "sum_array" DimY(array) times (since you seem to be summing Y's now, right?)

    on loop "sum_array"
    >>> Set Global Value A to Global Value A + ValueAtXY("Array", 1, loopindex("sum_array"))


    if your array has 1 based index, use loopindex +1

    a selection of my Fusion examples can be found Please login to see this link.

  • Well that's pretty cool. To expand on the idea is there a way to exclude a specific position in the array from being included in this loop? E.g. ValueAtXY("Array", 1, 2)?

    Oh and thanks!

    Edited once, last by ierofei: I'm ungrateful, forgot to thank. That's a floggin'.. (December 1, 2015 at 6:54 PM).

  • XD thanks for thanking

    if you have to exclude only some specific positions
    I would hard code them in the condition this way:

    on loop "sum_array"
    +loopindex("sum_array") <> number
    >>> Set Global Value A to Global Value A + ValueAtXY("Array", 1, loopindex("sum_array"))

    a selection of my Fusion examples can be found Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!