Skip to end of banner
Go to start of banner

Storing Data and Using that Data for Calculations

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Current »

Overview

Create a table that can store number data. These numbers can then be used to calculate other values.

Ingredients

Apps

Scaffolding

Macros

Table Data

Guide

Create a table

  • insert a Table Data macro

    • name it "purchaseTable"

  • edit the parameters

    • set Initial Rows is 1

Inside the Table Data macro

  • create a 4x2 table as below

    • add to teach column in the header row Item; Unit Price; Quantity; Total Price

Item

Unit Price

Quantity

Total Price







For this example, add the following names for each macro

In the Evaluate Data macro

  • type the following code:

${unitPrice} * ${quantity}

The Evaluate Data macro should now look as below.

Adding hidden stored data

Underneath the Table Data macro you created above

The Hidden Data macro is used when you want to enter data that you would rather not show to the reader of the page.

In the Hidden Data macro

  • add two Number Data macros

    • name them "discount" and "tax"

    • choose Allow Decimal Values for each

Adding calculations

It's now time to make Scaffolding 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


For each Evaluate Data macro

  • enter the following in the Display Format properties

    $ #,##0.00

Type in the following codes in the respective Evaluate Data macros

  • Net Total

    sumtable("purchaseTable","totalPrice")
  • Discount Amount

    ${netTotal} * ${discount} / 100
  • Tax Amount

    ${netTotal} * ${tax} / 100
  • Grand Total

    ${netTotal} - ${discAmt} + ${taxAmt}


The Evaluate Data macros should look similiar to the following.


  • Save/Update the page

  • choose Edit Contents

    • input the values "10" and "0.5" respectively for the Discount percentage and Tax percentage fields

Result


  • No labels