web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Building a Collection ...
Power Apps
Answered

Building a Collection from multiple lines of data

(1) ShareShare
ReportReport
Posted on by 226 Moderator

My issue today is working with a set of data that has the following format.

 

ProjectIDweekNumberpercentTime
2024-REQ-0012810
2024-REQ-001295
2024-REQ-001302
2024-REQ-0012715

 

What I need to do is have a collection by ProjectID that has columns for weekNumber and the percentTime in that field.  So it would look something like this.  Yes, I realize I will be building a line for each of the weeks of the year unless there are other thoughts.

ProjectIDweek28week29week30week27
2024-REQ-001105215

 

This is the code I wrote and it is not the desired results

 

ClearCollect(
 colTimeTracker,
 ShowColumns(
 AddColumns(
 TimeTracker,
 pTitle, Title,
 week28, LookUp(pmoTimeTracker, Title = TimeTracker[@Title] And weekNumber = 28, percentTime),
 week29, LookUp(pmoTimeTracker, Title = TimeTracker[@Title] And weekNumber = 29, percentTime),
 ),
 pmoTitle, week28, week29
 )
);

 

Maybe I am approaching this all wrong!  Any help is appreciated.


Glen

 

Categories:
I have the same question (0)
  • developingteal Profile Picture
    392 on at

    definitely use a collect, and then loop on it for each row, clear it whenever you need to. Clearcollect seems like it doesn't meet your needs/what you are trying to do 

  • Verified answer
    Hack-7 Profile Picture
    226 Moderator on at

    I was able to create a solution that worked.  Not sure if it was the best way to do it but it works.

     

    Here is a Snip of the code for reference if someone wants it:

    ClearCollect(
     colTimeList,
     AddColumns(
     GroupBy(TimeTracker, projectID, results),
     pm, LookUp(Projects, Title = projectID).pm,
     AFE, LookUp(CostObjects, projectID = projectID, costObject),
     ProjectDetails, LookUp(Projects, Title = projectID).projectTitle,
     week1, If(IsBlank(LookUp(results, weekNum = 1).percentTime), 0, LookUp(results, weekNum = 1).percentTime),
     week2, If(IsBlank(LookUp(results, weekNum = 2).percentTime), 0, LookUp(results, weekNum = 2).percentTime),

     I had to use the If() statement in each of the week#s since JSON to CSV does not like NULL values and not all of the fields had data.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard