{"record":{"id":"a3df522411757210","repo":"pentaho/pentaho-kettle","slug":"unable-to-find-the-second-argument-field-0-for-calculation-1","errorCode":null,"errorMessage":"Unable to find the second argument field '{0} for calculation #{1}","messagePattern":"Unable to find the second argument field '(.+?) for calculation #(.+?)","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java","lineNumber":124,"sourceCode":"          if ( function.getCalcType() != CalculatorMetaFunction.CALC_CONSTANT ) {\n            data.getFieldIndexes()[i].indexA = data.getCalcRowMeta().indexOfValue( function.getFieldA() );\n            if ( data.getFieldIndexes()[i].indexA < 0 ) {\n              // Nope: throw an exception\n              throw new KettleStepException( \"Unable to find the first argument field '\"\n                + function.getFieldName() + \" for calculation #\" + ( i + 1 ) );\n            }\n          } else {\n            data.getFieldIndexes()[i].indexA = -1;\n          }\n        } else {\n          throw new KettleStepException( \"There is no first argument specified for calculated field #\" + ( i + 1 ) );\n        }\n\n        if ( !Utils.isEmpty( function.getFieldB() ) ) {\n          data.getFieldIndexes()[i].indexB = data.getCalcRowMeta().indexOfValue( function.getFieldB() );\n          if ( data.getFieldIndexes()[i].indexB < 0 ) {\n            // Nope: throw an exception\n            throw new KettleStepException( \"Unable to find the second argument field '\"\n              + function.getFieldName() + \" for calculation #\" + ( i + 1 ) );\n          }\n        }\n        data.getFieldIndexes()[i].indexC = -1;\n        if ( !Utils.isEmpty( function.getFieldC() ) ) {\n          data.getFieldIndexes()[i].indexC = data.getCalcRowMeta().indexOfValue( function.getFieldC() );\n          if ( data.getFieldIndexes()[i].indexC < 0 ) {\n            // Nope: throw an exception\n            throw new KettleStepException( \"Unable to find the third argument field '\"\n              + function.getFieldName() + \" for calculation #\" + ( i + 1 ) );\n          }\n        }\n\n        if ( function.isRemovedFromResult() ) {\n          tempIndexes.add( getInputRowMeta().size() + i );\n        }\n      }\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java#L106-L142","documentation":"For calculations that use a second argument, Calculator resolves fieldB against the input row metadata. If fieldB is non-empty but indexOfValue returns < 0, processRow throws KettleStepException 'Unable to find the second argument field ... for calculation #N'. As with field A, the message reports the calculated field's name, not the missing argument.","triggerScenarios":"processRow init: function.getFieldB() is set but the named field is absent from data.getCalcRowMeta().","commonSituations":"Second argument field renamed or removed upstream; manual typo in the 'Second argument field' box; stale metadata after upstream edits.","solutions":["Correct 'Second argument field' in calculation #N to an existing input field","Re-pick the field from the dropdown after previewing upstream output","Restore the upstream step that produced the missing field"],"exampleFix":"// before\nfn.setFieldB(\"vat_rate\"); // upstream field is \"VAT\"\n// after\nfn.setFieldB(\"VAT\");","handlingStrategy":"validation","validationCode":"if (!Utils.isEmpty(fn.getFieldB()) && calcRowMeta.indexOfValue(fn.getFieldB()) < 0)\n  throw new IllegalArgumentException(\"Calc fieldB not in input: \" + fn.getFieldB());","typeGuard":null,"tryCatchPattern":"catch (KettleStepException e) { /* open the calculation named in the message and fix field B */ throw e; }","preventionTips":["Verify two-argument calculations reference existing fields for both A and B","Re-save the step with refreshed fields after upstream changes","Use consistent casing for field names"],"tags":["kettle","pdi","calculator","field-mapping"],"backgroundTag":"resource-not-found","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}