I want to link 2 number values (RMSE & dosemax) in a field calculator formula. When I run the modeler, I add these values but it doesn't recognize them. I dont want to create a new table. Just use these number in the formula.
-
You can't do this directly using the number parameters. You will need to create a custom script which reads those number values, inserts them into a string expression, and finally outputs the expression as a string parameter which can then be fed into the Field Calculator tool. – Joseph May 25 '18 at 12:42
-
I starts to be hard for me to follow. Do you have a picture of where i can do this script ? – Marc Robin May 25 '18 at 12:44
To create a custom script, you can go to the Processing Toolbox > Scripts > Tools > Create new script
and use something like the following (change the expression accordingly, you do not need to add quotes around the number parameters):
##Example=name
##dosemax=number
##RMSE=number
##expression=output string
dose = str(dosemax)
rmse = str(RMSE)
expression = 'if("moyennemea" < minumum("moyennemea")+3*rmse, 0.75*dose, dose)'
Save the script into your /.qgis2/processing/scripts
directory. Then add the script to your model selecting the input number parameters for the script:
Then in the Field Calculator tool, select the script for the expression:
The expression should now use the number values from the parameters.