+ Reply to Thread
Results 1 to 9 of 9

Trying to calculate the SUM of my hours worked for individual subjects in a table.

  1. #1
    Registered User
    Join Date
    11-12-2018
    Location
    Portsmouth, England
    MS-Off Ver
    2019
    Posts
    12

    Trying to calculate the SUM of my hours worked for individual subjects in a table.

    Hi, as the title says I'm trying to calculate the sum of my hours per unit and put it into a column. I am not that experienced with excel but I will be updating this spreadsheet recording my progress throughout the year so I am looking to use formulas rather than code. I have tried combining index and match but that only returns the first piece of data it finds in the table.

    I'm sorry if i havent explained it properly, I wrote it all out then accidentally clicked the back button on my mouse, deleting everything bar the title.

    Here is the table i would like to use to cross reference the unit codes and input the total amount of hours for each individual unit.

    image 1 excel.png

    Here is the table that stores my recorded data.

    image 2 excel.png

    Thank you in advance,

    Michael
    Last edited by JustMike; 11-13-2018 at 10:11 PM.

  2. #2
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Trying to calculate the SUM of my hours worked for individual subjects in a table.

    Welcome to the forum.

    For your 'how often', put this in C3 and drag down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Change the range $E$14:$E$44 to cover at least the entire range of your data ($E$14:$E$10000 if needed). If you have the data in an Excel Table (which it looks like you have) then you can use a structured table reference instead - it'll look something like this: Table2[[#All],[Unit Short Code]]. If your summary is also in an Excel Table, you can replace the 'A3' with a structured reference as well: [@[Unit Short Code]]. Then, the formula will be:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In this case, you probably won't need to drag down either - the table will probably automatically fill in down the column (dependent on your exact settings).

    For the hours, use one of these (without/with Tables):
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Edit: Format the results using the custom format [h]:mm so that you can count hours past 24 - if you use just h:mm then 25 hrs will display as 1:00.


    ps For future reference, it's easier if you can upload a sample file, with some representative (non-confidential) data, instead of pictures. That way we can tailor the answer better to your question.

    Hope that helps.
    Last edited by Aardigspook; 11-12-2018 at 07:54 AM. Reason: Add note about [h]:mm format
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  3. #3
    Registered User
    Join Date
    11-12-2018
    Location
    Portsmouth, England
    MS-Off Ver
    2019
    Posts
    12

    Re: Trying to calculate the SUM of my hours worked for individual subjects in a table.

    Thank you for replying, yeah sorry about that I didn't think to just give you the file. I'm trying to use the formulas you gave me, thanks but I'm already using a formula for how often and it is pretty much what you gave me just expanded to a table. I'm trying to use the second lot of formulas but I'm not getting the correct outcome. It just didn't add up, the total should be 382:32 but its giving me something like 60-70 and then the sum formula i have for the hours is giving me 22:32 so I'm am very lost right now. I shall try to upload the file for you to have a look.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Trying to calculate the SUM of my hours worked for individual subjects in a table.

    I think a source of the confusion might be the [h]:mm custom formatting in the "Hours" and "Duration" columns and in your "Total Hours" cell. Revert those formats back to "Number" for the moment.

    Then the key is to note that your "Duration" column formula returns numbers that are in units of days. Thus in the first row of Table1 11:00 am minus 10:00 am = 0.042 (days) = 24*0.042 = 1.0 hours.

    Your Table2 "Hours" column is actually in days, not hours. Your "Total Hours" cell (really it's days not hours)= 15.939. 15.939*24 = 382.5 hours which is the answer you expected.

    Hopefully this clears up some of the confusion!

  5. #5
    Registered User
    Join Date
    11-12-2018
    Location
    Portsmouth, England
    MS-Off Ver
    2019
    Posts
    12

    Re: Trying to calculate the SUM of my hours worked for individual subjects in a table.

    Thank you GeoffW283 for that, I looked into everything a bit more and it turns out it was a bit buggy with the [h]:mm and hh:mm like you said but i also looked into the total number because 382 is a stupid amount of hours for such little time. It turns out I set one of the dates to be in 1900 so it was giving me a lot more hours.

  6. #6
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Trying to calculate the SUM of my hours worked for individual subjects in a table.

    Right - cell H56 had the superfluous 1900 date.

    Currently for duration, your calculation is =SUM(H14,-G14). You can write that more simply as "=H14-G14", but I would change that formula to "=24*(H14-G14)" so that the duration column is then in hours. Table2 then works as you would expect and your "Total Hours" in E7 should be 94.533

    Note that if you create the cell I14 formula by clicking on cells H14 and G14 rather than typing "H14-G14" you will automatically get the equivalent table references: "=24*([@[End Time]]-[@[Start Time]])"

    All set now?

  7. #7
    Registered User
    Join Date
    11-12-2018
    Location
    Portsmouth, England
    MS-Off Ver
    2019
    Posts
    12

    Re: Trying to calculate the SUM of my hours worked for individual subjects in a table.

    yeah its all working now thanks, i just changed the cells type to [h]:mm assuming that it would put as many hours necessary instead of just the two from hh:mm and its working fine. Thanks for all the help

  8. #8
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Trying to calculate the SUM of my hours worked for individual subjects in a table.

    Glad we could help. (Geoff, thanks for jumping in.)

    As you've only recently joined, you may not know that you can mark the thread as Solved if your original question has been taken care of so others know there's an answer here. Instructions to do it are in my sig - if you could take a moment to do it, that would be appreciated. Please also consider thanking anyone who helped you by clicking * Add Reputation under the post which helped. Thanks.

  9. #9
    Registered User
    Join Date
    11-12-2018
    Location
    Portsmouth, England
    MS-Off Ver
    2019
    Posts
    12

    Re: Trying to calculate the SUM of my hours worked for individual subjects in a table.

    A thanks, sorry I didn't notice that and will do it now.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Formula to calculate hours worked w/lunch or w/o + OT column only total after 40 hours
    By blinhart in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-31-2023, 11:14 AM
  2. Replies: 5
    Last Post: 05-22-2015, 07:27 AM
  3. [SOLVED] Calculate and lookup last weeks total hours worked from a table without #N/A error message
    By thetaplus in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-18-2014, 03:54 AM
  4. Replies: 6
    Last Post: 01-30-2014, 06:58 AM
  5. Replies: 2
    Last Post: 01-17-2014, 02:22 PM
  6. Replies: 4
    Last Post: 02-12-2013, 07:01 AM
  7. Replies: 2
    Last Post: 02-11-2013, 02:26 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1