cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Displaying numbers in scientific/engineering notation

I have a canvas app where I need to display to the user, calculated values in scientific notation in both a text label and a text input. There does not appear to be any native solution accomplish this, but before I go to some extreme length of manually parsing output as a string, I figured I should ask.

Although something like the following does not throw an error, it also doesn't work as expected:

 

 

Text(string, "[$-en-US]0.####E+00;-0.####E+00")

 

 

Is there any way to accomplish this formatting in a fashion similar to Excel?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Displaying numbers in scientific/engineering notation

Hi @Jibberish :

Do you want to displaying numbers in scientific/engineering notation?

Firstly, let me explain why your code not work.

The point is the text function can only convert numbers into strings in a specific format, not scientific calculations.

I think this link will help you a lot:

Text function in Power Apps

Secondly, I’ve made a test for your reference:

1\add a text input control(TextInput6)

2\add a label control and set its Text property to(TextInput6.Text cannot be negative, otherwise you need to add 2 more if functions):

 

If(
    Value(TextInput6.Text) >= 1,        /* Determine whether the value is greater than or equal to 1, greater than 1 means "+ EXX", less than 1 means "-1XX"*/
    Value(TextInput6.Text) / (Power(
        10,
        (Len(
            Text(
                RoundDown(
                    Value(TextInput6.Text),
                    0
                )
            )
        ) - 1)
    )) & "+E" & Text(
        Len(
            Text(
                RoundDown(
                    Value(TextInput6.Text),
                    0
                )
            )
        ) - 1
    ),                  /* Convert value to 0.00+E00 format*/
    Power(
        10,
        Len(
            Text(
                RoundDown(
                    1 / Value(TextInput6.Text),
                    0
                )
            )
        )
    ) * Value(TextInput6.Text) & "-E" & Len(
        Text(
            RoundDown(
                1 / Value(TextInput6.Text),
                0
            )
        )
    )
)

 

 

Best Regards,

Bof

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Displaying numbers in scientific/engineering notation

Hi @Jibberish :

Do you want to displaying numbers in scientific/engineering notation?

Firstly, let me explain why your code not work.

The point is the text function can only convert numbers into strings in a specific format, not scientific calculations.

I think this link will help you a lot:

Text function in Power Apps

Secondly, I’ve made a test for your reference:

1\add a text input control(TextInput6)

2\add a label control and set its Text property to(TextInput6.Text cannot be negative, otherwise you need to add 2 more if functions):

 

If(
    Value(TextInput6.Text) >= 1,        /* Determine whether the value is greater than or equal to 1, greater than 1 means "+ EXX", less than 1 means "-1XX"*/
    Value(TextInput6.Text) / (Power(
        10,
        (Len(
            Text(
                RoundDown(
                    Value(TextInput6.Text),
                    0
                )
            )
        ) - 1)
    )) & "+E" & Text(
        Len(
            Text(
                RoundDown(
                    Value(TextInput6.Text),
                    0
                )
            )
        ) - 1
    ),                  /* Convert value to 0.00+E00 format*/
    Power(
        10,
        Len(
            Text(
                RoundDown(
                    1 / Value(TextInput6.Text),
                    0
                )
            )
        )
    ) * Value(TextInput6.Text) & "-E" & Len(
        Text(
            RoundDown(
                1 / Value(TextInput6.Text),
                0
            )
        )
    )
)

 

 

Best Regards,

Bof

View solution in original post

Highlighted
New Member

Re: Displaying numbers in scientific/engineering notation

Thanks!

 

Yeah I knew that Text() wouldn't work, but it was the closest functionality I could find to get my point across. It almost seems like Value() should take this as an overload parameter or something. Regardless, the code you provided works perfectly for what I need. I just wish there had been built in functionality for this since all the underlying number types in use are already floating point.

 

Thanks again!

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (3,442)