cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TimoMigchielsen
Post Prodigy
Post Prodigy

If statement in HTML Text

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>
"

 

2 REPLIES 2
gabibalaban
Super User II
Super User II

Hi @TimoMigchielsen ,

Definitively the <td>.

Here is some hints:

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

 

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

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,194)