cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

6 REPLIES 6
Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (47,961)