You are viewing limited content. For full access, please sign in.

Question

Question

Performing calculations on a dynamic table

asked on May 16, 2023

I'm trying to multiply the values of 4 cells of a row and auto populate the result in the 5th column. As I add a new row I need to do this math again, and finally get the sum of the 5th column to a text field.

I'm using this formula in the 5th column. =PRODUCT(1.5,7.48,basin_storage.basin_1_cubic_feet).

 

Laserfiche is not populating the correct value for the 5th column though. Is there any other method of doing this?

 

0 0

Answer

SELECTED ANSWER
replied on May 16, 2023 Show version history

Technically it isn't populating the "wrong" value, just not the one you were expecting. The problem is with the variables you're using in the formula.

Any repeatable value, like fields in tables or collections, is multivalued so when you use the variable in a formula that would be referencing all of the values.

If you want a row-by-row calculation, you need to tell the formula which value to use, and you do that with the INDEX function.

Forms also has a ROW() function which will return the index of the "current" row, which you would combine with the index to reference the corresponding values from the row.

For example, in the following formula

=PRODUCT(1.5,7.48,basin_storage.basin_1_cubic_feet)

If "basin_storage.basin_1_cubic_feet" is a column in the same row, you would need to instead use the following

=PRODUCT(1.5,7.48,INDEX(basin_storage.basin_1_cubic_feet,ROW()))

The syntax is INDEX([variable],[index])

Inside a table/collection, ROW() provides the "current" row index, so you get

INDEX([variable],ROW())

If you need to reference multiple columns/variables from the row, you need to wrap each variable in its own separate INDEX function like so

PRODUCT(INDEX(table.column1,ROW()),INDEX(table.column2,ROW()))

 

1 0
replied on May 17, 2023

That worked and now it's giving me the correct values. Thank you!

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.