##### Page tree
Go to start of banner

# Simple calculation with formula field

Playground and DEMO space

This is a playground and demo space for ConfiForms and ConfiDoc addons developed and supported by Vertuna LLC

Most pages provide a storage format for the demo, so you can use the free add-on from Atlassian Confluence Source Editor to import this configuration into your Confluence and see it in action

Please note, all the examples here are provided without any obligation and may or may not be incomplete or may have bugs, and we provide NO SUPPORT for these examples and demos.

Here is a simple demo to show how the formula fields can be used

We have 2 types of fields for calculations:

• Calculated - which is calculated ONLY when the record is created
• Formula - which is calculated and re-calculated each time the record is saved (created or updated)

You can use any of the functions or operations documented here: Supported math operators, formulas and functions

There is also a way to do calculations with ConfiForms Field Definition Rules

Here we have a simple form with 4 fields:

2 of number types and 2 of formula types

We have the following formulas:

• ([entry.f1] + [entry.f2])
• CONCAT("Some random: ", ((RANDOM() + [entry.f1] - [entry.f2] + NOW())))
 f1 * f2 *

Stored data

f1

f2

My formula 1

My formula 2

3 2 5 Some random: 1555909197981.246
-1 3 2 Some random: 1555909197980.669
5 5 10 Some random: 1555909197988.033
10 20 30 Some random: 1555909197983.674
5 7 12 Some random: 1555909197996.021
43 43 86 Some random: 1555909198001.969
3 2 5 Some random: 1555909198006.333
2 3 5 Some random: 1555909198014.492
99 33 132 Some random: 1555909198085.651
3 3 6 Some random: 1555909198030.059
10 20 30 Some random: 1555909198023.195
3 2 5 Some random: 1555909198049.011
1212 1212 2424 Some random: 1555909198052.870
1 2 3 Some random: 1555909198062.346
6 3 9 Some random: 1555909198070.289
4 2 6 Some random: 1555909198072.316
2 5 7 Some random: 1555909198089.007
15 15 30 Some random: 1555909198096.213
12 1 13 Some random: 1555909198117.553
1 2 3 Some random: 1555909198109.751
1 2 3 Some random: 1555909198112.664
1 2 3 Some random: 1555909198115.309
2 2 4 Some random: 1555909198124.858
5 5 10 Some random: 1555909198127.738
12 3 15 Some random: 1555909198140.148
19862 12234 32096 Some random: 1555909205762.119
2 3 5 Some random: 1555909198136.023
2 2 4 Some random: 1555909198140.940
1 2 3 Some random: 1555909198142.065
1 2 3 Some random: 1555909198146.508
2 3 5 Some random: 1555909198149.808
3 2 5 Some random: 1555909198154.071
2 4 6 Some random: 1555909198154.052
12 13 25 Some random: 1555909198158.151
9 2 11 Some random: 1555909198175.458
1 2 3 Some random: 1555909198173.912
2 2 4 Some random: 1555909198178.183
123 321 444 Some random: 1555909197984.202
67 78 145 Some random: 1555909198174.805
12 12 24 Some random: 1555909198188.058
1 2 3 Some random: 1555909198190.191
10 10 20 Some random: 1555909198195.381
3 3 6 Some random: 1555909198198.959
1 1 2 Some random: 1555909198201.737
5 5 10 Some random: 1555909198204.284
23 33 56 Some random: 1555909198197.653
25 10 35 Some random: 1555909198225.118
2 4 6 Some random: 1555909198211.574
10 15 25 Some random: 1555909198211.986
555 333 888 Some random: 1555909198441.033
123 321 444 Some random: 1555909198024.106
1 1 2 Some random: 1555909198225.542
1 2 3 Some random: 1555909198227.149
2 3 5 Some random: 1555909198230.652
2143 324 2467 Some random: 1555909200054.808
3 2 5 Some random: 1555909198238.461
20 35 55 Some random: 1555909198225.998
3 5 8 Some random: 1555909198241.111
1 2 3 Some random: 1555909198245.816
2 3 5 Some random: 1555909198248.299
56 8 64 Some random: 1555909198300.821
1 2 3 Some random: 1555909198254.321
1 2 3 Some random: 1555909198257.231
1 2 3 Some random: 1555909198261.240
1 2 3 Some random: 1555909198264.736
1 1 2 Some random: 1555909198268.488
6 7 13 Some random: 1555909198270.756
6 6 12 Some random: 1555909198274.943
3 3 6 Some random: 1555909198277.749
1 2 3 Some random: 1555909198279.622
4 4 8 Some random: 1555909198284.919
1 2 3 Some random: 1555909198286.657
12 12 24 Some random: 1555909198291.205
3 2 5 Some random: 1555909198295.992
8 9 17 Some random: 1555909198296.516
5 2 7 Some random: 1555909198304.909
1 1 2 Some random: 1555909198304.591
1 2 3 Some random: 1555909198306.217
1 5 6 Some random: 1555909198306.142
2 3 5 Some random: 1555909198313.287
10 10 20 Some random: 1555909198318.582
5 5 10 Some random: 1555909198320.277
80 80 160 Some random: 1555909198324.963
5 10 15 Some random: 1555909198322.425
5 7 12 Some random: 1555909198328.165
2 4 6 Some random: 1555909198331.602
808 909 1717 Some random: 1555909198235.743
9 9 18 Some random: 1555909198339.684

Storage format for this demo:

```<ac:structured-macro ac:macro-id="e44fca82-119b-4e79-b70a-1d521f0f13e3" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">myform1</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="9930843c-b7ee-493d-b93d-6c91cf13da7a" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="embedded">true</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="c1d112a1-145d-4822-9263-57e7f1d95202" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">f1</ac:parameter>
<ac:parameter ac:name="fieldLabel">f1</ac:parameter>
<ac:parameter ac:name="type">number</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="5b285aed-c238-42cb-8fb0-74b504f51edd" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">f2</ac:parameter>
<ac:parameter ac:name="fieldLabel">f2</ac:parameter>
<ac:parameter ac:name="type">number</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="9981f97b-d090-401d-95d2-b19d45a4df9f" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">myformula1</ac:parameter>
<ac:parameter ac:name="fieldLabel">My formula 1</ac:parameter>
<ac:parameter ac:name="extras">([entry.f1] + [entry.f2])</ac:parameter>
<ac:parameter ac:name="type">formula</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="f6b5b3d7-3462-4068-b23c-2ccee3789f66" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">myformula2</ac:parameter>
<ac:parameter ac:name="fieldLabel">My formula 2</ac:parameter>
<ac:parameter ac:name="extras">CONCAT("Some random: ", ((RANDOM() + [entry.f1] - [entry.f2] + NOW())))</ac:parameter>
<ac:parameter ac:name="type">formula</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>Stored data</p>
<ac:structured-macro ac:macro-id="1d573801-7d23-412f-aa1e-c3c04d1fcc63" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">myform1</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="dc71204e-5341-4543-af04-45ab036c827d" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">f1</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="12af5c9f-b5bb-475e-b9c1-470d60b3bd6c" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">f2</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="0c76996a-654f-4b77-848b-9d8b2212a85f" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">myformula1</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="9a8cf996-366b-4a8b-be43-da01d32dc449" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">myformula2</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>```
• No labels