{"record":{"id":"38a1e035ab3e748a","repo":"pentaho/pentaho-kettle","slug":"unable-to-find-the-first-argument-field-0-for-calculation-1","errorCode":null,"errorMessage":"Unable to find the first argument field '{0} for calculation #{1}","messagePattern":"Unable to find the first 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":110,"sourceCode":"\n        if ( !Utils.isEmpty( function.getFieldName() ) ) {\n          data.getFieldIndexes()[i].indexName = data.getCalcRowMeta().indexOfValue( function.getFieldName() );\n          if ( data.getFieldIndexes()[i].indexName < 0 ) {\n            // Nope: throw an exception\n            throw new KettleStepException( BaseMessages.getString(\n              PKG, \"Calculator.Error.UnableFindField\", function.getFieldName(), \"\" + ( i + 1 ) ) );\n          }\n        } else {\n          throw new KettleStepException( BaseMessages.getString( PKG, \"Calculator.Error.NoNameField\", \"\"\n            + ( i + 1 ) ) );\n        }\n\n        if ( !Utils.isEmpty( function.getFieldA() ) ) {\n          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;","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java#L92-L128","documentation":"For calculations needing a first argument (field A, unless the calc type is CALC_CONSTANT), Calculator resolves fieldA against the input row metadata. If fieldA is non-empty but indexOfValue returns < 0, processRow throws KettleStepException 'Unable to find the first argument field ... for calculation #N'. Note the message reports getFieldName() (the calculated field) rather than the missing argument field itself, which can be confusing.","triggerScenarios":"processRow init: function.getFieldA() is set but the named field is absent from data.getCalcRowMeta(), and calcType != CALC_CONSTANT.","commonSituations":"Field A renamed upstream; manually typed field name with casing/typo; reusing Calculator metadata across transformations with different fields.","solutions":["Correct 'First argument field' in calculation #N to an existing input field","Re-pick the field from the dropdown to match the current upstream layout","Rename the calculation's fieldName too if the message shows the wrong label (message prints fieldName, not fieldA)"],"exampleFix":"// before\nfn.setFieldA(\"price_with_tax\"); // upstream has \"price\"\n// after\nfn.setFieldA(\"price\");","handlingStrategy":"validation","validationCode":"if (!Utils.isEmpty(fn.getFieldA()) && fn.getCalcType() != CALC_CONSTANT && calcRowMeta.indexOfValue(fn.getFieldA()) < 0)\n  throw new IllegalArgumentException(\"Calc fieldA not in input: \" + fn.getFieldA());","typeGuard":null,"tryCatchPattern":"catch (KettleStepException e) { /* message shows calculated field name; open that calc and fix field A */ throw e; }","preventionTips":["Re-pick field A after upstream renames","Preview the Calculator's input to see the actual field list","Remember the error text names the calculated field, not fieldA — check field A first"],"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"}