Data Filtering by Column/ Horizontal

%3CLINGO-SUB%20id%3D%22lingo-sub-1498838%22%20slang%3D%22en-US%22%3EData%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1498838%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20date%20in%201st%20column%20and%20names%20in%202nd%2C%203rd%2C%204th%20column%20and%20so%20on.%20How%20can%20I%26nbsp%3Bfilter%20a%20data%20to%20get%20the%20count%20of%20each%20name%20in%20the%20specified%20date%20range.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Data%20Filter.jpeg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F202178iC6C764CC8B90AEF3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Data%20Filter.jpeg%22%20alt%3D%22Data%20Filter.jpeg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CSPAN%3EEnclosed%20excel%20file%20with%20data%20and%20sample%20outcome%20required.%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1498838%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%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1498942%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1498942%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F714430%22%20target%3D%22_blank%22%3E%40sandeeptikait%3C%2FA%3E%26nbsp%3B%20Here%20is%20a%20formula%20that%20works%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUMPRODUCT(--(%24B%242%3A%24B%2416%26gt%3B%3D%24L%243)*(%24B%242%3A%24B%2416%26lt%3B%3D%24N%243)%2C(--(%24C%242%3A%24C%2416%3D%24K6)%2B(%24D%242%3A%24D%2416%3D%24K6)%2B(%24E%242%3A%24E%2416%3D%24K6)%2B(%24F%242%3A%24F%2416%3D%24K6)%2B(%24G%242%3A%24G%2416%3D%24K6)%2B(%24H%242%3A%24H%2416%3D%24K6)))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EI%20wonder%20if%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%3B%26nbsp%3Bor%20someone%20else%20might%20chime%20in%20with%20a%20'better'%20answer.%3C%2FP%3E%3CP%3EI'm%20pretty%20sure%20some%20of%20those%20new%20array%20functions%20like%20FILTER%20could%20help%20out%20here.%3C%2FP%3E%3CP%3EMaybe%20I'll%20get%20access%20to%20them%20some%20day...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1499883%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1499883%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%26nbsp%3B%2C%20IMHO%20-%20%22best%20solution%22%20is%20quite%20individual%20and%20depends%20on%20criterion.%20From%20my%20point%20of%20view%20that's%20any%20one%20which%20works%20and%20which%20concrete%20person%20understands%20better.%20Thus%20using%20such%20pattern%20potentially%20the%20person%20could%20save%20a%20lot%20of%20time%20on%20deployment%20and%20maintenance.%20That%20in%20particular%20means%20that%20for%20the%20same%20person%20today%20one%20solution%20could%20be%20considered%20as%20best%2C%20and%20in%20a%20while%20another%20one%2C%20assuming%20both%20do%20exactly%20the%20same%20job.%20Sorry%20for%20some%20philosophy%2C%20with%20your%20experience%20that%20could%20be%20not%20new.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F714430%22%20target%3D%22_blank%22%3E%40sandeeptikait%3C%2FA%3E%26nbsp%3B%2C%20if%20play%20with%20modern%20Excel%20functionality%2C%20formula%20could%20be%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSUM(--(%0A%20%20INDEX(Range%2C%0A%20%20%20%20%20SEQUENCE(%20COUNTIFS(INDEX(Range%2C0%2C1)%2C%22%26gt%3B%3D%22%26amp%3B%24L%243%2CINDEX(Range%2C0%2C1)%2C%22%26lt%3B%3D%22%26amp%3B%24N%243)%2C1%2C2)%2C%0A%20%20%20%20%20SEQUENCE(1%2CCOLUMNS(Range)-1%2C2%2C1)%0A%20%20)%3DK6)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ewhere%20the%20%22Range%22%20is%20named%20range%20for%20entire%20source%20data.%20If%20extract%20unique%20names%20and%20return%20counts%20as%20spill%20it'll%20be%20more%20complicated.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMost%20probably%20other%20formula%20(without%20Power%20Query)%20solutions%20exist.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1499901%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1499901%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F714430%22%20target%3D%22_blank%22%3E%40sandeeptikait%3C%2FA%3E%26nbsp%3BOffering%20a%20PowerQuery%20approach%2C%20using%20three%20Named%20Ranges%20(names%2C%20Start%20and%20End).%20Although%20I%20still%20consider%20myself%20a%20relative%20newbie%20at%20the%20subject%2C%20I'm%20rather%20pleased%20with%20the%20outcome%20%3A)%2C%20but%20at%20the%20same%20time%20convinced%20that%20it%20probably%20can%20be%20done%20better.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EResults%20are%20shown%20in%20the%20small%20table%20in%20N5%3AO11.%20Change%20the%20Start%20and%2For%20End%20dates.%26nbsp%3BSelect%20the%20Data%20ribbon%20and%20press%22Refresh%20All%22%20for%20an%20updated%20result.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1500155%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1500155%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F714430%22%20target%3D%22_blank%22%3E%40sandeeptikait%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20another%20modern%20dynamic%20array%20solution.%26nbsp%3B%20One%20form%20that%20I%20like%20is%20to%20use%20the%20beta-release%20function%20LET%20to%20generate%20a%20self-documenting%20formula%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20LET(%0A%20%20firstRow%2C%20XLOOKUP(Start%2C%20Date%2C%20NameRange%2C%20%2C1)%2C%0A%20%20finalRow%2C%20XLOOKUP(End%2C%20Date%2C%20NameRange%2C%20%2C-1)%2C%0A%20%20filteredRange%2C%20firstRow%3AfinalRow%2C%0A%20%20COUNTIFS(filteredRange%2C%20Name)%20)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20uses%20the%20fact%20that%20XLOOKUP%20returns%20a%20range%20to%20build%20the%20filtered%20range%20to%20search.%26nbsp%3B%20Without%20LET%2C%20one%20would%20have%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20COUNTIFS(XLOOKUP(Start%2CDate%2CNameRange%2C%20%2C1)%3AXLOOKUP(End%2CDate%2CNameRange%2C%20%2C-1)%2C%20Name)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1500666%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1500666%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%26nbsp%3B%20Thanks%20for%20your%20response.%20You%20solution%20for%20counting%20the%20number%20of%20occurrence%20is%20fine.%20But%20how%20would%20I%20get%20the%20unique%20records%20of%20names%2C%20if%20there%20are%20hundreds%20of%20names%20in%20the%20list.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1500720%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1500720%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%3CSPAN%3EThanks%20for%20your%20response.%20You%20solution%20for%20counting%20the%20number%20of%20occurrence%20is%20fine.%20But%20how%20would%20I%20get%20the%20unique%20records%20of%20names%2C%20if%20there%20are%20hundreds%20of%20names%20in%20the%20list.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1500874%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1500874%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELooks%20good%20to%20me.%20About%20the%20only%20point%20where%20I%20would%20differ%20is%20in%20that%20I%20would%20have%20converted%20the%20named%20range%20to%20a%20Table%20before%20starting%20with%20PQ.%20That%20both%20makes%20the%20input%20dynamic%20and%20saves%20the%20promote%20headers%20step%20in%20the%20M%20code.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1500931%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1500931%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F714430%22%20target%3D%22_blank%22%3E%40sandeeptikait%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20UNIQUE%20function%20requires%20the%20table%20to%20be%20unpivoted%20and%20that%20is%20a%20somewhat%20messy%20process.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20LET(%0A%20%20m%2C%20ROWS(NameTable)%2C%0A%20%20n%2C%20COLUMNS(NameTable)-1%2C%0A%20%20k%2C%20SEQUENCE(m*n)%2C%0A%20%20rowNum%2C%201%2BQUOTIENT(k-1%2Cn)%2C%0A%20%20colNum%2C%201%2BMOD(k-1%2Cn)%2C%0A%20%20list%2C%20INDEX(NameTable%2C%20rowNum%2C%201%2BcolNum)%2C%0A%20%20SORT(UNIQUE(list))%20)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EWithout%20the%20LET%20function%2C%20the%20process%20is%20worse.%26nbsp%3B%20One%20would%20either%20have%20to%20implement%20each%20line%20as%20a%20separate%20named%20formula%20using%20Name%20Manager%20or%2C%20worse%20still%2C%20write%20it%20as%20a%20nested%20formula.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20are%20(paid)%20function%20libraries%20that%20can%20help.%26nbsp%3B%20Charles%20Williams's%20FastExcel%20includes%20an%20UNPIVOT%20function%20which%20reduces%20the%20process%20of%20determining%20a%20sorted%20list%20of%20distinct%20names%20to%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20LET(%0A%20%20unpivoted%2C%20UNPIVOT(NameTable%2C%2C1%2C%2C%2C0)%2C%0A%20%20list%2C%20INDEX(unpivoted%2C%20%2C3)%2C%0A%20%20SORT(UNIQUE(list))%20)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1501107%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1501107%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3BGood%20point.%20Will%20keep%20that%20in%20mind!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1501954%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20Filtering%20by%20Column%2F%20Horizontal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1501954%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEven%20without%20LET()%20your%20code%20will%20be%20very%20similar%2C%20only%20with%20global%20names.%3C%2FP%3E%0A%3CP%3EMy%20variant%20is%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DUNIQUE(%0A%20%20%20%20INDEX(Range%2C%0A%20%20%20%20%20%20%20MOD(SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1))-1%2C14)%2B2%2C%0A%20%20%20%20%20%20%20INT(%20SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1)%2C%2C(ROWS(Range)-1)*2)%2F%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(ROWS(Range)-1))%0A%20%20%20)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EMore%20interesting%20is%20spill%20for%20counts%2C%20here%20LET%20could%20be%20more%20useful.%20Without%20it%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DTRANSPOSE(%0A%20%20%20%20MMULT(%0A%20%20%20%20%20%20%20SEQUENCE(1%2C(COLUMNS(Range)-1)*(ROWS(Range)-1)%2C%2C0)%2C%0A%20%20%20%20%20%20%20(%0A%20%20%20%20%20%20%20%20%20%20INDEX(Range%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MOD(SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1))-1%2C14)%2B2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20INT(%20SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1)%2C%2C(ROWS(Range)-1)*2)%2F%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(ROWS(Range)-1))%0A%20%20%20%20%20%20)%3DTRANSPOSE(K6%23))*%0A%20%20%20%20%20%20%20(INDEX(Range%2C%20MOD(SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1))-1%2C14)%2B2%2C%201%20)%26gt%3B%3D%24L%243)*%0A%20%20%20%20%20%20%20(INDEX(Range%2C%20MOD(SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1))-1%2C14)%2B2%2C%201%20)%26lt%3B%3D%24N%243)%0A%20%20%20)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ENot%20sure%20how%20to%20combine%20both%20spills%20together.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I have date in 1st column and names in 2nd, 3rd, 4th column and so on. How can I filter a data to get the count of each name in the specified date range.

 

