Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Apple Shortcuts and the way to add the some calculation in it with the variables.

Good day.

I'm trying to add a some formula, like an "(income_amount*usd_rate*100*12)/(73606320*0,9)" by using the "Calculate expression" tool in Shortcuts application but when I run the script it return the error. As I understood I can't add the variable in to the "Calculate expression" it took only а numbers to return the result.

How can I insert the formula with variables in to the Shortcuts.


Posted on Apr 15, 2022 5:53 PM

Reply
Question marked as Top-ranking reply

Posted on May 2, 2022 9:52 PM

After a half month I decide to look back to this problem and find the way to solve it by adding some extra lines of “apple shortcut” included functions. The problem is that when you use the “Ask for number” function at user side of interface it gives the digital layout with the “ , “ symbol instead “ . “ as it shown in screenshot below.

You can choose the “Ask for text” function with the alphabetic interface where you can find the “ . “ symbol but after all manipulations to change the inputed by that way text into the number format you will lose the decimal part of inputed text. The only way which i found is use the “Get numbers from input” function by giving to that a inputed number , then use the “Replace” function to replace the “ , “ symbol in it by the “ . “ and then use that result in my calculation, as it chosen below in the screenshot.


For me, this solution is not so much correct than at the current moment is the only one I met.

I think it's pretty hidden problem which will be corrected by the creators. As the part of their application works with the “,” and another with the “.”.

8 replies
Question marked as Top-ranking reply

May 2, 2022 9:52 PM in response to nem87

After a half month I decide to look back to this problem and find the way to solve it by adding some extra lines of “apple shortcut” included functions. The problem is that when you use the “Ask for number” function at user side of interface it gives the digital layout with the “ , “ symbol instead “ . “ as it shown in screenshot below.

You can choose the “Ask for text” function with the alphabetic interface where you can find the “ . “ symbol but after all manipulations to change the inputed by that way text into the number format you will lose the decimal part of inputed text. The only way which i found is use the “Get numbers from input” function by giving to that a inputed number , then use the “Replace” function to replace the “ , “ symbol in it by the “ . “ and then use that result in my calculation, as it chosen below in the screenshot.


For me, this solution is not so much correct than at the current moment is the only one I met.

I think it's pretty hidden problem which will be corrected by the creators. As the part of their application works with the “,” and another with the “.”.

Apr 20, 2022 3:22 PM in response to Alancito

You were right from the first remark, when You advised to change all "," to ".", which I did immediately. But to my surprise the error remained. Today I finally found the reason for which at first glance I did not pay attention. It is hidden in the utility execution form of “Ask for Number”. (ie. The output grid for entering numbers has only the symbol "," for decimal numbers). And whenever I inserted any USD exchange rate, it was assigned to a variable “usd_rate” with the "," which should have been "." to execute the form to calculate the expression (income_amount*usd_rate*100*12)/(73606320*0.9).

I try to change the “Ask for Number” to “Ask for Text” and then in the row when i assign the provided input to the variable “usd_rate” make the “Provided input” “type” the “Number”. It works but not as well as I want. (ie. it took only the whole part of entered number with the part of some numbers after “.”. If I type the 1.6 for in the “Ask for Text” form i. some part of my script it took only the “1” of entered number “1,6”).


Thanks for the help.



Apr 20, 2022 1:35 AM in response to nem87

nem87 wrote: "...But the second problem is that this tool does not accept variables, it only work with static numbers, otherwise it gives an error. If you put "7+7" in the argument, then it will work, but if you put "currency+7" it will give an error."

nem ~ What value is in your variable "currency"? ...If "currency" contains a number, "currency+7" will not give an error:



...But if "currency" contains a currency code such as "USD", it will correctly give an error:



nem ~ Perhaps you want a result of "USD7"? – If so, post back here for possible suggestions.


õ¿õ¬

Apr 19, 2022 5:26 PM in response to Alancito

Thanks for the quick response. Yes, you are right that "," should be replaced with "." so that it doesn't throw an error. But the second problem is that this tool does not accept variables, it only work with static numbers, otherwise it gives an error. If you put "7+7" in the argument, then it will work, but if you put "currency+7" it will give an error.

Apr 19, 2022 5:39 PM in response to Camelot

In the Apple Numbers decimals attempted by the “,” and I thought that for Apple’s scripting or calculating tools there is a single standard for entering such numbers. But I though that it is a bug of the function named the “Calculate expression” in the Apple Shortcuts app., it gives the possibility to choose the previously announced variable as argument of it, but in fact it can't accept it.

Apple Shortcuts and the way to add the some calculation in it with the variables.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.