# Formula

Added in v0.3. Formula is for making creating transactions with patterns easier, such as Netflix and Spotify subscriptions, Uber and Lyft bills, even salaries.

Like account replacement, a config is needed before start using formula. The formula config is `key: value`

format. The key is the formula name (can't be a command name), the value is the content to parse with Costflow Syntax. Some variables are allowed in the value. The variable should be wrapped in double curly braces `{{ }}`

. The variables allowed in current version:

- amount: the first number in the input. You can use some basic math operations with the amount, e.g.
`amount * 0.8`

; - pre: the original input excludes the formula name;

More variables will be supported in future versions.

The way formula works is: convert the formula based on its config, then parse the value with Costflow Syntax all over again. So the value should follow Costflow Syntax too.

For example, we wrote a formula config for AWS transaction:

If we run `f aws 60`

or just `aws 60`

in Costflow Hub / CLI / Playground, the formula will run like this:

Formula is created for transactions, but it can be used for other directives. Here are some formula config examples: