Trouble in calculating Principal Eligible for Loan Adjudication system

I am calculating the Principal Eligible (P) value using the formula below, where
EMI = 1,000
SP4RepayTerm = 2.5
AssignR = 0.15

Note: All variables are declared as Double and used in the formula carried from other module (Sub process 4)via involved Workflow


Formula:
P = [EMI * ((1 + R)^Term - 1)] / [R * (1 + R)^Term]

Implementation in UiPath:
P= EMI * ((1 + GlobalVariablesNamespace.GlobalVariables.AssignR) ^ SP4RepayTerm - 1) / (GlobalVariablesNamespace.GlobalVariables.AssignR * (1 + GlobalVariablesNamespace.GlobalVariables.AssignR) ^ SP4RepayTerm)

Expectation :
Value displayed in Double

Actual :
P = 0

The formula is correct.
The actual problem is that AssignR is not being passed as a valid Double (likely 0 or Nothing), causing the entire expression to result in 0.
Log the value of R before calculation and ensure it is numeric and converted to a Double.

Hi @sobin_paul ,

Please check the AssignR variable type is a string, if yes then convert it using AssignR = CDbl(AssignR)otherwise the formula returns 0.

Cheers

@sobin_paul

few steps to debug

  1. Are all message boxes showing expected values
  2. keep a breakpoint on the activity and check the local panel variable and argument values before and after execution
  3. check if there are any variables with same name and different scope

cheers

  1. Add a log or message box before calculation:,
Log Message: "R=" + AssignR.ToString + ", Term=" + SP4RepayTerm.ToString + ", EMI="+EMI.ToString

If any prints 0 or blank, then root cause found

  1. Use Assign R = R / 100 only if you are passing 15 instead of 0.15
R = R / 100  
  1. Simplify UiPath formula
powValue = (1 + R) ^ SP4RepayTerm
P = EMI * (powValue - 1) / (R * powValue)
  1. keep a breakpoint on the activity and check the local panel variable and argument values before and after execution.
  2. use workflow arguments, not globals. Globals may have default = 0, so workflow might be using 0 instead of actual input.

@sobin_paul Better way is to check step by step weather all the expexcted outcomes are coming properly for each activity add as break point in variable ‘P’ and first manually check the calculation in immediate pannel and later check the same step in immediate pannel after the value assigned to ‘P’ is is working or not
it not just chck data type and the formula is it working properly or not