Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
What is an Analysis Action?
An
Analysis Action action runs analysis on tables. For more information about running tables, see Analysis Models for Batch Processing Data. Insert excerpt _run_analysis_icon _run_analysis_icon nopanel true
Note |
---|
Analysis actions only allow transactional tables with a Period of Transactional to be included to ensure correct model operation. |
Example
In a weather application, a user can search for the weather data for any location using a form field connected to an actionflow.
The actionflow is set up as follows:
Each time the application user runs the action, the calculate node selects a number from a sequence to add the ForecastID identifier. When the subsequent analysis node runs, it saves the ForecastID to the tables that are being run.
The expressions in the tables can reference:
- the ForecastID identifier.
'_context.ForecastID'
- The location provided by the user '_context.Location'.
The location value is sent in an API call using HTTP collectors connected to a HTTP datasource, as shown in the following analysis model:
Using Context Parameters
Tables that are being run may rely on context parameters in their attribute expressions. Adding attributes with the same name as the context parameters to the analysis node will work in the same way.Creating Analysis Actions
- Click and drag the
Analysis action icon from the toolbar onto the canvasInsert excerpt _run_analysis_icon _run_analysis_icon nopanel true - Enter a name for the Analysis action, then select Create Action
- In the Analysis action
on the right, populate the following details, as requiredInsert excerpt _property_settings _property_settings nopanel true
Tables
Add tables to this list to run analysis on when the Actionflow is triggered. Analysis is ran simultaneously on all tables in this list.
- To add a table, in the Tables section click the
icon to open a list of tables for the application in the RepositoryInsert excerpt _tables _tables name icon nopanel true - Drag a table from the list into the Tables section
Input Parameters & _Context
Attributes mapped into Analysis actions can be used in the attribute expressions on the table using the internal variable _context, e.g._context.AttributeName.
To do this, add attributes to the Input Parameters section of the Analysis action properties using the same name as in the Expression for the attribute on the table.
For example, if a table relies on the expression '_context.Name'
, an attribute called 'Name'
can be added to the analysis nodeAnalysis action. The value for this can then be mapped to this attribute from any preceding connection.
Example Uses
If your table contains a Last Updated attribute, you can use Input Parameters and the _context variable to map an Output Attribute containing the expression now or today from a Calculate action onto the Input Parameters on the Analysis action, and then into the table using the _context variable.
Advanced
When an Analysis action is used in an Actionflow, the records are processed in parallel. While we can control the order records exit an Analysis action, we cannot control the order they are processed.
Insert excerpt _check_
box_
tick _check_
Prioritise Throughput Over Ordering to process records in parallel to optimise performance. This means the order records are processed is nondeterministic.box_tick nopanel true
When disabled (default), records are processed in the order they are provided.
_parentHTML Comment | ||
---|---|---|
| ||
|
|
Basic Settings
We recommend that you always enter a description to explain the purpose of this item.
Tables
This section has a toolbar with standard buttons. The grid contains a list of tables.
To add a table, in the section toolbar clickAdvanced
hidden | true |
---|
Worked Example
Here is a worked example using the Retail Data (available from the Learning Centre).
In this example, we are using:
- A Shop Stock screen containing a grid of the Shop Stock data, a pie chart of the Shop Stock data and a grid of the Shop Departments data - this screen was created using the Multi-Tile template
Tip |
---|
If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Intermediate Application. For these example, we'll be working on the Shop Stock screen. |
Import Bulk Stock
In this example, we'll set up an Actionflow that runs analysis on a table importing a bulk stock delivery and we'll map values into this data. As an optional process, we'll combine this bulk stock delivery with our existing stock and display this on the Shop Stock screen.
Review Tables
- Open the Analysis Model, Actionflow Intermediate Data
- Click on the tables to review the data
- The Shop_Stock_Processed table contains the data on your Shop Stock screen and ERD
- The Shop_Stock_Additional_Processed table represents a new delivery of stock into your warehouse and requires combining into main stock data
- This is the table we will run analysis on as part of this example
- Note that this table has a Period of Transactional, which will allow us to run analysis on it via the Actionflow
Actionflow Setup
- On the Shop Stock screen, add an Actionflow to the icon
- Set the Input to
Insert excerpt _actionflow_on_click _actionflow_on_click nopanel true - Add a
action to the canvas and connect theInsert excerpt _action_calculate _action_calculate nopanel true
node to itInsert excerpt _input _input nopanel true - On the Calculate action, add two Output Attributes:
- Name:
distributionCentreID
- Type:
Integer
- Expression:
1001
- Type:
- Name:
distributionCentre
- Type:
String
- Expression:
"North"
- Type:
- Name:
- Add a
action to the canvasInsert excerpt _action_analysis _action_analysis nopanel true - On its Properties, in the Tables section, click the
iconInsert excerpt _tables _tables name icon nopanel true - Drag across the Shop_Stock_Additional_Processed table from the Repository to the Analysis action properties
- Connect the Calculate action to the Analysis action and map across both attributes
- Click on the Analysis action to view these two attributes in the Input Parameters
Table Attributes Setup
- On the Analysis Model, Actionflow Intermediate Data, click on the table, Shop_Stock_Additional_Processed
- Double-click on the attribute, distributionCentreID, and change the Expression to
_context.distributionCentreID
- This is then referring to the attribute setup on the Calculate action
- Make the same change for the attribute, distributionCentre, so it too is referring to the attribute set on the Calculate action
- Save the Analysis Model
At this point, you can run the Actionflow and see the results of the Actionflow in the Shop_Stock_Additional_Processed table, which will now contain 50 records, along with the values for Distribution Centre ID and Distribution Centre as set in the Calculate action.
Optionally, follow the additional steps below to combine the new stock data with our existing stock data and display it on the Shop Stock screen.
Combine Data & Display (Optional)
- On the Actionflow, create a
action with the Primary Table, Shop_Stock_Additional_Processed, and connect the Analysis action to the View actionInsert excerpt _action_view _action_view nopanel true - In its Properties, in the Data Retrieval Options section, set the Data Range to Latest
- This will ensure that this data isn't continuously added if the Actionflow is run repeatedly
- For the Output Attributes section, click the
icon and drag across all attributesInsert excerpt _attributes_icon _attributes_icon nopanel true
- In its Properties, in the Data Retrieval Options section, set the Data Range to Latest
- Create a
action to save the data to the Shop_Stock_Processed tableInsert excerpt _action_save _action_save nopanel true - In its Properties, in the Basic Settings section, set the Type to Insert and
toggle on Auto Save AttributesInsert excerpt _toggle_on _toggle_on nopanel true
- In its Properties, in the Basic Settings section, set the Type to Insert and
- Connect the View to the Save action and map across all attributes
Expand title Checkpoint - On the Shop Stock screen, run the Actionflow by pressing Import New Stock
- The additional 50 records will be added to the Available Stock grid
Tip |
---|
If you go wrong at any point and alter your data in an unexpected way, you can roll back your training data to its original state - see Rolling Back Test Data. |