Title: Conditional formatting
Last modified: December 9, 2021

---

# Conditional formatting

 *  Resolved [jorg2](https://wordpress.org/support/users/jorg2/)
 * (@jorg2)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/conditional-formatting-10/)
 * Hi there,
 * is conditional formatting of values in a collumn based on rules possible?
 * Example: Collumn “Sales”
 * – If Sales < 10 then font color = red
    – If Sales >= 10 AND Sales < 100 then 
   font color = yellow – If Sales >= 100 then font color = green
 * If it’s not a built in function, is there a workaround?
 * Best regards
    Jorg

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [jorg2](https://wordpress.org/support/users/jorg2/)
 * (@jorg2)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/conditional-formatting-10/#post-15149083)
 * The best solution for me would be if the values (10, 100) could be defined dynamically
   based on sql-queries that select basic user inputs made before.
 * Another solution for me could be to do conditional formatting based on the content
   of a hidden collumn “ColorCode”:
 * – If ColorCode = 1 then font color Sales = red
    – If ColorCode = 2 then font 
   color Sales = yellow – If ColorCode = 3 then font color Sales = green
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/conditional-formatting-10/#post-15150101)
 * Hi Jorg,
 * This combination of conditions cannot be added using URL parameters. Sorry! But
   you can add a default where in your publications and projects. This is explained
   here:
    [https://wpdataaccess.com/docs/documentation/data-publisher/adding-filters/](https://wpdataaccess.com/docs/documentation/data-publisher/adding-filters/)
   [https://wpdataaccess.com/docs/documentation/data-projects/adding-filters/](https://wpdataaccess.com/docs/documentation/data-projects/adding-filters/)
 * I am currently extending the Query Builder with a visual component. When that
   part is ready, the next step is to support query based publications. I hope to
   have this available first quarter next year.
 * Does this help?
 * Thanks,
    Peter
 *  Thread Starter [jorg2](https://wordpress.org/support/users/jorg2/)
 * (@jorg2)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/conditional-formatting-10/#post-15151112)
 * Hi Peter,
 * thank you for your instant reply.
 * I understand that it’s possible to use complex statements / subqueries in where
   clauses. This makes a solution possible to
    – Filter by username with environment
   variable $$USERID$$ AND – Filter a subset of records for example that meet the
   condition (sales > 100)
 * This makes it possible to devide the records of a large dataset into several 
   output tables depending on conditions that are defined in the where clause (or
   Shortcode or URL Parameters). I bought the premium version and I’m currently 
   testing this.
 * My goal is to make large datasets in ONE table more readable by adding a visual
   component (font color) so that the user can easily identify records where he 
   has to take some action. It’s important to mention that the conditions for formatting
   are variable from user to user. Example: User 1 Table 1: Sales > 100 => font 
   green, User 1 Table 2: Sales > 35 => font green, User 2 Table 1: Sales > 10 =
   > font green. The cutting values for green are calculated in the backend. They
   are available in a MySQL table.
 * I thought there could be a solution by adding CSS or custom Javascript to a collumn.
   I saw that there is a “Code Manager Plugin” that is completing WP Data Access.
   Is there a solution by adding Javascript etc. with the Code Manager?
 * Many Greetings
    Jorg
    -  This reply was modified 4 years, 6 months ago by [jorg2](https://wordpress.org/support/users/jorg2/).
 *  Plugin Author [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * (@peterschulznl)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/conditional-formatting-10/#post-15153324)
 * Hi Jorg,
 * >>> I thought there could be a solution by adding CSS or custom Javascript to
   a collumn.
 * Here is an example using the Code Manager:
    [https://wpdataaccess.com/docs/documentation/data-publisher/advanced-settings/#javascript-functions-more-complex](https://wpdataaccess.com/docs/documentation/data-publisher/advanced-settings/#javascript-functions-more-complex)
 * You can also add a one liner to your publication advanced settings like this:
   “
   rowCallback”: “if (data[1] == ‘Z 800 E ABS’) { jQuery(row).find(‘td:eq(1)’).addClass(‘
   colorBlack’); } else { jQuery(row).find(‘td:eq(1)’).addClass(‘colorGreen’); }”
 * Personally I prefer the Code Manager solution as this makes your custom code 
   more readable and managable. But the choice is yours.
 * Have a nice weekend 😊
    Peter

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Conditional formatting’ is closed to new replies.

 * ![](https://ps.w.org/wp-data-access/assets/icon-256x256.png?rev=3299063)
 * [WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards](https://wordpress.org/plugins/wp-data-access/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-data-access/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-data-access/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-data-access/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-data-access/reviews/)

## Tags

 * [conditional formatting](https://wordpress.org/support/topic-tag/conditional-formatting/)

 * 4 replies
 * 2 participants
 * Last reply from: [Passionate Programmer Peter](https://wordpress.org/support/users/peterschulznl/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/conditional-formatting-10/#post-15153324)
 * Status: resolved