Azure Data Factory: Aggregate By Day But Keep Original Timestamp Column

Holomew 26 Reputation points
2021-06-10T12:35:50.93+00:00

I would like to aggregate by maximum value for a day.

To achieve this, I'm casting the original timestamp type to a date type and using maximum for that day.

However, I lose the original timestamp which I'd like to keep.

For example, the incoming data:

ID Value Timestamp
ABC 11 2021-06-10T07:33:21
ABC 2 2021-06-10T03:28:04
ABC 14 2021-06-10T05:45:17

So I cast the timestamp to date type then I'm aggregating by maximum(Value) and grouping by ID and the newly-created date column (no timestamp) to get the max value for that ID and day. But I'd like to keep the timestamp also. e.g.:

ID Value Date Timestamp
ABC 14 2021-06-10 2021-06-10T05:45:17

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

Accepted answer
  1. MarkKromer-MSFT 5,211 Reputation points Microsoft Employee
    2021-06-10T19:52:38.447+00:00

    In your Derived Column, create a new column instead of overwriting the original Timestamp column. Call it something like 'date_for_agg'. You can use a Select to remove the temp column from your flow or just drop it in the Sink mapping.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. KranthiPakala-MSFT 46,462 Reputation points Microsoft Employee
    2021-06-18T06:36:14.75+00:00

    Hi @bartnoble,

    In addition to Mark Kromer's input, sharing the implementation GIF below to achieve the above requirement, as it can be beneficial for others reading this thread.

    106790-image.png

    Here is the GIF:

    106885-dataflowaggregateadddatecolumn.gif

    Hope this helps.

    ----------

    Please don’t forget to Accept Answer and Up-Vote wherever the information provided helps you, this can be beneficial to other community members.

    2 people found this answer helpful.
    0 comments No comments

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.