Hoping someone can help with a travel costs automation I am working on!
It’s all pretty basic but I’m stuck on adding toll costs as a list variable to my calculations. There is more detail in the comments of my existing shortcut;
Basically, I want to add multiple list results to a calculation. I don’t know if lists or dictionaries are my best option because, to be honest, I’m not sure how dictionaries work here!
But, I know i need to be able to select one or more values and add this to my calculation and then multiply that total x 2, it if it is a return journey.
The last variable is tricky for me. e.g. If my journey is 100km with two tolls in one direction but, say, 125km with one toll on the return leg… it appears well beyond my skill set at the moment!
Would appreciate any advice from the hive mind!
The example below of selecting multiple numbers from a list and then adding them together may help you in the right direction.
Thanks Roger! That worked! It doesn’t solve the variable of coming back through a different toll system but all of the math now adds up correctly. Thanks again!
If I’m understanding what you are trying to do correctly then the following shortcut may help…
It creates a dictionary of tolls and their costs, asks you to select which tolls were used on the outward journey and which tolls were used on the return journey, gets the relevant prices from the dictionary and adds them together.
Just a note that the shortcut often crashes if you run it from inside the shortcuts editor due to a shortcuts bug with the Choose From List action, but it always works fine if you run it by tapping on the tile the My Shortcuts window.
Wow. Yes! Amazing!! I will pour over this and add it to my shortcut. Thanks @RogerDowning.
As far as I remember there should be an action Calculate Statistics which can calculate the sum of a list (and other things). I can’t check if it is still there in iOS 13, because I don’t have it.
Yes, you’re correct.
Thanks for mentioning.
I’d never had occasion to use that action before so wasn’t aware it could do that.
So that allows the original shortcut I posted in my first reply to be simplified to…
Also updated the toll calculation shortcut I posted to use the Calculate Statistics action and include some comments as to what it’s doing.