## 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 3 of formula types

We have the following formulas in this form:

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

Example configuration of a formula field:

 f1 * f2 *

Stored data

f1

f2

My formula 0

My formula 1

My formula 2

3 7 0.43 10 Some random: 1670637010106.704
8 9 0.89 17 Some random: 1670637010110.315
9 8 1.12 17 Some random: 1670637010112.605
.2 .2 Expression: [(ROUND(.2 / .2,2))] could not be calculated, Unknown operator '.' at position 8 Expression: [(.2 + .2)] could not be calculated, Unknown operator '.' at position 2 Expression: [CONCAT("Some random: ", ((RANDOM() + .2 - .2 + NOW())))] could not be calculated, Unknown operator '.' at position 38
2 2 1 4 Some random: 1670637010120.983
1 2 0.5 3 Some random: 1670637010119.307
33 2 16.5 35 Some random: 1670637010152.074
1 32 0.03 33 Some random: 1670637010090.243
1 2 0.5 3 Some random: 1670637010120.834
1 2 0.5 3 Some random: 1670637010121.317
1 1 1 2 Some random: 1670637010122.892
4 1 4 5 Some random: 1670637010126.467
123 123 1 246 Some random: 1670637010123.923
2 2 1 4 Some random: 1670637010123.261
3 4 0.75 7 Some random: 1670637010123.133
3 4 0.75 7 Some random: 1670637010123.548
3 2 1.5 5 Some random: 1670637010126.547
33 32 1.03 65 Some random: 1670637010126.830
5 5 1 10 Some random: 1670637010126.927
3 4 0.75 7 Some random: 1670637010125.677
2 2 1 4 Some random: 1670637010137.032
1 2 0.5 3 Some random: 1670637010136.907
12 12 1 24 Some random: 1670637010137.503
.1 .2 Expression: [(ROUND(.1 / .2,2))] could not be calculated, Unknown operator '.' at position 8 Expression: [(.1 + .2)] could not be calculated, Unknown operator '.' at position 2 Expression: [CONCAT("Some random: ", ((RANDOM() + .1 - .2 + NOW())))] could not be calculated, Unknown operator '.' at position 38
1 3 0.33 4 Some random: 1670637010136.844
1 2 0.5 3 Some random: 1670637010138.417
1 2 0.5 3 Some random: 1670637010138.811
34 56 0.61 90 Some random: 1670637010117.859
3 4 0.75 7 Some random: 1670637010139.239
1 1 1 2 Some random: 1670637010140.913
4 5 0.8 9 Some random: 1670637010140.498
56,56 54 56 Expression: [(56,56 + 54)] could not be calculated, Too many numbers or variables Some random: 56.87226791974117
1.1 4 0.28 5.1 Some random: 1670637010138.518
5 4 1.25 9 Some random: 1670637010143.590
15 30 0.5 45 Some random: 1670637010127.763
60 15 4 75 Some random: 1670637010188.349
1 2 0.5 3 Some random: 1670637010142.996
100 200 0.5 300 Some random: 1670637010043.115
2 33 0.06 35 Some random: 1670637010113.946
1 1 1 2 Some random: 1670637010144.860
100.10 100.10 1 200.2 Some random: 1670637010144.350
5 6 0.83 11 Some random: 1670637010144.477
15 45 0.33 60 Some random: 1670637010115.915
3 4 0.75 7 Some random: 1670637010145.728
2 3 0.67 5 Some random: 1670637010145.967
1 2 0.5 3 Some random: 1670637010146.970
3 7 0.43 10 Some random: 1670637010144.074
2 3 0.67 5 Some random: 1670637010156.219
100 200 0.5 300 Some random: 1670637010057.247
1 5 0.2 6 Some random: 1670637010154.839
4 5 0.8 9 Some random: 1670637010157.486
4 5 0.8 9 Some random: 1670637010158.116
123 234 0.53 357 Some random: 1670637010048.401
12 12 1 24 Some random: 1670637010160.561
3 4 0.75 7 Some random: 1670637010159.556
3 2 1.5 5 Some random: 1670637010161.361
11111 22222 0.5 33333 Some random: 1670636999050.004
1 2 0.5 3 Some random: 1670637010160.149
1 1 1 2 Some random: 1670637010162.282
10 10 1 20 Some random: 1670637010162.421
1 3 0.33 4 Some random: 1670637010160.728
0.2 0.2 1 0.4 Some random: 1670637010163.863
1 2 0.5 3 Some random: 1670637010162.982
1 4 0.25 5 Some random: 1670637010160.906
12 12 1 24 Some random: 1670637010164.072
10 10 1 20 Some random: 1670637010164.098
23 45 0.51 68 Some random: 1670637010143.160
1 2 0.5 3 Some random: 1670637010164.265
3 7 0.43 10 Some random: 1670637010161.230
5345345 534534 10 5879879 Some random: 1670641820977.128
43.54534 6545.456456 0.01 6589.001796 Some random: 1670637003665.069
1 1 1 2 Some random: 1670637010167.256
144 144 1 288 Some random: 1670637010169.167
114 114 1 228 Some random: 1670637010170.983
114 114 1 228 Some random: 1670637010171.279
114 114 1 228 Some random: 1670637010171.543
114 114 1 228 Some random: 1670637010172.186
114 114 1 228 Some random: 1670637010172.727
5 5 1 10 Some random: 1670637010172.391
4 4 1 8 Some random: 1670637010173.801
2 1 2 3 Some random: 1670637010174.755
1 2 0.5 3 Some random: 1670637010173.639
1 2 0.5 3 Some random: 1670637010173.896
1 2 0.5 3 Some random: 1670637010174.340
2 3 0.67 5 Some random: 1670637010174.433
1097 1079 1.02 2176 Some random: 1670637010193.751
58 2 29 60 Some random: 1670637010232.190
100 100 1 200 Some random: 1670637010176.772
1 1 1 2 Some random: 1670637010176.053
1 2 0.5 3 Some random: 1670637010176.169
56 87 0.64 143 Some random: 1670637010146.110
1 2 0.5 3 Some random: 1670637010177.689
1 1 1 2 Some random: 1670637010178.071
1 2 0.5 3 Some random: 1670637010178.388
2 3 0.67 5 Some random: 1670637010178.186
5 9 0.56 14 Some random: 1670637010175.802
3 3 1 6 Some random: 1670637010180.292
4 4 1 8 Some random: 1670637010180.359
1 2 0.5 3 Some random: 1670637010180.106
2 3 0.67 5 Some random: 1670637010180.498
3 4 0.75 7 Some random: 1670637010109.461
5000 5000 1 10000 Some random: 1670637010111.171
3 3 1 6 Some random: 1670637010111.426
12 13 0.92 25 Some random: 1670637010111.580
.5 .7 Expression: [(ROUND(.5 / .7,2))] could not be calculated, Unknown operator '.' at position 8 Expression: [(.5 + .7)] could not be calculated, Unknown operator '.' at position 2 Expression: [CONCAT("Some random: ", ((RANDOM() + .5 - .7 + NOW())))] could not be calculated, Unknown operator '.' at position 38
0.5 0.7 0.71 1.2 Some random: 1670637010114.748
1 1 1 2 Some random: 1670637010114.101
4 5 0.8 9 Some random: 1670637010114.118
69 420 0.16 489 Some random: 1670637009764.639
1 2 0.5 3 Some random: 1670637010114.436
2 4 0.5 6 Some random: 1670637010114.930
2 3 0.67 5 Some random: 1670637010115.288
3 4 0.75 7 Some random: 1670637010116.052
50 10 5 60 Some random: 1670637010157.311
0 0 0 0 Some random: 1670637010118.663
1 2 0.5 3 Some random: 1670637010117.560
3 7 0.43 10 Some random: 1670637010114.218
1 1 1 2 Some random: 1670637010119.922
11 2 5.5 13 Some random: 1670637010128.032
2 1 2 3 Some random: 1670637010120.128
33 22 1.5 55 Some random: 1670637010131.621
3 3 1 6 Some random: 1670637010120.415
5 5 1 10 Some random: 1670637010121.842
2 2 1 4 Some random: 1670637010121.274
4 5 0.8 9 Some random: 1670637010120.099
4 5 0.8 9 Some random: 1670637010121.151
8+9 12+2 10.75 31 Some random: 1670637010129.980
10.2352 15.2350 0.67 25.4702 Some random: 1670637010118.610
1 2 0.5 3 Some random: 1670637010122.088
10 15 0.67 25 Some random: 1670637010118.199
10 30 0.33 40 Some random: 1670637010104.392
8 9 0.89 17 Some random: 1670637010123.610
3 4 0.75 7 Some random: 1670637010124.128
5 6 0.83 11 Some random: 1670637010124.412
2 3 0.67 5 Some random: 1670637010125.688
4 4 1 8 Some random: 1670637010126.593
0.2 0.5 0.4 0.7 Some random: 1670637010126.253
1 2 0.5 3 Some random: 1670637010126.708
100000 100000 1 200000 Some random: 1670637010127.787
1 1 1 2 Some random: 1670637010128.195
6 7 0.86 13 Some random: 1670637010127.415
10 2 5 12 Some random: 1670637010136.622
1 2 0.5 3 Some random: 1670637010128.508
1 2 0.5 3 Some random: 1670637010128.732
21 7 3 28 Some random: 1670637010144.070
1 2 0.5 3 Some random: 1670637010129.951
1 2 0.5 3 Some random: 1670637010129.700
999 998 1 1997 Some random: 1670637010132.008
17 3 5.67 20 Some random: 1670637010145.762
5 6 0.83 11 Some random: 1670637010131.303
5 4 1.25 9 Some random: 1670637010133.646
1 1 1 2 Some random: 1670637010132.346
25000 0,30 0 Expression: [(25000 + 0,30)] could not be calculated, Too many numbers or variables Some random: 25000.72291792569
5 8 0.62 13 Some random: 1670637010130.751
124 333 0.37 457 Some random: 1670637009925.131
5 1 5 6 Some random: 1670637010138.812
4 1223 0 1227 Some random: 1670637008915.878
2 3 0.67 5 Some random: 1670637010134.506
45 1908 0.02 1953 Some random: 1670637008272.645
3 3 1 6 Some random: 1670637010136.425
1 2 0.5 3 Some random: 1670637010135.180
5 5 1 10 Some random: 1670637010136.670
1 2 0.5 3 Some random: 1670637010136.073
1 2 0.5 3 Some random: 1670637010136.785
1.6 5 0.32 6.6 Some random: 1670637010134.817
4 5 0.8 9 Some random: 1670637010137.372
1 2 0.5 3 Some random: 1670637010138.223
2 3 0.67 5 Some random: 1670637010138.512
1 2 0.5 3 Some random: 1670637010138.213
1 0 0 1 Some random: 1670637010141.064
2 3 0.67 5 Some random: 1670637010139.181
10 1 10 11 Some random: 1670637010150.809
1 1 1 2 Some random: 1670637010141.474
1 4 0.25 5 Some random: 1670637010139.447
1 1 1 2 Some random: 1670637010142.849
7 2 3.5 9 Some random: 1670637010147.671
1 1 1 2 Some random: 1670637010143.174
351 357 0.98 708 Some random: 1670637010137.773
7,567,953,414 1000000 7 Expression: [(7,567,953,414 + 1000000)] could not be calculated, Too many numbers or variables Some random: 7.183662838335186
25 23 1.09 48 Some random: 1670637010146.445
5 9 0.56 14 Some random: 1670637010140.594
13213 123123213 0 123136426 Some random: 1670513900145.428
8 9 0.89 17 Some random: 1670637010144.560
4 3 1.33 7 Some random: 1670637010147.209
123 123 1 246 Some random: 1670637010146.853
10 5 2 15 Some random: 1670637010151.460
2 2 1 4 Some random: 1670637010147.867
4 4 1 8 Some random: 1670637010147.085
4 4 1 8 Some random: 1670637010147.529
12 12 1 24 Some random: 1670637010148.726
1 2 0.5 3 Some random: 1670637010147.856
2 3 0.67 5 Some random: 1670637010148.604
1 2 0.5 3 Some random: 1670637010148.778
1,5 1,2 1 Expression: [(1,5 + 1,2)] could not be calculated, Too many numbers or variables Some random: 1.576500619568440
5 5 1 10 Some random: 1670637010150.296
1 2 0.5 3 Some random: 1670637010149.710
2 2 1 4 Some random: 1670637010151.688
2 3 0.67 5 Some random: 1670637010150.860
10 5 2 15 Some random: 1670637010156.792
1 2 0.5 3 Some random: 1670637010151.154
1 2 0.5 3 Some random: 1670637010111.861
1 2 0.5 3 Some random: 1670637010111.502
0 1 0 1 Some random: 1670637010112.522
10 20 0.5 30 Some random: 1670637010103.691
54 34 1.59 88 Some random: 1670637010133.128
2 5 0.4 7 Some random: 1670637010111.116
1 2 0.5 3 Some random: 1670637010113.670
2 3 0.67 5 Some random: 1670637010114.794
3 4 0.75 7 Some random: 1670637010114.851
1 2 0.5 3 Some random: 1670637010114.129
12 9 1.33 21 Some random: 1670637010119.818
3 4 0.75 7 Some random: 1670637010115.434
100 200 0.5 300 Some random: 1670637010026.630
1000 3 333.33 1003 Some random: 1670637011123.855
10 5 2 15 Some random: 1670637010132.118
20 40 0.5 60 Some random: 1670637010107.708
0 101 0 101 Some random: 1670637010027.771
3 3 1 6 Some random: 1670637010128.401
1 2 0.5 3 Some random: 1670637010127.103
1 23 0.04 24 Some random: 1670637010107.571
20 30 0.67 50 Some random: 1670637010119.362
20 50 0.4 70 Some random: 1670637010100.162
5 2 2.5 7 Some random: 1670637010133.311
8 9 0.89 17 Some random: 1670637010129.416
7 7 1 14 Some random: 1670637010131.835
100 200 0.5 300 Some random: 1670637010031.723
3 3 1 6 Some random: 1670637010132.522
4 2 2 6 Some random: 1670637010134.446
10 20 0.5 30 Some random: 1670637010122.146
1 6 0.17 7 Some random: 1670637010128.667
1 1 1 2 Some random: 1670637010133.481
1 2 0.5 3 Some random: 1670637010133.422
1 2 0.5 3 Some random: 1670637010133.485
1 1 1 2 Some random: 1670637010134.085
0.2 1 0.2 1.2 Some random: 1670637010134.549
4 2 2 6 Some random: 1670637010137.469
3 3 1 6 Some random: 1670637010136.993
2 3 0.67 5 Some random: 1670637010135.756
1 1 1 2 Some random: 1670637010149.711
3 3 1 6 Some random: 1670637010149.852
22 5 4.4 27 Some random: 1670637010167.904
75 25 3 100 Some random: 1670637010200.425
10 5 2 15 Some random: 1670637010155.778
1 2 0.5 3 Some random: 1670637010150.039
3.8 1.2 3.17 5 Some random: 1670637010153.842
1.13 5.456 0.21 6.586 Some random: 1670637010148.597
1.54467 0.00003 51489 1.5447 Some random: 1670637010154.212
1.761 3123.87 0 3125.631 Some random: 1670637007029.904
154.21 123.00 1.25 277.21 Some random: 1670637010185.007
12.00 132.00 0.09 144 Some random: 1670637010033.670
153.00 21.00 7.29 174 Some random: 1670637010285.812
132.00 123.001 1.07 255.001 Some random: 1670637010163.657
123, 312.51 0.39 435.51 Some random: 1670637009964.777
1.23334 5122 0 5123.23334 Some random: 1670637005034.291
54.12 00.09 54 NA Some random: 54.64754096601811
123 0.1 1230 123.1 Some random: 1670637010279.042
1 1 1 2 Some random: 1670637010156.002
1 1 1 2 Some random: 1670637010159.243
1 2 0.5 3 Some random: 1670637010159.176
12 32 0.38 44 Some random: 1670637010140.823
1 1 1 2 Some random: 1670637010161.769
2 1 2 3 Some random: 1670637010162.106
1 2 0.5 3 Some random: 1670637010160.626
.10 .10 Expression: [(ROUND(.10 / .10,2))] could not be calculated, Unknown operator '.' at position 8 Expression: [(.10 + .10)] could not be calculated, Unknown operator '.' at position 2 Expression: [CONCAT("Some random: ", ((RANDOM() + .10 - .10 + NOW())))] could not be calculated, Unknown operator '.' at position 38
2 3 0.67 5 Some random: 1670637010161.747
5 10 0.5 15 Some random: 1670637010158.831
1 1 1 2 Some random: 1670637010163.335
1 2 0.5 3 Some random: 1670637010162.759
1,5 2 1 Expression: [(1,5 + 2)] could not be calculated, Too many numbers or variables Some random: 1.126934700436670
1 2 0.5 3 Some random: 1670637010163.891
2 5 0.4 7 Some random: 1670637010162.963
3 7 0.43 10 Some random: 1670637010161.231
3 3 1 6 Some random: 1670637010165.374
1 1 1 2 Some random: 1670637010166.276
4 5 0.8 9 Some random: 1670637010165.976
2.3 2.1 1.1 4.4 Some random: 1670637010166.314
4 4 1 8 Some random: 1670637010167.076
7 7 1 14 Some random: 1670637010167.354
1 2 0.5 3 Some random: 1670637010167.125
2 3 0.67 5 Some random: 1670637010167.859
1 2 0.5 3 Some random: 1670637010167.251
1 2 0.5 3 Some random: 1670637010168.970
4 3 1.33 7 Some random: 1670637010172.977
1 2 0.5 3 Some random: 1670637010170.296
3 4 0.75 7 Some random: 1670637010171.080
1 2 0.5 3 Some random: 1670637010171.823

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