# Formulas

With formulas and variables, you can create prototypes that truly come to life. Formulas are expressions that allow you to add logic to your interactions. From validating passwords to counting items in a shopping cart, and even calculating total account balances, formulas make it all possible.

With ProtoPie's formula capabilities, you can access layer properties, perform calculations, and utilize a wide range of functions for tasks like text manipulation and advanced mathematics.

Formulas are added using the formula input field. Simply include layer properties, functions, and variables as needed. Need a quick reference? Just click on the + icon to explore the available layers and variables at your disposal.

Tip: by enabling the Improved Formula Input Field in Labs, you can quickly identify whether a variable used inside a formula is local, meaning it can be used in the active scene only, or global, meaning it can be used in all scenes.

New to formulas? Don't worry, we've got you covered! Here are some resources to help you make the most out of ProtoPie's Formulas.

• Syntax — Just like any language, formulas have their own set of rules and principles. Learn the syntax to confidently craft your first formula.
• Layer properties — Access a wide range of layer properties to bring your interactions to life. Mastering layer properties is the first step towards creating dynamic prototypes.
• Functions — Take advantage of our predefined formulas that perform specific tasks. Functions process data and deliver results, making your prototypes even more powerful.
• Use cases — Explore practical examples of how formulas can be used effectively. Learn from real-world scenarios and apply the knowledge to your own projects.

## Difference Between Formulas & Variables

Formulas and variables work together seamlessly to enhance your prototypes. Here's a quick breakdown of their relationship:

Variables: Think of variables as handy "baskets" that hold values. They allow you to store and retrieve data, making it easier to reuse information throughout your prototype. Variables can be used independently or in conjunction with formulas. For example, you use formulas to retrieve a value stored in a variable.

Formulas: Formulas are expressions that calculate and "return" a result. They are powerful tools for creating dynamic interactions. You can use formulas to perform calculations, manipulate text, and accomplish various tasks. Formulas can also include variables to access stored values.

The synergy between formulas and variables allows you to take your prototypes to the next level. Variables store values that can be utilized by formulas, while formulas can even be stored within variables for reuse across scenes.

In summary, formulas and variables complement each other, offering flexibility and efficiency in your prototype development process.

## Learning the Basics

Formulas may seem intimidating, but they are more accessible than you think. With just a few formulas, anyone can create dynamic interactions!

In this video tutorial, you'll learn how to make an engaging interaction using ProtoPie. Watch as we demonstrate how to move a rectangle layer to the position of another rectangle layer, no matter where it is in the scene.

## Practicing with Examples

### Making a Tab Bar

To make responses work dynamically, use formulas instead of fixed values. This video tutorial shows you how to animate a simple tab interaction using formulas.