# Applying conditional formatting rules

In this section, we'll look at a few practical applications of conditional formatting.

### 1. Number threshold

You can compare your measures against a threshold value and apply formatting if the condition is satisfied. In this case, we've changed the font color to green if AC exceeds 25m or the previous year's variance exceeds  4m.

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2FUl06RHuy0EIv1kiJa09P%2Fimage.png?alt=media&#x26;token=8f59e4c8-4578-4de3-837d-5e4d5645ed6c" alt=""><figcaption><p>Setting a rule based on a number threshold</p></figcaption></figure>

### 2. Column comparisons

You can compare two columns from your data, E.g. Sales versus Forecast, and apply conditional formatting if the condition is satisfied.&#x20;

{% tabs %}
{% tab title="Charts" %}
Let's highlight the quarters where the Actuals exceed the Plan and the Previous year's actuals.&#x20;

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2FVLqd5sm0LUdhO5KtP7c9%2Fimage.png?alt=media&#x26;token=9441895c-d348-4779-909d-08578ce24ed8" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Tables" %}
In this example, we have highlighted the cells in light blue when AC exceeds the previous year's actuals.

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2FFpHp6O2lWErsEtuStBqw%2Fimage.png?alt=media&#x26;token=cbb2dfaa-af67-4b55-85aa-642e1583d7e9" alt=""><figcaption><p>Conditional formatting based on comparing values</p></figcaption></figure>
{% endtab %}
{% endtabs %}

### 3. Calculated comparisons

In the condition, you can apply simple calculations like addition, subtraction, multiplication, and division.&#x20;

{% tabs %}
{% tab title="Charts" %}
Let's highlight the bullets where the Actuals exceed 98% of the Plan.

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2Fqy1ufWHlfmxURnJ0y4dd%2Fimage.png?alt=media&#x26;token=4cd8e2cb-8a67-4142-b319-23d0e814a54e" alt=""><figcaption><p>Conditional formatting based on column comparisons in a chart</p></figcaption></figure>
{% endtab %}

{% tab title="Tables" %}
In this table, we've highlighted the cells in green when AC is greater than 98% of the plan.

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2FG2txkVMRsFET9WMEpsSD%2Fimage.png?alt=media&#x26;token=f365ed41-54aa-4532-bbb8-8f22e4bc1627" alt=""><figcaption><p>Calculated comparisons</p></figcaption></figure>
{% endtab %}
{% endtabs %}

### 4. Conditional formatting for relative time periods

For date-based reports, apply conditional formatting to highlight data for specific time periods - like the past week, past month, next week, or previous day. This helps direct users' focus to recent activity.&#x20;

{% tabs %}
{% tab title="Charts" %}
In the example, we've highlighted the sales measure for the past week with a hatched fill and a different color.

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2FklJctBIpfGmCPQGleHwZ%2Fimage.png?alt=media&#x26;token=6cca257e-84e8-4ba4-8637-a39a138075a5" alt=""><figcaption><p>Conditional formatting for the past week</p></figcaption></figure>
{% endtab %}

{% tab title="Tables" %}
We've used conditional formatting rules based on relative dates to highlight the quantity and sales for the current month.

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2FQ3zDEu8P3TlRptR5kMsp%2Fimage.png?alt=media&#x26;token=629dc697-74d2-4476-918e-3b571f3eb671" alt=""><figcaption><p>Conditional formatting based on relative dates for tables</p></figcaption></figure>
{% endtab %}
{% endtabs %}

### **5. Conditional formatting based on grand average**

Gain deeper insights in small multiples mode with the grand average option in conditional formatting. You can apply formatting based on the average values across all panels and highlight categories greater or less than the overall average.&#x20;

Before we can use the grand average in a conditional formatting rule, we need to enable the **Average Panel** toggle from trellis settings. The average panel is the last one, titled '3 Segments'.

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2FY7zH5LpHwFJG6ldOaWCy%2Fimage.png?alt=media&#x26;token=8fe80aac-c94d-4578-922b-66d4e306b260" alt=""><figcaption><p>Enabling average panel</p></figcaption></figure>

As a practical example, let's create a conditional formatting rule that compares the enhanced profit with the grand average profit.

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2FoGTtQGnWufzWEXGtjnNN%2Fimage.png?alt=media&#x26;token=c4018111-8da7-4d12-94e4-4a2c021e55a7" alt=""><figcaption><p>Conditional formatting rule based on grand average</p></figcaption></figure>

Notice how we've highlighted the regions with enhanced profits greater than the grand average across segments.

<figure><img src="https://3132984990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbOoZhPvC57Z0CNgep4Ib%2Fuploads%2FHsdJzpPSDTxtXqpf88Sz%2Fimage.png?alt=media&#x26;token=498a8840-9c75-4a4f-a29c-e96bc158b368" alt=""><figcaption><p>Conditional formatting based on grand average</p></figcaption></figure>

We'll look at color scales in the next section.
