Store data and use that data for calculations
On this page: |
---|
Overview
Create a table that can store number data. These numbers can then be used to calculate other values.
Ingredients
App | Scaffolding |
---|---|
Macro | Table Data |
Guide
Step 1 - Create a table
Insert a Table Data macro and name it
purchaseTable
.Edit the parameters and set Initial Rows as
1
.Create a 4x2 table inside the Table Data macro.
Add the following names in the header row:
Item | Unit Price | Quantity | Total Price |
---|---|---|---|
Insert a Text Data, Number Data and Evaluate Data macro respectively into each table cell under each header as shown:
For this example, add the following names for each macro
Text Data:
item
Number Data:
unitPrice
Number Data:
quantity
Evaluate Data:
totalPrice
Type the following code in the Evaluate Data macro:
${unitPrice} * ${quantity}
The macro looks as shown:
Step 2 - Add hidden stored data
Create a Hidden Data macro under the Table Data macro created in the above section.
The Hidden Data macro is used when you want to enter data to be hidden from the reader of the page.
Add two Number Data macros in the Hidden Data macro.
Name them
discount
andtax
.Set Allow Decimal Values as true for both macros as shown:
Step 3 - Add calculations
Let’s use Scaffolding to do some math and calculate the following:
Net Total (excluding tax and discount)
Discount Amount
Tax Amount
Grand Total (including tax and discount)
Add four Evaluate Data macros for each of the values above and give them relevant names, as below.
Enter the following in the Display Format properties for each Evaluate Data macro:
$ #,##0.00
Type the following codes into the respective Evaluate Data macros:
Net Total
sumtable("purchaseTable","totalPrice")
Discount Amount
Tax Amount
Grand Total
The Evaluate Data macros must look similar to the following image:
Save the page
Click Edit Contents and in the Hidden Data macro:
Input the value
10
for the Discount percentage field.Input the value
0.5
for the Tax percentage field.
Click Publish.