cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

Collection based on Sharepoint List and an document library

Hi

I have a list of student in a SPList.  There is a number column is "ProfilePictureID"

I have students profile pictures in a document library with the ID being the connector to the SPList column "ProfilePictureID".

 

I already have a collection of the students to give me just the ones currently on the course.

ClearCollect(ColStudentsInTown,Filter(LongTermStudents,ProgramStartDate<=Today() And ProgramEndDate>=Today()));

I wish to make a collection of the Profile pictures just for these students. 

Basically I want to being in only the images off the document library that are needed.

I have tried this without success.  I think I need a ForAll formula??
ClearCollect(ColProfileImage,Filter(ProfileImages,LookUp(ColStudentsInTown,ProfilePictureID=ID)))

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Collection based on Sharepoint List and an document library

Hi @StuCundy ,

Maybe something like this

 

Clear(ColProfileImage);
ForAll(
   ColStudentsInTown As MyImages,
   Collect(
      ColProfileImage,
      Lookup(
         ProfileImages,
         ProfilePictureID = MyImages.ID
      )
   )
)

 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

16 REPLIES 16
Highlighted
Super User
Super User

Re: Collection based on Sharepoint List and an document library

Hi @StuCundy ,

Maybe something like this

 

Clear(ColProfileImage);
ForAll(
   ColStudentsInTown As MyImages,
   Collect(
      ColProfileImage,
      Lookup(
         ProfileImages,
         ProfilePictureID = MyImages.ID
      )
   )
)

 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Highlighted
Responsive Resident
Responsive Resident

Re: Collection based on Sharepoint List and an document library

@StuCundy Use this formula:

 

Clear(ColProfileImage); ForAll(ColStudentsInTown As Student, Collect(ColProfileImage, Lookup(ProfileImages, ProfilePictureID = Student.ID)))

 

ForAll function in Power Apps 


Please click Accept as solution if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it 👍

 

Highlighted
Super User
Super User

Re: Collection based on Sharepoint List and an document library

@ganeshsanap ,

Pretty much what I said . . .

Highlighted
Responsive Resident
Responsive Resident

Re: Collection based on Sharepoint List and an document library

@WarrenBelz Yes. But, I think there is some syntax error in your formula. I guess you are missing one comma(,) in your formula. 

Highlighted
Super User
Super User

Re: Collection based on Sharepoint List and an document library

@ganeshsanap not sure where

Anyway @StuCundy I think this will work for you.

Highlighted
Responsive Resident
Responsive Resident

Re: Collection based on Sharepoint List and an document library

@WarrenBelz Inside ForAll() and before Collect function.

Highlighted
Post Patron
Post Patron

Re: Collection based on Sharepoint List and an document library

Hi Guys

@WarrenBelz @ganeshsanap 

Thanks for your wisdom.  I entered the formula and get an error.

 

 

Clear(ColProfileImage);
ForAll(
    ColStudentsInTown As Students,
    Collect(
        ColProfileImage,
        LookUp(
            ProfileImages,
            ID = Students.ProfilePictureID
        )
    )
)

 

Just to clarify, ProfilePictureID is a number column in the SPlist and this = ID in the document library.
My Student list is actually called LongTermStudents but I assume that is not an issue here as we are just making a virtual list for the purpose using "As". 

 

Now I am Creating the Collection ColStudentsInTown just before this command so is there enough time maybe?

 

My total formula is 

 

ClearCollect(
    ColStudentsInTown,
    Filter(
        LongTermStudents,
        ProgramStartDate <= Today() And ProgramEndDate >= Today()
    )
);Clear(ColProfileImage);
ForAll(
    ColStudentsInTown As Students,
    Collect(
        ColProfileImage,
        LookUp(
            ProfileImages,
            ID = Students.ProfilePictureID
        )
    )
);
Set(
    ShowThisStudent,
    false
)

 

Highlighted
Super User
Super User

Re: Collection based on Sharepoint List and an document library

@StuCundy ,

What is the error?

Highlighted
Post Patron
Post Patron

Re: Collection based on Sharepoint List and an document library

Hi @WarrenBelz 

When I hover over the Lookup area is says that 'ProfilePicture' column doesn't exist. 

lookup.png

Yes I did once have a column called ProfilePicture in the Sharepoint list but now only ProfilePictureID.

It is still trying to reference the deleted column....

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,289)