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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add condition to looku...
Power Apps
Unanswered

Add condition to lookup if returns blank

(0) ShareShare
ReportReport
Posted on by 27

Hi all,

 

I have a power apps form which creates incidents in a sharepoint list.  The form control also has another data connection with another sharepoint list on the same site called locations. This list holds the duty managers who are available at each location.  I'm using a dropdown for locations to then do a look-up on this locations list to get the duty managers for the location and display them:

 

TonyH_0-1694606495298.png

 

I'm doing this using the following in the text label to the right of the locations dropdown:

Text -> Concat(

                     Lookup(

                             Locations,

                              Title = DataCardValue2.Selected.Value

                      ).DutyManager,

                      DisplayName & "; "

               )

 

However there are some locations in the dropdown that won't have any duty managers assigned to them.  In this case I'd like the user to select a dutymanager from the dropdown on the right.  (This dropdown is optional but when there are no duty managers brought back in the lookup then form validation ensures that the user has to select this field when they try to submit.)

 

When there are no dutymanagers brought back, I'd like a warning to display to the user advising them that for that location they will have to select a duty manager from the dropdown on the right hand side.  

 

I thought that I could do this by adding a semi-colon to the text above and then using "if(isBlank(..." but I don't think that you can do this.  The other way I've attempted this (messing about with the visible property of the text label doesn't work because it displays when no location has been selected - or maybe I was doing it wrong...)

 

Hoping for some pointers to understand the best to do this.

 

Thanks,

Anthony

 

Categories:
  • CU18061035-1 Profile Picture
    18 Microsoft Employee on at

    Hi @TonyH 

     

    You want to create a formula that you can use that will be:

    True when the Site Location dropdown has a value and the Assigned Duty Managers is blank

     

    Assuming the Site Location Dropdown is named "DataCardValue2" and "Assigned Duty Managers" control is named "DataCardValue3", your formula would be:

     

     

     

    Not(IsBlankOrError(DataCardValue2.Selected.Value))&& IsBlankOrError(DataCardValue3.Text)

     

     

     This checks to make sure something was selected for Site Location/DataCardValue2 and the Duty Manager Control/DataCardValue3 is not empty.

     

    You can use this Conditional where ever you need it. You could put it on the Visible Property of a Text Box to show the Warning message. You could put it on the AlternateDutyManager_DataCard Required Property to make that control Required when there is no Duty Manager.

     

    Hopefully this gets you moving in the right direction.

     

    -Mark

    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

  • TonyH Profile Picture
    27 on at

    Hi @MarkBandR ,

     

    Thanks for that, you've captured the logic of what I wanted to know.  The next step I'd like to do is to implement a step when this condition is true I'd like to notify the user.  

     

    Originally I'd thought to put the code snippet inside an if condition and if true use the notify function.  However the middle field (note to self: reference names to fields) which you'd assumed was datacard3 is actually a text label field (lbl_dutyMgr).

     

    For some reason, the notify function isn't allowed in the visible property.  I then tried to put this on the OnChange property of datacardvalue2 (which shows the list of locations on the left hand side)  However this displayed the warning message in a not consistent form.  When changing locations (when one was selected that had no staff the message would not flash until another location was chosen and this might have staff or not).

     

    With OnSelect was again inconsistent.  Again any pointers greatly appreciated.

  • CU18061035-1 Profile Picture
    18 Microsoft Employee on at

    Hi @TonyH 

     

    Switch your code from the OnSelect (which fires when the control is selected) to the OnChange event which fires when the controls value changes.

     

    Something like this:

     

    If(
     Not(IsBlankOrError(dd_SiteLocation.Selected.Value)) && IsBlankOrError(
     LookUp(
     DutyManager,
     SiteLocation.Value = dd_SiteLocation.Selected.Value,
     Title
     )
     ),
     Notify(
     "Warning! No Duty Manager - Select Someone from the Alternate Duty Manager Dropdown",
     NotificationType.Warning,
     5000 //Time in milliseconds to display the message, set to 0 to display indefinitely
     );
     
    );

     

    -Mark

    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks

  • TonyH Profile Picture
    27 on at

    Thanks @MarkBandR I appreciate your help but it seemed inconsistent the behaviour.  At the moment, I don't have the time to investigate too much so I'll leave it as there is form validation.  Fingers crossed I can understand what's happening here at some other time.

  • CU18061035-1 Profile Picture
    18 Microsoft Employee on at

    Hi @TonyH 

     

    Hopefully you can get it sorted out.

     

    You had mentioned you were using the OnSelect Event. You should be using the OnChange event which should get you consistency.

     

    The OnChange event only fires when the dropdown is changed.

     

    -Mark

    If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 194 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 150

Last 30 days Overall leaderboard