hello hope you doing good, i have been trying to use the button option to insert two formtext and sum them but as you can see on the template code below I need to put them a name but if I do that I will sum all the formtext I have, is there a way to insert the formtext and get an individual sum for each time I click the button?
{note}Rental type: {formmenu: ; default=Two year's schedule E\ ; Individual Property Calc; name=rental type}{endnote}
{if: rental type
= "Two year's schedule E "}{note}
Formula:
Line 26 + Line 18 = Annual Rental Income {endnote}
2023
{formtext: name=line 26}+{formtext: name=line 18} = {=line 26
+ line 18
}
{yescount=count(filter(hello, (x) -> contains(x, "yes")))}
{repeat: 1 + yescount; locals=hello}{formtext: name=line 26}+{formtext: name=line 18} = {=line 26
+ line 18
}
{note: preview=no}{formtoggle: name=toggle}{endnote}{if: toggle = no}{button: toggle = yes
; label=Add Property✍️}{else}{button: toggle = no
; label=Delete Property↩️}{endif}
{endrepeat}
----Review Docs & Income------
Income Type: Rental
1040's on file?: sch E’s
Documents for continuation: N/A
Calculation
2023: ${formtext}
2024: ${formtext}
Decreasing: ${formtext}
{elseif: rental type
= "Individual Property Calc"}
----Review Docs & Income------
Income Type: Individual Rental
1040's on file?: Y sch e’s
Documents for continuation: leases
Calculation
2020: ${formtext}
2021: ${formtext}
Increasing: ${formtext}{endif}
Hi @Aldo_Barahona,
Using same name causing this issue. In the example below I renamed line 26
and line 18
inside of repeat scope into line26a
and line18a
. That fixes the issue.
{formtext: name=line 26}+{formtext: name=line 18} = {=`line 26` + `line 18`}
{yescount=count(filter(hello, (x) -> contains(x, "yes")))}
{repeat: 1 + yescount; locals=hello}{formtext: name=line 26a}+{formtext: name=line 18a} = {=`line 26a` + `line 18a`}
{note: preview=no}{formtoggle: name=toggle}{endnote}{if: toggle = no}{button: toggle = yes
; label=Add Property✍️}{else}{button: toggle = no
; label=Delete Property↩️}{endif}
{endrepeat}
thank you for your help, i feel weird now cause the solution was just 1 letter away
I can't believe I did not think about it hahahaha, thanks I appreciate your help
@Mansur_Kutybayev do you know how can i do to sum all the results i get from all 2023 ?
Hi @Aldo_Barahona,
Yes, you can use the {repeat} locals variable hello
to access all the variables in the {repeat} scope, such as line 18a
and line 26a
. After that, I utilized the reduce function to accumulate the sum across all the iterations of {repeat}. I've created a snippet to demonstrate that. Please feel free to ask if you have any further questions.
{formtext: name=line 26}+{formtext: name=line 18} = {=`line 26` + `line 18`}
{yescount=count(filter(hello, (x) -> contains(x, "yes")))}
{repeat: 1 + yescount; locals=hello}{formtext: name=line 26a}+{formtext: name=line 18a} = {=`line 26a` + `line 18a`}
{note: preview=no}{formtoggle: name=toggle}{endnote}{if: toggle = no}{button: toggle = yes
; label=Add Property✍️}{else}{button: toggle = no
; label=Delete Property↩️}{endif}
{endrepeat}
Total (line 18) = {=reduce(hello, 0, (a, v) -> v["line 26a"] + a)}
Total (line 26) = {=reduce(hello, 0, (a, v) -> v["line 18a"] + a)}
Grand Total (line 18 + line 26) = {=reduce(hello, 0, (a, v) -> v["line 26a"] + v["line 18a"] + a)}
thank you for your answer @Ashwin_MittalTB is working good, but seems that i am having an issue with the button option, as you can see below seems that the toggles for some reason are mixed even after changing the same of each toggle, after triying to use the "add property" toggle is not added in the 2023 part, i need to use the one for 2022 but then another "add property " is created and we see 2, is kind of intertwined i tried to fix it but no solutions cam you give a hand on this, thanks in advance
--------2023--------
{yescount=count(filter(helloa, (x) -> contains(x, "yes")))}
{repeat: 1 + yescount; locals=helloa}{formtext: name=line 26a}+{formtext: name=line 18a} = {=`line 26a` + `line 18a`}
{note: preview=no}{formtoggle: name=togglea}{endnote}{if: togglea = "no"}{button: togglea = "yes"
; label=Add Property✍️}{else}{button: togglea = "no"
; label=Delete Property↩️}{endif}
{endrepeat}
Grand Total (line 18 + line 26) = {=reduce(helloa, 0, (a, v) -> v["line 26a"] + v["line 18a"] + a)}
--------2022--------
{yescount=count(filter(hello, (x) -> contains(x, "yes")))}
{repeat: 1 + yescount; locals=hello}{formtext: name=line 26}+{formtext: name=line 18} = {=`line 26` + `line 18`}
{note: preview=no}{formtoggle: name=toggle}{endnote}{if: toggle = no}{button: toggle = yes
; label=Add Property✍️}{else}{button: toggle = no
; label=Delete Property↩️}{endif}
{endrepeat}
Grand Total (line 18 + line 26) = {=reduce(hello, 0, (a, v) -> v["line 26"] + v["line 18"] + a)}
i think i got it, the formula for "yesount" was the same and i did not know i needed to change the name for that too, but now is working thanks to all
1 Like