cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to do simple sums with variable values?

So I have a flow to analyse results from a quiz on MS FORMs.

 

I've got variables set up for the number of questions and the score.  I want to email the person with their results and their percentage score.

 

I cannot figure out how to multiply or divide the values held within the variables so I have a percentage.

 

I may be going about this in completely the wrong way if so let me know.

2 ACCEPTED SOLUTIONS

Accepted Solutions
DeepakS
Super User
Super User

Hi @Anonymous ,

 

You can use mul(), div() and other available functions to perform math operation. i would like to see what are doing to help you further.

i would suggest you to use compose action to perform there operations with your variable.

Like following expression multiple my variable with 10.

mul(10,variables('MyVar'))
 
Thanks

View solution in original post

v-litu-msft
Community Support
Community Support

Hi @Anonymous,

 

You could initialize an integer variable named Score, then create multiple conditions to increase the Score by using the Increment variable action if the answer is correct, here I have 4 questions, so it has 4 conditions.

Annotation 2020-04-17 111222.png

 

Annotation 2020-04-17 111246.png

Then use the expression to divide the Score and Total score, then convert it into a percentage, my total score is 100, for example:

concat(string(mul(div(float(variables('Score')),float(100)),100)),'%')

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
fchopo
Super User
Super User

Hello @Anonymous 

Please, have a look at the following threads:

You can also have a look at math functions reference guide: https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference

Hope it helps!

Ferran

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
efialttes
Super User
Super User

Hi!

you have initialized variables of type either integer or float, right?

All you need to use is to work with math WDL functions by means of expressions

 

math WDL functions documented here:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#m...

 

How to add expressions explained here:

https://flow.microsoft.com/es-es/blog/use-expressions-in-actions/

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



DeepakS
Super User
Super User

Hi @Anonymous ,

 

You can use mul(), div() and other available functions to perform math operation. i would like to see what are doing to help you further.

i would suggest you to use compose action to perform there operations with your variable.

Like following expression multiple my variable with 10.

mul(10,variables('MyVar'))
 
Thanks

View solution in original post

v-litu-msft
Community Support
Community Support

Hi @Anonymous,

 

You could initialize an integer variable named Score, then create multiple conditions to increase the Score by using the Increment variable action if the answer is correct, here I have 4 questions, so it has 4 conditions.

Annotation 2020-04-17 111222.png

 

Annotation 2020-04-17 111246.png

Then use the expression to divide the Score and Total score, then convert it into a percentage, my total score is 100, for example:

concat(string(mul(div(float(variables('Score')),float(100)),100)),'%')

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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!

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.

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

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