SOLVED

Can Excel do this?

%3CLINGO-SUB%20id%3D%22lingo-sub-1645862%22%20slang%3D%22en-US%22%3ECan%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1645862%22%20slang%3D%22en-US%22%3E%3CP%3EHey%2C%20I%20am%20working%20on%20a%20school%20project%20and%20I%20would%20like%20to%20know%20if%20what%20I%20want%20to%20create%20is%20even%20possible%20in%20Excel.%3C%2FP%3E%3CP%3EI%20have%20a%20simple%20table%20with%20employees%2C%20hours%20and%20salary.%20What%20I%20want%20to%20know%20if%20is%20it%20possible%20to%20just%20provide%20Excel%20with%20a%20date%20and%20hour%20and%20it%20would%20automatically%20count%20how%20many%20hours%20an%20employee%20had%20worked%2C%20select%20shift%20by%20itself%20and%20count%20the%20salary%20according%20to%20selected%20shift%20and%20money%20rate%3F%20I%20know%20just%20some%20basics%20from%20my%20statistics%20course%20at%20college%20and%20I%20am%20not%20sure%20if%20Excel%20(or%20myself%20perhaps)%20could%20do%20it.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20uploaded%20my%20sheet%20so%20anyone%20can%20see%20what%20I%20mean.%20I%20am%20thankful%20for%20every%20reply.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1645862%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20for%20web%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1646748%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1646748%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F786297%22%20target%3D%22_blank%22%3E%40mikim1kolaj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou've%20said%20it's%20a%20school%20project%20and%20you%20want%20to%20know%20if%20what%20you%20want%20to%20create%20is%20even%20possible%20in%20Excel.%20Right%3F%3C%2FP%3E%3CP%3EThe%20answer%20to%20that%20question%20is%20%22Yes%2C%20it%20is%20possible.%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20probably%20would%20take%20a%20bit%20more%20explanation%20of%20what%20you%20want%20to%20do%2C%20but%20Excel%20is%20very%20good%20at%20that%20kind%20of%20thing.%20So%20since%20it's%20a%20project%20for%20school%2C%20have%20at%20it.%20I'll%20point%20you%20in%20the%20direction%20of%20the%20many%20functions%20that%20enable%20one%20to%20look%20things%20up%20from%20a%20table.%20And%20I'd%20suggest%20searching%20(probably%20on%20Google)%20for%20how%20those%20work....%20there%20are%20in%20Excel%20several%20ways%20to%20accomplish%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20were%20you%20expecting%20somebody%20here%20to%20do%20your%20homework%20for%20you%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1647004%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1647004%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3BNo%2C%20not%20at%20all%2C%20sir%2C%20I%20want%20to%20do%20it%20myself%2C%20but%20I%20didn't%20know%20if%20Excel%20was%20even%20capable%20of%20doing%20it.%20I'll%20try%20my%20best%20to%20do%20it%20with%20the%20help%20of%20Google.%20Thank%20you%20very%20much%20for%20your%20reply!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1654845%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1654845%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3BSir%2C%20I%20have%20managed%20to%20create%20almost%20my%20whole%20table.%20I%20only%20have%20a%20problem%20with%20Shift%20H%2C%20which%20starts%20at%2017%3A00%20on%20Friday%20and%20ends%20at%206%3A00%20on%20Monday.%20Could%20you%20please%20provide%20me%20with%20some%20help%20with%20column%20L%3F%20I%20know%20I%20need%20to%20add%20%3CEM%3E%3DIF(C2%3D%22Friday%22%3C%2FEM%3E%20then%20do%20this%2C%20if%20not%2C%20do%20that%2C%20but%20I%20can't%20get%20it%20to%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1657263%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1657263%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F786297%22%20target%3D%22_blank%22%3E%40mikim1kolaj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20you've%20done%20is%20impressive.%20Instead%20of%20giving%20you%20the%20answer%2C%20I%20want%20to%20give%20you%20a%20few%20other%20pointers.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EFirst%20of%20all%2C%20I%20think%20you're%20not%20entirely%20correct%20with%20your%20assumption%20that%20you%20need%20to%20begin%20with%20%3CEM%3E%3DIF(C2%3D%22Friday%22%3C%2FEM%3E%20because%20(if%20I%20understand%20correctly%20how%20this%20is%20working)%2C%20the%20%22H%22%20Holiday%20rate%20would%20apply%20for%20somebody%20starting%20on%20Saturday%20or%20Sunday%20as%20well%20as%20starting%20on%20Friday.%20So%20there%20are%20more%20conditions%20that%20need%20to%20be%20taken%20into%20account%20in%20determining%20whether%20the%20hours%20are%20paid%20as%20%22H%22%20hours.%20So%20you%20need%20to%20spell%20those%20out%20as%20well.%3C%2FLI%3E%3CLI%3ESecond%2C%20there%20i've%20pointed%20you%20to%20three%20functions%20that%20might%20come%20in%20handy.%20You%20created%20a%20table%20that%20looks%20up%20the%20name%20of%20the%20day%20based%20on%20dates%20in%20September.%20There's%20a%20function%20that%20does%20that%20automatically%2C%20with%20a%20lot%20of%20variations%20within%20it.%20I've%20given%20you%20a%20simple%20example%20of%20that.%20The%20%3CSTRONG%3E%3DWEEKDAY()%3C%2FSTRONG%3E%20function%20returns%20a%20number%20from%201%20to%207.%20You%20could%20use%20those%20numbers%20in%20your%20formulas%20rather%20than%20the%20names%20of%20the%20days--it%20would%20make%20the%20formulas%20shorter%2C%20to%20some%20extent.%20But%20also%2C%20you%20could%20do%20math%20with%20them.%20So%20if%20Friday%20was%20day%205%2C%20Saturday%20day%206%2C%20and%20so%20on....your%20IF%20statement%20could%20simply%20say%20%3DIF(%3CEM%3Eday%3C%2FEM%3E%26gt%3B%3D5%2C.........)%3C%2FLI%3E%3CLI%3EThird%2C%20if%20you%20want%20the%20name%20of%20the%20day%20to%20appear%2C%20use%20%3CSTRONG%3E%3DCHOOSE()%3C%2FSTRONG%3E%20to%20turn%20the%20number%20into%20the%20name%20of%20the%20day.%3C%2FLI%3E%3CLI%3EFourth%2C%20in%20my%20very%20first%20response%2C%20I%20had%20suggested%20you%20look%20for%20how%20Excel%20can%20be%20used%20to%20retrieve%20data%20from%20a%20table.%20You've%20chosen%20to%20use%20IF%20statements%20for%20that.%20I've%20given%20you%20a%20demonstration%20of%20how%20you%20can%20use%20%3CSTRONG%3EINDEX%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EMATCH%3C%2FSTRONG%3E%20to%20get%20the%20hourly%20rates%20and%20apply%20them.%20I%20changed%20the%20headings%20of%20the%20shift%20column%20so%20as%20to%20be%20able%20to%20use%20the%20D%2C%20E%2C%20N%2C%20H%20designations%20as%20the%20reference%20in%20%3CSTRONG%3EMATCH%3C%2FSTRONG%3E....%3C%2FLI%3E%3C%2FOL%3E%3CP%3ESo%20let%20me%20turn%20it%20back%20to%20you%20now%2C%20with%20those%20pointers%2C%20and%20see%20if%20you%20can%20resolve%20your%20weekend%20issue.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1657336%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1657336%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3BThank%20you%20very%2C%20very%20much.%20I%20couldn't%20get%20clues%20like%20that%20in%20Google%2C%20that's%20why%20I%20asked%20you%2C%20sir.%20I%20will%20try%20to%20implement%20those%20functions%20over%20the%20weekend%20and%20I'll%20get%20back%20to%20you%20when%20I%20manage%20to%20make%20it%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1657617%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1657617%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F786297%22%20target%3D%22_blank%22%3E%40mikim1kolaj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere's%20a%20great%20website%20for%20help%20with%20Excel%20functions.%20%3CA%20href%3D%22https%3A%2F%2Fexceljet.net%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fexceljet.net%2F%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20recommend%20also%20looking%20at%20examples%20on%20that%20site%20for%20the%20functions%20WORKDAYS%2C%20VLOOKUP%2C%20XLOOKUP%2C%20as%20well%20as%20the%20ones%20I%20included%20in%20my%20sample.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1660387%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1660387%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3BThank%20you%2C%20sir.%20I%20have%20used%20the%20functions%20you%20provided%2C%20as%20well%20as%20I%20got%20help%20from%20exceljet.%20In%20cell%20Q13%20I%20have%20created%20a%20function%20which%20gives%20H%20or%200%2C%20depending%20on%20the%20number%20of%20day%20from%20WEEKDAY%20and%20hour.%20I%20have%20then%20created%20a%20new%20sheet%20with%2031%20days%20of%20this%20function.%20Then%2C%20for%20every%20shift%20in%20K%2C%20L%2C%20M%2C%20N%20I%20entered%20IF%20statement%2C%20which%20depending%20on%20the%20outcome%20of%20the%20function%20in%20new%20sheet%20either%20counts%20the%20number%20of%20hours%20in%20each%20shift%20or%20just%20gives%200%2C00%20and%20continues.%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20to%20a%20point%20in%20which%20two%20shifts%20collide%20with%20each%20other.%20When%20it%20is%20Friday%20%26gt%3B%3D17%3A00%20up%20until%20Monday%20%26lt%3B%3D06%3A00%20it%20works%20really%20good%2C%20however%2C%20when%20an%20employee%20works%20for%20example%20Monday%2004%3A00%20until%20Monday%2012%3A00%20it%20gives%206hrs%20in%20K%2C%200%2C08hrs%20in%20H%2C%20and%20loses%20the%20rest%20of%20the%20time.%20Did%20I%20overdid%20it%20to%20a%20point%20where%20it%20just%20simply%20can't%20work%20or%20is%20it%20fixable%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20really%20grateful%20for%20your%20help%2C%20if%20I%20am%20abusing%20your%20free%20time%20please%20just%20let%20me%20know.%3C%2FP%3E%3CP%3EAlso%2C%20it%20is%20difficult%20for%20me%20to%20explain%20what%20I%20did%20and%20what%20I%20mean%20because%20English%20is%20not%20my%20main%20language%2C%20therefore%20I%20am%20sorry%20if%20you%20can't%20understand%20me%20clearly.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1660475%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1660475%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F786297%22%20target%3D%22_blank%22%3E%40mikim1kolaj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20are%20explaining%20yourself%20very%20well%20in%20English.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20might%20(this%20is%20a%20guess%20on%20my%20part)%20benefit%20from%20the%20%3CSTRONG%3EIFS%3C%2FSTRONG%3E%20function...take%20a%20look%20at%20it%20on%20exceljet.%20It%20sometimes%20is%20easier%20than%20nesting%20IF%20within%20IF%20within%20IF.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20not%20be%20able%20to%20take%20a%20close%20look%20until%20much%20later%20today%2C%20I'm%20afraid.%20I%20had%20wondered%20about%20that%20matter%20of%20crossing%20shift%20boundaries%2C%20but%20it%20did%20seem%20as%20if%20you%20had%20it%20resolved%20in%20your%20earlier%20version.%20So%20keep%20working....I'll%20look%20later%2C%20but%20maybe%20you%20will%20be%20able%20to%20do%20it%20on%20your%20own.%20That's%20always%20more%20satisfying.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1660942%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1660942%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F786297%22%20target%3D%22_blank%22%3E%40mikim1kolaj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'd%20suggest%20to%20start%20from%20day%20one.%20Shifts%20could%20be%20defined%20as%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20506px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F217991i4698901319277998%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Ein%20final%20version%20format%20Shift%20Star%2FEnd%20as%20time%20to%20hide%20years.%3C%2FP%3E%0A%3CP%3EInto%20the%20main%20table%20I%20added%20two%20helper%20columns%20(S%20and%20T)%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20320px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F217993i5AB8922480F2AB46%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Enot%20to%20complicate%20main%20formula%2C%20but%20mainly%20to%20clean%20confusing%20records%20as%20start%20on%20Sun%2022%3A00%20and%20end%20on%20Sun%2003%3A00.%3C%2FP%3E%0A%3CP%3EFormulas%20here%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EStart%3A%0A%3DMOD(B3-1%2C7)%2B1%2BMOD(E3%2C1)%0A%0AEnd%3A%0A%3DMOD(B3-1%2C7)%2B1%2BMOD(I3%2C1)%2BIF(MOD(I3%2C1)%3CMOD%3E%3C%2FMOD%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Epayment%20is%20calculated%20as%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMPRODUCT(%0A%20%20IF(%20(S3%26gt%3BShiftStart)*(T3%3CSHIFTEND%3EShiftStart)*%0A%20%20%20%20(S3%20%3CSHIFTEND%3E%3DShiftStart)*%0A%20%20%20%20(T3%26lt%3B%3DShiftEnd)*%0A%20%20%20%20(T3-IF(ShiftStart%26gt%3B%3DS3%2CShiftStart%2CS3))*Rate*24%0A%20%20)%0A)%3C%2FSHIFTEND%3E%3C%2FSHIFTEND%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20ShiftStart%2C%20ShiftEnd%20and%20Rate%20are%20named%20columns%20in%20helper%20range%20with%20shifts.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20a%20cosmetic%20comment%20to%20previous%20formulas%2C%20it's%20not%20necessary%20to%20use%20formulas%20as%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DCHOOSE(C3%2C%22Monday%22%2C%22Tuesday%22%2C%22Wednesday%22%2C%22Thursday%22%2C%22Friday%22%2C%22Saturday%22%2C%22Sunday%22)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eto%20return%20weekday%20name%2C%20it's%20enough%20to%20apply%20%3CEM%3Edddd%3C%2FEM%3E%20custom%20format%20to%20date.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1661484%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1661484%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BSir%2C%20thank%20you%20for%20your%20time%20and%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20cleans%20everything%20up%20for%20sure%2C%20however%20I%20still%20cannot%20make%20it%20work%20when%20shift%20H%20and%20D%20collide%20with%20each%20other..%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20row%203%20for%20instance%20if%20an%20employee%20starts%20work%20Sun%2022%3A30%2C%20and%20ends%20work%20Mon%2006%3A30%2C%20the%20outcome%20of%20working%20hours%20is%20correct%20-%208hrs%2C%20but%20neither%20my%20(with%20great%20help%20of%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3B)%20formula%2C%20nor%20yours%20work%20correctly.%20The%20sum%20product%20of%20these%20hours%20should%20be%3A%207.5hrs%20in%20shift%20H%2C%200.5hrs%20in%20shift%20D%2C%20multiplied%20by%20defined%20rates%20should%20give%3A%202992%24.%20The%20same%20goes%20for%20Sun%2023%3A30%20-%20Mon%2007%3A00.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20I%20need%20to%20add%20more%20rows%20with%20defined%20hours%20to%20the%20sheet%20H%20for%20example%20%3A%3C%2FP%3E%3CTABLE%20border%3D%221%22%20width%3D%2237.20650337837837%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2216.00331674958541%25%22%20height%3D%2230px%22%3ESun%2022%3A30%3C%2FTD%3E%3CTD%20width%3D%2221.20456277172695%25%22%20height%3D%2230px%22%3EMon%2006%3A30%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2216.00331674958541%25%22%20height%3D%2230px%22%3ESun%2023%3A00%3C%2FTD%3E%3CTD%20width%3D%2221.20456277172695%25%22%20height%3D%2230px%22%3EMon%2007%3A00%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2216.00331674958541%25%22%20height%3D%2230px%22%3ESun%2023%3A30%3C%2FTD%3E%3CTD%20width%3D%2221.20456277172695%25%22%20height%3D%2230px%22%3E%3CP%3EMon%2007%3A30%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3Eand%20index%20them%20with%20letters%20for%20example%20H1%2C%20H2%2C%20H3%20and%20if%20that%20shift%20occurs%20the%20SUMPRODUCT%20would%20count%20it%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1661777%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1661777%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F786297%22%20target%3D%22_blank%22%3E%40mikim1kolaj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYes%2C%20that%20was%20missed.%20I%20added%20the%20condition%20if%20both%20TiimeStart%20and%20TimeEnd%20are%20outside%20the%20hours%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMPRODUCT(%0A%20%20IF(%20(S3%26gt%3BShiftStart)*(T3%3CSHIFTEND%3E%3DShiftEnd)%2C(ShiftEnd-ShiftStart)*Rate*24%2C%0A%20%20%20%20(S3%26gt%3BShiftStart)*%0A%20%20%20%20(S3%20%3CSHIFTEND%3E%3DShiftStart)*%0A%20%20%20%20(T3%26lt%3B%3DShiftEnd)*%0A%20%20%20%20(T3-IF(ShiftStart%26gt%3B%3DS3%2CShiftStart%2CS3))*Rate*24%0A%20%20)%0A%20)%0A)%3C%2FSHIFTEND%3E%3C%2FSHIFTEND%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EPlease%20check%20in%20attached%20file.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1662162%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1662162%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F786297%22%20target%3D%22_blank%22%3E%40mikim1kolaj%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20you%2C%20I%20appreciate%20that%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%20has%2C%20from%20all%20appearances%2C%20been%20able%20to%20resolve%20all%20of%20your%20functional%20issues.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20still%20want%20to%20puzzle%20through%20some%20of%20this%20to%20make%20sure%20I%20understand%20the%20use%20of%20MOD%20and%20SUMPRODUCT%20in%20this%20connection.%20I'm%20sure%20anything%20I%20would%20have%20come%20up%20with%20would%20have%20been%20more%20rudimentary%2C%20but%20at%20least%20I%20would%20have%20been%20able%20to%20explain%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20a%20most%20interesting%20problem!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1662248%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20Excel%20do%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1662248%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3B%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BI%20would%20really%20like%20to%20thank%20both%20of%20you%20for%20the%20help%20you%20have%20provided%20me%20with.%20A%20week%20ago%20I%20didn't%20know%20more%20than%20SUM%20and%20AVERAGE%20in%20Excel%2C%20now%20I%20am%20more%20aware%20of%20its%20powers%20and%20it%20made%20me%20sign%20up%20for%20a%20course%20so%20I%20can%20fully%20understand%20this%20great%20piece%20of%20software.%20Perhaps%20one%20day%20I%20could%20help%20someone%20here%20who%20might%20be%20in%20a%20position%20like%20I%20was%20these%20couple%20days%20ago.%20Once%20again%2C%20great%20thank%20you%20for%20the%20help%2C%20I%20appreciate%20it%20very%20much%20and%20I%20wish%20all%20the%20best%20for%20you.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hey, I am working on a school project and I would like to know if what I want to create is even possible in Excel.

I have a simple table with employees, hours and salary. What I want to know if is it possible to just provide Excel with a date and hour and it would automatically count how many hours an employee had worked, select shift by itself and count the salary according to selected shift and money rate? I know just some basics from my statistics course at college and I am not sure if Excel (or myself perhaps) could do it. 

I have uploaded my sheet so anyone can see what I mean. I am thankful for every reply.

15 Replies
Best Response confirmed by mikim1kolaj (Occasional Contributor)
Solution

@mikim1kolaj 

 

You've said it's a school project and you want to know if what you want to create is even possible in Excel. Right?

The answer to that question is "Yes, it is possible."

 

It probably would take a bit more explanation of what you want to do, but Excel is very good at that kind of thing. So since it's a project for school, have at it. I'll point you in the direction of the many functions that enable one to look things up from a table. And I'd suggest searching (probably on Google) for how those work.... there are in Excel several ways to accomplish it.

 

Or were you expecting somebody here to do your homework for you?

@mathetes No, not at all, sir, I want to do it myself, but I didn't know if Excel was even capable of doing it. I'll try my best to do it with the help of Google. Thank you very much for your reply!

@mathetes Sir, I have managed to create almost my whole table. I only have a problem with Shift H, which starts at 17:00 on Friday and ends at 6:00 on Monday. Could you please provide me with some help with column L? I know I need to add =IF(C2="Friday" then do this, if not, do that, but I can't get it to work.

@mikim1kolaj 

 

What you've done is impressive. Instead of giving you the answer, I want to give you a few other pointers.

 

  1. First of all, I think you're not entirely correct with your assumption that you need to begin with =IF(C2="Friday" because (if I understand correctly how this is working), the "H" Holiday rate would apply for somebody starting on Saturday or Sunday as well as starting on Friday. So there are more conditions that need to be taken into account in determining whether the hours are paid as "H" hours. So you need to spell those out as well.
  2. Second, I've pointed you to several functions that might come in handy. You created a table that looks up the name of the day based on dates in September. There's a function that does that automatically, with a lot of variations within it. I've given you a simple example of that. The =WEEKDAY() function returns a number from 1 to 7. You could use those numbers in your formulas rather than the names of the days--it would make the formulas shorter, to some extent. But also, you could do math with them. So if Friday was day 5, Saturday day 6, and so on....your IF statement could simply say =IF(day>=5,.........)
  3. Third, if you want the name of the day to appear, use =CHOOSE() to turn the number into the name of the day.
  4. Fourth, in my very first response, I had suggested you look for how Excel can be used to retrieve data from a table. You've chosen to use IF statements for that. I've given you a demonstration of how you can use INDEX and MATCH to get the hourly rates and apply them. I changed the headings of the shift column so as to be able to use the D, E, N, H designations as the reference in MATCH....

So let me turn it back to you now, with those pointers, and see if you can resolve your weekend issue.

@mathetes Thank you very, very much. I couldn't get clues like that in Google, that's why I asked you, sir. I will try to implement those functions over the weekend and I'll get back to you when I manage to make it work.

@mikim1kolaj 

 

Here's a great website for help with Excel functions. https://exceljet.net/

 

I recommend also looking at examples on that site for the functions WORKDAYS, VLOOKUP, XLOOKUP, as well as the ones I included in my sample.

@mathetes Thank you, sir. I have used the functions you provided, as well as I got help from exceljet. In cell Q13 I have created a function which gives H or 0, depending on the number of day from WEEKDAY and hour. I have then created a new sheet with 31 days of this function. Then, for every shift in K, L, M, N I entered IF statement, which depending on the outcome of the function in new sheet either counts the number of hours in each shift or just gives 0,00 and continues. 

It works to a point in which two shifts collide with each other. When it is Friday >=17:00 up until Monday <=06:00 it works really good, however, when an employee works for example Monday 04:00 until Monday 12:00 it gives 6hrs in K, 0,08hrs in H, and loses the rest of the time. Did I overdid it to a point where it just simply can't work or is it fixable?

 

I am really grateful for your help, if I am abusing your free time please just let me know.

Also, it is difficult for me to explain what I did and what I mean because English is not my main language, therefore I am sorry if you can't understand me clearly.

@mikim1kolaj 

 

You are explaining yourself very well in English.

 

You might (this is a guess on my part) benefit from the IFS function...take a look at it on exceljet. It sometimes is easier than nesting IF within IF within IF.

 

I will not be able to take a close look until much later today, I'm afraid. I had wondered about that matter of crossing shift boundaries, but it did seem as if you had it resolved in your earlier version. So keep working....I'll look later, but maybe you will be able to do it on your own. That's always more satisfying.

@mikim1kolaj 

I'd suggest to start from day one. Shifts could be defined as

image.png

in final version format Shift Star/End as time to hide years.

Into the main table I added two helper columns (S and T)

image.png

not to complicate main formula, but mainly to clean confusing records as start on Sun 22:00 and end on Sun 03:00.

Formulas here

Start:
=MOD(B3-1,7)+1+MOD(E3,1)

End:
=MOD(B3-1,7)+1+MOD(I3,1)+IF(MOD(I3,1)<MOD(E3,1),1,0)

payment is calculated as

=SUMPRODUCT(
  IF( (S3>ShiftStart)*(T3<ShiftEnd),(T3-S3)*Rate*24,
    (S3>ShiftStart)*
    (S3 <ShiftEnd)*
    (IF( ShiftEnd<=T3,ShiftEnd,T3) - S3)*Rate*24+

    (T3>=ShiftStart)*
    (T3<=ShiftEnd)*
    (T3-IF(ShiftStart>=S3,ShiftStart,S3))*Rate*24
  )
)

 

Here ShiftStart, ShiftEnd and Rate are named columns in helper range with shifts.

 

As a cosmetic comment to previous formulas, it's not necessary to use formulas as

=CHOOSE(C3,"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")

to return weekday name, it's enough to apply dddd custom format to date.

@Sergei Baklan Sir, thank you for your time and help.

 

This cleans everything up for sure, however I still cannot make it work when shift H and D collide with each other..

 

In row 3 for instance if an employee starts work Sun 22:30, and ends work Mon 06:30, the outcome of working hours is correct - 8hrs, but neither my (with great help of @mathetes ) formula, nor yours work correctly. The sum product of these hours should be: 7.5hrs in shift H, 0.5hrs in shift D, multiplied by defined rates should give: 2992$. The same goes for Sun 23:30 - Mon 07:00.

 

Do I need to add more rows with defined hours to the sheet H for example :

Sun 22:30Mon 06:30
Sun 23:00Mon 07:00
Sun 23:30

Mon 07:30

and index them with letters for example H1, H2, H3 and if that shift occurs the SUMPRODUCT would count it?

@mikim1kolaj 

Yes, that was missed. I added the condition if both TiimeStart and TimeEnd are outside the hours:

=SUMPRODUCT(
  IF( (S3>ShiftStart)*(T3<ShiftEnd),(T3-S3)*Rate*24,
  IF( (S3<=ShiftStart)*(T3>=ShiftEnd),(ShiftEnd-ShiftStart)*Rate*24,
    (S3>ShiftStart)*
    (S3 <ShiftEnd)*
    (IF( ShiftEnd<=T3,ShiftEnd,T3) - S3)*Rate*24+

    (T3>=ShiftStart)*
    (T3<=ShiftEnd)*
    (T3-IF(ShiftStart>=S3,ShiftStart,S3))*Rate*24
  )
 )
)

Please check in attached file.

@mikim1kolaj 

 

With you, I appreciate that @Sergei Baklan has, from all appearances, been able to resolve all of your functional issues.

 

I still want to puzzle through some of this to make sure I understand the use of MOD and SUMPRODUCT in this connection. I'm sure anything I would have come up with would have been more rudimentary, but at least I would have been able to explain it.

 

Thanks for a most interesting problem!

@mathetes , @Sergei Baklan I would really like to thank both of you for the help you have provided me with. A week ago I didn't know more than SUM and AVERAGE in Excel, now I am more aware of its powers and it made me sign up for a course so I can fully understand this great piece of software. Perhaps one day I could help someone here who might be in a position like I was these couple days ago. Once again, great thank you for the help, I appreciate it very much and I wish all the best for you. 

@mathetes , the idea behind is that dates are integers and start from Jan 01, 1900 which is Sunday. With MOD(date, 7) we move any date into this first week and work with datetime only within it. MOD(time,0) is to be more safe, to be sure we have only time, not time plus one-two dates in case of incorrect entry.

SUMPRODUCT checks if start/end time is within time range for defined datetime, or our of the range, or one of the is in the middle and depends on that takes the difference.

@mikim1kolaj , you are welcome, glad to help. Excel is infinite, good luck on the way of improving your skills in it - that's never ended process.