Filter is not working in Dataflow in ADF

siva prasad kukati 20 Reputation points
2023-07-07T09:36:31.7666667+00:00

We are looking to get 1year data from current date based on PurchaseDocumentCreatedDateTime column in dataflow. .Below expression is not working.

toTimestamp(PurchaseDocumentCreatedDateTime) >= toTimestamp(addDays(currentDate('UTC'),-365), 'yyyy-MM-dd HH:mm:ss.SSS','en-US')

We have tried with sampling data and data is available but filtering is not working. when we use below expression and in datapreview we can able to see some data.

toTimestamp(PurchaseDocumentCreatedDateTime) <= toTimestamp(currentDate())

So, it looks like even data is available filter is not working to filter data for 1year.Could you please suggest on this

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

Accepted answer
  1. KranthiPakala-MSFT 46,602 Reputation points Microsoft Employee
    2023-07-08T16:53:44.17+00:00

    @siva prasad kukati Welcome to Microsoft Q&A forum and thanks for reaching out here.

    In your expression **toTimestamp(PurchaseDocumentCreatedDateTime) >= toTimestamp(addDays(currentDate('UTC'),-365), 'yyyy-MM-dd HH:mm:ss.SSS','en-US')** , assuming PurchaseDocumentCreatedDateTime is of type string and I see that you are using toTimestamp() function for converting the CurrentUTC which is already in timestamp type. Please note that toTimestamp() does not expect a parameter of type 'timestamp'.

    You can just get rid of the toTimestamp() function on the right hand side and it should work.

    Sample below:

    toTimestamp(PurchaseDocumentCreatedDateTime)  >= addDays(currentUTC(), -365)
    

    Please note that CurrentUTC gets the current timestamp as UTC. If you want your current time to be interpreted in a different timezone than your cluster time zone, you can pass an optional timezone in the form of 'GMT', 'PST', 'UTC', 'America/Cayman'. To convert the UTC time to a different timezone use fromUTC()

    I did tested the above and it works as expected.

    User's image

    Expression used to filter data: toTimestamp(DateTime) >= addDays(currentUTC(), -365)

    Output:

    User's image

    Hope this helps. Let me know if you have further query.

    Thanks


    Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.


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.