cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
yohannes_adeba
Frequent Visitor

display graphs inside Power apps html text control

Hello.

Is there any way to insert graphs inside the HTML text control so it can be added inside email body? I have a collection named 'Job applications' in my app. For this collection, I am able to create an HTML table inside the HTML text control with <table><th><tr> tags.I'm able to email the info inside the HTML text control.  However I couldn't find a way to graph the collection and show it inside the HTML text control. My collection has fields "Region","Job title" and I want to group by "Region" and count "Job titles".

1st question : Is there a way to Group the collection by "Region" and display bar graph inside the HTML text control? Y axis is Count all "Job titles" inside each region.

 

2nd question: Is there any way to display the  Data Table created on another screen inside the HTML text control?

2 ACCEPTED SOLUTIONS

Accepted Solutions
EddieE
Super User
Super User

@yohannes_adeba 
You can add a table to your HTML text, like this

"
<head>
<style>
table {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 4px;
}

th {
  background-color: LightGray;
}

tr:nth-child(even) {
  background-color: #dddddd;
}
</style>
</head>

<table>
    <tr>
        <th>Region</th>
        <th>Job Titles</th>
    </tr> " &
    Concat( 
        AddColumns(
    GroupBy(yourCollectionName, "Region", "grpRegion"),
    "Job Titles",
    CountRows(grpRegion)
    ),
        "<tr>
            <td>" & Region & " </td>
            <td>" & 'Job Titles' & " </td>
        </tr>
  ")
& "
</table>"

** Note: all of the html code inside of the <head> ... </head> tags just sets the table style. You can adjust this to suit your needs.

 

You send a test email to yourself to check this using

// note: htmlTable is the name of my HTML text control
Office365Outlook.SendEmailV2("youremail@yourcompany.com", "HTML Table", htmlTable.HtmlText)

Looks something like this

EddieE_0-1656641717282.png

 

 

For adding your graph image to the email, this old solution may work? If not, then I think you may need to do some research to get it working, sorry.

View solution in original post

@yohannes_adeba 
Just use '.' to give the required data - usually you can use something like Region.Value, eg

"
...
<tr>
            <td>" & Region.Value & " </td>
            <td>" & 'Job Titles' & " </td>
            <td>" & 'Éxtra column 1' & " </td>
            <td>" & 'Éxtra column 2' & " </td>
        </tr>
..."

 

View solution in original post

5 REPLIES 5
EddieE
Super User
Super User

@yohannes_adeba 
You can add a table to your HTML text, like this

"
<head>
<style>
table {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 4px;
}

th {
  background-color: LightGray;
}

tr:nth-child(even) {
  background-color: #dddddd;
}
</style>
</head>

<table>
    <tr>
        <th>Region</th>
        <th>Job Titles</th>
    </tr> " &
    Concat( 
        AddColumns(
    GroupBy(yourCollectionName, "Region", "grpRegion"),
    "Job Titles",
    CountRows(grpRegion)
    ),
        "<tr>
            <td>" & Region & " </td>
            <td>" & 'Job Titles' & " </td>
        </tr>
  ")
& "
</table>"

** Note: all of the html code inside of the <head> ... </head> tags just sets the table style. You can adjust this to suit your needs.

 

You send a test email to yourself to check this using

// note: htmlTable is the name of my HTML text control
Office365Outlook.SendEmailV2("youremail@yourcompany.com", "HTML Table", htmlTable.HtmlText)

Looks something like this

EddieE_0-1656641717282.png

 

 

For adding your graph image to the email, this old solution may work? If not, then I think you may need to do some research to get it working, sorry.

yohannes_adeba
Frequent Visitor

Thank you so much, Eddie. The table worked but please allow me to ask an extended question. 1. Can I add additional column(s) here?

Region(group by)Total(Job title)%age of Job tile
   

 

2. What if the 'Region' column is of choice type.

@yohannes_adeba 

Yes, you can add Headers where the <th> tags are and then associated data where the <td> tags are inside of the Concat(), ie

 

<table>
    <tr>
        <th>Region</th>
        <th>Job Titles</th>
        <th>Extra column 1</th>
        <th>Extra column 2</th>
    </tr> " &
    Concat( 
        AddColumns(
    GroupBy(yourCollectionName, "Region", "grpRegion"),
    "Job Titles",
    CountRows(grpRegion)
    ),
        "<tr>
            <td>" & Region & " </td>
            <td>" & 'Job Titles' & " </td>
            <td>" & 'Éxtra column 1' & " </td>
            <td>" & 'Éxtra column 2' & " </td>
        </tr>
  ")
& "
</table>"

 

yohannes_adeba
Frequent Visitor

Thanks Eddie. But my "Region" column is of choice type. This one is working only when it's a single-line-text type. Do you have any so/n if the "Region" is of choice type?

@yohannes_adeba 
Just use '.' to give the required data - usually you can use something like Region.Value, eg

"
...
<tr>
            <td>" & Region.Value & " </td>
            <td>" & 'Job Titles' & " </td>
            <td>" & 'Éxtra column 1' & " </td>
            <td>" & 'Éxtra column 2' & " </td>
        </tr>
..."

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,191)