0

Product from multiple records

I have several data records with a field “Year” and “TWR”. For each year, there are multiple records with different TWR values.

Now, (in another table) I want to calculate the product of the TWR field for each year.

Calculating the sum would be easy, but I have no idea how to compute the product.

Can someone give me a hint?

Thank you,

Pascal

1 reply

null
    • Fred
    • 4 days ago
    • Reported - view

    You can try something like this:

    let allNumbers := (select Table2).A;
    let startMulti := 1;
    for num in allNumbers do
        startMulti := startMulti * num
    end;
    startMulti
    

    Line 1: gets all of the values in the field A from Table2.

    Here are the values in the field A:

    Line 2: I create a variable that will store the product of the values in the array from line 1. I had to remember that I needed to set line 2 to 1 not 0 since we are multiplying. :)

    Lines 3 - 5: A for loop is used to iterate through the array from line 1 then multiplies each value.

    Line 6: displays the final results. Which is 480,000,000.

Content aside

  • 4 days agoLast active
  • 1Replies
  • 23Views
  • 2 Following