How to Calculate & Track Your Business Mileage Automatically with Google Sheets

Sdílet
Vložit
  • čas přidán 6. 09. 2024
  • How to set up a Google Spreadsheet to automatically calculate and keep track of your business mileage, ready for your year-end expense claim.
    ⭐ My Referral Links ⭐
    🏎️ Schedule a FREE test drive or order Tesla Products: geni.us/SoN-TESLA
    💡 Split £100 with me when you switch to 🐙 Octopus Energy: geni.us/SoN-Oc...
    🧋 Get £10 off at Huel: geni.us/SoN-Huel
    🎸 Buy musical instruments, audio & PA gear from Thomann: geni.us/SoN-Th...
    🌍 My KIT profile: kit.co/paulfp
    (Commissions/credits are earned from these links, which helps support me and the channel.)
    The Spreadsheet formula uses Google Maps' API to plot the driving route between the two locations and then extracts the distance driven. Copy & Paste this into the appropriate cell inside Google Sheets:
    =importxml("maps.googleapi..." & C2 & "&destination=" & D2 & "&sensor=false&alternatives=false&key=" & API_KEY!$A$1,"//leg/distance/value")
    [Change C2 and D2 to whichever cells have your start/end points in, and ensure you have a sheet called API_KEY with your API key in cell A1.]
    The formula to turn the result of the above into miles is:
    =ROUNDUP(CONVERT(E2, "m", "mi"), 1)
    [Change E2 to whichever cell it should be referencing.]
    ⭐🤩 If this video has helped you, a Super Thanks would be very much appreciated! 😘😉
    ► Support on PATREON: / switchedonnetwork
    ► Browse our MERCH: teespring.com/...
    ► Explore our GEAR: kit.co/paulfp
    Check out our Amazon Influencer shops!
    ► UK: www.amazon.co....
    ► USA: www.amazon.com...
    Let's connect... ###
    Twitter - / switchedonnet
    Facebook - / switchedonnetwork
    Instagram - / switchedonnetwork
    Tumblr - / switchedonnetwork
    Pinterest - www.pinterest....
    Visit our website at www.switchedon... and enable push notifications so you never miss a new video or post.
    Switched On Network is hosted by Paul Freeman-Powell
    ► Follow Paul on Twitter: / paulfp
    ► Follow Paul on Facebook: / paulfp
    We sometimes use free sound effects in our videos from www.freesfx.co.uk
    Stock video clips are (usually) from VideoBlocks, now called Storyblocks Video. You can get a free trial at videoblocks.go...
    DISCLOSURE: As an Amazon Associate we earn from qualifying purchases.
    Copyright © Innobella Media Limited 2018. All Rights Reserved.
    www.innobellam...

