cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Multiply dynamic content by a decimal?

I have a flow that sends an e-mail once a form response has been approved and it works fine for what we need it for (I'm not very good with Power Automate but I've tinkered around and figured out some basics). However, I now need to add a line that multiplies one of the responses by a percentage and provides the result in the e-mail that automatically goes out once the response is approved.

 

 

Flow.PNG

 

I'm wanting the "Total Invoice Amount" dynamic content to by multiplied by 15% to spit out a fee in the highlighted area. I've tried using mul() and everything I try says "Expression is invalid." Any help is appreciated.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

@DanielCarrasco 

Try adding a zero in front of the decimal.  Here's mine:

 

mul(float(body('Get_response_details')?['rad28bd42b51143a9bc3c7505da370bf7']),0.15)

 

That worked.  But when I take the zero out, I get an error.   I get it, I guess.  Maybe it needs to know there's a number there and not some weird syntax.

 

-Ed

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

View solution in original post

8 REPLIES 8
Super User II
Super User II

@DanielCarrasco 

Hey there.  What does the expression look like, as a whole?  The field coming from the Form, is it formatted as a number?  You may need to do something like: mul(float(<formoutput>),0.15)

 

Keep us posted.  Good luck!

-Ed

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

I'm not sure how to answer that, sorry. This is what it looks like when I try to enter the expression, then choose the "Total Invoice Amount" dynamic content, and I'm getting the "expression is invalid" message when I try to save it:

 

mul(body('Get_response_details')?['rdb4f988cc9b546d9bb1b3f18ef562ae9'],.15)
 
 

@DanielCarrasco 

No worries, let's try this first and see what happens:

 

mul(float(body('Get_response_details')?['rdb4f988cc9b546d9bb1b3f18ef562ae9']),.15)

 

I'm working under the assumption that Forms is probably sending a text field over and we'll need to convert it.  If we can change the format on the Form itself to a number, that would help.

There's also a chance it's sending stuff like a dollar sign and weird things like that.  If you click on the flow name from the "My flows" screen, you'll see past runs (they probably will have a "failed" or something next to them).  If you click on one of those runs, you'll see the error, but then you can also go up a step or two to see what kind of data the Form is sending.

 

Keep at it.

-Ed

@edgonzales 

 Ed-

 

I tried that expression but it still won't let me save ("expression is invalid"). On the Form itself I do have this field set up as a number format.

 

 

@DanielCarrasco 

Try adding a zero in front of the decimal.  Here's mine:

 

mul(float(body('Get_response_details')?['rad28bd42b51143a9bc3c7505da370bf7']),0.15)

 

That worked.  But when I take the zero out, I get an error.   I get it, I guess.  Maybe it needs to know there's a number there and not some weird syntax.

 

-Ed

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

View solution in original post

@edgonzales 

 

I gave that a shot this morning and it did let me enter the expression and save the flow at least, but the flow itself is still failing at the Send an Email step:

 

InvalidTemplate. Unable to process template language expressions in action 'Send_an_email_(V2)' inputs at line '1' and column '2136': 'The template language function 'float' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

@edgonzales 

 

Ed - I think I've got it figured out now. I used your suggestion of "0.15" instead of .15, but also including converting the dynamic content into an integer and it works perfectly:

 

mul(int(body('Get_response_details')?['rdb4f988cc9b546d9bb1b3f18ef562ae9']),0.15)
 
Thanks for your suggestions. Definitely helpful!

That's great!  I'll have to read more about int() as I always thought it turns things into whole numbers.  I'm glad to hear it doesn't, though, that makes things way easier.

 

Awesome job!

 

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (54,888)