The Data Responder Tutorials

Data processing formula editor

How to use the Formula Editor?

Learn how to effectively use the Formula Editor in Data Responder to create and calculate custom KPIs. Follow our step-by-step guide to unlock advanced data processing capabilities.

Share

Introduction

This guide will introduce you to the basics of using the formula editor in Data Responder to calculate custom KPIs. We’ll explore how to create simple formulas and progress to advanced expressions, leveraging the full potential of the editor powered by the robust math.js library. Let’s get started!


Understanding the Formula Editor

The formula editor allows you to create custom KPIs by combining variables, mathematical operations, and conditions. It supports a wide range of operations and ensures flexibility to handle special cases effectively.


Creating Simple Formulas

To start, let’s calculate a basic KPI: Gross Profit Margin.

The formal Formula::

$$
\text{Gross Profit Margin (%)} = \left( \frac{\text{Gross Profit}}{\text{Total Revenue}} \right) \times 100
$$

Implementation in the Formula Editor:

				
					(( {{DS1_gross_sales}} - {{DS1_gross_costs}} ) / {{DS1_gross_sales}} ) * 100
				
			

In this example:

{{DS1_gross_sales}} represents the total sales.
{{DS1_gross_costs}} represents the total costs.

The formula calculates the percentage of gross profit relative to gross sales.


Handling Special Cases with Conditional Expressions

Logical operators in the formula editor, allow you to define conditional logic and handle various scenarios effectively. These operators include && (and), || (or), ! (not), and comparison operators like ==, !=, <, >, <=, and >=. For instance, you can create formulas that adapt to specific conditions, such as {{DS1_gross_sales}} > 0 && {{DS1_gross_costs}} < {{DS1_gross_sales}} ? “Profit” : “Loss”, which evaluates whether sales exceed costs to determine profitability. By combining logical operators with conditional expressions (condition ? value_if_true : value_if_false), you can build robust formulas that automatically adjust calculations to account for exceptions, missing data, or thresholds.

Now let’s refine the formula to handle cases where gross sales might be zero. To prevent errors or division by zero, we’ll use a conditional expression in the Formula Editor:

				
					{{DS1_gross_sales}} != 0 ? (( {{DS1_gross_sales}} - {{DS1_gross_costs}} ) / {{DS1_gross_sales}} ) * 100 : 0
				
			

Here, the formula checks whether {{DS1_gross_sales}} is not equal to zero before performing the calculation. If it is zero, the result defaults to 0.


Tips for Writing Effective Formulas

  • Use parentheses to ensure correct operation order.
  • Handle edge cases using conditional expressions.
  • Test your formulas with sample data to verify accuracy.
  • Document your variables for easier maintenance.


Conclusion

With the formula editor, you can tailor KPI calculations to your business needs. Whether you’re calculating simple percentages or designing complex metrics, the combination of a user-friendly interface and the powerful math.js engine ensures precision and flexibility.

Start experimenting with your formulas today and unlock the full potential of your data!

Periods comparison

How to Compare Periods?

Find out the best practices for comparing different time periods in data analysis to make

Get started

Start monitoring your business processes in minutes.

Start 30 days for free, without a credit card.