cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nekinekic
Regular Visitor

Checking names on two collections updating table

I have two collections that I would like to cross reference names on

Collection 1

Name
Bob
Tom

Collection 2

Task NumberName
1Bob
2Bob
1Harry
2Harry

Table

TaskNameOther
.........

So in my case I would like to see if Collection 2 has a matching Name in Collection 1, if it does than not to update the table with that Name and Tasks, if it does not have a matching name than to update the table with the Name and Tasks.

So if I were to check Collection 2 against Collection 1 in this example the table would yield

Table

TaskNameOther
1Harry...
2Harry...

I would put in the code I wrote but no part of it works so it would just be a waste of time. I would appreciate any help. Thanks. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @nekinekic ,

 

I did a test for you.

 

1\ This is my collection1.

ClearCollect(Collection1,{Name:"Bob"},{Name:"Tom"})

v-xiaochen-msft_0-1619589521775.png

 

2\ This is my collection2.

ClearCollect(Collection2,{TaskNumber:1,Name:"Bob"},{TaskNumber:2,Name:"Bob"},{TaskNumber:1,Name:"Harry"},{TaskNumber:2,Name:"Harry"})

v-xiaochen-msft_1-1619589557936.png

 

3\ This is my Table

ClearCollect(Table,{Task:6,Name:"Test",OtherColumn1:"Test"})

v-xiaochen-msft_2-1619589702917.png

 

4\ Add a button control and set its onselect property to:

ForAll(Collection2 As A,If(CountRows(Filter(Collection1,Collection1[@Name]=A.Name))=0,Patch(Table,Defaults(Table),{Task:A.TaskNumber,Name:A.Name})))

 

5\ The result is as follows:

v-xiaochen-msft_3-1619590006595.png

 

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

View solution in original post

2 REPLIES 2
Chitrakant27
Advocate I
Advocate I

Hi nekinekic,

you can use search function to check that name is available on collection 1 or not.

 Search(Table*, SearchStringColumn1 [, Column2, ... ] )  Example Search(Collection2,"Rahul","Name") 

then use patch or update function to add new record on Collection2.

 

Thanks,

Chitrakant27

 

v-xiaochen-msft
Community Support
Community Support

Hi @nekinekic ,

 

I did a test for you.

 

1\ This is my collection1.

ClearCollect(Collection1,{Name:"Bob"},{Name:"Tom"})

v-xiaochen-msft_0-1619589521775.png

 

2\ This is my collection2.

ClearCollect(Collection2,{TaskNumber:1,Name:"Bob"},{TaskNumber:2,Name:"Bob"},{TaskNumber:1,Name:"Harry"},{TaskNumber:2,Name:"Harry"})

v-xiaochen-msft_1-1619589557936.png

 

3\ This is my Table

ClearCollect(Table,{Task:6,Name:"Test",OtherColumn1:"Test"})

v-xiaochen-msft_2-1619589702917.png

 

4\ Add a button control and set its onselect property to:

ForAll(Collection2 As A,If(CountRows(Filter(Collection1,Collection1[@Name]=A.Name))=0,Patch(Table,Defaults(Table),{Task:A.TaskNumber,Name:A.Name})))

 

5\ The result is as follows:

v-xiaochen-msft_3-1619590006595.png

 

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (58,733)