---
title: "Data Quality Studio: Creating Data Quality Rules through Custom SQL and Atlan AI Suggestions"
url: "https://atlan.com/demos/data-quality-studio-creating-data-quality-rules-through-custom-sql-and-atlan-ai-suggestions/"
description: "Build advanced, flexible data quality checks! Learn how to use custom SQL and Atlan AI in Data Quality Studio for reliable, trustworthy data."
format: "Video"
video: "https://videos.ctfassets.net/nwa1c00rtgxb/5VLvNhDviiA7oqhYI5C7C/87d1bf0c8538157108e8459b4e7159a8/Creating_Data_Quality_Rules_through_Custom_SQL_and_Atlan_AI_Suggestions.mp4"
content_purpose: ["Product Overview"]
target_persona: ["General", "Data Engineer", "Data Analyst", "Data Scientist", "IT Administrator", "Data Steward", "Data Governance Lead"]
journey_stage: ["S2 - Discovery", "C1 - Onboarding", "C3 - Adoption", "C4 - Expansion"]
use_case_context: ["Training"]
product: ["Data Marketplace - Data Quality"]
content_type: "video transcript"
transcript_source: "contentful"
---

# Data Quality Studio: Creating Data Quality Rules through Custom SQL and Atlan AI Suggestions

Transcript of the video at https://atlan.com/demos/data-quality-studio-creating-data-quality-rules-through-custom-sql-and-atlan-ai-suggestions/

<!-- Body: machine transcript stored on the Contentful entry (field contentBody), timestamps kept, product names corrected. Not yet edited by a person. -->

## Creating Data Quality Rules through Custom SQL and Atlan AI Suggestions

Atlan’s Data Quality Studio comes with several out-of-the-box, pre-built rules, making it easy for anyone to start validating their data—no SQL required. But it doesn’t stop there. For more advanced use cases, you can write custom SQL rules or even get a head start with Atlan AI, which helps generate rule logic when you’re not quite confident in your SQL skills. It’s flexible enough for both beginners and power users to work side by side. Let’s see this in action

Clicking on the asset icon on the left hand navigation opens the asset discovery page. Here, we are able to see our entire data estate. For this, we are looking to add a new rule to our Master Credit Card Invoices table to check that the actual tax amount applied is greater than 6%.

We search for Master Credit Card Invoices to get our table, click on the table name hyperlink to open the asset overview page and click on the data quality tab, opening the data quality page. Clicking on the add rule brings the data quality rule creation options. In this case, we are looking to create a custom rule, so we select custom SQL.

The custom SQL popup window appears and we are presented with the capability to write our own SQL for the rule. The custom SQL option allows you to create complex rules, from combining multiple columns to aggregates to joining other tables.

Two key aspects to note when creating a custom rule.

- They must return a single numerical value, as on the left side, you will provide the validation of the rule based on is greater than or equal to, is less than or equal to, or equals. So utilizing counts, case statements and other options to create a single numerical value is needed
- When creating a custom SQL rule, it will be attached to only the table that you create it on, even if you join other tables or additional columns. In the overview, it will show as a Table Level rule.
Now, we already have our query ready to go, so we simply paste it in and then click on the Test SQL Query to validate it. Our validation completes and we see that we do not have any rows that are failing our new rule.

But what if weren’t proficient at SQL but still wanted to create complex rules comparing multiple columns. This is where Atlan AI comes in. At the top, we can ask Atlan AI to generate a query for us. For Atlan AI, all comparison data must be inside the table you have selected. Let’s try this out. We enter in

create an accuracy check where tax amount should equal the rounded to 2 decimals calculation of quantity * tax rate * unit price / 100

Atlan AI writes out our query for us, even removing our existing query, showing the changes, and clicking apply gives us our new query ensuring that our tax amount column is equal to the calculated tax amount. We test the SQL and it works, with no rows failing our check.

Regardless of the SQL being generated by Atlan AI or by ourselves, we need to additionally fill out the information on the left hand side to save the rule.

First, we enter the rule name, in this case we put Tax Rate Equals Calculated Value. In the description we add in that it checks the tax rate is equal to the calculation of quantity, tax rate, and unit price divided by 100.

Below this is the validation of the query. As said before, we must return a numeric value from our SQL, and in this case, it is the total number of rows where it is failing the rule, so we say that we should pass the query if the results are less than or equal to 0, meaning if there is a single row that fails, the rule should fail.

Next, we add the dimension that the rule applies to, in this case this is checking the accuracy of our tax rate, so we select tax rate.

Finally, if we wanted to change the notification settings for the failures on this rule, we could expand the advanced settings. Clicking create saves our new data quality rule. The page updates, and we see our new rule listed.

Whether you’re writing complex custom rules or leaning on AI to get started, Data Quality Studio meets you where you are. It’s designed to support both experienced SQL users and those just starting out—so everyone can play a role in improving data quality and building trust across the organization.
