# Introduction to Formulas

Formulas are an integral part of Plecto. They are the recipes for taking data from data sources and converting it to metrics on dashboards. Their only job is to take registrations from a data source and calculate a result with their values. The widgets on the dashboards then use the formulas and display their result. The relationship between data source, registrations, formulas and dashboards is illustrated in the flowchart below: The data sources contain multiple registrations with individual values that formulas can put together to calculate a result to be displayed on a dashboard.

Formulas are a plain text representation of how a result is calculated, and its text has to follow a strict syntax for Plecto to understand it. The syntax can be thought of as a programming language similar to what is used in spreadsheets such as Google Sheets or Microsoft Excel.

In a spreadsheet, you usually organize your data in rows and do operations on the row’s columns such as summation or sorting. Plecto works in a very similar way - the registrations are rows in a table and their fields are the columns. The table below represents 3 registrations: A formula generally does the following steps when calculating a result:

• Choose data source.
• Narrow down which registrations to include from that data source.
• Choose which registration fields to look at.
• Calculate the result from the values of the registrations’ fields, e.g. sum them.

Plecto offers two editors for creating formulas:

• A simple editor that is very easy to use and create formulas quickly for simple tasks: • An advanced editor for creating more complex formulas with more advanced functionality: ### Dates on widgets

Widgets on a dashboard have a setting to choose a time interval for their formula. This means that if a formula, for instance, calculates a sum of won deals, the widget defines what time interval to pick registrations from. This could be the current month, previous day, next year or many other combinations. It allows the same formula to be used for calculating values for different time intervals and very easy comparison between time periods. There is no need to have multiple formulas doing the same thing. 