cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jibberish
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
v-bofeng-msft
Community Support
Community Support

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
v-bofeng-msft
Community Support
Community Support

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

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,077)