cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Livearus
Helper I
Helper I

Power Automate Flow - reduce decimal places?

Hello,

 

I hope you can help me here. I just get stuck with my Power Automate Flow. Admittedly, I am not particularly familiar with that either.

 

I want to email data from SharePoint as a custom table (dynamic content).

 

That already works, but the output numbers, which come from a calculated column (SharePoint), are provided with an unbelievable number of decimal places.

 

I have now tried to convert the numbers using "FormatNumber Expression", but the flow outputs an error and says that the numbers from the calculated columns are of the "String" type. Does anyone have any idea how to proceed here?

 

regards

1 ACCEPTED SOLUTION

Accepted Solutions
Livearus
Helper I
Helper I

Your example above is returned to me with "This is an invalid argument".

 

But it doesn't matter, I found the problem, if you want to call it that. Strangely enough, I have to shorten the column name in the function by one letter, which would make you think that it is an invalid reference. But apparently not for Power Automate. Very strange. Anyway, I came across it by accident. If someone has an idea that could be ahead of me, I would be interested, but the only thing that matters for now is that it somehow works. 😅

 

Thank you for all the help.

 

regards

Livearus

View solution in original post

7 REPLIES 7
Paulie78
Super User
Super User

Use the float() function within your FormatNumber to convert it from a string to a float, which can then be formatted.

Great, that worked. Unfortunately, this does not apply to the output of a calculated column, where a percentage value is calculated from two other columns.

 

In the appendix, which code I used in the flow. How the display currently looks in the output and how in SharePoint.

 

Can you or someone else help me with this too?

 

sbreport_FlowCode.JPGsbreport_Output.JPGsbreport_SharePointView.JPG

 

regards

In the meantime, using the calculation, in the flow itself with the "Div" and "Mul" functions, I was also able to more or less solve the problem.

 

formatNumber (mul (div (float (NumberColumnName), float (CalculateColumnName)), 100), '0,0.00', 'de-DE')

 

Strangely, however, an error occurs again when using the "float" function:

 

Error message: "The template language function" float "was called with an invalid parameter. The value cannot be converted to the target type .."

 

This concerns a percentage calculation using a calculated column and an ordinary number column. The calculated column is simply not converted with the "float" function. If I omit the function, I get the error message that it is a "string". I tried the example above, so that not only the calculated column is in the "float" function, but also the number column.

 

I also tried that only the calculated column is in the "float" function:

 

formatNumber (mul (div (float (NumberColumnName), CalculateColumnName), 100), '0,0.00', 'de-DE')

 

I am at a loss, I have no idea why the values ​​from the calculated column cannot be converted.

 

regards

Paulie78
Super User
Super User

I would personally not use the calculated column. I would perform the same calculation in Power Automate that the calculated column is doing. Then your data type would be correct right away.

That would be a basic solution. Unfortunately, I am asked that the calculation also take place in SharePoint.

The data are daily reports. These are created in a Power App and uploaded or retrieved in SharePoint.

 

As a fallback solution, however, you must be able to enter the data directly in SharePoint even if the app cannot be reached. The calculated columns are used to calculate total values, which the end user cannot do.

 

What is strange is that the calculated column does not differ from the others and still cannot be converted.

 

Otherwise yes, I would prefer your solution. Do you have an idea ahead of the problem may lie?

My guess is that the column cannot be converted to a float because it contains invalid characters (Namely the , and % symbols). So you could replace them with nothing, your float expression would look something like this:

float(replace(replace(outputs('PercentColumn'), '%', ''), ',', ''))

But you would replace the part outputs('PercentColumn') with your Percentage column.

Livearus
Helper I
Helper I

Your example above is returned to me with "This is an invalid argument".

 

But it doesn't matter, I found the problem, if you want to call it that. Strangely enough, I have to shorten the column name in the function by one letter, which would make you think that it is an invalid reference. But apparently not for Power Automate. Very strange. Anyway, I came across it by accident. If someone has an idea that could be ahead of me, I would be interested, but the only thing that matters for now is that it somehow works. 😅

 

Thank you for all the help.

 

regards

Livearus

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,158)