Dynamic Pivot Columns with a Total Column

Derek Horrall 201 Reputation points
2020-07-16T18:23:57.013+00:00

I have a Data Flow that pivots rows into columns. The columns of the pivot are dynamic, so a new column is created if there is a new row value automatically. What I want to do is dynamically also add a column that SUMS the pivot columns to create a TOTAL. Is this possible in a Data Flow?

12736-2020-07-16-14-17-02-book1-excel.png

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,222 questions
0 comments No comments
{count} votes

Accepted answer
  1. HarithaMaddi-MSFT 10,136 Reputation points
    2020-07-17T09:22:41.31+00:00

    Hi @DerekHorrall-5611,

    Welcome to Microsoft Q&A Platform.

    Below is one approach to implement the above requirement. I have used 2 sources in dataflow - one with pivoted and one is the original file as you mentioned to achieve this.

    Used below transformations -

    • Aggregate - This transformation is to summarize on original source before unpivoting to generate Total
    • Join - This transformation joins the above aggregate output with pivoted source data based on ID and adds Total field

    Attaching the GIF showing the same and source files to the answer.

    12609-pivotedsourcefile.png
    12803-originalsourcefile.png
    12766-dynamictotalcalculation.gif

    Hope this helps!

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.