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

Collection not collecting a LookUp to another list

Power Apps Community,

 

I have two SharePoint lists that are connected by IDs that track a time entry and an associated tag in the Title column:

 

TimeEntries.ID = TimeEntryTags.TimeEntryID

 

I have a created collections for both of these lists using the same date filters where VarUserName is the Full Name of the user and StartTimeAsNumber is the date as a number in yyyymmdd format:

 

ClearCollect(EntriesCol1, Filter(TimeEntries, Title = VarUserName, StartTimeAsNumber >= Value(FilterByStartDateInput_1.Text)));

 

ClearCollect(TagsCol1, Filter(TimeEntryTags, 'Full Name' = VarUserName, StartTimeAsNumber >= Value(FilterByStartDateInput_1.Text)));

 

Next, I want to create a new collection which has the Tag associated with the TimeEntry.

 

ForAll(EntriesCol1, Collect(EntriesWithTagCol2, {TimeID: ID, Tag: LookUp(TagsCol1, TimeEntryID = ID).Title}));

 

For some reason, the Title column of TagsCol1 does not transfer to the new collection EntriesWithTagCol2.

 

I can use a gallery to display EntriesCol1 and then use a LookUp in a Label to get the associated tag in the Title column:

 

Label.Text within Gallery = LookUp(TagsCol1, TimeEntryID = ThisItem.ID).Title

 

I can also hard code labels with the matching IDs to get the Title column:

 

LookUp(TagsCol1, TimeEntryID = 118).Title

 

Why can I not get the ForAll(EntriesCol1 statement to work with the LookUp to get the Title column from TagsCol1?

 

I would really appreciate some help. I've spent a lot of time banging my head against a wall trying to figure this out.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@ltd224 

Try altering your formula to the following:

ForAll(
   AddColumns(EntriesCol1, "id", ID), 
   Collect(EntriesWithTagCol2, {TimeID: id, Tag: LookUp(TagsCol1, TimeEntryID = id).Title})
);

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

6 REPLIES 6
RandyHayes
Super User
Super User

@ltd224 

Try altering your formula to the following:

ForAll(
   AddColumns(EntriesCol1, "id", ID), 
   Collect(EntriesWithTagCol2, {TimeID: id, Tag: LookUp(TagsCol1, TimeEntryID = id).Title})
);

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

yashag2255
Dual Super User II
Dual Super User II

@ltd224 

 

Can you try to update the expression to:

ForAll(EntriesCol1, Collect(EntriesWithTagCol2, {TimeID: ID, Tag: LookUp(TagsCol1, TimeEntryID = ThisRecord.ID).Title}));

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

ThisRecord is nice to use, but be cautious with it - it has some unexpected results.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes

That worked great! Any idea why I couldn't use the ID field from the List? There must be something special about it that wouldn't allow it to work.

 

In my troubleshooting I discovered some anomalies but couldn't discover the root issue.

 

Thanks for the help!

@ltd224 

Good news!

It's all about ambiguity...in your first formula, you were referencing the ID of the wrong source in your Lookup.

There are things like Disambiguation notation that can be used and other objects like ThisRecord as was also mentioned, but they sometimes do not reference what you might think.

In the formula I gave you, we end up adding a totally different column and then specifically referencing that column in the LookUp - there is nothing ambiguous then, it's a totally different column than the other source.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
ltd224
Frequent Visitor

Thanks again Randy!

 

For anyone else that views this thread, using RenameColumns still has disambiguation problems. That was one of my troubeshooting steps but still didn't work.

 

Randy's solution works great.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

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.

Top Solution Authors
Top Kudoed Authors
Users online (1,005)