Numerical Conditional Formatting for Datatable doesn't work properly

I am trying to get conditional formatting working and it seems that the formatting for numbers somehow truncates the significant digits and only considers the integer part of a number. Even in the example shown in the user guide doesn’t seem to work properly at

            'if': {
                'column_id': 'Temperature',
                'filter': 'Temperature > num(3.9)'
            'backgroundColor': '#3D9970',
            'color': 'white',

The cell for New York City Temperature shows up as green even though the value is less than 3.9. I’ve tested this in other scenarios and it seems like the conditional formatting for numbers only uses the integer part of the condition (“3” but not “3.9”). I am using the dash packages suggested for installation in the user guide.

One “hack” I came up with is to create a second column with the value of the first column multiplied by 100, and then filter on that column, but apply the conditional formatting to the first column.

Also, this hack will work on columns which have formatted numbers (with dollar signs, commas, percent signs, etc.). You could have a doppelgänger column which you filter on and then apply the conditional formatting to the formatted number column.

@dcomfort This issue has been fixed in and will be in the next dash release (est. March 4th)

1 Like