web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Multiple If statements...
Power Apps
Unanswered

Multiple If statements best practice

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I'm very new to PowerApps and I'm really struggling with the If statements. I want to ensure that the users answer all of the mandatory questions before navigating to the next screen. My current OnSelect function on the next button is:

 

If(IsEmpty(DataCardValue42.SelectedItems),
 If(IsEmpty(DataCardValue44.SelectedItems),
 If(IsEmpty(DataCardValue43.SelectedDate),
 Notify("You need to answer all mandatory questions",NotificationType.Error),Navigate(SignUp_Work,ScreenTransition.Cover))))

 

For some reason, it doesn't work, and I really don't understand how to write the best multiple If statements. Can anyone guide me?

 

Thanks,

 

Categories:
I have the same question (0)
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    If(IsEmpty(DataCardValue42.SelectedItems),
    If(IsEmpty(DataCardValue44.SelectedItems),
    If(IsBlank(DataCardValue43.SelectedDate),
    Notify("You need to answer all mandatory questions",NotificationType.Error),Navigate(SignUp_Work,ScreenTransition.Cover))))

     

    Can you try this?

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    @Anonymous 

    Seems like you could just use Or, ie

     

    If(
    IsEmpty(DataCardValue42.SelectedItems) ||
     IsEmpty(DataCardValue44.SelectedItems) ||
     IsEmpty(DataCardValue43.SelectedDate),
     Notify("You need to answer all mandatory questions",NotificationType.Error),Navigate(SignUp_Work,ScreenTransition.Cover))
  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    The way I handle this is by using a counter.  Each time a required field is changed to a non-blank I increment the counter.  Each time a required field is changed to a blank value I decrement the counter.  then use a single If that checks to see if the counter is equal to or greater than the number of required fields on the screen to enable the submit button.

  • Community Power Platform Member Profile Picture
    on at

    Many thanks @Anonymous I see that it is very similar to Power BI actually. I don't understand why I failed.

  • Community Power Platform Member Profile Picture
    on at

    This is a great idea! @Pstork1 I'm quite new to PowerApps as I mentioned (It's my 3rd week), can you guide me with that? Although I've received an answer to my question, it'd be nice to learn this method, as I've quite a lot of mandatory fields in another form. 

     

    Thank you

  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    For each required field put an IF() in the onChange event to increment a variable counter if the value is not blank or decrement the counter if it is blank.

     

    Set the displayMode of the submit button to disabled if the counter is not equal to or greater than the number of required fields on the screen.

  • Community Power Platform Member Profile Picture
    on at

    Thanks @Pstork1 It's a very smart approach. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard