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 / Improve if statement f...
Power Apps
Unanswered

Improve if statement for error message on selected.value(Option set) cards and visibility behavior

(0) ShareShare
ReportReport
Posted on by 99

I have an error message that will populate the top screen whenever the values that are provided in the drop down box are not selected or values are typed. I have 2 questions:

1. How can I improve this if statement to check if the values selected are from the values listed in the drop down (Ensure that values weren't typed).

2. The error message is visible on screen refresh due to all my fields being reset every time the screen refreshes (entering and exiting the screen prompts a refresh), how can I make the message visible only when the user has clicked on the field below whilst leaving the preceding field blank/incorrect selection? That way users opening up the app and entering that screen aren't already faced with a error message.

 

If there is a completely different approach to this that is simpler I'm all ears!

 

See my images below:

 

Error message visible with first card values being shown (none selected)

Error message with options shownError message with options shown

 

If statement to check whether the value of the first card IS NOT a value that is listed for pre-selection

Ultimately this would need to be applied to all the cards in the form.

current formula for the first cardcurrent formula for the first card

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @MattP13 ,

    Assuming your field name is Department, firstly you need to ensure this does not display as soon as the screen opens, so on the OnChange of the dropdown, put this

    If(
     Not(
     DataCardValue7.Selected.Result in Choices(YourListName.Department)
     )
     UpdateContext({vError:"Please enter a correct department in the Department field"})
    )

    The Text of the error label would be

    vError

    and in the Save and Exit screen code add this

    UpdateContext({vError:Blank()})

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

  • MattP13 Profile Picture
    99 on at

    @WarrenBelzWorks like a charm, thanks Warren!

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