calculation

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

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hello  

    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.

  • 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 

  • 0
    Certified Senior Developer
    in reply to KM

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

Reply Children
No Data