Power Apps Data Table Conditional Formatting

While I was working with Power Apps Data table control, there was a requirement where I needed to apply some conditional formatting to it. However, we can not format various conditions like a gallery control in a Power Apps table.

In this Power Apps tutorial, I will discuss how to work with Power Apps Data table conditional formatting like:

  • Power Apps Data table conditional formatting based on SharePoint single-column
  • Power Apps Data table conditional formatting based on SharePoint multiple columns

Power Apps Data Table Conditional Formatting

We can apply certain or limited conditions and formats in the Power Apps Data table control. Let’s refer to the scenarios below to achieve this.

Example-1: Power Apps Data Table Conditional Formatting based on SharePoint single column

For example, imagine you have a Power Apps Data table control and want to show the user-chosen row in red if certain requirements are met, such as the selected row having a Rejected value. To work around this, refer to the instructions below:

  • There is a SharePoint list named Products with columns below:
ColumnData type
TitleSingle line of text
VendorChoice [APPLE, HP, SAMSUNG, DELL, LENOVO]
Customer NameSingle line of text
StatusChoice [Submitted, Approved, Rejected]

Apart from these columns, it has other columns with various data types.

Data table conditional formatting in Power Apps
  • The selected rejected row in the data table is what I want to color red right now, as shown below.
PowerApps data table conditional formatting
  • To do so, select the Power Apps Data table and apply the below code on its SelectedColor property as:
SelectedColor = If(
    DataTable7.Selected.Status.Value = "Rejected",
    Color.Red,
    Color.Black
)

Where,

  1. DataTable7 = Data table control name
  2. Status = SharePoint choice field name
  3. “Rejected” = Specify the choice value that you want to view with red color

The above code specifies if the data table selected value is Rejected, then it will appear with red color; otherwise, it will be black color.

NOTE:

If the SharePoint Status column is a Single line of Text column, then you can use this code on data table’s SelectedColor property as: If(DataTable7.Selected.Status = “Rejected”, Color.Red, Color.Black)
Power Apps data table conditional formatting
  • Finally, save, publish, and preview the app. The selected row in the data table will appear red when you choose the Rejected row.

This is how to apply conditional formatting based on SharePoint single-column in a Power Apps Data table control.

Example-2: Power Apps Data table conditional formatting based on SharePoint multiple columns

Next, we will see how we can apply the conditional formatting to a Power Apps data table with SharePoint multiple fields.

  • In Power Apps, there is a Data table control with some records. All the data are retrieved from the same above SharePoint list (Products).
  • I want to highlight the data table row containing the title as Mobile or the vendor as DELL. So when a user selects either Mobile or DELL vendor, the particular row will be highlighted in brown.
Power Apps Data table conditional formatting
  • To work with this, select the Data table control and set its SelectedColor property as:
SelectedColor = If(
    tblProducts.Selected.Title = "Mobile" || tblProducts.Selected.Vendor.Value = "DELL",
    Color.Brown,
    Color.Black
)

Where,

  1. tblProducts = Data table name
  2. Title = SharePoint text column
  3. Vendor = SharePoint choice column
Power Apps Data table conditional formatting based on multiple columns
  • At last, save, publish, and preview the app. The selected row will become brown when the user chooses the DELL vendor or Mobile option.

This way, we can work with Power Apps data table conditional formatting based on SharePoint multiple columns.

Conclusion

I hope this Power Apps tutorial found you well on how to apply various conditional formatting to a Data table control based on some conditions like:

  • Apply conditional formatting based on SharePoint single-column in the Power Apps Data table.
  • How to work with Power Apps Data table conditional formatting based on SharePoint multiple columns.

Additionally, you may like some more Power Apps tutorials:

>