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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,748)