GitHub user sam-hieken edited a comment on the discussion: Conditional 
formatting improvements

If anyone's still looking for a solution to the first issue, happy to say I 
discovered a great workaround for conditional formatting on non-numeric columns 
(though unfortunately it's quite hacky).

Basically, you can take advantage of the fact that the table will render 
columns as HTML if "Render columns in HTML format" is enabled. You can create a 
calculated column in Superset (or in a view through your database) based on 
your non-numeric column that conditionally checks values and wraps them in an 
HTML tag you can style. For example:


<img width="811" alt="Screenshot 2025-02-03 at 7 58 40 PM" 
src="https://github.com/user-attachments/assets/6c97853b-2164-4bf6-b3d7-c62d4b9f3899";
 />


Of course we can use a CSS class to handle repetitive styling through the CSS 
editor in the dashboard...


<img width="551" alt="Screenshot 2025-02-03 at 8 25 33 PM" 
src="https://github.com/user-attachments/assets/1047db00-72e0-404b-97b5-fb054c6bf715";
 />


And here's the result:


<img width="432" alt="Screenshot 2025-02-03 at 8 30 40 PM" 
src="https://github.com/user-attachments/assets/7c0d9420-43ae-4a68-89d9-e71c070e6367";
 />


Again, not ideal, but at least you also get a lot of flexibility in how it 
looks. Keep in mind you can just use the original column for dashboard filters 
so the HTML isn't included in the select options.

**Important Note:** Just to clarify, `level_pretty` is a calculated column (I 
don't believe this trick will work with metrics, but I'd need to do more 
testing). The column "Level" in the table I showed is `level_pretty`. 

GitHub link: 
https://github.com/apache/superset/discussions/22790#discussioncomment-12049591

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: 
notifications-unsubscr...@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to