Skip to main content
Matik Help Center home page Help Center
Matik Blog Case Studies
  1. Matik
  2. FAQ and Troubleshooting
  3. Common Errors

Error: Divide by zero

mceclip1.png

This article explains what to do if you are seeing an error message that says "Warning - Generated with errors: Slide x: Divide_by_zero - QueryError: division by zero."

For presentation generators (end users)

If you are an end user of Matik, contact your administrator if you encounter this issue.

For content creators (administrators)

The following error message results from a divide by zero error in Dynamic Content within a template. It occurs when the parameters of a query result in a zero in the denominator. 

For example, in the piece of Dynamic Content below, we are trying to display the average page views per user for a specific company by dividing the number of views by the total number of users.

mceclip4.png

Let's imagine the input for this dynamic content is company_name = 'SimpleTicket' and no SimpleTicket users made any views. As a result, the table page_views would have zero rows when filtered on company_name = 'SimpleTicket' , COUNT(view_id) = 0 and COUNT(user_id) = 0. Since most databases are unable to divide by zero, this throws a query error which is then passed to Matik. 

As an administrator, you can resolve this issue by finding what Dynamic Content and parameters are creating the divide by zero error, then editing the query to handle the zero in the denominator. 

In the problem above, we can resolve it by adding a NULLIF() and COALESCE() function to our query, as shown here:

mceclip6.png

When COUNT(user_id) = 0, the NULLIF() function will return NULL in the denominator. This prevents the divide by zero error from being thrown. The result is COUNT(view_id) / NULL, which equals NULL. Practically speaking, we want our query to return zero rather than NULL, so we wrap this in a COALESCE() function to return 0 if our first calculation returns NULL.

The example above was written in Amazon Redshift. Different databases and data warehouses have slightly different SQL syntax and functionality. Refer to your data source's documentation for more information on your specific data source.

Was this article helpful?

Have more questions? Submit a request

Related articles

  • Tags Overview
  • How do I use an Input as Dynamic Content?
  • I'm experiencing presentation timeout and long runtime issues
  • Dynamic Content Overview

Articles in this section

  • How to view presentation generation errors
  • Error: TooManyRowsForChartError: There was an error populating the chart for <Dynamic Content Name>...
  • Error: There was an error updating the chart. Google returned 400: Requested writing within range (Cell Range), but tried writing to column(column letter)
  • Error: (Comparison Operator) not supported between instances of (type) and (type)
  • Error: Comparing None value: (logical comparison)
  • Error: Google had an internal error when copying a presentation to your Google Drive
  • Error: We couldn't check for the existence of the Custom Matik Presentations folder in your drive. Have you connected to Google?
  • Error: Divide by zero
  • Warning: Generated with errors: Column does not exist in return value

Comments

0 comments

Please sign in to leave a comment.

Personalize data-driven content in minutes

Product

  • How it Works
  • Security

Solutions

  • Sales
  • Customer Success
  • Ops & Strategy
  • Data

Resources

  • Blog
  • Case Studies
  • Help Center

Company

  • About Us
  • Careers
  • Terms of Service
  • Privacy Policy

© 2022 Matik, Inc.