Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
fabioRond
New Member

How to convert Hex to text and Hex to Datetime

Hi,

I have a data source from a DB that stores most of the data as a binary that were firstly converted into hex.

I am trying to find a formula to convert hex to text (ASCII) but I do not get what passages are required.

the format of the data is text in hex numbers and I would need to bring them to text ASCII ("4551303237" => "EQ027").

 

I tried to convert them to decimal and then to text but it does not work.

 

I tried this method from @Greg_Deckler 

https://community.powerbi.com/t5/Desktop/convert-from-hexadecimal-value-to-number/td-p/28435

 

then this

https://xxlbi.com/blog/converting-hexadecimal-to-decimal-numbers-in-power-query/

 

then this 

https://community.powerbi.com/t5/Desktop/convert-from-hexadecimal-value-to-number/td-p/28435

 

no luck so far even if with this page I get the conversion on the first attempt (http://www.unit-conversion.info/texttools/hexadecimal/)

 

I also tried using Text from or BinaryFormat.Text(2, TextEncoding.Ascii)

 

I was able to get a date out of the hex data using this formula but the year is not correct, probably because it should be DateTime. (40468AE5D5C2E02C =>13/02/1900)

Date.From( BinaryFormat.ByteOrder(BinaryFormat.Double, ByteOrder.BigEndian)( Binary.FromText([#"HEX(fom.Value)"], BinaryEncoding.Hex))) )  

 

Seems a trivial thing to do but I was not able to understand why Power Query is not covered

 

 

1 ACCEPTED SOLUTION

Found the solution probably could help someone else. @Greg_Deckler not sure if is the correct approach, hope make more sense to expert users .

= (textHEX as text , Loop as number , optional Value as text) =>
let
totalLoops = Text.Length(textHEX) ,
CurrentLoop = Loop + 2,
CurrentValue = Value & Character.FromNumber(Expression.Evaluate("0x" & Text.Range(textHEX, Loop, 2))),
output =
if CurrentLoop >= totalLoops
then CurrentValue
else @TestFunction(textHEX,CurrentLoop, CurrentValue)

in
output

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

@fabioRond So you are starting with a hex value of 4551303237 and then you want to convert it to "text" of "EQ027"? I'm not sure how one equates to the other.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  That is done easily in MatLab with a simple conversion Base 16 (hexadecimal) and to char. so the 45 is translated to 69 and then converted to Ascii char "E". I am not so expert to reconstruct the same approach with a function in power query

Found the solution probably could help someone else. @Greg_Deckler not sure if is the correct approach, hope make more sense to expert users .

= (textHEX as text , Loop as number , optional Value as text) =>
let
totalLoops = Text.Length(textHEX) ,
CurrentLoop = Loop + 2,
CurrentValue = Value & Character.FromNumber(Expression.Evaluate("0x" & Text.Range(textHEX, Loop, 2))),
output =
if CurrentLoop >= totalLoops
then CurrentValue
else @TestFunction(textHEX,CurrentLoop, CurrentValue)

in
output

mh2587
Super User
Super User

referring this article may be you get some idea
https://dax.tips/2019/10/02/dax-base-conversions/


✔ Answered? Mark as solution

Muhammad Hasnain | Super User • Fabric • Power BI • Data Engineering

Let's connect on LinkedIn

unfortunately is not helping

 

my data are already as hex which then is converted in MatLab directly into text using ASCII.

 

I am not using DAX but power query.

 

was trying to replicate the same step used with python using the BinaryFormat

https://www.adamsmith.haus/python/answers/how-to-convert-a-string-from-hex-to-ascii-in-python

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.