How to format text output in PowerApps in scientific notation?

293 Views Asked by At

enter image description here

In the image above, I have a text label that is dependent on a radio. If a button is selected, a multiplication is done on a value from a collection, and then the output is sent to a text label.

After the multiplication, the number I have is 71015997100, but I need to display it like 7.101e+10

Can someone guide me on how to do this?

The desired output is: 7.101e+10 or 7.101E+10

1

There are 1 best solutions below

2
On

You can use an expression like the one below to format the number in exponential notation:

With(
  { v: 71015997100 },
  With(
    { p10: RoundDown(Log(v),0) },
    $"{Text(v/10^p10,"0.000")}e+{p10}"))

If you may have values smaller than 1 (in which case you would need a negative power of 10), you can use something like the following:

With(
  { v:.005697 },
  With(
    { p10: RoundDown(Log(v),0) - If(v<1, 1, 0) },
    $"{Text(v/10^p10,"0.000")}e{If(v<1,"-","+")}{Abs(p10)}"))