How can I calculate a percentage?

In this example, we're dividing our cancelled subscriptions over our total subscriptions to calculate our churn rate, which is a common SaaS metric.

Create your two layers where you wish to calculate a percentage. This is what my layers look like:

Count of Subscriptions that have started paying, and have not cancelled.

Count of Subscriptions that have started paying, and have not cancelled.

Count of Subscriptions that have cancelled in the past month.

Count of Subscriptions that have cancelled in the past month.

After you've created your two layers, make sure to use a Cross Join.

cross-join.png

In the Data Pipeline, click +Add Step, then choose Add Column from the dropdown menu. Title your column, then enter the percentage formula, which is as follows:

100.0 * "Column1" / "Column2"

To round your percentage, use the SQLite round() function. Your formula will look like this:

round( 100.0 * "Column1" / Column2", 2)

Where 2 is the number of decimal places.

If your column values are integers and you would like your results to have decimal precision, be sure to multiply by 100.0. This will convert the top value to a decimal before the division step, and will ensure your results are in decimal form.

Our example looks as follows:

percent.png

Click Ok, and your percentages will be calculated.