SOLVED

How to find unique value and display the value based on the earliest date/time criteria

%3CLINGO-SUB%20id%3D%22lingo-sub-2366373%22%20slang%3D%22en-US%22%3EHow%20to%20find%20unique%20value%20and%20display%20the%20value%20based%20on%20the%20earliest%20date%2Ftime%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2366373%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20to%20find%20unique%20values%20from%20column%20A%20in%20a%20table%20generated%20via%20Power%20Query%2C%20and%20based%20on%20another%20column%20that%20displays%20date%2Ftime%20(in%20column%20B)%20find%20the%20earliest%20date%20and%20display%20the%20total%20from%20column%20C%20for%20each%20distinct%20unique%20value%20from%20A.%3C%2FP%3E%3CP%3EI%20tried%20different%20methods%20but%20wasn't%20able%20to%20succeed%20so%20I'd%20appreciate%20any%20help%20here.%3C%2FP%3E%3CP%3EPlease%20find%20attached%20sample%20with%20explanation.%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2366373%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2366422%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20find%20unique%20value%20and%20display%20the%20value%20based%20on%20the%20earliest%20date%2Ftime%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2366422%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1024126%22%20target%3D%22_blank%22%3E%40ragomes1972%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20use%20Power%20Query%20the%20easiest%20way%20to%20generate%20second%20table%20is%20by%20it.%3C%2FP%3E%0A%3CP%3E-%20reference%20first%20query%3C%2FP%3E%0A%3CP%3E-%20sort%20by%20Sprint%20and%20Time%2C%20both%20ascending%3C%2FP%3E%0A%3CP%3E-%20add%20Index%20to%20fix%20table%20in%20memory%3C%2FP%3E%0A%3CP%3E-%20remove%20duplicates%20on%20sprints%3C%2FP%3E%0A%3CP%3E-%20remove%20other%20columns%3C%2FP%3E%0A%3CP%3E-%20load%20to%20sheet%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20check%20attached.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2963430%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20find%20unique%20value%20and%20display%20the%20value%20based%20on%20the%20earliest%20date%2Ftime%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2963430%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1024126%22%20target%3D%22_blank%22%3E%40ragomes1972%3C%2FA%3E%26nbsp%3BHi.%20Should%20you%20prefer%20not%20to%20do%20it%20in%20power%20query%2C%20as%20suggested%20by%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%2C%20you%20may%20do%20it%20directly%20on%20the%20worksheet.%20Assuming%20excel%20365%20and%20setting%20upp%20two%20formulas%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bosinander_0-1636899283081.png%22%20style%3D%22width%3A%20555px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F326945iABF795248B33E84D%2Fimage-dimensions%2F555x204%3Fv%3Dv2%22%20width%3D%22555%22%20height%3D%22204%22%20role%3D%22button%22%20title%3D%22bosinander_0-1636899283081.png%22%20alt%3D%22bosinander_0-1636899283081.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EG3%26nbsp%3B%3DUNIQUE(Table1%5BSprint%20Commit%5D)%3C%2FP%3E%3CP%3Eto%20find%20the%20unique%20sprints.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EG4%20uses%20the%20unique%20sprints%20as%20'local'%20name%20data%20and%20defines%20minData%20being%20the%20minimal%20date%20for%20each%20unique%20sprint.%3C%2FP%3E%3CP%3EFinally%20defines%20output%20as%20an%20xlookup%20of%20the%20combination%20of%20data%20(unique%20sprints)%20with%20their%20minimal%20date%20and%20returns%20the%20points.%3C%2FP%3E%3CP%3EYou%20may%20change%20the%20last%20line%20from%20output%20to%20minDate%20or%20data%20to%20se%20how%20each%20of%20them%20turns%20out.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DLET(data%3BG3%23%3B%3CBR%20%2F%3EminDate%3BMINIFS(Table1%5BLog%20Date-Time%5D%3BTable1%5BSprint%20Commit%5D%3Bdata)%3B%3CBR%20%2F%3Eoutput%3BXLOOKUP(data%20%26amp%3B%20%22%7C%22%20%26amp%3B%20minDate%3B%20Table1%5BSprint%20Commit%5D%20%26amp%3B%20%22%7C%22%20%26amp%3B%20Table1%5BLog%20Date-Time%5D%3BTable1%5BTotal%20points%5D)%3B%3CBR%20%2F%3Eoutput%3CBR%20%2F%3E)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20result%20is%20a%20little%20different%20than%20in%20the%20example.%3C%2FP%3E%3CP%3EShuold%20you%20though%20need%20the%20%3CSTRONG%3Efirst%3C%2FSTRONG%3E%20instead%20of%20the%20%3CSTRONG%3Esmallest%3C%2FSTRONG%3E%20timestamp%2C%20the%20formula%20could%20rather%20be%3C%2FP%3E%3CP%3E%3DXLOOKUP(G3%23%3BTable1%5BSprint%20Commit%5D%3BTable1%5BTotal%20points%5D)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bosinander_2-1636900752593.png%22%20style%3D%22width%3A%20674px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F326948i15BE4B393DFCDAB1%2Fimage-dimensions%2F674x214%3Fv%3Dv2%22%20width%3D%22674%22%20height%3D%22214%22%20role%3D%22button%22%20title%3D%22bosinander_2-1636900752593.png%22%20alt%3D%22bosinander_2-1636900752593.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2963607%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20find%20unique%20value%20and%20display%20the%20value%20based%20on%20the%20earliest%20date%2Ftime%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2963607%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1159986%22%20target%3D%22_blank%22%3E%40bosinander%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20a%20comment%2C%20I'm%20not%20sure%20what%20could%20be%20the%20reason%20for%20having%20Power%20Query%20table%20land%20it%20into%20the%20sheet%20and%20generate%20final%20result%20by%20formulae%20then.%20IMHO%2C%20much%20easier%20to%20add%20few%20extra%20steps%20to%20Power%20Query.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnyway%2C%20if%20dynamic%20arrays%20I'd%20suggest%20to%20put%20result%20into%20one%20spill%2C%20not%20combine%20two%20separate%20spills.%20That%20could%20be%20like%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DLET(%0A%20sorted%2C%20SORTBY(%20Table1%2C%20Table1%5BSprint%20Commit%5D%2C1%2C%20Table1%5BLog%20Date-Time%5D%2C1)%2C%0A%20sprints%2C%20UNIQUE(%20Table1%5BSprint%20Commit%5D%20)%2C%0AINDEX(%20sorted%2C%20XMATCH(%20sprints%2C%20INDEX(sorted%2C0%2C1))%2C%20%7B1%2C3%7D%20)%20)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2963762%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20find%20unique%20value%20and%20display%20the%20value%20based%20on%20the%20earliest%20date%2Ftime%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2963762%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%3B%3C%2FP%3E%3CP%3E%26gt%3B%20IMHO%2C%20much%20easier%20to%20add%20few%20extra%20steps%20to%20Power%20Query.%3CBR%20%2F%3ESure%20is%20if%20the%20sheet%20user%20is%20a%20bit%20of%20a%20Power%20Query%20developer.%20But%20if%20a%20user%20gets%20a%20sheet%20loaded%20from%20someone%20else%2C%20data%20pasted%20from%20somewhere%20or%20for%20any%20other%20reason%20prefers%20to%20finalize%20on%20the%20spreadsheet%2C%20also%20your%20worksheet%20solution%20is%20a%20functional%20way%20to%20do%20it%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERe%20one%20or%20two%20spilling%20cells%2C%20there%20are%20fmpov%20pros%20and%20cons%20with%20both%20solutions%20and%20in%20this%20case%20I%20suggested%20two%20cells.%3CBR%20%2F%3Eeg%2C%20if%20the%20user%20wants%20a%20sum%20of%20the%20total%20points%20in%20table%202%2C%20it%20may%20be%20easier%20to%20understand%20a%20solution%20with%20two%20cells%20and%20the%20possibility%20to%20use%20SUM(H3%23).%3C%2FP%3E%3CP%3EWith%20one%20spilling%20cell%20it%20will%20be%20needed%20to%20use%20SUM(G3%23%20H%3AH)%2C%20SUM(INDEX(H3%23%2C%2C2))%20or%20any%20other%20way%20to%20reference%20the%20spilled%20data%20column.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EBy%20buiding%20it%20all%20in%20one%20though%2C%20one%20gets%20a%20solution%20with%20fewer%20formulas%20that%20can%20be%20manipulated%20by%20mistake%20so%20if%20it%20should%20be%20my%20own%20solution%20to%20in%20the%20future%20be%20managed%20solely%20by%20me%20or%20you%2C%20I%20might%20do%20it%20all%20in%20one%20cell.%3C%2FP%3E%3CP%3EIn%20this%20case%20though%2C%20I%20consider%20educating%20in%20somehow%20smaller%20steps%20and%20reusing%20a%20limited%20set%20of%20functions%20that%20can%20be%20combined%20into%20a%20wide%20range%20of%20application%20areas.%3CBR%20%2F%3EAnyhow%2C%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1024126%22%20target%3D%22_blank%22%3E%40ragomes1972%3C%2FA%3E%26nbsp%3Bnow%20have%20some%20different%20ways%20to%20solve%20the%20problem%20and%20I%20hope%20at%20least%20one%20of%20them%20will%20be%20a%20suitable%20one.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2964615%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20find%20unique%20value%20and%20display%20the%20value%20based%20on%20the%20earliest%20date%2Ftime%20criteria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2964615%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1024126%22%20target%3D%22_blank%22%3E%40ragomes1972%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESource%20%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.extendoffice.com%2Fdocuments%2Fexcel%2F3333-excel-find-earliest-date-based-on-criteria.html%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.extendoffice.com%2Fdocuments%2Fexcel%2F3333-excel-find-earliest-date-based-on-criteria.html%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EKutools%20for%20Excel%3C%2FSTRONG%3E%E2%80%99s%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAdvanced%20Combine%20Rows%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efeature%20can%20help%20you%20to%20get%20the%20earliest%20or%20latest%20date%20of%20each%20item%20in%20Column%20A%20without%20any%20formulas.%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwww.extendoffice.com%2Fproduct%2Fkutools-for-excel.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSTRONG%3EKutools%20for%20Excel%3C%2FSTRONG%3E%26nbsp%3B%3C%2FA%3E%3A%26nbsp%3B%3CSTRONG%3Ewith%20more%20than%20300%20handy%20Excel%20add-ins%2C%20free%20to%20try%20with%20no%20limitation%20in%2060%20days%3C%2FSTRONG%3E.%26nbsp%3B%3C%2FSPAN%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E%3CDIV%20class%3D%22%22%3E%3CA%20title%3D%22Click%20for%20free%20trial%22%20href%3D%22https%3A%2F%2Fwww.extendoffice.com%2Fdownload%2Fkutools-for-excel.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EGo%20to%20Download%3C%2FSPAN%3E%3CBR%20%2F%3EFree%20Trial%2060%20days%3C%2FA%3E%3CA%20href%3D%22https%3A%2F%2Fwww.extendoffice.com%2Forder%2Fkutools-for-excel.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EPurchase%3C%2FSPAN%3E%3CBR%20%2F%3EPayPal%20%2F%20MyCommerce%3C%2FA%3E%3C%2FDIV%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3EIf%20you%20have%20installed%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EKutools%20for%20Excel%3C%2FSTRONG%3E%2C%20please%20do%20as%20follows%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3E1%3C%2FSTRONG%3E.%20If%20you%20want%20to%20keep%20the%20original%20data%2C%20you%20can%20copy%20and%20paste%20the%20data%20to%20another%20range%2C%20and%20then%20select%20the%20pasted%20range%20that%20you%20want%20to%20use.%3C%2FP%3E%3CP%3E%3CSTRONG%3E2%3C%2FSTRONG%3E.%20Then%20click%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EKutools%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%26gt%3B%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EContent%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%26gt%3B%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAdvanced%20Combine%20Rows%3C%2FSTRONG%3E%2C%20see%20screenshot%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Syede320_0-1636962307421.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F327008i9D2197B8FA71CE2E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Syede320_0-1636962307421.png%22%20alt%3D%22Syede320_0-1636962307421.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E3%3C%2FSTRONG%3E.%20In%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ECombine%20Rows%20Based%20on%20Column%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Edialog%20box%2C%20please%20click%20the%20column%20name%20that%20you%20want%20to%20get%20the%20date%20based%20on%2C%20and%20then%20click%3CSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EPrimary%20Key%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eoption%2C%20see%20screenshot%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Syede320_1-1636962307503.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F327010iFE0ACA7537B269C2%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Syede320_1-1636962307503.png%22%20alt%3D%22Syede320_1-1636962307503.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E4%3C%2FSTRONG%3E.%20Then%20click%20the%20date%20column%20that%20you%20want%20to%20return%20the%20latest%20or%20earliest%20date%2C%20and%20select%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ECalculate%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%26gt%3B%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMax%20%2F%20Min%3C%2FSTRONG%3E%2C%20(%20select%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMax%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20get%20the%20latest%20date%20and%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMin%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20return%20the%20oldest%20date)%2C%20see%20screenshot%3A%3C%2FP%3E%3CP%3EWebsite%20%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.gnitcm.net%2Ftoday-jobs%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fwww.gnitcm.net%2Ftoday-jobs%2F%3C%2FA%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Syede320_2-1636962307619.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F327009iA1743096C32544B0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Syede320_2-1636962307619.png%22%20alt%3D%22Syede320_2-1636962307619.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ETips%3C%2FSTRONG%3E%3A%20If%20you%20check%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMy%20data%20has%20headers%3C%2FSTRONG%3E%2C%20your%20header%20within%20the%20data%20range%20will%20be%20ignored%20automatically%2C%20to%20get%20the%20correct%20date%20format%2C%20please%20uncheck%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EUse%20formatted%20values%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eoption.%3C%2FP%3E%3CP%3E%3CSTRONG%3E5%3C%2FSTRONG%3E.%20Then%20click%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EOk%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ebutton%2C%20the%20latest%20or%20oldest%20date%20base%20on%20each%20item%20has%20been%20returned%20as%20follows%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESource%20%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.extendoffice.com%2Fdocuments%2Fexcel%2F3333-excel-find-earliest-date-based-on-criteria.html%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.extendoffice.com%2Fdocuments%2Fexcel%2F3333-excel-find-earliest-date-based-on-criteria.html%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi, 

