cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ErikH63
Resolver I
Resolver I

Hex to decimal conversion

Hello,

 

Does anyone know if there is a way to convert a hexadecimal to decimal in flow?  I am still a noob at flow.

 

Thanks,

    -Erik

2 ACCEPTED SOLUTIONS

Accepted Solutions
Paulie78
Super User III
Super User III

Hi @ErikH63 

 

It is possible to do this, although not as easy as you would expect. Please see the following flow:

https://ibb.co/bPGX9RD

HexToDec.png

 

Because this is somewhat complicated to recreate I have copied the contents of the scope for you, so if you want to recreate this your end, you need to do the following:

  1. Create an Initialize Variable action, name the variable Decimal
  2. Copy the code below into your clipboard, and then add a new action to your flow, click on "My Clipboard" and then press CTRL-V. Then the "HexToDec" scope will appear and you can paste it in.

You cannot put variables in a scope, which is why you have to create that part yourself.

Here is the code for the scoped section:

{"id":"14f6f66f-e620-4b12-86aa-cf5e-c83ac028","brandColor":"#8C3900","connectionReferences":{},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"HexToDec","operationDefinition":{"type":"Scope","actions":{"Hex":{"type":"Compose","inputs":"474318F","runAfter":{},"description":"The Hex Number to be converted"},"DecToHexMapping":{"type":"Compose","inputs":[{"Dec":0,"Hex":"0"},{"Dec":1,"Hex":"1"},{"Dec":2,"Hex":"2"},{"Dec":3,"Hex":"3"},{"Dec":4,"Hex":"4"},{"Dec":5,"Hex":"5"},{"Dec":6,"Hex":"6"},{"Dec":7,"Hex":"7"},{"Dec":8,"Hex":"8"},{"Dec":9,"Hex":"9"},{"Dec":10,"Hex":"A"},{"Dec":11,"Hex":"B"},{"Dec":12,"Hex":"C"},{"Dec":13,"Hex":"D"},{"Dec":14,"Hex":"E"},{"Dec":15,"Hex":"F"}],"runAfter":{"Hex":["Succeeded"]},"description":"Mapping of decimal numbers to hexidecimal"},"HexPower":{"type":"Compose","inputs":[1,16,256,4096,65536,1048576,16777216,268435456,4294967296,68719476736,1099511627776,17592186044416,281474976710656,4503599627370496],"runAfter":{"DecToHexMapping":["Succeeded"]},"description":"Array of Multiplication Powers"},"Apply_to_each":{"type":"Foreach","foreach":"@range(0,length(outputs('Hex')))","actions":{"HexMultiplier":{"type":"Compose","inputs":"@outputs('HexPower')[item()]","runAfter":{"filterDecHexMapping":["Succeeded"]},"description":"Get the hex multiplier for current iteration"},"Increment_variable":{"type":"IncrementVariable","inputs":{"name":"Decimal","value":"@mul(first(body('filterDecHexMapping'))['Dec'], outputs('HexMultiplier'))"},"runAfter":{"HexMultiplier":["Succeeded"]},"description":"Add the created decimal to the variable"},"CurrentHexChar":{"type":"Compose","inputs":"@substring(outputs('Hex'), sub(sub(length(outputs('Hex')), item()),1),1)","runAfter":{},"description":"The current character of the hexidecimal number"},"filterDecHexMapping":{"type":"Query","inputs":{"from":"@outputs('DecToHexMapping')","where":"@equals(item()['Hex'], outputs('CurrentHexChar'))"},"runAfter":{"CurrentHexChar":["Succeeded"]},"description":"Find the Decimal Number that is equal to the Hex"}},"runAfter":{"HexPower":["Succeeded"]},"description":"Iterate through each character of the hex number"},"Decimal_Converted":{"type":"Compose","inputs":"@variables('Decimal')","runAfter":{"Apply_to_each":["Succeeded"]}}},"runAfter":{"Initialize_variable":["Succeeded"]}}}

Let me know how you get on.

Blog: tachytelic.net

YouTube: https://www.youtube.com/c/PaulieM/videos

If I answered your question, please accept it as a solution 😘

View solution in original post

Hey @ErikH63 

 

You cannot Format a number out of box.

 

If you have office script enabled it is possible.

 

Script - 

 

function main(workbook: ExcelScript.Workbook, hexString:string)
{
  // Your code here

 

  var yourNumber = parseInt(hexString, 16);
 
  return yourNumber;
}
 
CFernandes_0-1620806819940.png
CFernandes_1-1620806838128.png

If you are new to Office Script then I did a demo recently for a User Group - You can find it at https://www.youtube.com/watch?v=afmE0JEtoU8&list=PLlNMfcMu9Cv61XBVCDio1NSRqLO-g5ZGn&index=5 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

 

View solution in original post

15 REPLIES 15
v-duann-msft
Community Support
Community Support

Hi @ErikH63

 

Thank you for posting.

 

According to your description, you would like to convert hex to decimal using flow. If any misunderstanding, please kindly let me know.

 

I’m afraid it’s impossible to archive your purpose in flow as there is no formula or action supported. But I found a workaround for you. You can try PowerApps instead.

ClearCollect(Hex2Dec,{Hex:"1",Dec:1},{Hex:"2",Dec:2},{Hex:"3",Dec:3},{Hex:"4",Dec:4},{Hex:"5",Dec:5},{Hex:"6",Dec:6},{Hex:"7",Dec:7},{Hex:"8",Dec:8},{Hex:"9",Dec:9},{Hex:"A",Dec:10},{Hex:"B",Dec:11},{Hex:"C",Dec:12},{Hex:"D",Dec:13},{Hex:"E",Dec:14},{Hex:"F",Dec:15});

 

You can also go to below thread for reference:

Solved: convert Hex to Ascii text - Power Platform Community (microsoft.com)

 

Hope the content above may help you.

 

Best regards,

Anna

Thanks Anna, you have it correct.  In my research I did find the PowerApp method, but I was really hoping to do it in a flow.  Thanks for confirming that a flow won't work.

 

-Erik

Paulie78
Super User III
Super User III

Hi @ErikH63 

 

It is possible to do this, although not as easy as you would expect. Please see the following flow:

https://ibb.co/bPGX9RD

HexToDec.png

 

Because this is somewhat complicated to recreate I have copied the contents of the scope for you, so if you want to recreate this your end, you need to do the following:

  1. Create an Initialize Variable action, name the variable Decimal
  2. Copy the code below into your clipboard, and then add a new action to your flow, click on "My Clipboard" and then press CTRL-V. Then the "HexToDec" scope will appear and you can paste it in.

You cannot put variables in a scope, which is why you have to create that part yourself.

Here is the code for the scoped section:

{"id":"14f6f66f-e620-4b12-86aa-cf5e-c83ac028","brandColor":"#8C3900","connectionReferences":{},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"HexToDec","operationDefinition":{"type":"Scope","actions":{"Hex":{"type":"Compose","inputs":"474318F","runAfter":{},"description":"The Hex Number to be converted"},"DecToHexMapping":{"type":"Compose","inputs":[{"Dec":0,"Hex":"0"},{"Dec":1,"Hex":"1"},{"Dec":2,"Hex":"2"},{"Dec":3,"Hex":"3"},{"Dec":4,"Hex":"4"},{"Dec":5,"Hex":"5"},{"Dec":6,"Hex":"6"},{"Dec":7,"Hex":"7"},{"Dec":8,"Hex":"8"},{"Dec":9,"Hex":"9"},{"Dec":10,"Hex":"A"},{"Dec":11,"Hex":"B"},{"Dec":12,"Hex":"C"},{"Dec":13,"Hex":"D"},{"Dec":14,"Hex":"E"},{"Dec":15,"Hex":"F"}],"runAfter":{"Hex":["Succeeded"]},"description":"Mapping of decimal numbers to hexidecimal"},"HexPower":{"type":"Compose","inputs":[1,16,256,4096,65536,1048576,16777216,268435456,4294967296,68719476736,1099511627776,17592186044416,281474976710656,4503599627370496],"runAfter":{"DecToHexMapping":["Succeeded"]},"description":"Array of Multiplication Powers"},"Apply_to_each":{"type":"Foreach","foreach":"@range(0,length(outputs('Hex')))","actions":{"HexMultiplier":{"type":"Compose","inputs":"@outputs('HexPower')[item()]","runAfter":{"filterDecHexMapping":["Succeeded"]},"description":"Get the hex multiplier for current iteration"},"Increment_variable":{"type":"IncrementVariable","inputs":{"name":"Decimal","value":"@mul(first(body('filterDecHexMapping'))['Dec'], outputs('HexMultiplier'))"},"runAfter":{"HexMultiplier":["Succeeded"]},"description":"Add the created decimal to the variable"},"CurrentHexChar":{"type":"Compose","inputs":"@substring(outputs('Hex'), sub(sub(length(outputs('Hex')), item()),1),1)","runAfter":{},"description":"The current character of the hexidecimal number"},"filterDecHexMapping":{"type":"Query","inputs":{"from":"@outputs('DecToHexMapping')","where":"@equals(item()['Hex'], outputs('CurrentHexChar'))"},"runAfter":{"CurrentHexChar":["Succeeded"]},"description":"Find the Decimal Number that is equal to the Hex"}},"runAfter":{"HexPower":["Succeeded"]},"description":"Iterate through each character of the hex number"},"Decimal_Converted":{"type":"Compose","inputs":"@variables('Decimal')","runAfter":{"Apply_to_each":["Succeeded"]}}},"runAfter":{"Initialize_variable":["Succeeded"]}}}

