# Validity Rules

{% hint style="success" %}

#### Validity Rules

In this series of detailed workshops we're going to:

* Understand the business value and ROI of implementing business rules
* Master the 7 Data Quality Dimensions in PDC
* Create and configure business rules with detailed step-by-step guidance
* Implement rule actions (Status, Tags, Webhooks) and understand their purpose
* Organize rules using rule groups for operational efficiency
* Monitor and interpret rule execution results for continuous improvement

{% endhint %}

x

***

{% hint style="info" %}

#### Accessing your Catalog

To get started using the Data Catalog, log in using the address and credentials provided by your Data Catalog service user or administrator.
{% endhint %}

To access your catalog, please follow these steps:

1. Open **Google Chrome** web browser.
2. Navigate to:

{% embed url="<https://pdc.pentaho.lab>" %}

3. Enter following email and password, then click **Sign In**.

Username: <david.park@adventureworks.com> (mapped to Business Steward role)

Password: Welcome123!

***

x

x

{% tabs %}
{% tab title="Order Dates" %}
{% hint style="info" %}

#### Valid Order dates

**Scenario:** Ensure OrderDate is never in the future and ShipDate is after OrderDate.
{% endhint %}

**Business Rule Configuration:**

```
Rule Name: Order_Date_Validity
Description: Validates logical date relationships in orders
Data Quality Dimension: Validity
Schedule: Daily
Target: Sales.SalesOrderHeader
```

**SQL Query:**

```sql
SELECT 
    COUNT(*) AS total_count,
    SUM(CASE 
        WHEN OrderDate <= GETDATE() 
        AND (ShipDate IS NULL OR ShipDate >= OrderDate)
        AND (DueDate >= OrderDate)
        THEN 1 ELSE 0 
    END) AS scopeCount,
    SUM(CASE 
        WHEN OrderDate > GETDATE() 
        OR (ShipDate IS NOT NULL AND ShipDate < OrderDate)
        OR (DueDate < OrderDate)
        THEN 1 ELSE 0 
    END) AS nonCompliant
FROM Sales.SalesOrderHeader
```

***

x
{% endtab %}

{% tab title="Product Quantity Range" %}
{% hint style="info" %}

#### Product Quantity Range

**Scenario:** Inventory quantities should be within reasonable business ranges.
{% endhint %}

**Business Rule Configuration:**

```
Rule Name: Inventory_Quantity_Validity
Description: Validates inventory quantities are within acceptable ranges
Data Quality Dimension: Validity
Schedule: Daily
Target: Production.ProductInventory
```

**SQL Query:**

```sql
SELECT 
    COUNT(*) AS total_count,
    SUM(CASE 
        WHEN Quantity >= 0 
        AND Quantity <= 10000 
        AND Bin BETWEEN 1 AND 100
        THEN 1 ELSE 0 
    END) AS scopeCount,
    SUM(CASE 
        WHEN Quantity < 0 
        OR Quantity > 10000 
        OR Bin NOT BETWEEN 1 AND 100
        THEN 1 ELSE 0 
    END) AS nonCompliant
FROM Production.ProductInventory
```

***

x
{% endtab %}
{% endtabs %}

x

x

{% tabs %}
{% tab title="First Tab" %}
x
{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}

x


---

# 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/data-catalog/business-rules/validity-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.
