Azure Data Flow convert Hex to Integer

João Augusto de Freitas 26 Reputation points
2021-03-04T12:15:50.75+00:00

Good morning everyone.

We are using data factory and data flow to transform and after consume some data in power bi.

There is an column called "time" in csv we are transforming, it's type is hexadecimal, for instance "6022D4D8". This value it's an hex representation of timestamp in seconds.

0x6022D4D8 = 1612895448 = 2021-02-09 18:30:48 (in seconds)

Directly, with the value in plain text, it's possible to get the desire result:

toTimestamp(seconds(toInteger(0x6022D4D8)))

But, using the column string "time" we can't do it.

We tried everything: toInteger('0x' + time), unhex(time).

Could you helps us?

Kind regards

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

Accepted answer
  1. Kiran-MSFT 691 Reputation points Microsoft Employee
    2021-03-31T14:10:54.72+00:00

    Dataflow functionality is continuously improved.
    You can use toInteger(hexValue, ‘%x’) to convert from hex to base 10 integer. toLong also allows the same. Make sure to trim 0x from the string using substring or right functions.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. João Augusto de Freitas 26 Reputation points
    2021-03-31T12:32:13.463+00:00

    After tried everything and also tried to work on @MartinJaffer-MSFT solution, we were not able to make the conversion on data factory natively, so we created an Azure Function to do the job and insert it on Data Factory pipeline just before the data flow, converting every hex data to integer in C#.
    That's not the best solution, but we can remove that when Microsoft create a function inside Data Flow.
    Thank you anyway and best regards

    1 person found this answer helpful.