• Resolved christofferjo

    (@christofferjo)


    Hello,

    I am a complete beginner in WordPress. I am creating fields in Calculated field forms, and now I would like to include a Sum into Set equation (or in the Advanced equation’s editor). The predefined mathematical operator Sum can only sum fields/values. I would like to have a sum with an expression and summarize it over some indexes. This would be possible with a For loop as well, but I can’t get any of the solutions to work. Can you please help me with including this code into my field?

    Best regards Christoffer

Viewing 1 replies (of 1 total)
  • Thread Starter christofferjo

    (@christofferjo)

    Managed to solve it myself. Thought I send the solution if someone else have similar problems. Paste this code into the Set equation window field:

    (function() {
    sum = fieldname55;
    for (let i = 1; i < fieldname47 ; i++ ) {
    sum = sum + fieldname55*POW(fieldname46,i)
    }
    return sum
    })();

    If the webpage is buggy and removes your code, and replaces it with [object Object], just log out and log in again, maybe refreshing the page solves that issue as well.

    Best regards Christoffer

Viewing 1 replies (of 1 total)
  • The topic ‘Creating a For loop in Advanced equation’s editor’ is closed to new replies.