Skip to main content
kavyam0002
April 16, 2024
Solved

calculation

  • April 16, 2024
  • 12 replies
  • 1 view

here in the image 

1st, 2nd and 3rd columns are input and it has to generate the 4th, 5th and 6th column 

can anyone help me with this 

4th column will be calculated with 3rd column/1st column

5th is minus of 4th column

6th is increment of 1 year 

for brief it is a depreciation logic for every year

    Best answer by kavyam0002

    a!forEach(
      items: enumerate(ri!years) + 1,
      expression: {
        a!localVariables(
          local!calculateDepreciationAmt: ri!actualAmount / ri!years,
          local!marketValue: ri!actualAmount - (local!calculateDepreciationAmt * fv!item),
          local!depreciationDate: todate(
            datetime(
              year(tostring(ri!registrationDate_dt)) + fv!item,
              month(tostring(ri!registrationDate_dt)),
              day(tostring(ri!registrationDate_dt))
            )
          ),
          {
            local!calculateDepreciationAmt,
            local!depreciationDate,
            local!marketValue
          }
        )
      }
    )

    12 replies

    karumurua531442
    April 16, 2024

    hi [mention:bd2e537916fe4b31980bfba549754efc:e9ed411860ed4f2ba0265705b8793d05]  are trying to do this in excel sheet or appian grid filed

    kavyam0002
    April 16, 2024

    doing it in expression rule and result will be stored in DB 

    karumurua531442
    April 16, 2024

    Hi [mention:bd2e537916fe4b31980bfba549754efc:e9ed411860ed4f2ba0265705b8793d05]  I am still unable to capture your requirement could you please share your code snippet for better understanding

    shubhama926776
    Brainy
    April 16, 2024

    Hello [mention:bd2e537916fe4b31980bfba549754efc:e9ed411860ed4f2ba0265705b8793d05] 

    I try to mimic your requirement using map function but you can create CDT or Record according to your need and save this into DB.
    Below is my understanding
    For each row, Dividing the value in column D by the value in column B. Then, subtracting  column E from the value in column D. Finally, it increments the date in column F by one year.

    a!localVariables(
      local!data: {
        a!map(
          "COLB": 5,
          "COLC": "02/01/2024",
          "COLD": 10000,
          "COLE": 2000,
          "COLF": 8000,
          "COLG": "01/31/2029"
        ),
        a!map(
          "COLB": 3,
          "COLC": "02/01/2024",
          "COLD": 10000,
          "COLE": 2000,
          "COLF": 8000,
          "COLG": "01/31/2029"
        )
      },
      a!forEach(
        items: local!data,
        expression: a!update(
          fv!item,
          { "COLE", "COLF", "COLG" },
          {
            fv!item.COLD / fv!item.COLB,
            fv!item.COLD - (fv!item.COLD / fv!item.COLB),
            todate(
              datetime(
                year(tostring(fv!item.COLC)) + 1,
                month(tostring(fv!item.COLC)),
                day(tostring(fv!item.COLC))
              )
            )
          }
        )
      )
    )



    Let me know if that works for you.

    शुभम्
    kavyam0002
    April 16, 2024

    the input will be example 

    years - 5

    amount - 10000

    initial year - 1st feb 2024

    so we have to calculate until amount comes to 0, by incrementing every year 

    karumurua531442
    April 16, 2024

    Can we have  a stored procedure for this logic will that be easy ?