4 Replies Latest reply on Apr 29, 2014 11:39 AM by IvicaČevis
      • 1. Re: Calculate balance between income and expense
        Magus069 Level 4

        Using FormCalc language will make it easier...

         

        In your balance field you should check if its index is higher than 0, if it is, then you should use the Balance before itself and add it to the current balance.

         

        if ($.parent.index > 0) then

             $.rawValue = Income - Expense + $.resolveNode(Concat("Table1.Row1[", $.parent.index - 1,"]")).Balance

        else

             $.rawValue = Income - Expense

        endif

         

        It should be something like this... change the names to use the right reference_syntax

        • 2. Re: Calculate balance between income and expense
          IvicaČevis Level 1

          Thanks Magus069, it is easier in FormCalc and I didn't know that.

           

          I have one question about code: ", $.parent.index - 1," - commas after and before Quotation marks are part of the syntax?

          • 3. Re: Calculate balance between income and expense
            Magus069 Level 4

            Yes, the Concat method in FormCalc is taking any value, converting the value into string and concats all the values together...

             

            If you seperate the values you concat these:

            "Table1.Row1["

            $.parent.index - 1

            "]"

            Which should result in any of the rows you have in the form

            Table1.Row1[0]

            Table1.Row1[1]

            Table1.Row1[2]

            if $.parent.index -1 is returning the right number, your Field is inside the row directly you only need 1 parent to reach the Row1

            if $.parent.index -1 is not returning the right number, check in your hierarchy, your Field should be inside a form, which the form is directly in the row, so you would need 2 parent to reach your Row1

             

            $.parent.index - 1          or

            $.parent.parent.index - 1


            • 4. Re: Calculate balance between income and expense
              IvicaČevis Level 1

              Thank you! Very good explained!