{"record":{"id":"270dfbb32010118a","repo":"pentaho/pentaho-kettle","slug":"calculator-error-unablefindfield","errorCode":"Calculator.Error.UnableFindField","errorMessage":"Calculator.Error.UnableFindField","messagePattern":"Calculator\\.Error\\.UnableFindField","errorType":"error_code","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java","lineNumber":97,"sourceCode":"      // get all metadata, including source rows and temporary fields.\n      data.setCalcRowMeta( meta.getAllFields( getInputRowMeta() ) );\n\n      data.setFieldIndexes( new FieldIndexes[meta.getCalculation().length] );\n      List<Integer> tempIndexes = new ArrayList<Integer>();\n\n      // Calculate the indexes of the values and arguments in the target data or temporary data\n      // We do this in advance to save time later on.\n      //\n      //CHECKSTYLE:Indentation:OFF\n      for ( int i = 0; i < meta.getCalculation().length; i++ ) {\n        CalculatorMetaFunction function = meta.getCalculation()[i];\n        data.getFieldIndexes()[i] = new FieldIndexes();\n\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          }","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/calculator/Calculator.java#L79-L115","documentation":"The Calculator step resolves each calculation function's source field name against the incoming row metadata via indexOfValue. When the field name is non-empty but the lookup returns a negative index, the field does not exist in the input rows, so processRow throws KettleStepException with the localized message Calculator.Error.UnableFindField, including the field name and 1-based calculation number.","triggerScenarios":"processRow, during first-row initialization: function.getFieldName() is non-empty but data.getCalcRowMeta().indexOfValue(fieldName) < 0 — i.e. a configured calculation references a field not present in the input stream.","commonSituations":"Renaming an upstream field without updating the Calculator; connecting the Calculator after a step that drops the field; typing the field name manually instead of using the field picker.","solutions":["Fix the 'Field name' in the failing calculation (shown as #N in the message) to match an existing input field","Re-select the field using the dropdown/'Get fields' so it matches the current upstream layout","Insert or restore the step that produces the missing field before the Calculator"],"exampleFix":"// before\nfunction.setFieldName(\"totalAmount\"); // upstream field is \"total_amt\"\n// after\nfunction.setFieldName(\"total_amt\");","handlingStrategy":"validation","validationCode":"for (int i = 0; i < meta.getCalculationFunctions().size(); i++) {\n  CalculatorMetaFunction fn = meta.getCalculationFunctions().get(i);\n  if (!Utils.isEmpty(fn.getFieldName()) && calcRowMeta.indexOfValue(fn.getFieldName()) < 0)\n    throw new IllegalArgumentException(\"Calc #\" + (i+1) + \" references missing field: \" + fn.getFieldName());\n}","typeGuard":"boolean calcFieldResolvable(RowMetaInterface row, CalculatorMetaFunction fn) { return Utils.isEmpty(fn.getFieldName()) || row.indexOfValue(fn.getFieldName()) >= 0; }","tryCatchPattern":"try { processRow-like init; } catch (KettleStepException e) { if (e.getMessage().contains(\"Unable to find field\")) { /* correct the field in step settings */ } throw e; }","preventionTips":["Pick field names from the dropdown, never free-type","Re-run step metadata validation after renaming upstream fields","Use a consistent field naming convention across the transformation"],"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"}