Komentáře • 125

  • @gilwoode
    @gilwoode Před rokem +2

    i Thought i ws pretty computer saavy but I cant figure this formula out. i keep getting #N/A ERROR I have a billing account setup

  • @patsteirer
    @patsteirer Před 3 lety +2

    So this is great, but what about when you have a list of locations with set miles between them. The mileage tracker isn't taking user inputed values for mileage, it's given a start location and an end location, with a sheet tabulating all possible distances between these locations. How would you create a form to select the starting and ending location, to then be given the mileage between them? The information is on different sheets, and the starting location can be any of the locations, and the ending location, can be any of the locations.

  • @slworking2
    @slworking2 Před 5 lety +3

    Thanks for the help here.
    Note: Google now requires HTTPS instead of HTTP. Please update your formula.

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety +1

      Ah yes, thanks! That was actually a typo on the website (just checked my own sheet and I've been using https) so that's been updated now. Thanks for pointing that out!

  • @JRazman
    @JRazman Před 6 lety +2

    When you pulled down your Starting Address in C2 with your starting address, it increased the address by 1 in C3
    So 10 Downing St, Westminster, London SW1A 2AA became 11 Downing St, Westminster, London SW1A 2AA.
    Which may have altered the calculated distance, as it was calculated from the wrong address.
    But other wise, nice mileage calculator with Google Sheets.

  • @MrOattee
    @MrOattee Před 5 lety +1

    I had the same formula parse error mentioned here in the comments. It's an issue with copying the formula from your website, once I deleted and typed out manually it worked first time. Hope that helps some people.

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety

      aargh! Yes, it's converted the quotes into fancy ones again. I fixed that a while ago but it must have messed up again. I'll go and fix again now. Cheers!

    • @MrOattee
      @MrOattee Před 5 lety +1

      @@SwitchedOnNetwork happy to help.

  • @chloefaaiuaso3286
    @chloefaaiuaso3286 Před 3 lety +1

    Struggling here. I created the billing account on the console, generated the API key (it says (API Key 1), re-typed the link into notepad and then pasted it into the spreadsheet. No matter what I do, the error says #N/A i.e. "imported content is empty".
    Heeelp. Please :)

  • @albulenaberisha2720
    @albulenaberisha2720 Před 3 lety +1

    thank you very much for this video. this was extremely helpful for organizing my business. all the best to you.

  • @user-im4dm7gp2q
    @user-im4dm7gp2q Před 5 měsíci

    Does this formula work if the origin and destination are given as Lat and Long ?

  • @arnoldchan7808
    @arnoldchan7808 Před 15 dny

    How to set up the API sheet?

  • @paulfp
    @paulfp Před 6 lety +2

    Whoops, I was too busy talking and didn't notice my funky spelling of the word "Desination"... ;-)

  • @soulsteela01
    @soulsteela01 Před 2 lety

    The video is great, clear and very helpful. But what if I go to a few different locations a day? Do I have to do a separate count for each trip? I mean I do 5-10 trips to different locations every day. And I need to put some data from previous months this way, but it'd take me ages.

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 2 lety

      Yeah I do each trip as a separate entry regardless of the date.

  • @rosebellbicar1125
    @rosebellbicar1125 Před 2 měsíci

    Not working now I guess. When using the formula, an error comes up stating Imported content is empty.

  • @rodb4410
    @rodb4410 Před 2 lety

    Thanks for the tutorial. Excellent job. I'm unsure how to track two vehicles on the same sheet and run totals for each vehicle and year end, any suggestions? I'm very new to sheets...this is probably a simple question and solution but wanted to do it the most uncluttered way. Thanks for any help

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 2 lety

      Glad it was useful! The easiest way to do 2 vehicles and keep totals separate etc. would be to duplicate and then rename the sheet (on the tab at the bottom toolbar) so you can run 2 side by side for each year, and name them YE22 Car 1, YE22 Car 2 etc.

  • @norcalnewsnetwork
    @norcalnewsnetwork Před 7 měsíci

    Hello Sir. I officiate baseball in the US. I want to calculate my mileage from work to the game field and then back to my home. What formula do I use for my third column for ending destination? And is this calculation you are providing is it direct straightline or is it actual using google map navagation or turn by turn?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 7 měsíci

      Yes, it grabs the total distance from a driving route from the turn by turn directions from Google Maps navigation. The best way would be to start at place A, set place B as a stop and then place C as the destination (so just 1 API call). You'll have to look up the API documentation to see exactly how to do that and then change the code accordingly.

  • @mattlloyd30
    @mattlloyd30 Před 8 měsíci

    Link to webaite goes to youtube channel... so can not copy formula

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 8 měsíci

      Ah yes sorry about that, I was having problems with the website so had to (temporarily) take it down. Hope to get it back up soon.

  • @joshfarrow2916
    @joshfarrow2916 Před 5 lety +2

    Can you download trips from a Google calendar into this spreadsheet?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety +1

      I imagine you probably can. Export events as a CSV, manipulate a bit in Notepad++ and then upload to Sheets. Not tried it myself so don't know the full details but yeah give it a go!

  • @PotterSpurn1
    @PotterSpurn1 Před 4 lety

    Thanks this was useful to find for the formulae for low mileage drivers. But could you tell me what is the formula would be for calculating total miles x 0.45 up to 10,000 miles and 0.25 miles afterwards so that th e calculation for cost auto-changes, once the 10,000 miles limit arrives on the spreadsheet and the 0.45 pence no longer applies. Surely there is a way of doing this automatically rather than sub-dividing one trip that take you from, say 9,827 miles to 10,002 miles, which may be hard to find if you have a long column of total mileages. Thanks.

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 4 lety

      I think you'd need more than just a single formula, probably have to write a function or something. I don't drive that much for business at the moment so no need for me 😂

  • @dannyp7424
    @dannyp7424 Před 5 lety +1

    Its only air miles I think like from zip to zip which probably will short you miles in the long run. I could be wrong though.

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety

      No, this method looks at a driving route suggested by Google Maps and gets the distance from that. Definitely not "as the crow flies" - you can check the distances by going to Google maps and they should be the same 👍

    • @blvrdialogue
      @blvrdialogue Před 3 lety

      You're right. Zip code to zip code and google chooses the zip. Not address to address, but it beats typing it all in if it's no big significance

  • @stevenrussellblack
    @stevenrussellblack Před rokem

    Thank you so much for this. Super fast and helped a ton. Thanks mate.

  • @TheTld007
    @TheTld007 Před 5 měsíci

    This is not working for me at all. API Key on API sheet, copied the formula from this video and it still doesn't work. Can you help?

    • @TheTld007
      @TheTld007 Před 5 měsíci

      N/A imported content is empty

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 měsíci

      Add another cell in your sheet so that it outputs the URL that's generated by putting the start/end points plus API key in. Then copy/paste that into a web browser and you'll see the full error message which will explain what's going wrong and you'll (hopefully) be able to clearly see what you need to do to fix it. Let me know how you get on!

  • @jakest9r
    @jakest9r Před 3 lety

    Amazing tutorial! Do I have to be specific with the date or can I just add which month the meeting was?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      Thanks! Answer to your question depends on the tax office in your country I guess and what level of record keeping they would require. I can't give advice on that but I record the exact date because why not? 🤣

  • @Rbionkah
    @Rbionkah Před 3 lety

    This did not work for me. Does the address have to be typed in some way?

  • @JeremiahFahim
    @JeremiahFahim Před 6 měsíci

    I have an issue with the API. URL that shows in Google Maps in the formula shows an error

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 6 měsíci

      Get the sheet to print the entire URL to a cell that you can copy/paste into a web browser then you'll be able to see the full text of the error and debug.

  • @RobinMatiucPianoSongs
    @RobinMatiucPianoSongs Před 3 lety

    Hi mate! Great job you've done with this video!!! Still useful after 3 and a half years!!! Can you please tell me where to look for more parameters at the end of the formula in order to have as results, let's say, "time of travel" or "time to leave ". Thanks a lot!

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      Do you mean bits of data like you'd see in the Google Maps web app, where you can tell it you'd need to arrive by a certain time, etc.? I'm not sure if/how they're accessible via the API with this method as I've never tried it, however if you paste the URL that's generated into a web browser you can view all the XML that comes back and see if there's anything useful for your needs. Good luck!

    • @RobinMatiucPianoSongs
      @RobinMatiucPianoSongs Před 3 lety +2

      @@SwitchedOnNetwork Hi there! Thanks a lot for the tip, it worked! I found the Travel Time...here is the Google Sheets formula: =importxml("maps.googleapis.com/maps/api/directions/xml?origin=" & C2 & "&destination=" & D2 & "&sensor=false&alternatives=false&key=___YOUR_API_KEY___","//leg/duration/text")

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      awesome, glad it worked!

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      I guess that could be really useful if you charge clients for time spent travelling as well as fuel cost :)

  • @irenejones17
    @irenejones17 Před 2 lety

    What is the formula for only miles? I don't need meters. Thanks!

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 2 lety

      This is it; I didn't need metres either but that's how the Google maps API works - it gives you the distance of a journey in metres so then that's converted into miles for the purposes of the spreadsheet with the formula I used.
      This is the formula to convert:
      =ROUNDUP(CONVERT(xx, "m", "mi"), 1)
      (Where xx is the cell)

  • @user-bk6gs9ti6v
    @user-bk6gs9ti6v Před rokem

    Somebody helps me with meters formula?

  • @robshawver8927
    @robshawver8927 Před 2 lety

    Please make an update for 2022 for this, I could not get it to work. Maybe I am doing the API wrong...?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 2 lety

      What's happening? Have you got an API key set up and enabled billing on the Google Cloud account?

  • @blvrdialogue
    @blvrdialogue Před 3 lety

    3 trips, one-way. Not to and from. That would be 12 miles. Great video, but I don't want metres on my chart. How can i do this with miles only?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      It's part of the working so it has to get the value in metres... you could probably rewrite the formula so it doesn't have to store it in a cell but that would make it more complicated. You could shove the column 1000 cols to the right so it's out of the way and still reference it I suppose!

    • @davidpage9681
      @davidpage9681 Před 2 lety

      you could always hide the metres column

  • @calebevans8986
    @calebevans8986 Před rokem

    What if I use feet!

  • @danadams5659
    @danadams5659 Před 3 lety

    Hi. I'm trying to integrate this into a chain where I use Google Forms, where I can quickly input a job on the fly. The data I put in is captured on Google sheets. On that google sheet I have second tab which simply ='s any data that arrives on the form input tab. The second tab has columns to work out the mileage calc. When I use the code from the website I get the error message: #N/A - Error The imported Content Is Empty. I tried referencing the input tab directly but that didn't seem to work either - Please, is there a way?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      So are you trying to grab a value from a cell in one sheet and use it in a formula in another, with the !SHEETNAME method?

    • @danadams5659
      @danadams5659 Před 3 lety

      @@SwitchedOnNetwork ​ Yes (I think so) I'm self taught so don't always know what I've done :) . Essentially I wanted to keep the data from the form unedited. So on Tab2 I hit "=" with cell A1 selected, switched to Tab1 (where form data is recorded) and selected A1. Switch back, drag so any tab1 data will be replicated in tab2 when I fill in the google form. In tab2 is an extra column to calculate mileage (by looking automatically at the ='Form responses 1'!C6' cell for job address column and comparing it to my home address) using your method. But I think its the API key thing - I couldn't actually find an explanation of that - I was hoping to create something that would be free/simple. API keys (whatever they are) might be a bridge too far.

  • @registerdevelopingharmony6364

    The formula I copied from your website says error when I load it into the spreadsheet.

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 6 lety

      Yeah it does that for me sometimes too. If you try again later, it should work. I'm not sure why the maps API seems temporamental, I've not debugged it... but as long as you've got the main data saved it'll calculate it when it works 👍😀

  • @ralphstevenson1214
    @ralphstevenson1214 Před 3 lety

    I am having issues on creating the API directions. After completing the all the tasks I am getting the #name? error. Any ideas why?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      My advice would be to debug it step by step from the start of the process, so get Sheets to output the full URL that it's querying Google Maps with and then paste that into a web browser yourself. At that point you may be able to spot the error just by looking at how the URL has been constructed but if not, you will get a more helpful error message in the browser. Good luck!

    • @ralphstevenson1214
      @ralphstevenson1214 Před 3 lety

      @@SwitchedOnNetwork so let me tell you how stupid I was today. I was imputing everything into excel vs sheets. Its amazing how this works when the data is put into the proper program. Now with all the stupidness out of the way is there a way to calculate miles from and to a location with several stops in the middle without adding the extra address to each line?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      Haha oops!
      Hmm no I don't think so, you'd need an address for each waypoint at least

  • @tanveerashraf884
    @tanveerashraf884 Před 3 lety

    i have cordinate not a adress. it doesnt work. can you please help me

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      Convert to address? Or modify the code to accommodate coordinates instead...

    • @tanveerashraf884
      @tanveerashraf884 Před 3 lety

      @@SwitchedOnNetwork can you please share your contact info so i can contact you. Please guide me

  • @anotherlandscapingcompany4294

    can you put the template up for download

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      The formula you need can be copied and pasted from this page here: www.switchedonnetwork.com/2018/01/25/how-to-automatically-calculate-track-your-business-mileage-with-google-sheets/
      hope that helps! Let me know how you get on :)

  • @lotfiouldadda2138
    @lotfiouldadda2138 Před 3 lety

    Guys i need a km formula for example i right 23 in a cell and when i hit enter it shows 23 Km anyone can help me

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      You mean just just want to add the text " km" after the number value?

  • @Rbionkah
    @Rbionkah Před 3 lety

    Just copy and past the formula? This did not work

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      Are you getting an error? Did you create an API account and have you set up your API key? (The process changed after this video was made, annoyingly, so you now need a billing account set up.)

  • @lemomentcapturer
    @lemomentcapturer Před 5 lety

    Hi thank you for sharing this awesome way to keep track of the mileage. I don't know if anything changed, but the formula doesn't seem to work. I had followed your step on your website and even waited for 24 hours to check again. And it's still not working. Any idea?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety +1

      Glad you like it! Yes there has been a change since I made the video - you must now with each request to the API with an access token and also have a billing account set up with Google. Don't worry, your free allowance should more than cover it. More details on the website...

    • @lemomentcapturer
      @lemomentcapturer Před 5 lety +1

      @@SwitchedOnNetwork Hi thank you again for getting back to me. I was reading the comments on your website for trouble shooting. But I have a hard time understanding them since I don't know anything about coding and bad at using the google sheet... Would you have step by step instructions? Sorry, if it's too inconvenient I understand.

    • @emilygrant5486
      @emilygrant5486 Před 5 lety +1

      @@lemomentcapturer I am having the same issue here. Might just calculate my mileage the old school way instead of using the API formula

    • @lemomentcapturer
      @lemomentcapturer Před 5 lety +1

      @@emilygrant5486 LOL! Yeah I finally gave up and went back to the old fashion way as well!!

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety +1

      Ooh no! It does work, I use it every time. What's the issue? I'll try to help 😀

  • @jamessolomon3467
    @jamessolomon3467 Před 5 lety

    Do you need to pay for the Google API?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety +1

      You need to set up a billing account (you didn't when I made the video) but your free credit allowance will more than cover this.

  • @chrisjennings5047
    @chrisjennings5047 Před 5 lety +1

    anybody else getting #ERROR Formula parse error? i've set up and tested my key...

    • @vascobrowne40
      @vascobrowne40 Před 5 lety

      same here. did you find out how to fix?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety

      Have you created a (free) billing account with Google, activated the maps API and put the API key in your spreadsheet? The process changed slightly since this video was made but it still works perfectly - I use it for my own business miles. Let me know how you get on 👍

    • @chrisjennings5047
      @chrisjennings5047 Před 5 lety

      @@SwitchedOnNetwork Yeah I have a paid google dev api account... not sure whats going on... there is a lot of stuff on google dev what needs to be activated exactly?

    • @chrisjennings5047
      @chrisjennings5047 Před 5 lety

      Thanks for your reply btw:)

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety

      ​@@chrisjennings5047 OK so make sure it's definitely an "API Key" you've generated under Credentials, and not any of the other options. Then it's the Directions API you need to enable for that project.
      Finally, the API key needs to be passed in the URL to the api endpoint inside your formula, like this: &key=xxx
      I created another sheet in my document and pasted the API key in there, so that I can reference it in the formula like this:
      &key=" & API_KEY!$A$1
      You should be up and running now - let me know!

  • @dcarr4413
    @dcarr4413 Před 5 lety

    How to receive the discount code? I can't locate your email

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 5 lety

      Hi - you can send me a message on either Facebook, Twitter or Instagram. Search for Switched on Network or look for the links on the channel or in video descriptions, and I'll send you a discount code :)

  • @tomsriverhandyman3092
    @tomsriverhandyman3092 Před 2 lety

    This is amazing

  • @mikemaman1
    @mikemaman1 Před 4 lety

    So you drove 8 miles and want 3.51 from the tax man. fuel price to cover 8 miles will be less than 3.51. how does it work? what am i missing here?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 4 lety

      It depends where you are in the world, but in the UK the tax authorities allow you 45p per mile plus 5p for each passenger. It covers all costs like wear and tear too, not just fuel.

    • @mikemaman1
      @mikemaman1 Před 4 lety

      @@SwitchedOnNetwork i am in uk. Just looks a bit strange if i spent about 800 on petrol and claim more than 2k back. Where does it go? Under expenses or another field? It's my first time 😂
      Thx.

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 4 lety

      Here's the info direct from the horse's mouth: www.gov.uk/expenses-and-benefits-business-travel-mileage/rules-for-tax

  • @Planetosheen
    @Planetosheen Před 7 měsíci

    Code doesn't work. I keep getting an error :(

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 7 měsíci

      Have you set up your API key correctly? If you construct the URL and then paste into a web browser you'll be able to see the exact error message and see what's going wrong.

  • @glenlaman4659
    @glenlaman4659 Před 6 měsíci

    The key to this is setting up the Goggle API. Without that it doesn't work. But how do
    mere mortals get the API?

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 6 měsíci

      You can just sign up, no heavenly credentials required 👍

  • @prophecyrevelations5653

    Google maps gives distance in miles if u ask what is the miles from point A to B. Its accurate and verifiable by the IRS in case of audit. This guy over complicates his life smh.

    • @SwitchedOnNetwork
      @SwitchedOnNetwork  Před 3 lety

      Hmm, how is this overcomplicating things? I find it really easy and still use it now - bung in where I went, drag the formula from the line above down, and it's all done. Then at the end of the year I have a figure to claim. I'm always keen to make things even simpler though - what are you suggesting? :)

    • @prophecyrevelations5653
      @prophecyrevelations5653 Před 3 lety +2

      @@SwitchedOnNetwork Hey whatever works, im always looking for new ideas just a new business owner approaching 10 year anniversary yet STILL learning so I'm no expert on anything however I'm not doing all that. Didn't mean to be critical, not saying it's wrong

  • @eliagudes
    @eliagudes Před 2 lety

    🤯🤯🤯🤯🤯

  • @Venkatesh.rangaraj
    @Venkatesh.rangaraj Před 4 lety +1

    Thank you. It is really helpful.
    I struggled for a bit figured it out finally.
    For KM:
    =importxml("maps.googleapis.com/maps/api/directions/xml?origin=" & C3 & "&destination=" & D3 & "&sensor=false&alternatives=false&key=___Your Key____","//leg/distance/text")