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

How to use the if function with multiple conditions ?

Hello world,

 

I am having trouble with the if Function. I am kinda a newbie in Powerapps...

What I want to achieve :

The user give a grade to his project on 5 standards. Answer can be "High", "medium" or "low". For instance :

Standard 1 : High

Standard 2 : High

Standard 3 : medium

Standard 4 : High

Standard 5 : low

 

The genaral grade is given by these conditions :

At least 1 High or 3 medium : High Grade

At least 2 Medium (no High) : medium grade

5 low (no medium or high) : Low grade

 

An image (High, Medium or Low) appears depending on your grade. Obviously, the low situation and the high situation with only one High is easy but I am having trouble to cover all the cases at once... For now I only have been to poorly use the if fonction with && or || but it doesn't work...

 

Many thanks if you can help me.


Regards,

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Anonymous 

I made a mistake on the condition for "Medium".  I used an OR condition.

 

(myScores.High = 0 Or myScores.Medium >=2)

 

 But it should be an AND condition instead.

 

(myScores.High = 0 And myScores.Medium >=2)

 

Note: I've edited the original post to make the correction

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

View solution in original post

5 REPLIES 5
mdevaney
Super User
Super User

@Anonymous 

Where is the information for standards being stored?  In a dropdown?  In a variable?

 

 

Anonymous
Not applicable

Hi  @mdevaney

I forgot to mention this point : in a dropdown

mdevaney
Super User
Super User

@Anonymous 

Put this code in the OnChange property of all your dropdowns.

 

ClearCollect(myStandards,
    Dropdown1.Selected.Value, 
    Dropdown2.Selected.Value, 
    Dropdown3.Selected.Value, 
    Dropdown4.Selected.Value, 
    Dropdown5.Selected.Value
);
Set(myScores,
    {
        High: CountRows(Filter(myStandards,Value="High")),
        Medium: CountRows(Filter(myStandards,Value="Medium")),
        Low: CountRows(Filter(myStandards,Value="Low"))
    }
);
Set(myGrade,
    If(
        (myScores.High >= 1 Or myScores.Medium >=3), "High Grade",
        (myScores.High = 0 And myScores.Medium >=2), "Medium Grade",
        "Low Grade"
    )
)

 

 

To display the grade you would put this code in a label

 

myGrade

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Anonymous
Not applicable

@mdevaney  Thanks, it seems to work with the high and medium grade but not the low. I don't understand why.

@Anonymous 

I made a mistake on the condition for "Medium".  I used an OR condition.

 

(myScores.High = 0 Or myScores.Medium >=2)

 

 But it should be an AND condition instead.

 

(myScores.High = 0 And myScores.Medium >=2)

 

Note: I've edited the original post to make the correction

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

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

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,803)