# Trigger an email when a specific value in a snowflake table reaches threshold

**URL:** <https://matillioncommunity.discourse.group/t/trigger-an-email-when-a-specific-value-in-a-snowflake-table-reaches-threshold/1477>\
**Category:** Matillion ETL\
**Created:** [September 28, 2021, 9:56am UTC](https://matillioncommunity.discourse.group/t/trigger-an-email-when-a-specific-value-in-a-snowflake-table-reaches-threshold/1477 "2021-09-28T09:56:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajinkya](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Ajinkya](https://matillioncommunity.discourse.group/u/Ajinkya)\
**Post date:** [September 28, 2021, 9:56am UTC](https://matillioncommunity.discourse.group/t/trigger-an-email-when-a-specific-value-in-a-snowflake-table-reaches-threshold/1477/1 "2021-09-28T09:56:30Z")

</div>

Greetings !

&nbsp;

We have a log table where we maintain daily rowcount of all major tables in snowflake.

&nbsp;

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

&nbsp;

To monitor data completeness/duplication , i need to send an email when rowcount of a particular table falls out of its min/max pre-defined threshold value.

&nbsp;

I know i will have to use python logic for this but unsure about how exactly i query the snowflake using python and get output as true/false so that i run following email component based on that.

&nbsp;

Thanks.

&nbsp;

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Bryan](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@Bryan](https://matillioncommunity.discourse.group/u/Bryan)\
**Post date:** [September 28, 2021, 4:10pm UTC](https://matillioncommunity.discourse.group/t/trigger-an-email-when-a-specific-value-in-a-snowflake-table-reaches-threshold/1477/2 "2021-09-28T16:10:39Z")

</div>

Hi [@Ajinkya](https://matillioncommunity.discourse.group/u/Ajinkya)​, there is a pattern that you can use that should not require a Python script to make the true/false determination you are looking for. You would want to use Query to Scalar component. The idea is that you have a job variable that will hold the true or false result. You then write a query against your log table using a CASE statement to determine if the the row count is outside your min/max values and then based on that you would return a true/false or 0/1, etc. This get's stored into your Job variable. The component after the Query to Scalar would be a "If" flow where you would use the Job variable to determine the path. Based on the path you can choose to send an email or not.

I hope this helps give you some context on how this scenario could be handled.
