Rules

From Q
(Redirected from Data Bars)
Jump to navigation Jump to search

A Rule governs how an output in Q, such as a chart or table, appears. The simplest rules are essentially identical to Conditional Formatting in Excel. For example, the chart below shades the bars proportional to the values.

Rules can also be used to manipulate the contents of outputs. In Example 2 the sample size is inserted into each column heading. In Example 3, a traditional table has been over-written with results from a special form of regression, Shapley Driver Analysis.

Example 1: Conditional formatting of a bar chart

This example is created using Automate > Color Scale and modifying the color options (on the Rules tab, beneath the table).

ConditionalFormattingBarsOrange.PNG.

Example 2: Adding sample sizes to column headings

This example uses Automate > Browse Online Library > Modify Headers - Add Sample Size to Column Labels.

RuleSampleSizeColumns.PNG

Example 3: Shapley regression

This example uses Regression - Legacy Driver Analysis - Table of Shapley Importance Scores, whereby a rule is added via QScript.

ShapleyRegressionRule.PNG

Alternative ways of applying rules

Highlight cells rules

By selecting Automate > Highlight Cells Rules you can create rules about how to color cells based on the range of values in the cells.

Top/Bottom rules

By selecting Automate > Top/Bottom Rules you can create rules about whether to select higher or lower valued cells (e.g., top 10%, below average).

Color scale

By selecting Automate > Color Scale you can shade cells according to their values (i.e., creating heat maps).

Data bars

By selecting Automate > Color Scale you can create a Grid of Bars Plot, such as in the first example above.

Custom Rule

All the rules are written in JavaScript (see Table JavaScript and Plot JavaScript for details). You can write your own rules in JavaScript, applying them by selecting Automate > Custom Rule > Edit JavaScript. See Creating a Custom Rule and Customizing Rules for more information.

Online Library

Custom rules have been created by Q staff to address a variety of common issues (e.g., adding sample sizes to column labels, changing the appearance of small values on tables). You can access custom rules by selecting Automate > Browse Online Library. See Rule Online Library for more information. You can also copy these rules end edit them to suit your needs.

QScript

Rules can also be applied using QScript. For example, the QScript called Regression - Legacy Driver Analysis - Table of Shapley Importance Scores in the Online Library creates new variables, a new table, and applies a custom rule to that table.

Editing, Deleting and Reapplying Rules

When a rule has been added to an output, a new tab will appear at the bottom left of the output called Rules. You can modify rules by clicking on the relevant rule and selecting Edit Rule or Delete Rule.

You can also search for where rules are used by pressing the magnifying glass, as well as apply them to other outputs (using the Apply button at the end of each row).

Further reading: Key Driver Analysis Software