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
Hi @aqidahadiqa ,
Could you tell me:
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
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
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
I know there is the function that can be used but the think is I don't know how to do. 😅
Hi @aqidahadiqa ,
Could you tell me:
If so, the point is to judge the following three conditions:
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:
Best Regards,
Wearsky
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
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
WarrenBelz
213
Most Valuable Professional
MS.Ragavendar
108
stampcoin
80