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

Displaying an Integer as a Hexadecimal?

Hello, 

 

I though this was a no-brainer, maybe it is and I am missing the obvious, but I have integers in my powerapp canvas form that I need to display as a hexadecimal, but I am not finding anything just the Excel dec2hex.  I am not working with the hex number just displaying. Any ideas?

 

For example 30 =  0x1E

 

Thanks for any help.  -Erik

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@ErikH63 

There is no decimal to hex function in PowerApps unfortunately.  You will have to perform the math in your app to do the conversion.  There are several direct and indirect methods to conversion, so it really depends on what you are up for.  If your numbers will be 2 digit hex (less than 256) then it is pretty straight forward.  If not, then it gets a little challenging.

 

With({_value: 255,
      _digits:["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]},

   Last(FirstN(_digits, RoundDown(_value / 16 , 0)+1)).Value &
   Last(FirstN(_digits, Mod(_value, 16)+1)).Value

)

Would provide FF as the result based on the _value of 255.

 

You can use this and replace the _value with whatever your number is coming from.  Also, this can be used in a component as a function for your app.  Again though, this is all simple hex with decimals less than 256.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@ErikH63 

There is no decimal to hex function in PowerApps unfortunately.  You will have to perform the math in your app to do the conversion.  There are several direct and indirect methods to conversion, so it really depends on what you are up for.  If your numbers will be 2 digit hex (less than 256) then it is pretty straight forward.  If not, then it gets a little challenging.

 

With({_value: 255,
      _digits:["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]},

   Last(FirstN(_digits, RoundDown(_value / 16 , 0)+1)).Value &
   Last(FirstN(_digits, Mod(_value, 16)+1)).Value

)

Would provide FF as the result based on the _value of 255.

 

You can use this and replace the _value with whatever your number is coming from.  Also, this can be used in a component as a function for your app.  Again though, this is all simple hex with decimals less than 256.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

ErikH63
Resolver I
Resolver I

Thank you for confirming that @RandyHayes .   I did seem to find an option in Power Automate flow with "format number".  It is amazing that this function is not in powerapps.  

Helpful resources

Announcements
PA 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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,142)