Conditional formatting of UDTable data

Product: PowerShell Universal
Version: 3.7.3

I’ve created a dashboard that contains a table of live data that gets refreshed every 60 seconds.

The data is live rail travel information. How can I conditionally format the rows/cells of the table so that for instance if a train is ‘On time’, it shows as green, but if the ‘Estimated Time’ is different from the ‘Scheduled Time’ it shows as orange?

New-UDDashboard -Title 'Live Travel Information' -HideNavigation -Content {
    New-UDDynamic -AutoRefresh -AutoRefreshInterval 60 -Content {
        $DepartureData = Get-DepartureBoard -AccessToken $AccessToken -CRS SOU -NumberOfResults 20
        $Services = $DepartureData.TrainServices | 
            Select-Object @{Name="Destination";Expression={
                                if(($_.destination.location.locationName).Count -gt 1){
                                    $_.destination.location.locationName -join "/"
        $Columns = @(
            New-UDTableColumn -Property Destination
            New-UDTableColumn -Property Time
            New-UDTableColumn -Property Estimated

        New-UDTypography -Text "Live Train Departures from $($DepartureData.LocationName). Last updated at: $(Get-Date $DepartureData.GeneratedAt -Format HH:mm)"

        New-UDRow -Columns {
            New-UDColumn -LargeSize 6 -Content {
                New-UDCard -Content {
                    New-UDTable -Data ($Services | Select-Object -First 10) -Columns $Columns

            New-UDColumn -LargeSize 6 -Content {
                New-UDCard -Content {
                    New-UDTable -Data ($Services | Select-Object -Skip 10) -Columns $Columns

You could use the render method for the estimated column. I didn’t test this specifically but it will be something like this:

 New-UDTableColumn -Property Estimated -Render { 
    if ($EventData.Estimated -gt $EventData.Time) {
        New-UDTypgraphy -Text $EventData.Estimated -Style @{ backgroundColor = "orange" }
    } else {
        New-UDTypgraphy -Text $EventData.Estimated -Style @{ backgroundColor = "green" }

Hi Adam,

Sorry for the my late reply. Your suggestion worked perfectly, thanks! I ended up switching to New-UDStyle as that adjusted the whole cell, but the Render method resolved my issue.