paulminors Posted August 23, 2017 Share Posted August 23, 2017 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 comment
GuiB Posted August 23, 2017 Share Posted August 23, 2017 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 https://nofile.io/f/vucR6c28GJq/Calculation+in+Workflow+Example.alfredworkflow Best! Link to comment
paulminors Posted August 23, 2017 Author Share Posted August 23, 2017 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 comment
GuiB Posted August 23, 2017 Share Posted August 23, 2017 Here it is: https://nofile.io/f/mPGnUHXWJVJ/Calculation+in+Workflow+Example.alfredworkflow 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! paulminors 1 Link to comment
paulminors Posted August 24, 2017 Author Share Posted August 24, 2017 This is great, thanks a lot for your support! Link to comment
slyfox Posted September 14, 2019 Share Posted September 14, 2019 (edited) 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 https://nofile.io/f/vucR6c28GJq/Calculation+in+Workflow+Example.alfredworkflow Best! Can you please show a screenshot where exactly to add the math formula to "Arg and Vars" as the link is dead? Edited September 14, 2019 by slyfox Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now