< Previous | Next >

Task 1-3: Defining the global aggregates

In this task, you define variables that store the calculated global aggregates for the solution.

About this task

Entity aggregates focus on an entity type in a model. The entity type in this scenario is the account type. Entity aggregates are run on a schedule, which you specify in its definition.

Event aggregates focus on event types. The event type in this scenario is the transaction type. Event aggregates do not have a schedule but are calculated every time that an event of the same type occurs.

In this tutorial, you define and use two global aggregates:
  • An entity aggregate that calculates daily the average balance of risky accounts so that you can monitor and respond to changes in the balance.
  • An event aggregate that calculates the average amount of the transactions that occur within the past 24 hours.

Each global aggregate that you create is in its own .agg file.

Procedure

  1. In the Solution Explorer view, click the MyCreditCardSolution project and then in the Solution Map view, click Define aggregates.
  2. On the Global Aggregate page, ensure that the BOM project that you created previously is specified: MyCreditCardSolutionBOM. Specify a name for the file as Average Risky Account Balance. The name that you specify is used as the name of the .agg file and as the default name of the global aggregate variable itself.
  3. Click Finish. An editor opens, populated with part of the syntax for the global aggregate:
    Define the global aggregate in the editor

    You define the aggregate by typing the expression, which is indicated as <expr>, similar to the way you create entities and events. However, the syntax is different. The completion menus prompt you with all possible entries.

  4. Create the following definition for the global entity aggregate:
    Definition for the global entity aggregate
    You can either type in the definition and use the completion menus, or copy and paste the following definition into the .agg file:
    define 'Average Risky Account Balance' as the average balance of all accounts , 
    	where the status of each account is Risky , 
    	evaluated every day at 1:00 AM 

    The first line defines the variable and its calculation. The where condition limits the calculation to only the accounts that have the Risky status. The schedule indicates how often the calculation is made. In this scenario, it runs once a day.

  5. Click Save.
  6. For the second aggregate, create a global event aggregate that finds the average amount of the transactions that occur within the past 24 hours:
    1. Create another .agg file with the name Average Transaction Amount Per Day.
    2. Define the global aggregate with the following definition. You can either type in the definition and use the completion menus, or copy and paste it into the .agg file:
      define 'Average Transaction Amount Per Day' as the average amount of all transactions , 
      	where the date of each transaction is during the last period of 1 day 
    3. Click Save.

Results

The global aggregates are defined and the modeling step is complete.
< Previous | Next >