| CARVIEW |
Select Language
HTTP/2 301
date: Tue, 30 Dec 2025 16:48:07 GMT
content-type: text/html; charset=UTF-8
location: https://docs.gravityforms.com/gform_calculation_format_result/
server: cloudflare
strict-transport-security: max-age=604800
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
content-security-policy: frame-ancestors 'self';
referrer-policy: no-referrer
referrer-policy: strict-origin-when-cross-origin
x-redirect-by: WordPress
fastcgi-cache: MISS
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=%2BPJ3EfycgSyrlMlPwRexiKyB63O9802coM42blE0dlvUD8wUnXedPlEn1EmtKOXCO6LtVcc61bn2URs2503%2F0TPL7GhZUzJEbrxQ%2FGKG8KRbDO4y"}]}
cf-ray: 9b6305db0a9cad8b-BLR
HTTP/2 200
date: Tue, 30 Dec 2025 16:48:08 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
vary: Accept-Encoding
strict-transport-security: max-age=604800
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
content-security-policy: frame-ancestors 'self';
referrer-policy: no-referrer
referrer-policy: strict-origin-when-cross-origin
link: ; rel="https://api.w.org/"
link: ; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
fastcgi-cache: HIT
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=Fzztfpiecd0FSsFZN%2Bg7Sg3qxh4v6jvnV3fK94UQpHTp37owV0aRwTOiys%2B7wBImWwqi%2FLp04In17TZYvBqix0v%2FtbFljzjR05YMxPO%2BZO487iFy"}]}
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
content-encoding: gzip
cf-ray: 9b6305e1ba24ad8b-BLR
gform_calculation_format_result - Gravity Forms Documentation
gform_calculation_format_result
Description
The “gform_calculation_format_result” filter can be used to override the default formatting for a calculated result.
Usage
The gform_calculation_result filter is a JavaScript filter.
gform.addFilter( 'gform_calculation_format_result', function( result, formulaField, formId, calcObj ) {
// do stuff
return result;
} );
Parameters
- formattedResult string | boolean (false)
The formatted calculation result. - result float
The calculation result. - formulaField Javascript Object
The current calculation field object. e.g.{"field_id":3,"formula":"{:1}+{:2}","rounding":""} - formId integer
The ID of the form in use. - calcObj Javascript Object
The calculation object.
Examples
Format the number field with id 1 as currency.
<script>
gform.addFilter( 'gform_calculation_format_result', function(formattedResult, result, formulaField, formId, calcObj ){
if ( formulaField.field_id == '1' ){ // Change 1 to your field id number
formattedResult = gformFormatNumber(result, !gformIsNumber(formulaField.rounding) ? -1 : formulaField.rounding, ',', '');
}
var currency = new Currency(gf_global.gf_currency_config);
return currency.toMoney(formattedResult);
});
</script>
Show always two decimals.
<script>
gform.addFilter('gform_calculation_format_result', function (formattedResult, result, formulaField, formId, calcObj) {
if (formulaField.field_id == '3') { // Change 3 to your field id number
var decimalSeparator = ',',
thousandSeparator = '.',
currency = new Currency(gf_global.gf_currency_config);
formattedResult = currency.numberFormat(result, 2, decimalSeparator, thousandSeparator);
}
return formattedResult;
});
</script>
Placement
Reference the article Adding JavaScript Code to the Frontend of Your Site.
Source Code
This filter is located in js/gravityforms.js.