web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to round to the ne...
Power Apps
Unanswered

How to round to the nearest even number?

(0) ShareShare
ReportReport
Posted on by 30

for example:

 

0.41 to 0.44, when rounded is 0.4

0.46 to 0.49 when rounded is 0.5

 

for 0.45, as it is 0.05 difference after rounded will be 0.4 as 4 is even number

0.5 is an odd number, so we cannot round to 0.5. It only can be rounded to an even number.

another example,

 

0.55 = 0.6

0.65 = 0.6

0.75 = 0.8

Categories:
I have the same question (0)
  • 365CornerDawid Profile Picture
    377 on at

    Hey @aqidahadiqa 

    Power have the 3 functions which can help you to achive this results:
    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-round

     

    • Round rounds up if the next digit is a 5 or higher. Otherwise, this function rounds down.
    • RoundDown always rounds down to the previous lower number.
    • RoundUp always rounds up to the next higher number.

    365CornerDawid_0-1606473789303.png

    365CornerDawid_1-1606473829816.png

     

     

     

    Hope this will help you if yes please remember to mark this answer as solution to help other community members to find resolutions faster.
    Regards
    Dawid

  • v-xiaochen-msft Profile Picture
    on at

    Hi @aqidahadiqa ,

     

    Could you tell me:

    1. Do you want to keep one decimal place?
    2. Do you want to rounddown it when the second decimal place is 1-4? (For example: 0.33 → 0.3)
    3. Do you want to judge the round based on the first digit after the decimal point when the second digit after the decimal point is 5?(For example: 0.35 → 0.4)
    4. Do you want to roundup it when the second decimal place is 6-9? (For example: 0.36 → 0.4)

     

    If so, the point is to judge the following three conditions:

    1. When the second digit after the decimal point is not 5, Use the round() function to round.
    2. When the second digit after the decimal point is 5, judge whether the previous digit is even. If so, use rounddown() function.
    3. When the second digit after the decimal point is 5, judge whether the previous digit is even. If not, use roundup() function.

     

    I've made a test for your reference:

     

    1\ Add a button control and set its onselect property to:

    Set(Var,5.75) // Var is a variable

     

    2\ Add a label control and set its Text property to:

    If(
    
     RoundDown(
    
     Mod( // Mod() Returns the remainder of a division.
    
     Var * 100,
    
     10
    
     ),
    
     0
    
     ) = 5 && Mod( // Judge whether the second digit after the decimal point is 5.
    
     RoundDown( 
    
     Var,
    
     1
    
     ) * 10,
    
     2
    
     ) = 0, // Judge whether the first digit after the decimal point is even.
    
     RoundDown( // execute rounddown() function
    
     Var,
    
     1
    
     ),
    
     RoundDown(
    
     Mod(
    
     Var * 100,
    
     10
    
     ),
    
     0
    
     ) = 5 && Mod( // Judge whether the second digit after the decimal point is 5.
    
     RoundDown(
    
     Var,
    
     1
    
     ) * 10,
    
     2
    
     ) = 1, // Judge whether the first digit after the decimal point is odd
    
     RoundUp( // execute roundup() function
    
     Var,
    
     1
    
     ),
    
     Round( // execute round() function
    
     Var,
    
     1
    
     )
    
    )

    3\ The result are as follow:

    v-xiaochen-msft_0-1606723092770.png

     

    v-xiaochen-msft_1-1606723092773.png

     

     

    v-xiaochen-msft_2-1606723092774.png

     

     

    Best Regards,

    Wearsky

  • aqidahadiqa Profile Picture
    30 on at

    I know there is the function that can be used but the think is I don't know how to do. 😅 

  • aqidahadiqa Profile Picture
    30 on at

    Thank you @v-xiaochen-msft , 

     

    regarding to your questions, 

     

    1. nope.. some number will be 2 decimal places.  for example 0.445 will be 0.44

    2. yes

    3. the judgement took place for the last digit is 5 && follow their decimal places.. some input need  1 decimal place, some input have 2 decimal places.

    4. yes

     

  • aqidahadiqa Profile Picture
    30 on at

    when we rounded to nearest number for 0.45, after rounded must be even number

     

    eg:

    0.45 rounded is 0.4

    0.55 rounded is 0.6

    0.65 rounded is 0.6

  • Verified answer
    v-xiaochen-msft Profile Picture
    on at

    Hi @aqidahadiqa ,

     

    Could you tell me:

    1. Whether the input number has two decimal places, the result will be kept one decimal place? (For example: 5.73→5.7 , 5.75→5.8, 5.76→5.8, 5.85→5.8)
    2. Whether the input number has three decimal places, the result will retain two decimal places? (For example: 5.73→5.7 , 5.75→5.8, 5.76→5.8, 5.85→5.8)
    3. Do you have any other needs? For example, other decimal places? How many digits should they keep?

     

    I modified the formula and the formula can satisfy the condition 1 and condition 2 mentioned above.

    In addition, when the number does not belong to Condition 1 or Condition 2, the digital output is equal to the input.

     

    You can refer to the following formula:

    1\ Set button’s onselect property to:

     

    Set(Var,***) //*** is a number

     

     

    2\ Set label’s Text property to:

     

    If(
    
     Len(
    
     Mid(
    
     Text(Var),
    
     Find(
    
     ".",
    
     Text(Var)
    
     ) + 1,
    
     8
    
     )
    
     ) = 3,
    
     If(
    
     RoundDown(
    
     Mod(
    
     Var * 1000,
    
     10
    
     ),
    
     0
    
     ) = 5 && Mod(
    
     RoundDown(
    
     Var,
    
     2
    
     ) * 100,
    
     2
    
     ) = 0,
    
     RoundDown(
    
     Var,
    
     2
    
     ),
    
     RoundDown(
    
     Mod(
    
     Var * 1000,
    
     10
    
     ),
    
     0
    
     ) = 5 && Mod(
    
     RoundDown(
    
     Var,
    
     2
    
     ) * 100,
    
     2
    
     ) = 1,
    
     RoundUp(
    
     Var,
    
     2
    
     ),
    
     Round(
    
     Var,
    
     2
    
     )
    
     ),
    
     Len(
    
     Mid(
    
     Text(Var),
    
     Find(
    
     ".",
    
     Text(Var)
    
     ) + 1,
    
     8
    
     )
    
     ) = 2,
    
     If(
    
     RoundDown(
    
     Mod(
    
     Var * 100,
    
     10
    
     ),
    
     0
    
     ) = 5 && Mod(
    
     RoundDown(
    
     Var,
    
     1
    
     ) * 10,
    
     2
    
     ) = 0,
    
     RoundDown(
    
     Var,
    
     1
    
     ),
    
     RoundDown(
    
     Mod(
    
     Var * 100,
    
     10
    
     ),
    
     0
    
     ) = 5 && Mod(
    
     RoundDown(
    
     Var,
    
     1
    
     ) * 10,
    
     2
    
     ) = 1,
    
     RoundUp(
    
     Var,
    
     1
    
     ),
    
     Round(
    
     Var,
    
     1
    
     )
    
     ),
    
     Var
    
    )

     

     

    If you have more needs, please tell me and I will be happy to help you.

    Best Regards,

    Wearsky

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard