cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Amelie
Frequent Visitor

Display numbers with decimals (Patch and sql)

Hi all,

Please help me with the following: I have an app where I am able to select a specific month by using a dropdown list and a text input where I have to add a specific number (with decimals) for the month selected.

 

After introducing the number, I have a submit button that add the data in a SQL database by using the following formula: Patch('[DBO].[number]', {Month: Dropdown. Selected. Value, Number: Value(text input. Text)}).

 

The issue is that: I want to display in the same app the number that is added with 2 decimals (I was not able to display the number with 2 decimals until now). From what I see, the data is stored in SQL as int. Is there a way that I can display the number with the 2 decimals? Thanks a lot!!!

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Amelie ,

 

Please change the Int data type to float data type in sql sever.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

7 REPLIES 7
v-xiaochen-msft
Community Support
Community Support

Hi @Amelie ,

 

Please change the Int data type to float data type in sql sever.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

Hi, 

Thank you for your reply!

Do I have to run this query in SQL server: 

ALTER TABLE DBO. Number
ALTER COLUMN Number FLOAT(20,2)

Also, if I want to add another column to this table containing the year, do I have to append the patch formula that I have? 

Thank you again!

v-xiaochen-msft
Community Support
Community Support

Hi @Amelie ,

 

If you are not familiar with sql syntax, I suggest you to manually modify the data type directly in SQL Server Management Studio.

v-xiaochen-msft_0-1614764147603.png

v-xiaochen-msft_1-1614764217866.png

At this time , this formula will work.

Patch('[DBO].[number]', {Month: Dropdown. Selected. Value, Number: Value(text input. Text)})

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

timl
Super User
Super User

Hi @Amelie 

Before you change your data type to float, can you confirm that you actually want to show your number with 2 decimals (as opposed to 2 digits)?

To expand on the latter, let's suppose the user selects 6 from your drop-down list (eg June). You can keep the underlying data type of your month column as int, but you can display the month number in your app with 2 digits (eg, 06) using this formula:

Text(6, "00")
Amelie
Frequent Visitor

To be more clear: I select a month, June, and I want to display for this month the number that was introduced (basically, this number is an index value (like a sales target) for June). Let's say that this number is 99.91. Now, when I display this number it shows only 99, and I want also to display the 2 decimals (.91).

Hope that this is clear enough.

 

Thanks!!

timl
Super User
Super User

@Amelie 

Thanks for the clarification. I misunderstood your question. In this case, Wearsky is correct and his post above will give you the answers that you seek.

Thanks again for the info! I have one more question:

After I changed the data type, I clicked save, but I received an error: "Saving changes is not permitted. The change you have made requires the following table to be dropped and re-created..". I searched online and it seems that I can change this option from the Tools menu by uncheck the box: Prevent saving changes that require the table to be re-created".

 

My question is: if I uncheck this and save the changes that I've made, I will loose the data that I already have in the table? I have just few rows, but I don't want to loose them.

 

Thank you!

Helpful resources

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

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,992)