cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
camer314
Helper I
Helper I

How to maintain decimal places in a collection

I have an interesting problem. I am keeping a collection that contains mainly floats and that collection is converted to JSON and sent to a web service. However that web service is very particular about whether it receives integers or floating point numbers.

 

My issue is, if I add for example 10.0 to a collection, that seems to be stored (or at least visualized as simply 10). However when I then convert that to JSON it also stays as simply 10 which then means on the web service side it now de-serializes as an integer and not the intended float and thus fails.

 

So my question is, how can I make PowerApps keep my intended data type. I am not sure actually whether this is an issue with the collection or with the JSON function. 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@camer314 

This is going to be an issue in the conversion with JSON.

There is not much you can do to change it.  So, the only option I might consider is to post-process the text created by JSON.

You can perhaps devise a way to utilize the Match and  Substitute functions to find the numbers without decimals and then substitute the format that you want with the substitute.

 

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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@camer314 

This is going to be an issue in the conversion with JSON.

There is not much you can do to change it.  So, the only option I might consider is to post-process the text created by JSON.

You can perhaps devise a way to utilize the Match and  Substitute functions to find the numbers without decimals and then substitute the format that you want with the substitute.

 

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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thanks @RandyHayes 

 

I might look at post-processing as you mention. its an annoying bug which i suspect will never get fixed because i have what i imagine is a rare use case.

 

For now what I have done is add some epsilon value to each (+0.000...1), subtract it for display, its small enough not to have a material effect on the usage and good enough for now.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,355)