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

Show records if value exists in another table

Hi all, 

 

I am trying to display (filter) records from a table if a value exists in another table. Below is the scenario; 

 

I have 3 tables i.e. Vendor, VendorUser, Invoices

 

Vendor Table

Vendor IDVendor Name
Vend001John Doe
Vend002Jane Doe
Vend003Joseph Doe

 

VendorUser Table

Vendor ID (Lookup from Vendor Table)User ID
Vend001User1@test.com

Vend003

User1@test.com

Vend002

User2@test.com

 

Invoices

Invoice NoVendor ID (Lookup from Vendor Table)
Inv123Vend001
Inv456Vend002

 

Now, in a PowerApp Gallery, I would like to be able to filter and show the invoices that are related to vendors which users are assigned to in the VendosUser Table i.e. user logged in with User1@test.com can only see Inv123 in the gallery. Inv456 cannot be shown since it is related to Vendor Vend002 which is not assigned to User1@test.com

 

Any ideas how this type of filtering can be done, please?

 

Thanks in advance! 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @yabela ,

 

I assume that your datasource is sp list and I did a test for you.

vxiaochenmsft_0-1631498789209.png

vxiaochenmsft_1-1631498806362.png

vxiaochenmsft_2-1631498825643.png

 

Add a gallery control and set its Items property to:

Filter(Ungroup(ForAll(Distinct(ForAll(Filter('VendorUser Table','User ID'="User1@test.com"),ThisRecord.'Vendor ID'.Value),Value) As A,Filter(Invoices,'Vendor ID'.Value=A.Result)),"Value"),!IsBlank(InvoiceNo))

 

The result is as follows:

vxiaochenmsft_3-1631498880935.png

 

Best Regards,

Wearsky

 

 

 

View solution in original post

3 REPLIES 3
AnthonyDo
Helper III
Helper III

Hi @yabela ,

 

Could you try,

Filter(Invoices, Vendor Id = Lookup(VendorUser, User ID = <currentuserloggedin>).Vendor ID)

 

currentuserlogged in would be a var where the logged in user would be stored e.g.  User1@test.com

 

Best Regards,

Anthony

AnthonyDo
Helper III
Helper III

Deer @yabela ,

 

Did the above help your case? If so please accept it as a solution so it could help other people with similiar cases.

 

Best Regards,

Anthony

v-xiaochen-msft
Community Support
Community Support

Hi @yabela ,

 

I assume that your datasource is sp list and I did a test for you.

vxiaochenmsft_0-1631498789209.png

vxiaochenmsft_1-1631498806362.png

vxiaochenmsft_2-1631498825643.png

 

Add a gallery control and set its Items property to:

Filter(Ungroup(ForAll(Distinct(ForAll(Filter('VendorUser Table','User ID'="User1@test.com"),ThisRecord.'Vendor ID'.Value),Value) As A,Filter(Invoices,'Vendor ID'.Value=A.Result)),"Value"),!IsBlank(InvoiceNo))

 

The result is as follows:

vxiaochenmsft_3-1631498880935.png

 

Best Regards,

Wearsky

 

 

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,448)