I have to find unique values from column A in a table generated via Power Query, and based on another column that displays date/time (in column B) find the earliest date and display the total from column C for each distinct unique value from A.

I tried different methods but wasn't able to succeed so I'd appreciate any help here.

Please find attached sample with explanation.

Thanks!

5 Replies
best response confirmed by ragomes1972 (Occasional Contributor)
Solution

@ragomes1972 

If you use Power Query the easiest way to generate second table is by it.

- reference first query

- sort by Sprint and Time, both ascending

- add Index to fix table in memory

- remove duplicates on sprints

- remove other columns

- load to sheet

 

Please check attached.

@ragomes1972 Hi. Should you prefer not to do it in power query, as suggested by @Sergei Baklan, you may do it directly on the worksheet. Assuming excel 365 and setting upp two formulas;

 

bosinander_0-1636899283081.png

 

G3 =UNIQUE(Table1[Sprint Commit])

to find the unique sprints.

 

G4 uses the unique sprints as 'local' name data and defines minData being the minimal date for each unique sprint.

Finally defines output as an xlookup of the combination of data (unique sprints) with their minimal date and returns the points.

You may change the last line from output to minDate or data to se how each of them turns out.

 

=LET(data;G3#;
minDate;MINIFS(Table1[Log Date-Time];Table1[Sprint Commit];data);
output;XLOOKUP(data & "|" & minDate; Table1[Sprint Commit] & "|" & Table1[Log Date-Time];Table1[Total points]);
output
)

 

