Time for action – creating a new formula

  1. We will use the formula editor to create a new formula that multiplies the Amount and Quantity. Then we will place it in the Details section so it makes its calculation row by row. Finally, we will change the type of object for the Amount and change the format in which the numbers are presented. We will create a formula to make a calculation based on the Amount and Quantity of each of the rows and place this value under the label Total. We choose the Data tab, right-click on Functions, and choose the Add Functions... option:
    Time for action – creating a new formula
  2. In the new window, we go to Common | Open Formula and click on OK.
    Time for action – creating a new formula
  3. We will configure the formula we just created. First, we change its name:
    • Function Name = FormulaTotal
  4. Next, we specify the calculation that this formula will make. We press the Time for action – creating a new formula button to the right of the formula. This will open the formula editor.
  5. In the lower-right portion of the formula editor, we see only the = sign where it says Formula:.
  6. The calculation that we want to make is a multiplication of the sum_amount and count_rental fields. To choose the sum_amount field, we press the Time for action – creating a new formula button and choose [sum_amount]. Let's see how our formula is coming along:
    Time for action – creating a new formula
  7. Next, we add the multiplication sign by either typing it from the keyboard or pressing the Time for action – creating a new formula button.
  8. Finally, we press the Time for action – creating a new formula button again, but this time we choose count_rental. Our formula should look like this:
    Time for action – creating a new formula

    Done! We have created our first formula.

  9. When you add a field to the formula, use the following nomenclature:
    [field_name]

    Now we press OK to continue. We add the recently created formula (FormulaTotal) to the Details section under the Total label:

    Time for action – creating a new formula

    If we choose FormulaTotal and look at Attributes.type, we see that it is a Text-field type object; this means we cannot apply the same format to it as we did in the previous chapter with sum_amount.

    Note

    Remember that what we did with sum_amount was configure its Attributes.format attribute with the value $ #,##0.00;($ #,##0.00). We were able to do this because sum_amount is a Number-field type object.

  10. Next, we will convert the FormulaTotal object to Number-field. To do so, we select FormulaTotal, and in the upper menu, we choose number-field by going to Format | Morph |.
  11. Next, we configure the following:
    • Attributes.format = $ #,##0.00;($ #,##0.00)

    Note

    Another way to do this is by adding a Number-field object to our report and assigning the value [FormulaTotal] to its Attributes.field attribute, and then configuring the desired format in Attributes.format.

What just happened?

We created a new formula. We did it by creating a function and then by going to Common | Open Formula. Next, we used the formula editor UI to create an expression that multiplies the fields Amount and Quantity. Finally, we added our formula to the Details section, so it will make its calculation row by row.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset