• No se han encontrado resultados

4.2. CASO PRÁCTICO EN EL TIANGUIS DEL TRUEQUE SANTIAGO

4.2.1. La leña como moneda de cambio en el tianguis de Santiago

Creates a new row for each value in a column identified as a pivot column.

Use this node to change how the relationship between rows is displayed. For each value in a pivot column, it produces a row in the output data set. You can create pivot sets to specify more than one pivot column.

Note

Table 115: Parameters

Parameter Description

Name The name for the output target for the UnPivot operation.

Display Name The name shown in the Palette pane.

Note

This option can only be changed when creating a template. It cannot be changed when us­ ing the node outside of a template.

Description (Optional.) Provides a comment about the operation. For example, "Emergency Employee Contact table."

Sequence Attribute The name of the sequence attribute showing the number of rows that were created from the initial source.

Non-Pivot Attributes The list of columns from the source table that will appear in the target table without modifica­ tion.

Header Attribute The name of the column that will contain the Pivot Attribute column names.

Data Field Attribute The name of the column that contains the unpivoted data. This column contains all the values found within the columns that are converted to rows.

The data type of this column should be consistent with the data type of Pivot Attributes. Each column in the Pivot Set must have the same data type, length, and scale.

Pivot Attributes The list of columns to be rotated into rows in the output table.

Mappings

The mappings tab shows how the input column names are mapped to output column names. If you have a large table, you can use Filter pattern to search for specific columns. See "Using the Mapping Editor" topic in the SAP HANA Developer Guide.

Input data

Select the input data General tab by clicking Input_<n>.

Table 116: General

Option Description

Name The name of the input source. You can rename this source.

Table 117: Signature

Option Description

Name The column name in the input source. This can be named the same as the output from the previous node.

Type The type of data contained in the column, for example, Nvarchar, Decimal, Date, and so on.

Length The number of characters allowed in the column.

Scale The number of digits to the right of the decimal point. This is used when the data type is a deci­ mal.

Nullable Indicates whether the column can be blank.

Use the Add, Remove, Up and Down buttons to edit the input fields accordingly.

Table 118: Fixed Content

Option Description

Fixed Content Enable to have the input table of the node saved with the flowgraph file. Otherwise, it is placed in a separate table connected to the node. For more information, see the SAP HANA Developer

Guide topic "Flowgraphs".

Output data

Only one data target is allowed.

Select the output data General tab by clicking Output_<n>.

Table 119: General

Option Description

Name The name of the output target. You can rename this source.

Kind Identifies the type of output target. Table 120: Signature

Option Description

Name The column name in the input source. This can be named the same as the output from the previous node.

Type The type of data contained in the column, for example, Nvarchar, Decimal, Date, and so on.

Length The number of characters allowed in the column.

Scale The number of digits to the right of the decimal point. This is used when the data type is a deci­ mal.

Nullable Indicates whether the column can be null.

Annotations

Create comments for users. For example, you might want to make a note of some particular settings in this flowgraph so that the administrator can schedule or understand certain customizations. The annotations are written to a table. See the "Application Function Modeler" section of the SAP HANA Developer Guide.

All

Shows all of the options in one screen. It includes, General, Mappings, and Annotations.

Example

Suppose you have a table containing rows for your team's expenses, broken down by expense type. This table was previously pivoted on the Expense column, to separate the expenses into internal, travel, and miscellaneous columns.

Employee Manager_ID Internal_Expense Travel_Expense Misc_Expense

Lucas Broderick 7532 1800 5500 150 Shannon Ellis 8174 3000 0 800 Abhiram Krishna 3553 4200 8700 0

This table has expense numbers in several columns, and now you want to unpivot the table so that you can more easily calculate the expense summaries, without losing the expense type. Set the UnPivot options as follows.

Option Value Notes

Sequence attribute Sequence This orders the expense type categories. On output, you'll see the se­ quence 1-3 for each employee's expense type.

Non-pivot attributes Employee Select Employee to have the employee still output in a column.

Header attribute Expense_Type A new column will list the expense types: internal, travel, or miscellaneous. Data field attribute Amount A new column will list the expense amount for each employee's expense

type. Pivot attributes Internal_Expense

Travel_Expense Misc_Expense

These columns will become fields in a row.

The output data set includes the employee name (not pivoted) and new columns for the pivot sequence, expense type (pivot header), and actual expense data. The Manager_ID column is not listed in the pivot or non-pivot attribute, so it is not included in the output.

Employee Sequence Expense_Type Amount

Lucas Broderick 1 Internal_Expense 1800 Lucas Broderick 2 Travel_Expense 5500 Lucas Broderick 3 Misc_Expense 150 Shannon Ellis 1 Internal_Expense 3000 Shannon Ellis 2 Travel_Expense 0 Shannon Ellis 3 Misc_Expense 800 Abhiram Krishna 1 Internal_Expense 4200 Abhiram Krishna 2 Travel_Expense 8700 Abhiram Krishna 3 Misc_Expense 0

Now suppose that instead of containing one type of data (expenses), your source table contains two types of data: expenses and days traveling domestically and internationally.

Employee Domestic_Expense International_Expense Domestic_Days International_Days

Lucas Broderick 2000 5000 10 5 Shannon Ellis 3000 0 0 0 Abhiram Krishna 4800 800 15 1

You'll create a target table that has data in two columns: expenses and days. Therefore, you'll create two pivot sets. The first pivot set will pivot the expense columns.

Option Value Notes

Sequence attribute Sequence This orders the expense type categories. On output, you'll see the se­ quence 1-2 for each employee's expense type.

Non-pivot attributes Employee Select Employee to have the employee still output in a column. Header attribute Expense_Type A new column will list the expense types: domestic or international. Data field attribute Amount A new column will list the expense amount for each employee's expense

type. Pivot attributes Domestic_Expense

International_Expense

These columns will become fields in a row.

Click Add to create the second pivot set to pivot on the day columns.

Option Value Notes

Sequence attribute Sequence This orders the expense type categories. On output, you'll see the se­ quence 1-2 for each employee's expense type.

Non-pivot attributes Employee Select Employee to have the employee still output in a column. Header attribute Day_Type A new column will list the expense days: international or domestic. Data field attribute Days A new column will list the days that each employee traveled domestically

Option Value Notes

Pivot attributes Domestic_Days International_Days

These columns will become fields in a row.

In this case, the output data set includes the employee name (not pivoted) and new columns for the pivot sequence, expense type, expense data, day type, and day data.

Employee Sequence Expense_Type Amount Day_Type Days

Lucas Broderick 1 Domestic_Expense 2000 Domestic_Days 10 Lucas Broderick 2 International_Expense 5000 International_Days 5 Shannon Ellis 1 Domestic_Expense 3000 Domestic_Day 0 Shannon Ellis 2 International_Expense 0 International_Day 0 Abhiram Krishna 1 Domestic_Expense 4800 Domestic_Day 15 Abhiram Krishna 2 International_Expense 800 International_Day 1

5.29 Add a Variable to the Container Node