Data Filter.jpeg

 

Enclosed excel file with data and sample outcome required.

14 Replies
Highlighted

@sandeeptikait  Here is a formula that works:

=SUMPRODUCT(--($B$2:$B$16>=$L$3)*($B$2:$B$16<=$N$3),(--($C$2:$C$16=$K6)+($D$2:$D$16=$K6)+($E$2:$E$16=$K6)+($F$2:$F$16=$K6)+($G$2:$G$16=$K6)+($H$2:$H$16=$K6)))

I wonder if @Sergei Baklan  or someone else might chime in with a 'better' answer.

I'm pretty sure some of those new array functions like FILTER could help out here.

Maybe I'll get access to them some day...

 

Highlighted

@mtarler , IMHO - "best solution" is quite individual and depends on criterion. From my point of view that's any one which works and which concrete person understands better. Thus using such pattern potentially the person could save a lot of time on deployment and maintenance. That in particular means that for the same person today one solution could be considered as best, and in a while another one, assuming both do exactly the same job. Sorry for some philosophy, with your experience that could be not new.

@sandeeptikait , if play with modern Excel functionality, formula could be

=SUM(--(
  INDEX(Range,
     SEQUENCE( COUNTIFS(INDEX(Range,0,1),">="&$L$3,INDEX(Range,0,1),"<="&$N$3),1,2),
     SEQUENCE(1,COLUMNS(Range)-1,2,1)
  )=K6)
)

