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 / If statement in HTML Text
Power Apps
Unanswered

If statement in HTML Text

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello there!

I am having some HTML code to export information from a gallery. I want the background to be changed green or red depending on whether is true or false. The whole thing works but we just need to have a condition and change the background of the information in the columns. How can I do this? I think it's either th or td that we have to change

Here is my code;

"<html>
<head> 
 <style>
 table {
 width: 100%;
 border-collapse: collapse;
 text-align: center;
 }

 th, td {
 text-align: center;
 border: 1px solid black;
 font-size: 12px;
 }

 h1{
 color:#325ca8;
 }

 tr:nth-child(even){background-color: #f2f2f2}

 th {
 background-color: #325ca8;
 color: white;
 }

 </style>
 </head>
 <body>
 <H1>Project " & DropdownOrder.SelectedText.Result & "-" & DropdownDeelorder.Selected.Result & "</H1>
 <Table>
 <tr><th>Verdieping</th>
 <th>UniekNummer</th>
 <th>Geopperd</th>
 <th>GeopperdDatum</th>
 <th>Gemonteerd</th>
 <th>GemonteerdDatum</th>
 <th>Opgeleverd</th>
 <th>OpgeleverdDatum</th>
 <th>Aantal</th></tr>
 " & Concat(
 Gallery3.AllItems;
 "<tr><td>" & Verdieping & "</td><td>"
 & UniekNummer & "</td><td>"
 & Geopperd & "</td><td>" 
 & GeopperdDatum & "</td><td>" 
 & Gemonteerd & "</td><td>" 
 & GemonteerdDatum & "</td><td>" 
 & Opgeleverd2 & "</td><td>" 
 & OpgeleverdDatum & "</td><td>"
 & Aantal & "</td></tr>"
) & "
</table>
</body>
</html>
"

 

Categories:
  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    Hi @Anonymous ,

    Definitively the <td>.

    Here is some hints:

    ForAll(
     Gallery3.AllItems,
     With(
     {border: If(condition,"green","red")},
     "<td style='background-color:" & border & "'>" & ColumnName & "</td>"
     )
     ),
     Value
    ) 

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    How would I implement that into the HTML I have right now? I can't seem to get it working

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
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard