cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Aceron
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

@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
mdevaney
Super User III
Super User III

@Aceron 

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

 

 

Aceron
Frequent Visitor

Hi  @mdevaney

I forgot to mention this point : in a dropdown

mdevaney
Super User III
Super User III

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

Aceron
Frequent Visitor

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

@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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,514)