where the "Range" is named range for entire source data. If extract unique names and return counts as spill it'll be more complicated.

 

Most probably other formula (without Power Query) solutions exist.

Highlighted

@sandeeptikait Offering a PowerQuery approach, using three Named Ranges (names, Start and End). Although I still consider myself a relative newbie at the subject, I'm rather pleased with the outcome :), but at the same time convinced that it probably can be done better.

 

Results are shown in the small table in N5:O11. Change the Start and/or End dates. Select the Data ribbon and press"Refresh All" for an updated result.

 

 

Highlighted

@sandeeptikait 

This is another modern dynamic array solution.  One form that I like is to use the beta-release function LET to generate a self-documenting formula

 

 

= LET(
  firstRow, XLOOKUP(Start, Date, NameRange, ,1),
  finalRow, XLOOKUP(End, Date, NameRange, ,-1),
  filteredRange, firstRow:finalRow,
  COUNTIFS(filteredRange, Name) )

 

 

It uses the fact that XLOOKUP returns a range to build the filtered range to search.  Without LET, one would have

 

= COUNTIFS(XLOOKUP(Start,Date,NameRange, ,1):XLOOKUP(End,Date,NameRange, ,-1), Name)

 

Highlighted

@mtarler  Thanks for your response. You solution for counting the number of occurrence is fine. But how would I get the unique records of names, if there are hundreds of names in the list.

Highlighted

@Peter Bartholomew Thanks for your response. You solution for counting the number of occurrence is fine. But how would I get the unique records of names, if there are hundreds of names in the list.

Highlighted

@Riny_van_Eekelen 

Looks good to me. About the only point where I would differ is in that I would have converted the named range to a Table before starting with PQ. That both makes the input dynamic and saves the promote headers step in the M code.

Highlighted

@sandeeptikait 

The UNIQUE function requires the table to be unpivoted and that is a somewhat messy process.

