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

Question

Question

How Can I Get a Field to Calculate by Row?

asked on February 13, 2019 Show version history

I am trying to get my Day Total to only calculate the totals for that day and is it possible to limit the day to $60.00?

The Name of the fields are BreakfastItems, LunchItems and DinnerItems.  

 

My code for the DayTotal is in the Day Total Formula.JPG.

Thank you!

 

0 0

Answer

SELECTED ANSWER
replied on February 14, 2019 Show version history

Sorry, just noticed you were using currency fields. Currency fields don't support maximums directly from Forms, so you have to add 1 line of JS referenced here.

Instead of using document ready, you should trigger the JS whenever a table field changes so make sure it applies to each row. 

If you use a number field as the last column, you can set it to have a maximum value from the field configuration without using JS. 

0 0

Replies

replied on February 13, 2019 Show version history

Use the Index() and Row() functions. 

=SUM( INDEX(Table.Col1,ROW()) , INDEX(Table.Col2,ROW()) , INDEX(Table.Col3,ROW()) )

INDEX takes in (column, row() ) which will give you the value at that column on the given row. 

Using your variables, it should be something like

=SUM(INDEX(Meals.BreakfastItems,ROW()) , INDEX(Meals.LunchItems,ROW()) , INDEX(Meals.DinnerItems,ROW()))

1 0
replied on February 13, 2019

I tried to put the formula in there, but I am not sure exactly how to use it.  

 

Thank you for the help.

0 0
replied on February 13, 2019

Don't use Day(), keep Row(), that's a function name so shouldn't be updated. 

1 0
replied on February 13, 2019

Hi Jared, 

That worked!  I appreciate the help.

Do you know how I could get a field to error out on a value higher than $60?

Thanks again!

1 0
replied on February 13, 2019

Go to the Basic tab and try to set a maximum of $60. That should show a generic error. You can also go to the custom errors tab if you want to put your own error message in there. 

0 0
replied on February 14, 2019

I tried that.  It doesn't work.  

When I go to the Error Messages tab and try to create one, the Field doesn't come up as an option to select.

Thank you!

0 0
SELECTED ANSWER
replied on February 14, 2019 Show version history

Sorry, just noticed you were using currency fields. Currency fields don't support maximums directly from Forms, so you have to add 1 line of JS referenced here.

Instead of using document ready, you should trigger the JS whenever a table field changes so make sure it applies to each row. 

If you use a number field as the last column, you can set it to have a maximum value from the field configuration without using JS. 

0 0
replied on February 14, 2019

Hi Jared,

How do I trigger the whenever a table field changes?

Thank you!

 

0 0
replied on February 13, 2019

I tried to put the formula in there, but I am not sure exactly how to use it.  

 

Thank you for the help.

You are not allowed to follow up in this post.

Sign in to reply to this post.