Skip to main content
Recursion Tool ⭐️

The Recursion tool recursively calculates data across levels in a parent-child tree.

Updated over a week ago

Overview

The Recursion tool allows you to perform calculations row by row across all levels in a parent-child relationship tree within your dataset. This tool is designed to help you gain deeper insights and perform complex calculations within hierarchical data structures.

Use Cases

  • Recursively Calculate Data: The Hierarchy tool calculates data row by row across all levels in a parent-child tree, making it possible to analyze and manipulate hierarchical data effortlessly.

  • Trace Parent-Child Relationships: By specifying the unique IDs (ID and Parent ID), the Hierarchy tool recursively traces the relationship between parent and child rows, providing valuable insights into the structure of your data.

  • This tool outputs the depth and path for each row. The top-level parent in each family of rows has a depth of 1. The child of that row has depth 2, and so on. The path field gives the list of IDs from the top-level parent to the current row.

Example

Input

ID

Manager ID

Name

1

Jane

2

1

Pat

3

2

Alex

Output

ID

Manager ID

Name

Depth

Path

1

Jane

1

1

2

1

Pat

2

1 > 2

3

2

Alex

3

1 > 2 > 3

Configuration

⚠️ No Duplicate Pairs: Ensure that there are no duplicate pairs of the ID and Parent ID fields within your dataset. Duplicate pairs can disrupt the hierarchy calculation.

⚠️ Top-Level ID: Make sure that the top level of your hierarchy always has a value in the ID field. Without this value, the tool won't be able to establish the hierarchy correctly.

  1. Select ID Field: Choose the field in your dataset that represents the unique ID for each individual row. For example, you might select "Employee ID."

  2. Select Parent ID Field: Specify the field that contains the ID of the specific row's parent. This establishes the parent-child relationship within your data.

  3. Aggregation (Optional): You can add aggregation to your hierarchy calculations to perform specific calculations on the data. To do this:

    a. Click the plus sign (+) to add an aggregation.

    b. Select an argument for your aggregation.

    c. Define your calculation, new field name, and select a delimiter if needed.

  4. Click "Apply" to save your settings.


Output Fields

The Recursion Tool generates specific output fields that you can use in your analysis. Here are the key output fields:

  1. Depth: This field represents the depth or path from the top of the hierarchy to the current row, including the current row.

  2. Path: Path is a concatenation of the hierarchy of the impacted employee IDs that Savant recursively traces from parent to the current row.

Did this answer your question?