Snowflake Transformation
Snowflake Transformation is used in the Enterprise version of process.science for Power BI to prepare the data. The package is designed to transform the data from the Snowflake database into a form that is suitable for Power BI. It creates four tables that can be used for analysis in Power BI.
Preparing the input table
Before the scripts can be used, you must ensure that your input table meets the following requirements. The column names for case_id, activity and timestamp are fixed and must be present in your input table. The other names can be changed in the script.
| Field Name | Description | Data Type | Mandatory |
|---|---|---|---|
case_id | Through this field the process instances can be differentiated. | STRING | ✓ |
activity | This field describes the activity that has taken place. | STRING | ✓ |
activity_grouped | This field describes the group of the activity that has taken place. | STRING | ✗ |
timestamp | This field describes when an event has taken place. | TIMESTAMP_* | ✓ |
timestamp_end | This field can be used to calculate the duration of activities. | TIMESTAMP_* | ✗ |
sort_key | This field can be used to adjust the sorting of the event log. | NUMBER | ✗ |
value | This allows you to set the costs for the current event. | NUMBER | ✗ |
automated | This allows you to set wether the activity was automated or not. | NUMBER | ✗ |
resource | This allows you to set user information for each activity.â | Any | ✗ |
Additional Activity Values | Further information per activity, e.g. quantity of items. All fields, not matching other names will be mapped as additional activity values and will be stored in the newly created event log table. | Any | ✗ |
Additional Cases Values | Further information per case, e.g. a company division. All fields starting with case_ will be mapped as additional cases values and will be stored in the newly created cases table. | Any | ✗ |
Additional Activity Values Grouped | Further information per activity group, e.g. quantity of items. All fields ending with _grouped will be mapped as additional activity group values and will be stored in the newly created event log table. | Any | ✗ |
Downloading the scripts
The scripts can always be downloaded in the latest version from our Self Service Portal. The scripts are contained in a ZIP file and must be unpacked.
Installation and configuration
Customise schema and database
If the output schema is not PUBLIC and the table is not PSTEST, you must adapt the scripts to use the correct schema and database. To do this, replace PUBLIC with the desired schema and PSTEST with the correct database.
Creating the static tables
- open the script
1_CreateStaticTables.sqland execute it in your database. - the script creates the tables
filter_and,filter_orand if the grouped calculation is to take place also the tablesfilter_and_grouped,filter_or_groupedandactivity_group_mapin your output schema.
This script must be executed whenever the structure of the input table changes.
Creating the procedures
The next step is to create the procedures that write the data to the tables. To do this, the scripts 2_CreateEventLogProcedure.sql, 3_CreateEventLogGroupedProcedure.sql, 4_CreateAdditionalGroupedTablesProcedure.sql , 5_CreateCasesDataProcedure.sql must be executed. This only needs to be done once.
Event log
The procedure ps_createEventLogDataTable creates the table eventlog in your output schema and fills it with the data from the input table. All additional columns that do not begin with case_ or end with _grouped are stored in the eventlog table.
CREATE OR REPLACE PROCEDURE ps_createEventLogTable(
SCHEMA_NAME STRING,
TABLE_NAME STRING,
ACTIVITY_GROUPED_NAME STRING,
TIMESTAMP_END_NAME STRING,
VALUE_NAME STRING,
AUTOMATED_NAME STRING,
RESOURCE_NAME STRING,
SORT_KEY_NAME STRING
)If the dynamic columns (timestamp_end, sort_key, value, automated and resource) are not present in the input table, they are automatically filled with default values.
Event log grouped
The procedure ps_createEventLogGroupedTable creates the table eventlog_grouped in your output schema and fills it with the data from the input table. This script is only executed if the grouped calculation is to take place, i.e. the activity_grouped column is present in the input table. All additional columns with the suffix _grouped are saved in the eventlog_grouped table.
CREATE OR REPLACE PROCEDURE ps_createEventLogGroupedTable(
SCHEMA_NAME STRING,
TABLE_NAME STRING,
ACTIVITY_GROUPED_NAME STRING,
TIMESTAMP_END_NAME STRING,
VALUE_NAME STRING,
AUTOMATED_NAME STRING,
RESOURCE_NAME STRING,
SORT_KEY_NAME STRING
)Filter tables
The procedure ps_createFilterTables creates the tables filter_and and filter_or.
CREATE OR REPLACE PROCEDURE ps_createFilterTables(
SCHEMA_NAME STRING
)Additional grouped tables
The procedure ps_createAdditionalGroupedTables creates the tables filter_and_grouped and filter_or_grouped. This procedure is only executed if the grouped calculation is to take place.
CREATE OR REPLACE PROCEDURE ps_createAdditionalGroupedTables(
SCHEMA_NAME STRING
)Cases table
The procedure ps_createCasesDataTable creates the table cases_data in your output schema and fills it with the data from the input table. All additional columns beginning with case_ are stored in the cases_data table.
CREATE OR REPLACE PROCEDURE ps_createCasesDataTable(
SCHEMA_NAME STRING,
TABLE_NAME STRING,
ACTIVITY_GROUPED_NAME STRING
)Loading the data
To load the data, the script 7_CreateMainProcedure.sql must be executed. This script creates a procedure that calls all other procedures that write the data to the tables. The procedure is called with the customised table and column names.
CREATE OR REPLACE PROCEDURE ps_mainProcedure(
SCHEMA_NAME STRING,
TABLE_NAME STRING,
ACTIVITY_GROUPED_NAME STRING,
TIMESTAMP_END_NAME STRING,
VALUE_NAME STRING,
AUTOMATED_NAME STRING,
RESOURCE_NAME STRING,
SORT_KEY_NAME STRING
)Execute the main procedure
To write the data to the tables, call the procedure ps_mainProcedure. The procedure is called with the customised table and column names.
CALL ps_mainProcedure('O2C', 'AUTOMOTIVE_EN', 'ACTIVITY_GROUPED_NAME', 'TIMESTAMP_END_NAME', 'VALUE_NAME', 'AUTOMATED_NAME', 'RESOURCE_NAME', 'SORT_KEY_NAME');