Jump to content

# How to run calculations in a workflow

## Recommended Posts

Hi, I have a calculation I have to make a lot.

{query}+({query}/0.971)

How would I set this up in a workflow (so I can make calculations quicker than the normal calculator)?

Thanks in advance!

##### Link to post

Here is 2 examples... If you don't want to do some scripting, the first example could be great to easily add a formula by modifying the "Arg and Vars" object (can duplicate to make more math functions). The second one is nicer if you prefer to have a direct feedback on the number you input

Best!

##### Link to post

Both of these options are really great! Thanks so much for this.

Can you comment on how to modify each of these to round to 2 decimal points?

##### Link to post

About commenting, we can't round to decimal using the builtin Alfred calculator since it rounds to the nearest integer. So, the trick for the first version is to multiply the result by 100 so we move the 2 decimals out and then round the value and divide back by 100.

`round(({query}+({query}/0.971))*100)/100`

For the second version, there's a builtin function in python to round a value and there's a second argument to specify the precision that we want, so 2 in this case

Hope this helps!

##### Link to post

This is great, thanks a lot for your support!

##### Link to post
• 2 years later...
On 8/23/2017 at 4:55 PM, GuiB said:

Here is 2 examples... If you don't want to do some scripting, the first example could be great to easily add a formula by modifying the "Arg and Vars" object (can duplicate to make more math functions). The second one is nicer if you prefer to have a direct feedback on the number you input

Best!

Can you please show a screenshot where exactly to add the math formula to "Arg and Vars" as the link is dead?

Edited by slyfox

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
×
×
• Create New...