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 / Creating a formatted H...
Power Apps
Answered

Creating a formatted HTML table from a collection

(0) ShareShare
ReportReport
Posted on by 92

I have a collection that is created from a reasonably complex (for me) SQL pivot query with dynamic column headers.

This is so that I can show a matrix type table to my users - what we are trying to show is that for any CATEGORY and SERVICE there is a specific MATRIX entry, category names and services change on a regular basis so these are maintained in different joined tables.

The collection is small, but I don't know how many columns or rows will be in the collection, not looking at many more than 10 columns and 20/30 rows, but the column names will change, hence dynamic.

What I need help with is how can I extract the number of and names of my columns to create the HTML table dynamically.

 

Here is some samples from the collection:

StevenMoore_0-1717172663009.png

 

Thanks

 

 

Categories:
I have the same question (0)
  • Verified answer
    gcmfaizan Profile Picture
    1,022 on at

    hi steven,

    here is an idea us can use this code and change the parameters:

    ClearCollect(
     MatrixCollection,
     {
     SID: 1,
     Service: "JJJJ",
     CategoryA: "Matrix1",
     CategoryB: "Matrix2",
     CategoryC: "Matrix3",
     CategoryD: "Matrix4"
     },
     {
     SID: 2,
     Service: "KKKK",
     CategoryA: "Matrix6",
     CategoryB: "Matrix7",
     CategoryC: "Matrix8",
     CategoryD: "Matrix9"
     },
     {
     SID: 3,
     Service: "LLLL",
     CategoryA: "Matrix11",
     CategoryB: "Matrix12",
     CategoryC: "Matrix13",
     CategoryD: "Matrix14"
     },
     {
     SID: 4,
     Service: "MMMM",
     CategoryA: "Matrix16",
     CategoryB: "Matrix17",
     CategoryC: "Matrix18",
     CategoryD: "Matrix19"
     }
    );
    
    ClearCollect(
     HTMLTable,
     "<table border='1'>",
     "<tr>",
     "<th>SID</th>",
     "<th>Service</th>",
     "<th>Category A</th>",
     "<th>Category B</th>",
     "<th>Category C</th>",
     "<th>Category D</th>",
     "</tr>",
     ForAll(
     MatrixCollection,
     "<tr>",
     "<td>" & ThisRecord.SID & "</td>",
     "<td>" & ThisRecord.Service & "</td>",
     "<td>" & ThisRecord.CategoryA & "</td>",
     "<td>" & ThisRecord.CategoryB & "</td>",
     "<td>" & ThisRecord.CategoryC & "</td>",
     "<td>" & ThisRecord.CategoryD & "</td>",
     "</tr>"
     ),
     "</table>"
    );

     

     

     

    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

     

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 762

#2
11manish Profile Picture

11manish 640

#3
Valantis Profile Picture

Valantis 548

Last 30 days Overall leaderboard