November 20, 2020

Show values based on Lookup List Conditions for Lookup Column in Power Apps

Overview:

In this article, we will learn how we can show only specific values as Lookup value based on some conditions in Power Apps.

Real-Life Business Use Case:

We have come across a scenario where we have two SharePoint lists.

Domains List:


Request List:


 - Domain is a Lookup column from Domains List in the Request List.

 - We are implementing a Power Apps Form for Requests List.

 - We only want to show those Domains which are active, so how can we achieve this?

Let’s get started!


Step 1: Open Power Apps Form. By default, all values appear in the Lookup Dropdown.

Below is the code for the Default event which is available for the lookup dropdown.


Step 2: Now, we need to change the code with the following code.

 Filter(  
   RenameColumns(  
     AddColumns(  
       RenameColumns(  
         Choices([@Requests].Domain),  
         "Id",  
         "MID"  
       ),  
       "Status",  
       LookUp(  
         Choices([@Requests].'Domain:Status'),  
         Id = MID  
       ).Value  
     ),  
     "MID",  
     "Id"  
   ),  
   Status = "Active"  
 )  


Understanding the code:

 - By default, Lookup has two columns, ID and Value. With the above formula, we added one additional column –“Status” by using AddColumns() function.

 - To achieve this, we need to use the "RenameColumns" function to make the exact final structure that the lookup value expects.

 

- Now, let’s test the result. We can see only Active records in the dropdown.

 

- Now, let’s fill the form and save the value. 


 - The values are stored successfully in the SharePoint list.


Conclusion:

This is how we can apply a lookup list condition to show only active requests in the Lookup column. Hope this is clear now! Stay connected for amazing Power Apps Articles! Happy Power Apping!

If you have any questions you can reach out to our SharePoint Consulting team here.

No comments:

Post a Comment