# How to do calculations in a workflow

## Recommended Posts

How do I preform simple calculations in a workflow, I need to have the workflow take my input and do this {querr}*(1/60)=

very simple, just not sure how to make a workflow do that.

Thank you

well the easiest way to do this is just to use the built in calculator feature

or if RPN is your thing there's this which I made but never use -

or you can use bash and bc:

Yea im just trying to find a way to use the built in calculator quicker, its a simple calculation I have to do often for time entires. I will look at the literature you provided, thank you

Hmm that didnt seem to do the trick and the other stuff is way over my head. Im looking for something to do this exactly

I input {query} it takes that and preforms 2 calculations and outputs both results

{query}*(1/60)=Decimal then Decimal*25= \$Result

then I need to paste Decimal and \$Result

I did find a workflow that was made a few years ago with a workflow that did the first part of this calculation but that link is now dead, anyone have any ideas, im surprised there isnt a simple function in workflows to do calculations, I dont know much about this stuff though

Try this in a Run Script box with language as python and input as {query}.  You can pipe it out to a Copy to Clipboard action.

```query="{query}"

x = float(query)/60

y = x*25

print x,y```
Edited by dfay

that is awesome, thank you so much! Is there any way to restrict it to only 2 points after the decimal, thank you so much for the help!

```query="{query}"

x = float(query)/60

y = x*25

print "%.2f" % x, "%.2f" % y```

You are incredible, thank you so much!