# Business Rules

{% hint style="info" %}
It’s not simply the quality and timeliness of data that matters, it’s what you can do with it that really matters. It’s all about showing more value to business people from having higher-quality, more up-to-date data.

Business Rules translate business requirements into logic-based rules you can use to tag your data. You can define business rules to manage your data and track its quality by designating whether or not that data is compliant.

You can use the [**Business Glossary**](broken://pages/cIqRTmUHvrAEy2vCrdZS#glossary) page to define the compliant and non-compliant data and data formats.

Using these definitions, you can use business rules to apply SQL commands (called Data Quality Rules) that identify non-compliant rows in your data. You can add any number of data quality rules to a Business Rule.

If rows are returned it means some of our data is non-compliant (this data is of poor data quality) and we should further investigate and remedy the data at source. Once that is complete, the number of non-compliant rows will hopefully reduce to zero, thus increasing the overall data quality.

Business Rules can be assigned any number of Data Quality (DQ):

• You can choose whether or not to enable data quality rules.

• You can also decide if a rule requires supervisor approval before being deployed.

• Use custom tags to track and group business rules according to your needs.

• For data quality type rules, you can further define one of the 7 standard dimensions of DQ.
{% endhint %}

<figure><img src="/files/0C5V3k9DMqSqFjUegCAB" alt=""><figcaption><p>Management - Business Rules</p></figcaption></figure>

#### Accessing Your Catalog

To access your catalog, please follow these steps:

1. Open Google Chrome web browser. and click on the bookmark, or

   Navigate to: [**https://pdc.pentaho.example/**](https://pdc.pentaho.example/)
2. Enter the following email and password, then click Sign In.

<table data-header-hidden><thead><tr><th width="156"></th><th></th></tr></thead><tbody><tr><td>Username</td><td>data_developer@hv.com</td></tr><tr><td>Password</td><td>Welcome123!</td></tr></tbody></table>

{% hint style="warning" %}

#### **Security Advisory: Handling Login Credentials**

For enhanced security, it is strongly recommended that users avoid saving their login details directly in web browsers. Browsers may inadvertently autofill these credentials in unrelated fields, posing a security risk.

**Best Practice**

• **Disable Autofill:** To mitigate potential risks, users should disable the autofill functionality for login credentials in their browser settings. This preventive measure ensures that sensitive information is not unintentionally exposed or misused.
{% endhint %}

3. From the Business Rules card click Add New and select: Add Business Rule.

{% tabs %}
{% tab title="1. Create a Rule" %}
{% hint style="info" %}
Business rules relate to data quality in at least two fundamental ways. First, they can automate the decisions that the company makes in its day-to-day operations, Second, they can be used to audit data produced by existing processes for compliance with external regulation as well as internal business policies and goals.
{% endhint %}

1. Click Management in the left navigation menu.&#x20;
2. In the 'Business Rules', click: 'Add Business Rule'.
3. In the Create Business Rule page, enter the following information.

<table><thead><tr><th width="237">Field</th><th>Description</th></tr></thead><tbody><tr><td>Business Rule Name (Required)</td><td>Enter the unique name of the rule that your users will recognize. Names must start with a letter, and contain only letters, digits, hyphens, or underscores. White spaces are supported, but trailing spaces are not allowed in names.</td></tr><tr><td>Created by</td><td>Select the username of the owner of the rule. The default value of this field is the logged-in user.</td></tr><tr><td>Description</td><td>Enter a description for this rule. For example, you may want to indicate the purpose of the rule to assist other users.</td></tr><tr><td>Note</td><td>Enter additional comments for the rule. For example, you may want to describe the workflow or use case of the rule.</td></tr><tr><td>Custom Tag</td><td>Add Tag - enables you to group the rules.</td></tr><tr><td>Rule Enabled</td><td><p>By default, a new rule is enabled.</p><p>Clear the check box to disable the rule. When a Rules Execution job is run, disabled rules are skipped and are not evaluated.</p></td></tr><tr><td>Rule Approved</td><td>Select to approve the rule. This option is only available to users with the Data Quality Administrator role.</td></tr></tbody></table>

{% hint style="info" %}
If you've taken a look at the synthea:patients table you will have noticed that not all the patient passport numbers have been entered.

Let's create a Business Rule, a Data Quality Rule, checking for the passport number.

When the Data Quality Rule is applied (non-compliant passport numbers >= 10% of total count) the corresponding Business Rule status = FAILED.
{% endhint %}

<figure><img src="/files/7fiYGqQK9IOtOa1PdQMl" alt=""><figcaption><p>patients.passport</p></figcaption></figure>

<table><thead><tr><th width="234">Field</th><th>Setting</th></tr></thead><tbody><tr><td>Business Rule Name</td><td>synthea:patients:passport</td></tr><tr><td>Created by</td><td>System Operator</td></tr><tr><td>Description</td><td>DQ - passport number</td></tr><tr><td>Note</td><td>Applies to all records</td></tr><tr><td>Custom Tag</td><td></td></tr><tr><td>Rule Enabled</td><td>check</td></tr><tr><td>Rule Approved</td><td>uncheck - if you 'approve' the rule you will not be able to configure the rule.</td></tr></tbody></table>

4. Click Create Business Rule to save your rule.

<figure><img src="/files/HHOttMJGpi0Jh5M07JoG" alt=""><figcaption><p>Create Business Rule</p></figcaption></figure>

6. In the confirmation window, click Configure to [**Configure a rule**](#configure-a-rule) or click Close to configure it later.

<figure><img src="/files/VYudPFT8PgITdWoW3C7o" alt=""><figcaption><p>Configure Business Rule</p></figcaption></figure>
{% endtab %}

{% tab title="Configure a Rule" %}
{% hint style="info" %}
After you create a Business Rule, you can configure it in the Configuration view of the Business Rule page.&#x20;
{% endhint %}

{% hint style="warning" %}
This task assumes you have completed [**Create a rule**](#create-a-rule) and are on the Business Rules page.
{% endhint %}

<figure><img src="/files/Ee0wZLgkdSXhmutZKBJh" alt=""><figcaption><p>Business Rule - synthea:patients:passport</p></figcaption></figure>

1. Locate the business rule you want to configure in the table of rules and select the View Details button (>) in its row.

<figure><img src="/files/DoIoX0wtL11JBTKbpVgD" alt=""><figcaption><p>Business Rule - View Details</p></figcaption></figure>

{% hint style="info" %}
In this example the Business Rule has already been previously executed & modified ..
{% endhint %}

2. If you have a large number of rules, select Show Filters to help you find the rule you want to edit.
3. Click Configuration tab and enter the following details:

<table><thead><tr><th width="246"></th><th></th></tr></thead><tbody><tr><td>Business Rule Type</td><td>Internal DQ</td></tr><tr><td>Data Quality Dimension</td><td>Completeness</td></tr><tr><td>Schedule </td><td>None</td></tr><tr><td>Update Row Count</td><td>Enable</td></tr></tbody></table>

4. Select the Data Quality Dimension -  to differentiate between different quality rules that you create.&#x20;

<table><thead><tr><th width="165">Dimension</th><th>Description</th></tr></thead><tbody><tr><td>Accuracy</td><td></td></tr><tr><td>Uniqueness</td><td></td></tr><tr><td>Consistency</td><td></td></tr><tr><td>Timeliness</td><td></td></tr><tr><td>Conformity</td><td></td></tr><tr><td>Completeness</td><td></td></tr><tr><td>Validity</td><td></td></tr></tbody></table>

5. Set the schedule to run the business rule - None

{% hint style="info" %}
As the Business Rule has been previously executed the Last Run detials are dispalyed.
{% endhint %}

<figure><img src="/files/ZGv97tDnMxQAqp2BOq0U" alt=""><figcaption><p>Business Rule - patients.passport</p></figcaption></figure>

6. Set the rule scope and condition:

   • Select resources on which you want the rule to be evaluated and applied. Select the target table or column.

   • Define the rule's condition for evaluation using the SQL query. Write an SQL query to identify non-compliant data by returning rows that do not match compliant rows and the scope count.

<figure><img src="/files/AF1g1GzG0sC9KwMPbnH3" alt=""><figcaption><p>Business Rule - set scope</p></figcaption></figure>

In the following SQL example patients table is selected to identify patients with missing (NULL) passport numbers.

```
SELECT 
	count(*) total_count,
	count(passport) scopeCount,
	SUM(CASE 
		WHEN passport isnull THEN 1
		ELSE 0
	END) nonCompliant
FROM synthea.patients
```

<table><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><pre><code>count(*) total_count
</code></pre></td><td>The total number of rows in the passport column in the patients table.</td></tr><tr><td><pre><code>count(passport) scopeCount
</code></pre></td><td>The number of patients with a passport number value.</td></tr><tr><td><pre><code>SUM(CASE 
		WHEN passport isnull THEN 1
		ELSE 0
	END) nonCompliant
</code></pre></td><td>When the value of the passport number is null then set as 1 = nonCompliant</td></tr></tbody></table>

Finally ..  configure some rule actions:

7. Set the rule: IF NON COMPLIANT ITEMS >= 10% then set the Business Rule Status to: FAILED

<figure><img src="/files/VBHyv4Q4jZD1T3UUQ9rL" alt=""><figcaption><p>Configure Rule Actions</p></figcaption></figure>

8. Run the rule ..

<figure><img src="/files/09nlY6LmyqhLT9QohuKU" alt=""><figcaption><p>Business Rule Status</p></figcaption></figure>

9. Check the status of the Job

<figure><img src="/files/ROuUghspbh7ew41Z236c" alt=""><figcaption><p>Business Rule - Workers</p></figcaption></figure>

10. And take a look at the Details ..

<figure><img src="/files/l5ZGv8OeUAKUS9mKT5Od" alt=""><figcaption><p>Business Rule - Details</p></figcaption></figure>
{% endtab %}

{% tab title="Rule Group" %}
{% hint style="info" %}
To organize the business rules, you can create a rule group and add your rules. This helps you keep your rules organized and easily accessible.
{% endhint %}

<figure><img src="/files/8UEZdNg4JX1tQzQxVMBZ" alt=""><figcaption></figcaption></figure>

1. Click Management in the left navigation menu.
2. Select Rules Group.
3. Enter the Rule group name, Description, and Note.
4. Set the schedule to run all the business rules in a group, and select one of the following schedules: Daily, Weekly, and Monthly.
5. Click Assign Rules, select the rules you want to add to a group, and then click Assign.

<figure><img src="/files/DnIoypBJcKR2UR1C0Shv" alt=""><figcaption><p>Assign Rules to Group</p></figcaption></figure>

6. Click Save Changes.
   {% endtab %}
   {% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://academy.pentaho.com/pentaho-data-catalog-en/snippet/management/business-rules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
