Azure Data Factory: Difference Between Two Record Values

Holomew 26 Reputation points
2021-06-09T17:56:04.773+00:00

Looking for a way in Azure Data Factory to get the difference of the same column from the latest record to next-latest record.

For example, how to create the "Difference" column here:

ID Value Difference
04 230 25
03 205 0
02 205 5
01 200

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

1 answer

Sort by: Most helpful
  1. PRADEEPCHEEKATLA-MSFT 88,471 Reputation points Microsoft Employee
    2021-06-10T11:28:24.12+00:00

    Hello @bartnoble,

    Welcome to Microsoft Q&A Platform.

    We can achieve this using Dataflows. Please do check the below steps in detail:

    Step1: Add two source transformations with your source data (because we need to do self-join in upcoming steps)

    104262-sourcetransformations.gif

    Step2: Perform Self-join using Join transformation

    104271-jointransformation.gif

    Step3: Select transformation to rename few columns as temp Columns

    104196-select1.gif

    Step4: Filter transformation to take only rows which we are interested

    104187-filter1.gif

    Step5: Select transformation to remove TempID Column

    104147-select2.gif

    Step6: Derived Column transformation to generate Difference column

    104263-derivedcol1.gif

    Step7: Select transformation to remove TempValue Column

    104148-select3.gif

    Step8: Sink transformation to load data in to desired sink resource

    104127-sink1.gif

    Hope this helps. Do let us know if you any further queries.

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

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    3 people found this answer 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.