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

Round a Labels Calculated Text Value to a Visible Whole Number, Without Changing the Labels Original Value

Hi PowerUsers, 

I am looking for some help with formatting a labels visible value to a whole number, whilst retaining the original value to be used in calculations elsewhere in the app.

The best way i can explain exactly what i am looking for is with the MS Excel screenshot below, which has a "Decrease Decimal" function in the number formatting toolbar.

DanW22_0-1652243475857.png

Is there a way in Power Apps to achieve the same result, without having to use a workaround? (I.E. adding a second label to format the viewed value)

Screenshots below of the app screen that contains the label that needs this formatting solution, and its current properties.

DanW22_1-1652243947085.pngDanW22_2-1652244032296.png

This is my first help request, so please let me know if there is anything else i need to provide to help with your response/solution.

9 REPLIES 9
RiccoHipp1903
Resolver II
Resolver II

Hello @DanW22 ,

 

not exactly sure what you want to achieve ?

 

You want, that the original value of the lable doesnt change while the visible can change?

DanW22
Frequent Visitor

Hi @RiccoHipp1903,

I believe you have summed up the gist of what i am trying to achieve.

Do you know of a way to format the value in a labels "Text" property to a whole number that is visible to the app user, but does not change/round the labels "Text" value that is used in other calculated fields in the app?

BCBuizer
Super User
Super User

Hi @DanW22 , 

You can set the number of decimals by wrapping your code in a Text function:

 

Text( 1234.59, "####.#" )   Formats the number with one decimal place.

 

https://docs.microsoft.com/en-us/power-apps/maker/canvas-apps/functions/function-text#number

My idea is, make at OnVisible a variable with the number. this number can be used for calculating.

 

In the text field round it of.

DanW22
Frequent Visitor

Hi @BCBuizer

Unfortunately using the text or the round function to format the calculated value results in changing the value. (216.01456412 becomes 216.) The labels text value is also used in other calculated fields that need the original calculated value (216.01456412) to work correctly. I am looking for a way to change how the value is displayed to the app user, without changing the value itself. (See Excel screenshot in 1st post)

Example of using Text function below;

DanW22_0-1652254258792.png

 

Thanks @RiccoHipp1903,

Had not thought of using a property like "OnVisible" to update the context of a variable, but it does mean each field with a text value that needs formatting will need to have its own variable, as well as updating each formula with the new variable in place of the previous "LabelName.Text" value.

You can do 

UpdateContext({WaterVolume: 216,1234567})

ANd in the text field:

Text( WaterVolume, "####.##" )

or anything like that.

 

and in any calculation labels you can use e.g

WaterVolume/0.123456789

Thanks @RiccoHipp1903,

The Water Volume label was singled out as an example, there are several other labels that require this formatting and use different formula's as highlighted below.

DanW22_1-1652256196371.png

I am assuming that the variable "WaterVolume" used in your suggestion above would need to be different for each formula when used in the OnVisible event of the screen. I.E. WaterVolume for Water Volume, EffVolume for Effective Volume, TankEff for Tank Efficiency, Etc.

Correct. For every Variable you need to define it 

UpdateContext({WaterVol: 216,123456, TankEff: 100.77,....})

 

The OnVisible Property set the values each time the screen is visible agian, so best is not to hardcore, instead locate them on a database

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.

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,655)