Shortcut to calculate sum of steps walked for the week

Hi all,

I am trying to build a shortcut that brings back a feature Apple recently killed.
It was possible to see in the Fitness app all steps I walked since the start of this week. On Monday (or Sunday, whatever your phone is set to think of the week’s first day) it would reset and start counting again.

I am obviously not good at this. At least to me it looks a bit clunky. And of course it does not work.
When running, it thinks about it for about 5 seconds then shows a checkmark and that’s it. No errors, no results, nothing.

If I separate the single steps as individual shortcuts and have it show the result, it works for each with no problem. Adding them together just won’t work.

Where am I going wrong?

Any help is highly appreciated!
Ritchey

Maybe try without the clipboard and just use the adjusted date as a variable

Hi @Ritchey

The way that you are referencing the dates in your selection of samples is the issue. The way it is set up, you are looking for samples that have a Start date of Monday and an End date of the current date. What you need to look for is samples that have a start date between Monday and now.

Also, make sure to set the time on your Monday date otherwise it defaults to midday and you will miss the first 12 hours of data:

Steps Since Monday Shortcut – link to my version of your Shortcut.

Hope this helps.

3 Likes

Thank you so much, Tony!
Now I just need to find out why the calculated step count is not right.

I feel like I stole too much of your time already. But if you may… what is the very first function doing (set variable totalSteps to Input)?
The shortcut displays the exact same (wrong) number if I delete this.

Thanks a lot again,
Ritchey

Ooops - my bad. The first version of the Shortcut that I put together used the variable to hold the step count; when I changed the Shortcut to not require the variable I forgot to remove that action. All the action does is to initialise (create the variable) and set it to empty.

Just having a quick look through the Shorcut again, there seems to be an issue with the action getting the date for Monday. Writing this, today is Wednesday 24 April, so the most recent Monday should be 22 April. The dates given by the Shortcut action:

last Monday shows 15 April
Monday shows 29 April
this Monday shows 29 April
next Monday shows 29 April

so it looks as though there is an issue with the date parsing in Shortcuts. I’m running iOS 17.5 latest public beta, but I get the same results in iPadOS 17.4.1 (latest non-beta release).

As a workaround, I’ve added some actions to check if the date calculated for Monday is 7 or more days ago and if it is, add 1 week to the calculated date. This should mean that if the date calculation gets fixed, the Shortcut should continue to work.

Shortcut Version 2

Hopefully this gets better results.

Thanks again!
I saw, too that the date was the Monday a week before. Weird.

Your solution fixes that, thank you!
Somehow the step count still does not match a manual summary of the daily results from the Fitness app or the Health app.
The shortcut calculates a higher number (like 15,000 steps) than what the apps consistently report.
I checked if my steps from Sunday would make up the difference but that is still way off.

Please don’t waste more time on this.
I learned a lot already thanks to you. I’ll keep fiddling with it. Maybe I figure it out.

Glad this has helped.

15000 steps is a lot of difference! If you find a solution, please post it here so we can all get a feeling as to where issues exist with Shortcuts and possible workarounds for them.

1 Like

I made a couple of shortcuts calculating the monthly walked steps and km’s. I found out when I bought a  Watch the calculated totals were not correct anymore. The steps registered by the Watch and iPhone in some cases were added together so the total was too high. I had to exclude the steps and km’s registered by the iPhone to get the correct total.

So if you have a  Watch, you have to exclude the iPhone numbers as follows:

So add the filter " Source is not your iPhone’s name"

2 Likes

Yeah, there’s is definitely something like this going on. I’m not sure if it is just adding the two.

If I exclude the iPhone as a data source, I am now missing about 15000 steps in the shortcut result compared to a manual addition of daily steps from the Fitness or Health app.

Very, very weird…

Indeed, maybe something is not correct in the calculation of the start day/time or end date/time. I had the same when I started.

You can use this.

This will give me the step total of Monday to Thursday, it is Friday now. I don’t know if it depends on the settings of you phone if Monday is considered the start of the week, if Sunday is the first weekday on your phone, then you need to add one day to “Get start of week”, if you want to start on Monday. If you want to get the steps you did today also included, then you have to add one day to current day.

2 Likes

YES!!!
Thank you! It was missing today‘s steps.

I did not find a good way to tell the shortcut to find all Health Samples between Monday and tomorrow.
So, I created another Specified Date (of tomorrow) and copy that to the clipboard.

But now it all works!
Thank you all again for your help.