Expand my Community achievements bar.

SOLVED

Calculate Total Cost for Regenerating Numeric Field

Avatar

Level 2

Hello,

I had a question about calculating a total cost for this form I have.

The only difficulty is that the field "cost" that I am trying to sum up is part of a subform that is regenerated at the click of the button.
The other part of the form includes "total cost" field is part of another subform that is fixed.

Ideally, this subform is replicated about 4 times which would mean that the grand total cost would have to sum up the 4 cost fields(3 of them were generated).

I have an example form that I can share via e-mail to help clarify the question.


Thanks,

-vargs

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

There are nice features in FormCalc for this. You can use the Sum function and refernce all objects of the same name by using a [*] syntax. So if your field Cost is in a repeating subform called Row the expression woudl be Sum(Row[*].Cost). This would add all of the Cost fields in all Rows (whether there are 2 or 50 ).

Hope that helps

Paul

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

There are nice features in FormCalc for this. You can use the Sum function and refernce all objects of the same name by using a [*] syntax. So if your field Cost is in a repeating subform called Row the expression woudl be Sum(Row[*].Cost). This would add all of the Cost fields in all Rows (whether there are 2 or 50 ).

Hope that helps

Paul

Avatar

Level 2

Thanks so much Paul,

I applied the code and it worked perfectly.

Your answers are always clear and concise and I appreciate your help.

-vargs

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----