The result is a little different than in the example.

Shuold you though need the first instead of the smallest timestamp, the formula could rather be

=XLOOKUP(G3#;Table1[Sprint Commit];Table1[Total points])

 

bosinander_2-1636900752593.png

 

@bosinander 

As a comment, I'm not sure what could be the reason for having Power Query table land it into the sheet and generate final result by formulae then. IMHO, much easier to add few extra steps to Power Query.

 

Anyway, if dynamic arrays I'd suggest to put result into one spill, not combine two separate spills. That could be like

=LET(
 sorted, SORTBY( Table1, Table1[Sprint Commit],1, Table1[Log Date-Time],1),
 sprints, UNIQUE( Table1[Sprint Commit] ),
INDEX( sorted, XMATCH( sprints, INDEX(sorted,0,1)), {1,3} ) )

 

@Sergei Baklan 

> IMHO, much easier to add few extra steps to Power Query.
Sure is if the sheet user is a bit of a Power Query developer. But if a user gets a sheet loaded from someone else, data pasted from somewhere or for any other reason prefers to finalize on the spreadsheet, also your worksheet solution is a functional way to do it

 

Re one or two spilling cells, there are fmpov pros and cons with both solutions and in this case I suggested two cells.
eg, if the user wants a sum of the total points in table 2, it may be easier to understand a solution with two cells and the possibility to use SUM(H3#).

With one spilling cell it will be needed to use SUM(G3# H:H), SUM(INDEX(H3#,,2)) or any other way to reference the spilled data column.


By buiding it all in one though, one gets a solution with fewer formulas that can be manipulated by mistake so if it should be my own solution to in the future be managed solely by me or you, I might do it all in one cell.

In this case though, I consider educating in somehow smaller steps and reusing a limited set of functions that can be combined into a wide range of application areas.
Anyhow, @ragomes1972 now have some different ways to solve the problem and I hope at least one of them will be a suitable one.

@ragomes1972 

 

Source : https://www.extendoffice.com/documents/excel/3333-excel-find-earliest-date-based-on-criteria.html

 

Kutools for Excel’s Advanced Combine Rows feature can help you to get the earliest or latest date of each item in Column A without any formulas.

Kutools for Excel with more than 300 handy Excel add-ins, free to try with no limitation in 60 days

If you have installed Kutools for Excel, please do as follows:

1. If you want to keep the original data, you can copy and paste the data to another range, and then select the pasted range that you want to use.

2. Then click Kutools > Content > Advanced Combine Rows, see screenshot:

Syede320_0-1636962307421.png

 

3. In the Combine Rows Based on Column dialog box, please click the column name that you want to get the date based on, and then click Primary Key option, see screenshot:

Syede320_1-1636962307503.png

 

4. Then click the date column that you want to return the latest or earliest date, and select Calculate > Max / Min, ( select Max to get the latest date and Min to return the oldest date), see screenshot:

Website : https://www.gnitcm.net/today-jobs/

Syede320_2-1636962307619.png

 

Tips: If you check My data has headers, your header within the data range will be ignored automatically, to get the correct date format, please uncheck Use formatted values option.

5. Then click Ok button, the latest or oldest date base on each item has been returned as follows:

 

Source : https://www.extendoffice.com/documents/excel/3333-excel-find-earliest-date-based-on-criteria.html