{"record":{"id":"760a6f5e35c5b2e8","repo":"pentaho/pentaho-kettle","slug":"unable-to-find-field-name-for-formula","errorCode":null,"errorMessage":"Unable to find field name for formula [","messagePattern":"Unable to find field name for formula \\[","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/formula/Formula.java","lineNumber":128,"sourceCode":"    try {\n      Object[] outputRowData = RowDataUtil.createResizedCopy( r, data.outputRowMeta.size() );\n      int tempIndex = rowMeta.size();\n\n      // Assign this tempRowData to the formula context\n      //\n      data.context.setRowData( outputRowData );\n\n      // Initialize parsers etc. Only do it once.\n      //\n      if ( data.formulas == null ) {\n        // Create a set of LValues to put the parsed results in...\n        data.formulas = new org.pentaho.reporting.libraries.formula.Formula[meta.getFormula().length];\n        for ( int i = 0; i < meta.getFormula().length; i++ ) {\n          FormulaMetaFunction fn = meta.getFormula()[i];\n          if ( !Utils.isEmpty( fn.getFieldName() ) ) {\n            data.formulas[i] = data.createFormula( meta.getFormula()[i].getFormula() );\n          } else {\n            throw new KettleException( \"Unable to find field name for formula [\"\n              + Const.NVL( fn.getFormula(), \"\" ) + \"]\" );\n          }\n        }\n      }\n\n      for ( int i = 0; i < meta.getFormula().length; i++ ) {\n        FormulaMetaFunction fn = meta.getFormula()[i];\n        if ( !Utils.isEmpty( fn.getFieldName() ) ) {\n          if ( data.formulas[i] == null ) {\n            data.formulas[i] = data.createFormula( meta.getFormula()[i].getFormula() );\n          }\n\n          // this is main part of all this step: calculate formula\n          Object formulaResult = data.formulas[i].evaluate();\n          if ( formulaResult instanceof LibFormulaErrorValue ) {\n            // inspect why it is happens to get clear error message.\n            throw new KettleException( \"Error calculate formula. Formula \"\n                + fn.getFormula() + \" output field: \" + fn.getFieldName() + \", error is: \" + formulaResult.toString() );","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/formula/Formula.java#L110-L146","documentation":"KettleException thrown in Formula.calcFields() when a FormulaMetaFunction has an empty fieldName, i.e. the formula result has neither a new field name nor (checked earlier) a replace field. Every formula must produce output into a named field, so the step refuses to compute it.","triggerScenarios":"A formula row exists in the step meta whose 'New field' name is blank and 'Replace value' is also blank; this passes dialog edits but fails when the first row is processed.","commonSituations":"User added a formula row in the dialog but never filled in the field name; a transformation was hand-edited in XML and the field_name attribute was dropped; import from another environment lost attributes.","solutions":["Open the Formula step dialog and set the 'New field' name (or a 'Replace value' field) for every formula row.","Remove any leftover blank formula rows.","Validate the transformation (Ctrl+T) which surfaces empty formula field names at design time."],"exampleFix":"// before\nnew FormulaMetaFunction(fn, null, \"NVL(x,0)\", ...); // no field name\n// after\nnew FormulaMetaFunction(fn, \"defaulted_x\", \"NVL(x,0)\", ...);","handlingStrategy":"validation","validationCode":"if (Utils.isEmpty(fn.getFieldName()) && Utils.isEmpty(fn.getReplaceField())) {\n  throw new KettleException(\"Formula row needs a field name or replace field: \" + fn.getFormula());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always fill 'New field' when adding a formula row","Delete blank formula rows before saving","Run transformation validation (Ctrl+T)","Avoid hand-editing .ktr XML attributes"],"tags":["formula","missing-field-name","configuration"],"backgroundTag":"empty-required-field","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"}