Azure Data Factory – Data Flow – Pivot Transformation

The Azure Data Factory Data Flow Pivot transformation can be used to reshape the data from the previous post at https://blog.westmorr.com/2024/01/09/azure-data-factory-data-flow-aggregate-and-sort/.

In that post, the following data slice was generated to visualize the total number of maintenance tickets by type at each building:

The goal is to surface key patterns in buildings based on maintenance types. By listing each building once and applying the Azure Data Factory Data Flow Pivot transformation, we organize columns to display the counts of distinct maintenance types for each building. This presentation enables decision-makers to discern meaningful patterns and strategize resource allocation and costly repairs effectively.

To note, the Maintenance_Tickets table has entries such as:

The design is to group entries by Building_Id and pivot on Maintenance_Type. To do this, add the Pivot transformation to the data flow, and specify the following:

  1. Group by tab: add a single column, “Building_Id”
  2. Pivot key tab: specify the “Maintenance_Type” column
  3. Pivoted columns tab:
    • Keep “Column name pattern” select field as default
    • Add “Total_” to the prefix
    • Keep “Column arrangement” as default
    • Set the pivot expression to count(Maintenance_Type)

By grouping buildings, specifying maintenance types, and pivoting columns with a count expression, the aim is to create a clear and structured representation. This makes it easier to analyze and understand the total occurrences of each maintenance type per building.

Afterwards, the results are as required:

Conclusion

In leveraging the ADF data flow Pivot transformation, this post demonstrated an effective method for reshaping data. By showcasing the transformation of maintenance tickets to reveal the total count per Maintenance_Type, it highlights the power of ADF in simplifying complex data operations. This approach enhances clarity and aids decision-making in managing and addressing maintenance needs efficiently.

More documentation for Pivot is available at https://learn.microsoft.com/en-us/azure/data-factory/data-flow-pivot.



Categories: Azure Data Factory

Tags: , ,

Leave a Reply