# QGIS 3 Graphical Modeler field calculator with attribute's parameters

I want to make a model with a vector layer to calculate the sum of two parameters contained in the attribute table of the layer.

I want to create two variables in the model, the name of the two fields of the attribute table to use in the model for the calculation of the new field (A and B), but the geoprocess of the advanced field calculator with python does not get to configure so that you can relate those two variables. • Have you tried this expression manually? – Erik Aug 29 '19 at 11:24
• Sure, but the layer result is empty, maybe not work. I suspect that he does not recognize the variables "A" and "B" – Alejandro Chamizo de Castro Aug 29 '19 at 11:39
• What do "A" & "B" stand for? Are they actual columns in the joined layer? – Erik Aug 29 '19 at 11:40
• Yes, they are 2 columns existing in the original layer. I would like to average two values (A + B) / 2 – Alejandro Chamizo de Castro Aug 29 '19 at 11:50

Use the normal Field Calculator and in the Formula option, select `Pre-calculated Value`. Then use the expression:

``````'(' || @a || ' + ' || @b || ') / 2'
``````

where the parameters `@a` and `@b` are the fields you assign when running the model. This is read by the field calculator as a string version of:

``````(A + B) / 2
`````` • Thanks @joseph. Run perfectly – Alejandro Chamizo de Castro Aug 29 '19 at 12:14
• @AlejandroChamizodeCastro - Most welcome, glad it helped :) – Joseph Aug 29 '19 at 12:18
{"ft_lang_label":"__label__en","ft_lang_prob":0.8877439,"math_prob":0.7849517,"size":425,"snap":"2021-31-2021-39","text_gpt3_token_len":89,"char_repetition_ratio":0.16152018,"word_repetition_ratio":0.0,"special_character_ratio":0.20470588,"punctuation_ratio":0.046511628,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9775697,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,3,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-07-24T07:49:37Z\",\"WARC-Record-ID\":\"<urn:uuid:18482cd8-9190-44d5-ae1f-034e76b63d8d>\",\"Content-Length\":\"170370\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b90fa8cf-b6a6-4502-a0f4-90d41091583b>\",\"WARC-Concurrent-To\":\"<urn:uuid:1228faec-23b4-4296-add7-6c1ab53c7f98>\",\"WARC-IP-Address\":\"151.101.193.69\",\"WARC-Target-URI\":\"https://gis.stackexchange.com/questions/333418/qgis-3-graphical-modeler-field-calculator-with-attributes-parameters?noredirect=1\",\"WARC-Payload-Digest\":\"sha1:ZDPIPHKNMX3AC7PFTUSOEKIUBOXGAOVE\",\"WARC-Block-Digest\":\"sha1:PVIDUYT7NX6JG7OIJXQPLB5ZSUGCU2V2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046150134.86_warc_CC-MAIN-20210724063259-20210724093259-00672.warc.gz\"}"}