cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jennifer_lteif
Frequent Visitor

Nested Filtering

Hello,

I have 4 dataverse tables: "Users" , "Resources", "Project resources" , "Projects". As you can see in the images below:

Screenshot 2021-08-17 001242.pngScreenshot 2021-08-17 001421.pngScreenshot 2021-08-17 001510.pngScreenshot 2021-08-17 001550.png
- "Users" and "Resources" have a common column which is [User ID]
- "Project resources" and " Resources" have [Res ID]
- "Projects" and "Project Resources" have [Project ID]

 

On my Powerapps App, I have created the following Login form and I used LOOKUP in order to make sure that user is registered under the "Users" table (or else he will get an error message and wont be able to get through)

Screenshot 2021-08-17 002551.png

 

 

This navigates him to the next page where I would like to show a gallery with the project available ONLY for that certain logged in user's ID. I have tried a few things on my screen's onvisible, however it is showing me all projects not the Projects assigned to the certain user that logged in. Screenshot 2021-08-17 003702.png

 

How is it possible to do so using the dataverse tables I showed above? Is there any function or solution for the gallery? I believe a Filter Function would work best.
Thank you.

@WarrenBelz @RandyHayes 

3 REPLIES 3
Irfan
Resolver II
Resolver II

Hi,

 

On my app load, I normally initialize a variable to store the logged in user's email address.

Set(userEmail,User().Email);

Irfan_0-1629150589431.png

 

You can either initalize a variable and use it througout your app OR can use the function User().Email whereevr you want. Basically, this will return back the logged in user's email address.

 

When you are filtering records, you can use this variable to fetch only those records which matches with the logged in user's email (presuming your logged in user email is the unique key between all your records in your primary table).


Eg: Presuming you have initialized a variable as explained above:

ClearCollect(coll_Users, Filter(User, Email=userEmail));

OR
ClearCollect(coll_Resource,Filter(Resource, Email=userEmail));

 

Thanks.

 

-Irfan

Hey @Irfan

I am using another custom user's table for testing purposes so that's why I am not using the user function.

The problem is how can I add all the filters functions needed under the same gallery to display the list of projects that are related to the signed-in user (from the custom users table, and the other custom tables that have the ID relationships to the projects and resources).

Could you please provide an example of how can I combine all the filter functions in the gallery?

Looking forward to your response.

Best regards,

Irfan
Resolver II
Resolver II

Hi @jennifer_lteif,

 

I have tried to mimic what you are doing through collections.

 

I have created 4 collections: User, Resource, ProjectResource and Project. In your case, you are directly hitting the datasource.

 

Irfan_0-1629240130355.png

Irfan_1-1629240154164.png

Irfan_2-1629240192233.png

Irfan_3-1629240224918.png

 

Next, I have place a dropdown on my screen which hooks to coll_Users and shows the column UserName from it

Irfan_4-1629240312135.png

 

 

Now the interesting part. How to show the projects which belongs to the selected user from the dropdown. For you, it would be similar to which user has logged in. I have used 3 new collections to filter out my data to keep things simple.

 

ClearCollect(Resources,Filter(coll_Resource,UserID = Dropdown1.Selected.UserID));

The above collection will first filter all my resources from resources collection (your resource table) based on the username selected in my dropdown.


ClearCollect(ProjectResource,Filter(coll_ProjectResource,ResID in Resources.ResID));

The above collection will than filter out the records from my projectresources collection (your project resource table)


ClearCollect(Project,Filter(coll_Project,ProjectID in ProjectResource.ProjectID));

The above collection will than filter out the records from my project collection based on the values from the above collection.

 

Eg:

Irfan_5-1629240740376.png

 

Irfan_6-1629240776810.png

 

 

-Irfan

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Users online (1,811)