DataTable - Color only substring in a cell

I was wondering if it is possible to apply color only to a part of the text of a DataTable cell

At the moment I have this table:

The code of that table is this one:

            columns=[{"name": "Version", "id": "Version"},
                     {"name": "Nº entities", "id": "Nº entities"},
                      {"name": "Nº types", "id": "Nº types"}
              'fontWeight': 'bold',
              'font-size': '1.1067708333333333vw',
              'text-align': 'center'
           style_cell={'text-align': 'left'},
            "Version": value1,
            "Nº entities": entities_version1,
            "Nº types": types_version1
            "Version": value2,
            "Nº entities": entities_version2 + entity_growth_text ,
            "Nº types": types_version2 + type_growth_text
                'overflowY': 'scroll', 'height': '8.138020833333334vw', 'width': '97.65625vw', 'margin-left': '0.6510416666666666vw'

I want to color only the brackets that are found in the second row of the table. In this case, entity_growth_text and type_growth_text variables.

If the number inside the brackets starts with a + , color should be green

Else if the number inside the brackets starts with a - , color should be red

Hope you can help me with this. Thanks in advance.

Hi @krakken

The DataTable conditional formatting does not support formatting a substring of a cell.

The only workaround I can think of is to split the “No. Entities” and “No. Types” into two columns and use mult-headers as shown here . Then the formatting can be applied to the second column

1 Like

Hi @AnnMarieW

Thank you for your answer.

Finally I have done this:


Thanks for the help

1 Like

@krakken Oh, I see what you are trying to do now. That looks nice! :+1:

And if you are just comparing 2 numbers the plotly indicators can work really well too.

1 Like

@AnnMarieW Thank you!


Thanks for post, I also have same issue and looking for solution, Really thankful post.

Also another solution is this one: python - DataTable - Color only substring in a cell - Stack Overflow

It is exactly what I was looking for

Ok, again thanks a lot for help, Really appreciate.