# Dash datatable Conditional Formatting

**URL:** <https://community.plotly.com/t/dash-datatable-conditional-formatting/40493>\
**Category:** Dash Python\
**Created:** [June 3, 2020, 8:15am UTC](https://community.plotly.com/t/dash-datatable-conditional-formatting/40493 "2020-06-03T08:15:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![geoforce](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@geoforce](https://community.plotly.com/u/geoforce)\
**Post date:** [June 3, 2020, 8:15am UTC](https://community.plotly.com/t/dash-datatable-conditional-formatting/40493/1 "2020-06-03T08:15:28Z")

</div>

Is is possible to style a cell based on the info that is in the cell next to it?

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/a/abab4feaf130b293a30965650225b33af346a573.png) I would like to get the same color to match the cell to the right

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [June 3, 2020, 1:52pm UTC](https://community.plotly.com/t/dash-datatable-conditional-formatting/40493/2 "2020-06-03T13:52:05Z")

</div>

Sure - the easiest way is to apply the same formatting to the column and the one to it’s left, for example:

```auto
import dash
import dash_table
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(6,4), columns=list('ABCD'))

app = dash.Dash( __name__ )

app.layout = dash_table.DataTable(
    id='table',
    columns=[{"name": i, "id": i} for i in df.columns],
    data=df.to_dict('records'),
    style_data_conditional=[
        {    

            'if': {
                'filter_query': '{C} > 0',
                'column_id': ['B', 'C']
               
            },
            'backgroundColor': 'dodgerblue',
            'color': 'white'
        },
    ]
)

if __name__ == ' __main__':
    app.run_server(debug=True)

```

And note - ability to use a list for `column_id` , `row_index` , and `header_index` was added in Dash 1.12.0

---

<div class="post-metadata">

**Author:** ![geoforce](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@geoforce](https://community.plotly.com/u/geoforce)\
**Post date:** [June 3, 2020, 5:20pm UTC](https://community.plotly.com/t/dash-datatable-conditional-formatting/40493/3 "2020-06-03T17:20:28Z")

</div>

Thank you so much!!! This worked great and gave me lots of good ideas on how to use formatting. Great help!!

---

<div class="post-metadata">

**Author:** ![AnnMarieW](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@AnnMarieW](https://community.plotly.com/u/AnnMarieW)\
**Post date:** [June 3, 2020, 5:34pm UTC](https://community.plotly.com/t/dash-datatable-conditional-formatting/40493/4 "2020-06-03T17:34:27Z")

</div>

Super - glad it helped! 😀

A lot of great examples were added to the tutorial recently. The latest release had many cool new features for data tables.

[https://dash.plotly.com/datatable/conditional-formatting](https://dash.plotly.com/datatable/conditional-formatting).
