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

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
Highlighted
Super User
Super User

Re: How to use the if function with multiple conditions ?

@Aceron 

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
Highlighted
Super User
Super User

Re: How to use the if function with multiple conditions ?

@Aceron 

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

 

 

Highlighted
Frequent Visitor

Re: How to use the if function with multiple conditions ?

Hi  @mdevaney

I forgot to mention this point : in a dropdown

Highlighted
Super User
Super User

Re: How to use the if function with multiple conditions ?

@Aceron 

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."

Highlighted
Frequent Visitor

Re: How to use the if function with multiple conditions ?

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

Highlighted
Super User
Super User

Re: How to use the if function with multiple conditions ?

@Aceron 

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

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (12,219)