Let me know how you get on.

Blog: tachytelic.net

YouTube: https://www.youtube.com/c/PaulieM/videos

If I answered your question, please accept it as a solution 😘

View solution in original post

Hey @ErikH63 

 

You cannot Format a number out of box.

 

If you have office script enabled it is possible.

 

Script - 

 

function main(workbook: ExcelScript.Workbook, hexString:string)
{
  // Your code here

 

  var yourNumber = parseInt(hexString, 16);
 
  return yourNumber;
}
 
CFernandes_0-1620806819940.png
CFernandes_1-1620806838128.png

If you are new to Office Script then I did a demo recently for a User Group - You can find it at https://www.youtube.com/watch?v=afmE0JEtoU8&list=PLlNMfcMu9Cv61XBVCDio1NSRqLO-g5ZGn&index=5 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

 

View solution in original post

Thank you, @Paulie78 that is definitely not as easy as I thought it might be.  I need to study this and then get back to this post.  -Erik

Thanks, @CFernandes  this is an interesting idea I will see if this will work for me. I will watch the video thank you very much for the response.  -Erik

@CFernandes ,this worked really well and video was great, thanks for showing me this it opens a bunch of new doors.    -Erik

Hello @CFernandes, I used the script idea you gave me, but I found an issue.  I can run this script fine when I am run it via my form in PowerApps but if anyone else runs this script the flow fails with the error:  Script not found. It may have been unshared or deleted.
clientRequestId: d0812d74-0586-4ea0-a5e9-9cac30d91bef

 

Do you happen to know how to deal with this, since I am not sure who runs this I cannot add owners to flow.

 

Thanks,  -Erik

@ErikH63 Hey Mate,

 

I think I understand your problem. 

 

The Power Apps connection work under the context of the user who launched the APP and Excel script is stored in your OneDrive, which the user cannot access.

 

I have not tried your excat scenario but you can try to create a child flow and share the connection(I will try your scenario on Monday).

 

You can have a look at my video tutorial in which I explain sharing of connections in Power apps. https://powerusers.microsoft.com/t5/Webinars-and-Video-Gallery/Avoid-Authentication-Prompts-when-Dep... 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

 

Hey @ErikH63,

 

I created a video in which I explain why you are facing this problem - You can find the video at https://www.youtube.com/watch?v=hmtlUFRg9Ic 

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Thank you so much, this is above and beyond just helping.   I really appreciate this!!!   I will view it and post when I am done. 

 

-Erik

Hi @CFernandes, one question, I have to know who will be running this for sharing, correct?  The issue with that is that I do not know who will be running it since it is a utility for a Sharepoint group.  Sorry to make this so difficult.

 

Thanks,

    -Erik

@ErikH63 If you use the parent child approach as mentioned in my video and manage run only users the Flow will always run under the user you have specified. 

Can I follow that with one more question, I am not sure if you are able to answer. I do not know how the user is setup,  so I am wondering if I end up leaving the company will the script stop working?  I guess there is some job security it this. 😉

 

Thank you again @CFernandes 

Hello @CFernandes , I am trying to call the ParentHex and ChildHex from a Sharepoint List PowerApp canvas form, is there a trick to this since I can seem to find the ParentHex, I can only find my Flows? The app was created in the sharepoint list, it is not in my apps.

 

Thanks,

    -Erik

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (39,472)