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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Looping Through a Coll...
Power Apps
Unanswered

Looping Through a Collection

(0) ShareShare
ReportReport
Posted on by 35
All - I am having issue retrieving values from a collection. More specially, I have a requirement to retrieve the values of a collection and write them to an HTML table.
At present, I have the following and am stuck trying to figure this out. Any help would be greatly appreciated...the issue appears to be with my Forall statement. Here I am trying to iterate through the collection until it reaches the max (2 in this case) and write this value. 
 
"<strong> Attendance Records: " & User().FullName & "</strong>" &
"<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" &
"<tr style='background-color:#efefef'>
<th>Date</th>
<th><center> Time In </center></th>
</tr>" &
"<tr>" &
"<td>" & ForAll(Sequence(2),ThisRecord.Value) & " </td>" &
</tr>" &
"</table>"
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,049 Most Valuable Professional on at
    Try this format
    "<strong> Attendance Records: " & User().FullName & "</strong>" & "<table width='100%' border='1' cellpadding='5' style='border:1px solid black; border-collapse:collapse'>" & "<tr style='background-color:#efefef'>
    <th>Date</th>
    <th><center> Time In </center></th></tr>" & 
    Concat(
        FirstN(
            CollectionName,
            2
        ),
        "<tr><td>" & Text(DateFieldName,"dd/mm/yyyy") & "</td><td>" & TimeInFieldName  & "</td></tr>"
    ) & "</table>"
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee
  • Verified answer
    Wee Teck Profile Picture
    45 on at

    The issue lies in the way you're using the ForAll statement within the HTML string. PowerApps doesn't directly support using ForAll in this context to iterate over a collection and embed it in a string.

    You’ll need to manually concatenate the values from the collection into your HTML table. The best approach is to use Concat() in PowerApps, which allows you to iterate over a collection or table and concatenate its values into a string.

    // Concatenate the rows for each record in the collection (assumed the collection is called 'AttendanceCollection')
    Concat(
    AttendanceCollection,
    "<tr>" &
    "<td>" & DateField & "</td>" &
    "<td><center>" & TimeInField & "</center></td>" &
    "</tr>"
    )

  • WarrenBelz Profile Picture
    153,049 Most Valuable Professional on at
    Did you review what I posted - I believe it also addresses your requirement for the first two items only - what you accepted is basically a copy of my post missing this requirement.
  • RH-25092337-0 Profile Picture
    35 on at
    I accepted your post as you mentioned my missing ingredient: Concat.
    I needed only to make use of the Concat function to iterate through my collection to write those values to my HTML table. Thanks.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard