cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dawidvh
Level 10

Mathematical Order of Operations - Bug with Format Text in Code

Hello Microsoft.

 

I am sure there used to be a forum for bugs on the community, but I can't seem to find it now.

 

I found that one of my formulas would randomly stop working and I then found that the "Format Text" option in the formula editor is destroying mathematical order of operations by removing brackets.

 

If we start with this formula it returns the correct value because we need the subtract to execute first.

Correct Value.jpgPowerApps Order of Operations

If you then choose to format text, it removes the brackets

Format Text.jpg

 

This then obviously breaks the intended result because of order of operations.

 

Incorrect Value.jpg

 

I am pretty sure this is a bug 😉

1 REPLY 1
bscramling
Level: Powered On

Re: Mathematical Order of Operations - Bug with Format Text in Code

Dawidvh,

 

You're not alone. I input this code...

 

RoundDown
(
    (
        (
    DateDiff(
        CheckInTime,
        LunchOutTime,
        Minutes
    )
     + 
    DateDiff(
        LunchInTime,
        CheckOutTime,
        Minutes
       )
    ) / 60
    ),
    1
)

...and it gives me the correct number. However, when I click "Format Text" I get the following...

 

RoundDown (
    DateDiff(
        CheckInTime,
        LunchOutTime,
        Minutes
    ) + DateDiff(
        LunchInTime,
        CheckOutTime,
        Minutes
    ) / 60,
    1
)

...which is giving me the wrong number. Quite annoying.

 

I also discovered that if you use /* --- */ at the end of your code to comment out some code, when you click "Format Text" it will sometimes, but not always, remove all the commented code.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 324 members 5,521 guests
Please welcome our newest community members: