Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can you do simple calculation in a Confluence Page Template?

Khanh Nguyen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 27, 2011

In the online doc: http://confluence.atlassian.com/display/DOC/Creating+a+Page+using+a+Template

the example shows an Order Form with Product, Quantity, Price and Total.

My question is: Is there a way to not have to enter the Total and have that be calculated (Quantity * Price)?

Is this possibel in Confluence? Can this be done as part of the page template?

Thanks!

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Khanh Nguyen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2011

Another idea I found was to create a User Macro and insert some javascript to do calculation of the "fields" -- you do have to match up the User Macro to the fields used in the Page Template. . . but it does work!

0 votes
CelesteCS October 2, 2014

Hello!

For any calculations in Confluence, including calculations over tables, you may use CelesteCS Math for Confluence. There are versions for both Confluence Server and Confluence Cloud.

Assume you have a table with three rows and four columns: A till D with two rows and want to summarize elements from B2 to D2. Then here is the formula you should specify in A2:

SUM(Table1.B2:D2)

If you want to calculate average value, use AVG function:

AVG(Table1.B2:D2)

As you see, it is very simple and is similar to EXCEL with equal set of functions.

There is a plenty of other functions in the macro, so you may perform any calculations using formulas in EXCEL style.

Thanks!

0 votes
David Peterson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 28, 2011

Hi there,

To achieve this, you will need to use a combination of either Scaffolding or Metadata, along with the Reporting Plugin. Note that Scaffolding and Reporting currently only work up to Confluence 3.5, not 4.0. For example, based on the link you posted:

------------

{table-data:Items}

|| Product || Quantity || Price || Total ||

| {text-data:Product} | {number-data:Quantity} | {number-data:Price||format='$'#,##0.00} | {eval-data:Total|format='$'#,##0.00}${Quantity} * ${Price}{eval-data} |

{table-data}

*Grand Total:* {eval-data:Grand Total|format='$'#,##0.00}sumtable("Items", "Total"){eval-data}

------------

The above actually just uses the Scaffolding plugin, but Reporting can give you even more power, particularly if you want to work with multiple pages using the same template. The other advantage of Scaffolding is that when you hit 'Edit' again, you still get nice form fields to fill out, rather than the text just becoming another part of the page.

Hope that helps!

Khanh Nguyen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2011

Another idea I found was to create a User Macro and insert some javascript to do calculation of the "fields" -- you do have to match up the User Macro to the fields used in the Page Template. . . but it does work!

Raju May 30, 2019

Hello Khanh,

Can you share those script here please.

Like Roger Skog likes this
TAGS
AUG Leaders

Atlassian Community Events