# \[Resolved\] Add a constraint for null values (that occur together)

**URL:** <https://forum.datacebo.com/t/resolved-add-a-constraint-for-null-values-that-occur-together/228>\
**Category:** Synthetic Data Creation\
**Tags:** constraints\
**Created:** [July 16, 2024, 9:53pm UTC](https://forum.datacebo.com/t/resolved-add-a-constraint-for-null-values-that-occur-together/228 "2024-07-16T21:53:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![neha](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.datacebo.com/neha/32/15_2.png) [@neha](https://forum.datacebo.com/u/neha)\
**Post date:** [July 16, 2024, 9:53pm UTC](https://forum.datacebo.com/t/resolved-add-a-constraint-for-null-values-that-occur-together/228/1 "2024-07-16T21:53:54Z")

</div>

Let’s use this topic to discuss this Q from @yuntien.lee:

> Can you also advise how to set constraints e.g. if AdmitType is null then AdmitDate is null?

---

<div class="post-metadata">

**Author:** ![neha](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.datacebo.com/neha/32/15_2.png) [@neha](https://forum.datacebo.com/u/neha)\
**Post date:** [July 16, 2024, 9:58pm UTC](https://forum.datacebo.com/t/resolved-add-a-constraint-for-null-values-that-occur-together/228/2 "2024-07-16T21:58:02Z")

</div>

Hi @yuntien.lee I started this thread to specifically advise you on this custom constraint. To make sure we provide the right guidance, I would like to clarify one case:

You mention that if `AdmitType` is null then `AdmitDate` must also be null. Does this inverse logic also apply – if `AdmitType` is NOT null then `AdmitDate` must also be NOT null?

I am also curious if this type of logic is only present for `AdmitType` and `AdmitDate` columns or whether you have other instances of very similar logic (all values must be null together, or not at all) for different groups of columns in your dataset?

---

<div class="post-metadata">

**Author:** ![yuntien.lee](https://avatars.discourse-cdn.com/v4/letter/y/7ba0ec/32.png) [@yuntien.lee](https://forum.datacebo.com/u/yuntien.lee)\
**Post date:** [July 17, 2024, 3:41pm UTC](https://forum.datacebo.com/t/resolved-add-a-constraint-for-null-values-that-occur-together/228/3 "2024-07-17T15:41:47Z")

</div>

No, the inverse does not apply, ie if AdmitType is NOT null then AdmitDate can sometimes be NULL due to data quality, but in the source data there are certain rows with AdmitType null but AdmitDate NOT null so we cleaned the data for that.  
Also the same rule applies for, if DischargeStatus is null then DischDate will be null.

---

<div class="post-metadata">

**Author:** ![neha](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.datacebo.com/neha/32/15_2.png) [@neha](https://forum.datacebo.com/u/neha)\
**Post date:** [July 17, 2024, 5:20pm UTC](https://forum.datacebo.com/t/resolved-add-a-constraint-for-null-values-that-occur-together/228/4 "2024-07-17T17:20:54Z")

</div>

Got it. So to generalize this a bit, would it be fair to say: Whatever combinations of null values appear in the real data should be the only combinations that appear in the synthetic data?

So for the `AdmitType`, `AdmitDate` columns, only 3 of the 4 possible combinations are allowed:

| AdmitType | AdmitDate |
| --- | --- |
| Not Null | Not Null |
| Not Null | Null |
| Null | Null |

---

<div class="post-metadata">

**Author:** ![yuntien.lee](https://avatars.discourse-cdn.com/v4/letter/y/7ba0ec/32.png) [@yuntien.lee](https://forum.datacebo.com/u/yuntien.lee)\
**Post date:** [July 19, 2024, 3:51pm UTC](https://forum.datacebo.com/t/resolved-add-a-constraint-for-null-values-that-occur-together/228/5 "2024-07-19T15:51:40Z")

</div>

Yes that should be correct according to our understanding.

---

<div class="post-metadata">

**Author:** ![neha](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.datacebo.com/neha/32/15_2.png) [@neha](https://forum.datacebo.com/u/neha)\
**Post date:** [January 26, 2026, 8:42pm UTC](https://forum.datacebo.com/t/resolved-add-a-constraint-for-null-values-that-occur-together/228/6 "2026-01-26T20:42:39Z")

</div>

Following up on this thread: We added the [FixedNullCombinations constraint](https://docs.sdv.dev/sdv/concepts/constraint-augmented-generation-cag/predefined-constraints/fixednullcombinations) in [version 0.28.0](https://forum.datacebo.com/t/sdv-enterprise-version-0-28-0/357). This constraint is able to accomplish the logic, so I’m marking this thread as resolved.
