# Rules (If conditions)

You can use conditional formatting to change the font color, style, icons, background color, or border color based on one or more IF conditions.

To get started, refer to the [Create Rule](https://docs.inforiver.com/premium-table/working-with-premium-table/5.-conditional-formatting/rules-if-conditions/bubble-charts) section. Once the title and applying options have been configured, follow the steps below to create one or more rules:

## 1. Create Rule

**STEP 1:** Choose 'Rules (If conditions)' in the **Format by** dropdown. You can see two sections - Style and Conditions.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FluTXFoJzC8wccEIphN7x%2Fimage.png?alt=media&#x26;token=2edac003-c3ff-4b10-b8e1-4f3416bacd7a" alt=""><figcaption><p>Choosing Rules (If conditions)</p></figcaption></figure>

**STEP 2:** Using the **Style** section, you can format text based on color/style, apply a background color or border color, or select icons. Within each of these options, you can change the color, border style, icon position, and visibility.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F775FLa0i0rXsBGfXPNZx%2Fimage.png?alt=media&#x26;token=14117cbf-02c2-40ef-a9fc-7d84fc78415c" alt=""><figcaption><p>Style options</p></figcaption></figure>

**STEP 3:** In the **Conditions** section, you can define conditions using options such as Number, Data selection, Value, Formula, and User Selection.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FpbIsE6oxBZCegpdmGyfy%2Fimage.png?alt=media&#x26;token=99433131-fc3b-47d6-b9b0-c7e6d906b8f8" alt=""><figcaption><p>Format by rules</p></figcaption></figure>

You can add multiple conditions and combine the rules with AND/OR. This is covered in the '[Add Condition](#add-conditions)' section.

Let's look at examples for each of these options.

## 2. Style

* **Font style: bold, italic, underline**

Set the font style according to the conditional formatting rules. Notice how we've used bold, italics, and underlining to highlight the values that meet the condition. Click on the <img src="https://content.gitbook.com/content/sB9HAei8v4FfKkH9M4gw/blobs/Kwjwbshmi2zBFJGUQSGh/image.png" alt="" data-size="line">icon to select a color for the underline.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FQCyN2wCQXWuv2JOt27Wj%2Fimage.png?alt=media&#x26;token=ff7cf928-deac-431d-b5d2-b32a38cea9ca" alt=""><figcaption><p>Font style</p></figcaption></figure>

* **Cell background**

Use a background color to highlight the cells that match the conditional formatting rule.

* **Font color**

Apply a custom font color when a conditional formatting rule is met.

* **Cell borders**

Highlight cells that satisfy the conditional formatting rule by setting a custom border. You can choose the border color by clicking the<img src="https://content.gitbook.com/content/sB9HAei8v4FfKkH9M4gw/blobs/i7If4esoeXWiRappyJYc/image.png" alt="" data-size="line"> icon.

* **Adding icons or text**

Display icons to apply conditional formatting on your data. You can also use custom icons by clicking the Upload Icon link.

You can position the text/icons with respect to the cell values. You can also choose to display only the icons or text and hide the cell values.

When you use icons, you have an additional option to align your icons in the grid. By default, the icons are left-aligned.

* **Hiding values**

Business reporting may require withholding certain information to protect strategic interests. You can use conditional formatting rules to mask values based on specific criteria.

## 3. Conditions

### 3.1. Number

In this example, we are highlighting the subcategories where the *Actual Sales* are greater than 300 thousand. Note that we have selected 'Bold' and selected 'Green' as the font color. We have chosen grey as the cell background color. The numbers field supports scaled entries such as 300k. Click 'Apply' once the changes are done.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FsIpT7XgBsLMvRT3zYN09%2Fimage.png?alt=media&#x26;token=6e18ea20-0b5f-4ad8-8899-a080607dfb6a" alt=""><figcaption><p>Conditional formatting based on a numeric input</p></figcaption></figure>

### 3.2. Data selection

You can also use a cell value in the condition.&#x20;

* Select 'Data selection', click on the 'select value from' field, and then click on a cell in the report.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F60qpZu9KJLxhxyrayY3E%2Fimage.png?alt=media&#x26;token=2b798407-d3db-4762-981b-da88ade1829a" alt=""><figcaption><p>Applying formatting based on a cell value in the report</p></figcaption></figure>

* The value of the selected cell appears in the condition field when you click on it.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FNrwnV6WfVvRBoJijbHU6%2Fimage.png?alt=media&#x26;token=3d4910e8-0a03-4036-9a73-2d050fe79d67" alt=""><figcaption><p>Selecting data from the report </p></figcaption></figure>

* Click on 'Apply' to apply the formatting where the actual sales are greater than the selected value.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FVjyhFUd3o3xjGm9Fu1xp%2Fimage.png?alt=media&#x26;token=2261cd7e-70e2-4510-a73b-417cc66c7614" alt=""><figcaption><p>Conditional formatting based on data selection</p></figcaption></figure>

### 3.3. Value

You can use conditional formatting based on another measure in the visual. Let's highlight actuals that are higher than the previous year's sales.

{% hint style="info" %}
Measures that were added from the data source, auto-calculated variances, columns/measures created using calculations, data input and simulations can all be used in the IF condition.
{% endhint %}

Click on the highlighted dropdown and select *PY Sales.* Click 'Apply'.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F8v4TsoVXju5Q4Ka0t05H%2Fimage.png?alt=media&#x26;token=b2961330-b67c-4fab-8a9b-cfd5c6fca376" alt=""><figcaption><p>Conditional formatting based on another measure </p></figcaption></figure>

### 3.4. Formula

You can create simple formulas using either numeric values or measures. Let's highlight the records where the actual sales are greater than the previous year's sales by at least 200,000. Configure as shown in the below image and click 'Apply'.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FK8oxIBPYhBB6iMiHV31k%2Fimage.png?alt=media&#x26;token=bfdc5a33-5db5-4743-b769-4bfebee3f69c" alt=""><figcaption><p>Conditional formatting based on formula</p></figcaption></figure>

### + Add Condition

The '**Add condition**' option lets you create nested AND/OR conditions. Data is formatted according to the logic and list of conditions that have been configured.

**STEP 1:** Click on **Add Condition** to add additional condition(s).

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FBFP4JFwGROJ6A1jrUMTI%2Fimage.png?alt=media&#x26;token=f11fc5ab-c7a0-4958-b0f5-b0b6f474af4b" alt=""><figcaption><p>Add Condition</p></figcaption></figure>

**STEP 2:** You can see another condition with default selections and an option to select AND/OR. Let's select 'AND' and 'Category' from the dropdown.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FvswxRB5r4BHRNcY6bdV4%2Fimage.png?alt=media&#x26;token=c0e53d9e-8c03-4e4b-a838-104d1e72c8aa" alt=""><figcaption><p>Adding a condition with AND</p></figcaption></figure>

**STEP 3:** You can see several options as shown in the below image. Let's go with the default option.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FlwYf5HibKm5DAl3cCgz9%2Fimage.png?alt=media&#x26;token=54f41160-30fd-4a08-b8bd-0fb989143574" alt=""><figcaption><p>Options for 'Category'</p></figcaption></figure>

**STEP 4:** In the 'Choose members' dropdown, let's select 'Computers' and 'Cell phones'.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F2Drt4iFktTOL3l8SCIg4%2Fimage.png?alt=media&#x26;token=a26ffbd5-bf11-4310-909e-d1c8400f8309" alt=""><figcaption><p>Selecting a category</p></figcaption></figure>

**STEP 5:** You can add as many conditions as you need and combine them with either AND or OR. Click on 'Apply' to apply the formatting.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FxX3p3ggg6iR8GuI60c2S%2Fimage.png?alt=media&#x26;token=fbd9af61-47f7-43cb-81d7-b87f8fcda4e7" alt=""><figcaption><p>Adding multiple conditions</p></figcaption></figure>

### 3.5. User selection

You can apply conditional formatting based on a selection during runtime, such as in the reading view. Consider the following scenario: we want to use conditional formatting on 'Actual Sales' based on either the user-selected actual sales or the previous sales value at runtime.

* Configure as shown in the below image. Note that 'Actual Sales' is set in the 'Apply to' field and 'Actual Sales' and 'PY Sales' in the IF condition. Click on the dropdown and select both.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F1llka3j7ZfNRcCi87cxP%2Fimage.png?alt=media&#x26;token=89846c52-2787-4f89-a185-dd5b701679ae" alt=""><figcaption><p>Conditional formatting based on user selection</p></figcaption></figure>

* Let's add an icon as formatting this time. Click on the 'Icon' checkbox. There are several customization options.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FzkPsFdm7uWQ7rQNnVeid%2Fimage.png?alt=media&#x26;token=25470b63-7680-4c7d-837a-0c03eb699e07" alt=""><figcaption><p>Adding an icon</p></figcaption></figure>

* Click on the icon dropdown and choose any icon.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FWzTSZWMMDtbk9lS0DvO4%2Fimage.png?alt=media&#x26;token=34250e10-a84f-4340-853c-29a9cac796ef" alt=""><figcaption><p>Choosing an icon</p></figcaption></figure>

* Let's change the flag color to green and the font color to black. Click 'Apply'.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FHMWU377Db6CwD03jLNfy%2Fimage.png?alt=media&#x26;token=228e8acc-fb94-4361-8f24-916f6af5edad" alt=""><figcaption><p>Customizing the icon color</p></figcaption></figure>

* Click on a value in any of the sales columns. You can see flag icons in the 'Actual Sales' column where the actual sales value is greater than the selected sales.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2Fg6KIkqu8P8qKPgvqzJbR%2Fuserselection.gif?alt=media&#x26;token=14a3b0f3-3695-4bf2-85f1-4428178912e0" alt=""><figcaption><p>Conditional formatting based on user selection</p></figcaption></figure>

### 4. Conditional formatting for data input fields

Highlight your data input fields, like number, dropdown, text columns, etc., with conditional formatting. When users enter values, you can define rules that automatically apply formatting when the rules are met, such as highlighting the cells when the budget entered exceeds a certain limit.

Let's draw attention to the input budget value that is more than 100,000.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2Fc2szaIFuYWAD18Xhnqvm%2Fdi%20cf.gif?alt=media&#x26;token=c710cf70-6b34-4c8f-9a18-5399fd1d9719" alt=""><figcaption><p>Conditional formatting for data input fields</p></figcaption></figure>

### 5. Rules for non-numeric measures

You can apply conditional formatting based on non-numeric measures using conditions such as "contains", "does not contain", "starts with", etc. In this example, we have used borders to highlight the words that contain "Contoso."

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FyopFm5vCJmjvNBW25QvQ%2Fimage.png?alt=media&#x26;token=b8e897d1-b300-4399-97a9-d9c1f3431dfb" alt=""><figcaption><p>Formatting based on text conditions</p></figcaption></figure>

In the next section, we'll be covering [Color scale](https://docs.inforiver.com/premium-table/working-with-premium-table/5.-conditional-formatting/rules-if-conditions/color-scale-and-data-bars).
