Transpose Data using ADF

Arul Karthic 26 Reputation points
2021-11-16T17:21:30.48+00:00

Hi,

It would be great if you could help me with the below scenario in ADF.

I have received the file in the following format and a new column will be added at the end for every week. Basically, this file will get dynamic column addition for the entire year.
For example: on 22/11/2021 new column will get added at the end as 14/11/2021 - 21/11/2021

Below is the sample source data.

149839-image.png

We want to transpose the data in the following format to load into the target table(Azure sql).

149817-image.png

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

Accepted answer
  1. svijay-MSFT 5,256 Reputation points Microsoft Employee Moderator
    2021-11-17T15:02:53.44+00:00

    Hello @Arul Karthic ,

    Thanks for the question and using MS Q&A platform.

    You could achieve your requirement using unpivot and pivot activity.

    150233-image.png

    Source data :

    150159-image.png

    Unpivot Action

    You can configure the Unpivot Action as below :

    150291-image.png

    Ungroup By : Type

    This is the Type Column from the source. Note the upper case 'T 'in Type.

    UnPivot Key : type

    This is new column name - I saw in your example you had type in both scenario. So I continued to have the same. Alternatively, you could provide a diff name - like date etc. to avoid confusion

    Unpivoted Columns: Value

    Value is the name I have given at my end with String as the datatype.

    You are converting the data in the format date:product:value

    Output of the Unpivot Action

    150281-image.png

    Pivot Action

    150253-image.png

    Group By : Unpivot1@type

    This is the Unpivot Key we used in the previous step (t - lower case)

    Pivot Key : Unpivot1@type

    Pivoted Columns : first(Value)

    Output of Pivot :

    150311-image.png

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    3 people found this answer helpful.

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.