With the Restructure node, you can generate multiple fields
based on the values of a nominal or flag field. The newly generated fields can contain values from
another field or numeric flags (0 and 1). The functionality of this node is similar to that of the
Set to Flag node. However, it offers more flexibility by allowing you to create fields of any type
(including numeric flags), using the values from another field. You can then perform aggregation or
other manipulations with other nodes downstream. (The Set to Flag node lets you aggregate fields in
one step, which may be convenient if you are creating flag fields.)
Figure 1. Restructure node
Example
Copy link to section
For example, the following dataset contains a nominal field,
Account, with the values Savings and Draft. The
opening balance and current balance are recorded for each account, and some customers have multiple
accounts of each type. Let's say you want to know whether each customer has a particular account
type, and if so, how much money is in each account type. You use the Restructure node to generate a
field for each of the Account values, and you select
Current_Balance as the value. Each new field is populated with the current balance
for the given record.
Table 1. Sample data before
restructuring
CustID
Account
Open_Bal
Current_Bal
12701
Draft
1000
1005.32
12702
Savings
100
144.51
12703
Savings
300
321.20
12703
Savings
150
204.51
12703
Draft
1200
586.32
Table 2. Sample data after
restructuring
CustID
Account
Open_Bal
Current_Bal
Account_Draft_
Current_Bal
Account_Savings
_Current_Bal
12701
Draft
1000
1005.32
1005.32
$null$
12702
Savings
100
144.51
$null$
144.51
12703
Savings
300
321.20
$null$
321.20
12703
Savings
150
204.51
$null$
204.51
12703
Draft
1200
586.32
586.32
$null$
Using the Restructure node with the Aggregate node
Copy link to section
In many cases, you may want to pair the Restructure node with an Aggregate node. In the previous example, one customer (with the ID
12703) has three accounts. You can use an Aggregate node to calculate the total balance for each
account type. The key field is CustID, and the aggregate fields are the new
restructured fields, Account_Draft_Current_Bal and
Account_Savings_Current_Bal. The following table shows the results.
Table 3. Sample data after restructuring and aggregation
CustID
Record_Count
Account_Draft_Current_
Bal_Sum
Account_Savings_Current_
Bal_Sum
12701
1
1005.32
$null$
12702
1
$null$
144.51
12703
3
586.32
525.71
More informattion
Copy link to section
Tips:
In many cases, a Type node is required upstream from a Restructure node. For details about the
Type node, see Type node and its many subsections.
After double-clicking a node to work with its properties, you can hover over tool tips to see
helpful information about various node properties.
Tutorials are available to introduce you to various modeling methods and techniques. See Tutorials.
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.