cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PhantomJoe
Level: Powered On

Percentage expression not working

I have a flow that triggers when a new Form response is submitted. This Form is a quiz and I have everything set-up so the details get added to a SharePoint list.

 

I have a Variable called Score that gets incremented every time an answer is declared correct and then a variable called Percentage that I was using a manual expression to set that variable to the percentage of questions correct.

 

I have been using the expression mul(div(variables('Score'),6),100) in my Set Variable item. 

This expression has been working succesfully until I added a few unrelated variables elsewhere in the Flow.

 

Can anyone help?

8 REPLIES 8
Super User
Super User

Re: Percentage expression not working

@PhantomJoe 

Please post a screen shot of your Flow - that will be a big help for those trying to assist.

Also, can you provide some detail on what's going wrong?  Are you seeing an error or is the result not accurate?  If you see an error, please include a screen shot of the error.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
PhantomJoe
Level: Powered On

Re: Percentage expression not working

@ScottShearer absolutely it's quite long I'm afraid

Teams Flow 1.PNGStart of flow where variables are setThis is the start of my flow where I initialise all of the variables that I use.The main one here is the Percentage variable which I initialise as an interger with nothing in the value box.

 

 

 

 

 

 

 

 

 

 

 

Teams Flow 2.PNGStart of apply to eachThis is where the apply to each starts. I retreive the response details and the user profile. The question responses are then checked to see if they are correct.

 

 

 

 

 

 

 

 

Teams Flow Questions.PNGStandard question formatThis is the condition for each question. If the response is the same as the string variable set earlier with the answer then the Score vaiable and the category variable gets incremented by 1.

 

 

 

 

 

Teams Flow 3.PNGEnd of flow still within apply to eachThis is the end of the flow still within 'Apply to each'. 

The 'Set Variable' shown is where I am having thre problems. What I am trying to do is set the Percentage variable to the percentage of questions correct. To acheive this I have been using the expression mul(div(variables('Score'),6),100) which I know works as it was previously working.

 

The next step is where I check for previous responses in the relevant SharePoint list from the same user and delete that response before adding details of the trigger response to the same list. 

 

Finally I send an email to the user depending on the percentage of questions correct.

Essentially the user will get a 'Congratulations' email if they get 100% otherwise they will get a 'Try Again' email.

 

 

I really hope someone can help.

 

Teams Flow Percentage after run.PNGOutput of set percentage variable

As I've said before the 'Set Vartiable' with the percentage expression was previously working until I added some new variables. These new variables are the category variables which have nothing to do with the percentage aspect.

PhantomJoe
Level: Powered On

Re: Percentage expression not working

@ScottShearer  absolutely. It's a bit long I'm afraid 

Teams Flow 1.PNGStart of flow where variables are setThis is the start of my flow where I initialise all of the variables that I use.The main one here is the Percentage variable which I initialise as an integer with nothing in the value box.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Teams Flow 2.PNGStart of apply to eachThis is where the apply to each starts. I retreive the response details and the user profile. The question responses are then checked to see if they are correct.

 

 

 

 

 

 

 

 

 

 

 

Teams Flow Questions.PNGStandard question formatThis is the condition for each question. If the response is the same as the string variable set earlier with the answer then the Score vaiable and the category variable gets incremented by 1.

 

 

 

 

 

 

 

 

Teams Flow 3.PNGEnd of flow still within apply to eachThis is the end of the flow still within 'Apply to each'. 

The 'Set Variable' shown is where I am having thre problems. What I am trying to do is set the Percentage variable to the percentage of questions correct. To acheive this I have been using the expression mul(div(variables('Score'),6),100) which I know works as it was previously working.

 

The next step is where I check for previous responses in the relevant SharePoint list from the same user and delete that response before adding details of the trigger response to the same list. 

 

Finally I send an email to the user depending on the percentage of questions correct.

Essentially the user will get a 'Congratulations' email if they get 100% otherwise they will get a 'Try Again' email.

 

 

I really hope someone can help.

 

Teams Flow Percentage after run.PNGOutput of set percentage variable

As I've said before the 'Set Vartiable' with the percentage expression was previously working until I added some new variables. These new variables are the category variables which have nothing to do with the percentage aspect.

Super User
Super User

Re: Percentage expression not working

@PhantomJoe 

Do you see an error or is the percentage just wrong?

If you see an error, please post it.

Can you tell me if the Question 6 condition evalutes to yes so that you variables get set? Please check a run.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
PhantomJoe
Level: Powered On

Re: Percentage expression not working

Hi @ScottShearer 

 

There is no error message. As per the last picture above it just gives 0.

 

I don't understand why as the basic maths works and the expression is correct.

 

Hopefully, this makes sense to someone.

Super User
Super User

Re: Percentage expression not working

@PhantomJoe 

From looking a a run, can you tell me if your variables ever get set?  In other words, does the condition evaluate to true?  Please verify by looking at a run.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
PhantomJoe
Level: Powered On

Re: Percentage expression not working

@ScottShearer 

All the other variables are fine and work correctly when checking a run.

As you can see in the image previously the Percentage variable seems to 'Set' however nothing actually gets 'set' into the variable - it's like the expression is skipped.

Super User
Super User

Re: Percentage expression not working

@PhantomJoe 

It is very hard to give you a definite answer without seeing the details of each step of the Flow in edit mode and after a run (with each action fully expanded).  I believe that the issue is not with your expression but rather one or all of the conditions that precede it.  You need to take a look at a run and expand everything.  Take a look at each condition and the outcome of that condition along with any actions that take place within the conditions.  If you do so, it should become very clear what is going wrong.

 

 

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 194 members 4,116 guests
Please welcome our newest community members: