# How to change the colour of different columns based on value of a specific row

**URL:** https://community.plotly.com/t/how-to-change-the-colour-of-different-columns-based-on-value-of-a-specific-row/48287
**Category:** Dash Python
**Created:** [December 17, 2020, 8:52am UTC](https://community.plotly.com/t/how-to-change-the-colour-of-different-columns-based-on-value-of-a-specific-row/48287 "2020-12-17T08:52:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Kartik](https://avatars.discourse-cdn.com/v4/letter/k/e274bd/32.png) [@Kartik](https://community.plotly.com/u/Kartik)
#### Post date: [December 17, 2020, 8:52am UTC](https://community.plotly.com/t/how-to-change-the-colour-of-different-columns-based-on-value-of-a-specific-row/48287/1 "2020-12-17T08:52:43Z")

</div>

Hi,

I have a data table to be displayed. I want to show different columns in a different color based on specific row values. IS that possible?

---

<div class="post-metadata">

### Author: ![Eduardo](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/eduardo/32/13310_2.png) [@Eduardo](https://community.plotly.com/u/Eduardo)
#### Post date: [December 17, 2020, 11:42am UTC](https://community.plotly.com/t/how-to-change-the-colour-of-different-columns-based-on-value-of-a-specific-row/48287/2 "2020-12-17T11:42:31Z")

</div>

Hi [Kartik](https://community.plotly.com/u/Kartik),

Yes, this is posible, this solution applies for your question:

> [@How to change background color of a cell based on the another cell value? (Conditional style in dash table)](https://community.plotly.com/t/how-to-change-background-color-of-a-cell-based-on-the-another-cell-value-conditional-style-in-dash-table/48176/2):
>
> HI @hamedk and welcome to the Dash community slight_smile One way to do this is to use a variable to update the background color for the cells. Here is an example: import dash import dash\_table import pandas as pd data = dict([("a", [4, 2, 1]), ("b", [6, 3, 0])]) df = pd.DataFrame(data) bg\_color = "white" if df.iloc[2]["a"] == 1: bg\_color = "green" app = dash.Dash(\_\_name\_\_) app.layout = dash\_table.DataTable( data=df.to\_dict("records"), columns=[{"name": i, "id": i} fo…

Instead of one cell background you need to apply for the entire column.

More info here:

> **[Conditional Formatting | Dash for Python Documentation | Plotly](https://dash.plotly.com/datatable/conditional-formatting)**
>
> \`dash\_table.DataTable\` is an interactive table that supports rich styling, conditional formatting, editing, sorting, filtering, and more.
