# Stopping a job at a component when certain criteria is met

**URL:** <https://matillioncommunity.discourse.group/t/stopping-a-job-at-a-component-when-certain-criteria-is-met/1445>\
**Category:** Matillion ETL\
**Created:** [September 8, 2021, 9:26pm UTC](https://matillioncommunity.discourse.group/t/stopping-a-job-at-a-component-when-certain-criteria-is-met/1445 "2021-09-08T21:26:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kerri.gathright](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/kerri.gathright/32/11_2.png) [@kerri.gathright](https://matillioncommunity.discourse.group/u/kerri.gathright)\
**Post date:** [September 8, 2021, 9:26pm UTC](https://matillioncommunity.discourse.group/t/stopping-a-job-at-a-component-when-certain-criteria-is-met/1445/1 "2021-09-08T21:26:57Z")

</div>

**I have a job that starts with Python code that calls an API for a report. If the report comes back "Data Not Available" I want to stop the job at that Python step and not continue.**

**What component is best to use for this logic?**

---

<div class="post-metadata">

**Author:** ![ian.funnell](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/ian.funnell/32/605_2.png) [@ian.funnell](https://matillioncommunity.discourse.group/u/ian.funnell)\
**Post date:** [September 9, 2021, 8:12am UTC](https://matillioncommunity.discourse.group/t/stopping-a-job-at-a-component-when-certain-criteria-is-met/1445/2 "2021-09-09T08:12:56Z")

</div>

Hi [@kerri.gathright](https://matillioncommunity.discourse.group/u/kerri.gathright)​,

There are different ways to do conditional branching in a Matillion ETL [orchestration job](https://documentation.matillion.com/docs/8347111). For what you have described there are two which you could look at first:

- In your Python Script component, make it raise an Exception if the report comes back "Data Not Available". By default that will make the component fail, which will make the job fail and stop with a failure message. But you can connect another branch onto the [red connection ring](https://documentation.matillion.com/docs/2694747), finishing in an "[end success](https://documentation.matillion.com/docs/2043150)". That will stop the job gracefully. It's like an except handler in Python.
- The more generic method is to use an [If Component](https://documentation.matillion.com/docs/2282996). You can make it check values of variables, and send the logic in different directions accordingly.

Hope that makes sense and is helpful

Ian

---

<div class="post-metadata">

**Author:** ![kerri.gathright](https://sea2.discourse-cdn.com/flex002/user_avatar/matillioncommunity.discourse.group/kerri.gathright/32/11_2.png) [@kerri.gathright](https://matillioncommunity.discourse.group/u/kerri.gathright)\
**Post date:** [September 9, 2021, 9:39pm UTC](https://matillioncommunity.discourse.group/t/stopping-a-job-at-a-component-when-certain-criteria-is-met/1445/3 "2021-09-09T21:39:03Z")

</div>

I decided to use the Python script, super useful thank you!

&nbsp;

I also added a start date parameter because I want that date to be the first one so I know I'm on the correct Thursday thereafter. I also added this start date in the job variables, however I think now I need to remove some of the other code or rearrange it because this new job variable is throwing an error. Suggestions?

&nbsp;

Python:

 ![0694G00000GGlggQAD_0D74G000007jhHDSAY](https://us1.discourse-cdn.com/flex002/uploads/matillioncommunity/original/1X/4fbb4a42058ff75e5892eed240a79adeca326c6e.png)

&nbsp;

Job variables:

 ![0694G00000GGlgqQAD_0D74G000007jhHDSAY](https://us1.discourse-cdn.com/flex002/uploads/matillioncommunity/original/1X/9e31096f0d4f4c4fc7ff9b3d9d3495ce14df2ebc.png)

&nbsp;