= LET(
  m, ROWS(NameTable),
  n, COLUMNS(NameTable)-1,
  k, SEQUENCE(m*n),
  rowNum, 1+QUOTIENT(k-1,n),
  colNum, 1+MOD(k-1,n),
  list, INDEX(NameTable, rowNum, 1+colNum),
  SORT(UNIQUE(list)) )

Without the LET function, the process is worse.  One would either have to implement each line as a separate named formula using Name Manager or, worse still, write it as a nested formula.

 

There are (paid) function libraries that can help.  Charles Williams's FastExcel includes an UNPIVOT function which reduces the process of determining a sorted list of distinct names to

= LET(
  unpivoted, UNPIVOT(NameTable,,1,,,0),
  list, INDEX(unpivoted, ,3),
  SORT(UNIQUE(list)) )

 

Highlighted

@Peter Bartholomew Good point. Will keep that in mind!

Highlighted

@Peter Bartholomew 

Even without LET() your code will be very similar, only with global names.

My variant is

=UNIQUE(
    INDEX(Range,
       MOD(SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1))-1,14)+2,
       INT( SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1),,(ROWS(Range)-1)*2)/
               (ROWS(Range)-1))
   )
)

More interesting is spill for counts, here LET could be more useful. Without it

=TRANSPOSE(
    MMULT(
       SEQUENCE(1,(COLUMNS(Range)-1)*(ROWS(Range)-1),,0),
       (
          INDEX(Range,
                MOD(SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1))-1,14)+2,
                INT( SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1),,(ROWS(Range)-1)*2)/
               (ROWS(Range)-1))
      )=TRANSPOSE(K6#))*
       (INDEX(Range, MOD(SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1))-1,14)+2, 1 )>=$L$3)*
       (INDEX(Range, MOD(SEQUENCE((COLUMNS(Range)-1)*(ROWS(Range)-1))-1,14)+2, 1 )<=$N$3)
   )
)

Not sure how to combine both spills together.

 

Highlighted

@Sergei Baklan 

First an observation.  Anything that can be done with LET could be done with named formula, I have used such calculations for years.  What you lose is the 'calculate once, use many times'; that would require helper ranges and not defined names.

 

The following gives both columns from a single spill but I wouldn't care to make any claims concerning computational efficiency!

= LET(
\1, "Filter range by date",
     firstRow, XLOOKUP(Start, NameTable[Date], NameTable, ,1),
     finalRow, XLOOKUP(End, NameTable[Date], NameTable, ,-1),
     filteredNames, firstRow:finalRow,
\2, "Calculate frequencies for filtered table",
    freqTable, COUNTIFS(filteredNames, filteredNames),
\3, "Unpivot both tables",
    m, ROWS(filteredNames),
    n, COLUMNS(filteredNames)-1,
    k, SEQUENCE(m*n),
    rowNum, 1+QUOTIENT(k-1,n),
    colNum, 1+MOD(k-1,n),
    nameList, INDEX(filteredNames, rowNum, 1+colNum),
    freqList, INDEX(freqTable, rowNum, 1+colNum),
\4, "Combine name and frequency lists",
    combined, IF({1,0}, nameList, freqList),
\5, "Sort unique on combined name and frequencies",
    SORT(UNIQUE(combined)) )

My indentation is not as interesting as yours because, in the main, I have used local names in place of nested formulas.  The jury is probably still out on whether one should write formulas like this; the fact that one can still has some shock value at the moment!

Highlighted

@Peter Bartholomew 

I have nothing against LET() in general except it is now only on beta channel. Thus it could be used mainly for modelling purposes, but not on practice for real projects.

Highlighted

@Sergei Baklan 

My use of LET is pure self-indulgence; though I am particularly interested in developing techniques that exploit the new function.  Before installing Office 365, I used to use named formula to bypass the dreaded implicit intersection.  That process still works, but it is now more convenient to develop formulas using LET and, also, the parameters are then presented in a logical sequence,  so providing self-documenting formulas.  Paste Names was all very well but the logic didn't exactly shine through.

 

For client work, I would clearly not be able to use LET.  A contract that required direct referencing and non-array solutions, it would simply turn down; if that is what is want, they can do it themselves  

 

Highlighted

@sandeeptikait  Here is a formula for finding unique names without the new functions (I hope it is ok that it isn't alphabetical):

=IFERROR(OFFSET($A$1,MOD(AGGREGATE(15,7, (ROW($C$3:$H$16)+100000*COLUMN($C$3:$H$16))/(--(COUNTIF(J$5:J10,$C$3:$H$16)=0)), 1),100000)-1,INT(AGGREGATE(15,7, (ROW($C$3:$H$16)+100000*COLUMN($C$3:$H$16))/(--(COUNTIF(J$5:J10,$C$3:$H$16)=0)), 1)/100000)-1),"")