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:
Column | Data type |
---|---|
Title | Single line of text |
Vendor | Choice [APPLE, HP, SAMSUNG, DELL, LENOVO] |
Customer Name | Single line of text |
Status | Choice [Submitted, Approved, Rejected] |
Apart from these columns, it has other columns with various data types.
- The selected rejected row in the data table is what I want to color red right now, as shown below.
- 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,
- DataTable7 = Data table control name
- Status = SharePoint choice field name
- “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)
- 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.
- 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,
- tblProducts = Data table name
- Title = SharePoint text column
- Vendor = SharePoint choice column
- 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:
- Filter Data table in Power Apps
- Power Apps Data Table URL
- Add a Blank Value to a Dropdown List in Power Apps
- Power Apps Data Table Default Select Row
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com