SOLVED

Help transposing rows of data with repeated headings into columns with unique headings

%3CLINGO-SUB%20id%3D%22lingo-sub-3276559%22%20slang%3D%22en-US%22%3EHelp%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276559%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%20I%20always%20receive%20raw%20data%20in%20the%20form%20of%201x9%20rows%20of%20numerical%20data.%20Each%20cell%20of%20the%20row%20is%20labeled%20S1%2C%20S2%2C%20S3%2C%20etc.%20(usually%20up%20to%20S4)%20but%20the%20labels%20can%20be%20repeated%20and%20in%20random%20order%20each%20time.%20So%2C%20if%20you%20include%20the%20headings%2C%20you%20could%20say%20it's%20a%202x9%20table.%20As%20an%20example%2C%20there%20may%20be%20two%20entries%20labeled%20S1%2C%20three%20entries%20labeled%20S2%2C%20two%20entries%20labeled%20S3%2C%20and%20one%20entry%20labeled%20S4.%20But%20the%20next%20row%20of%20data%20I%20get%20will%20be%20completely%20different%20and%20in%20a%20different%20order.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20be%20able%20to%20automatically%20transpose%20this%20data%20into%20ordered%20columns.%20I%20can%20do%20this%20manually%20but%20when%20data%20volume%20is%20high%20it%20becomes%20tedious.%20In%20the%20end%2C%20I%20want%204%20columns%20with%20headings%20S1%2C%20S2%2C%20S3%20and%20S4%20with%20all%20of%20the%20data%20entries%20listed%20underneath.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20%22hlookup%22%20and%20index%20%2F%20match%20functions%2C%20but%20it%20only%20returns%20the%20first%20data%20entry%20with%20a%20given%20label%2C%20but%20I%20need%20to%20collect%20all%20data%20entries%20with%20a%20given%20common%20label%20and%20transpose%20it%20into%20columns%20for%20further%20analysis.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20simple%20way%20to%20do%20this%3F%20Thanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3276559%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%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3277963%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3277963%22%20slang%3D%22en-US%22%3EGlad%20I%20could%20help%20%26amp%3B%20Thanks%20for%20providing%20feedback%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3277954%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3277954%22%20slang%3D%22en-US%22%3EHey%20this%20works%20great!%20Although%2C%20I%20do%20not%20understand%20all%20of%20it.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20noticed%20that%20the%20%22Data%22%20needs%20to%20be%20defined%20as%20a%20single%20block%20of%20cells.%20When%20I%20tried%20to%20define%20Data%20as%20a%20custom%20selection%20of%20various%20rows%2C%20I%20got%20errors.%20This%20would%20be%20needed%20so%20I%20can%20group%20the%20same%20data%20types%20together%2C%20for%20example%2C%20Temperatures%2C%20Pressures%2C%20etc.%20This%20is%20not%20a%20big%20problem%2C%20though.%20As%20a%20workaround%2C%20I%20simply%20grouped%20all%20of%20the%20data%20types%20together%20somewhere%20else%20then%20defined%20different%20versions%20of%20%22Data%22.%3CBR%20%2F%3E%3CBR%20%2F%3EMany%20thanks%20for%20your%20help!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3277411%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3277411%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1353933%22%20target%3D%22_blank%22%3E%40JTMoneyBest%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20LAMBDA%20functions%20(there's%20probably%20a%20better%20way...)%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361710iBECFB8BA37C5C1B5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screenshot.png%22%20alt%3D%22Screenshot.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E-%20Range%20A2%3AI12%20named%26nbsp%3B%3CEM%3E%3CSTRONG%3EData%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E-%20In%26nbsp%3B%3CSTRONG%3EK1%3C%2FSTRONG%3E%3A%26nbsp%3B%3D%22S%22%20%26amp%3B%20SEQUENCE(%2C4)%3C%2FP%3E%3CP%3E-%20In%26nbsp%3B%3CSTRONG%3EK2%3C%2FSTRONG%3E%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DLET(%0A%20%20%20%20src%2C%20%20%20%20TRANSPOSE(FILTER(Data%2CINDEX(Data%2C%2C1)%26lt%3B%26gt%3B%22%22))%2C%0A%20%20%20%20rws%2C%20%20%20%20ROWS(src)%2C%0A%20%20%20%20cls%2C%20%20%20%20COLUMNS(src)%2C%0A%20%20%20%20sqv%2C%20%20%20%20SEQUENCE(rws*cls)-1%2C%0A%20%20%20%20sqc%2C%20%20%20%201%2BQUOTIENT(sqv%2C%20rws)%2C%0A%20%20%20%20Stack%2C%20%20INDEX(src%2C%201%2BMOD(sqv%2Crws)%2C%20sqc)%2C%0A%20%20%20%20Series%2C%20FILTER(Stack%2CMOD(sqc%2C2)%3D1)%2C%0A%20%20%20%20Values%2C%20FILTER(Stack%2CMOD(sqc%2C2)%3D0)%2C%0A%20%20%20%20MAKEARRAY(MAX(COUNTIF(Data%2CK1%23))%2CCOLUMNS(K1%23)%2C%0A%20%20%20%20%20%20%20%20LAMBDA(rw%2Ccl%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20IFERROR(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20INDEX(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20FILTER(Values%2CSeries%3DINDEX(K1%23%2C%2Ccl))%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rw%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECorresponding%20sample%20attached%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3277297%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3277297%22%20slang%3D%22en-US%22%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%3CBR%20%2F%3EYour%202nd%20part%20is%20more%20straightforward%20and%20avoids%20Pivoting%2C%20a%20tranformation%20that%20can%20be%20slow%20with%20large%20dataset.%20Thanks%20for%20sharing%20it%20%26amp%3B%20Liked%20it%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3277063%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3277063%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F75890%22%20target%3D%22_blank%22%3E%40L%20z.%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELooks%20nice.%20Just%20in%20case%2C%20here%20is%20another%20variant%20for%20the%20second%20part%20of%20the%20script.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3277043%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3277043%22%20slang%3D%22en-US%22%3EGlad%20I%20could%20help.%20Power%20Query%20allows%20(easily)%20doing%20transformation%20that%20are%20complex%2Fquite%20impossible%20with%20formulas...%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3276980%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276980%22%20slang%3D%22en-US%22%3EI%20am%20not%20familiar%20with%20Power%20Query%2C%20but%20I%20can%20still%20use%20your%20suggestion%20with%20transpose%20with%20a%20filter%20if%20I%20just%20input%20all%20my%20raw%20data%20into%20one%20long%20row%2C%20which%20is%20not%20a%20problem.%20Thanks!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3276938%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276938%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1353933%22%20target%3D%22_blank%22%3E%40JTMoneyBest%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EForgot%20to%20say%20that%20the%20Power%20Query%20option%20easily%20takes%20more%20series%20into%20account%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361590i2BC5F27CADD90625%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screenshot.png%22%20alt%3D%22Screenshot.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3276771%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276771%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1353933%22%20target%3D%22_blank%22%3E%40JTMoneyBest%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20MAKEARRAY%20option%20won't%20work%20for%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22example%202.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361531iB3FC54E4019F16D0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22example%202.png%22%20alt%3D%22example%202.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Eand%20I%20currently%20have%20no%20idea%20how%20do%20it%20with%20formula.%20With%20Power%20Query%20no%20problem%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361534iA880B1D84062D9C1%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screenshot.png%22%20alt%3D%22Screenshot.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThe%20blue%20area%20is%20named%26nbsp%3B%3CEM%3E%3CSTRONG%3EData%3C%2FSTRONG%3E%3C%2FEM%3E%3CEM%3E.%20%3C%2FEM%3EQuery%20in%20the%20attached%20workbook...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3276744%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276744%22%20slang%3D%22en-US%22%3EI%20think%20we%20posted%20at%20the%20same%20time.%20Can%20I%20use%20the%20above%20when%20I%20have%20multiple%20input%20rows%20as%20in%20my%20new%20example%3F%20Thanks.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3276730%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276730%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1353933%22%20target%3D%22_blank%22%3E%40JTMoneyBest%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20have%20the%20LAMBDA%20functions%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361521iF065878FD5944A40%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screenshot.png%22%20alt%3D%22Screenshot.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%26nbsp%3B%3CSTRONG%3EK1%3C%2FSTRONG%3E%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DSORT(UNIQUE(A1%3AI1%2CTRUE)%2C%2C%2CTRUE)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%26nbsp%3B%3CSTRONG%3EK2%3C%2FSTRONG%3E%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DMAKEARRAY(MAX(COUNTIF(A1%3AI1%2CK1%23))%2CCOLUMNS(K1%23)%2C%0A%20%20%20%20LAMBDA(rw%2Ccl%2C%0A%20%20%20%20%20%20%20%20IFERROR(INDEX(FILTER(A2%3AI2%2CA1%3AI1%3DINDEX(K1%23%2C%2Ccl))%2C1%2Crw)%2C%22%22)%0A%20%20%20%20)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3276729%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276729%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F75890%22%20target%3D%22_blank%22%3E%40L%20z.%3C%2FA%3E%26nbsp%3BThank%20you!%20This%20works%20very%20well.%20But%20what%20about%20if%20I%20need%20to%20transpose%20multiple%20rows'%20data%20into%20the%20columns%3F%20Here%20is%20an%20example%20image%20of%20what%20I%20mean.%20Thanks%20again!%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22example%202.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361522iED4C9C69A30F9434%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22example%202.png%22%20alt%3D%22example%202.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3276658%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276658%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1353933%22%20target%3D%22_blank%22%3E%40JTMoneyBest%3C%2FA%3E%26nbsp%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%22Screenshot.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361497iB99F1EE9C97DD49D%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screenshot.png%22%20alt%3D%22Screenshot.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%26nbsp%3B%3CSTRONG%3EK2%3C%2FSTRONG%3E%20and%20copy%20right%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DTRANSPOSE(FILTER(%24A2%3A%24I2%2C%24A1%3A%24I1%3DK1))%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3276628%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276628%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F75890%22%20target%3D%22_blank%22%3E%40L%20z.%3C%2FA%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22example.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361488i9D4C015AF9FD1350%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22example.png%22%20alt%3D%22example.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20an%20example%20of%20what%20I%20receive%20on%20the%20left%20and%20what%20I%20want%20to%20produce%20on%20the%20right.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3276587%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20transposing%20rows%20of%20data%20with%20repeated%20headings%20into%20columns%20with%20unique%20headings%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3276587%22%20slang%3D%22en-US%22%3EPlease%20post%20a%20picture%20of%20what%20you%20receive%20%2B%20another%20one%20with%20what%20you%20expect%2C%20this%20will%20definitively%20clarify%20things.%20Thanks%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello, I always receive raw data in the form of 1x9 rows of numerical data. Each cell of the row is labeled S1, S2, S3, etc. (usually up to S4) but the labels can be repeated and in random order each time. So, if you include the headings, you could say it's a 2x9 table. As an example, there may be two entries labeled S1, three entries labeled S2, two entries labeled S3, and one entry labeled S4. But the next row of data I get will be completely different and in a different order.

 

I would like to be able to automatically transpose this data into ordered columns. I can do this manually but when data volume is high it becomes tedious. In the end, I want 4 columns with headings S1, S2, S3 and S4 with all of the data entries listed underneath.

 

I tried "hlookup" and index / match functions, but it only returns the first data entry with a given label, but I need to collect all data entries with a given common label and transpose it into columns for further analysis.

 

Is there a simple way to do this? Thanks!

 

 

15 Replies
Please post a picture of what you receive + another one with what you expect, this will definitively clarify things. Thanks

@L z. example.png

 

This is an example of what I receive on the left and what I want to produce on the right.

best response confirmed by JTMoneyBest (Occasional Contributor)
Solution

@JTMoneyBest 

 

Screenshot.png

 

in K2 and copy right:

=TRANSPOSE(FILTER($A2:$I2,$A1:$I1=K1))

@L z. Thank you! This works very well. But what about if I need to transpose multiple rows' data into the columns? Here is an example image of what I mean. Thanks again!example 2.png

@JTMoneyBest 

 

If you have the LAMBDA functions

Screenshot.png

 

in K1:

=SORT(UNIQUE(A1:I1,TRUE),,,TRUE)

 

in K2:

=MAKEARRAY(MAX(COUNTIF(A1:I1,K1#)),COLUMNS(K1#),
    LAMBDA(rw,cl,
        IFERROR(INDEX(FILTER(A2:I2,A1:I1=INDEX(K1#,,cl)),1,rw),"")
    )
)

 

I think we posted at the same time. Can I use the above when I have multiple input rows as in my new example? Thanks.

@JTMoneyBest 

 

The MAKEARRAY option won't work for

example 2.png

and I currently have no idea how do it with formula. With Power Query no problem

Screenshot.png

The blue area is named Data. Query in the attached workbook...

@JTMoneyBest 

Forgot to say that the Power Query option easily takes more series into account

Screenshot.png

I am not familiar with Power Query, but I can still use your suggestion with transpose with a filter if I just input all my raw data into one long row, which is not a problem. Thanks!
Glad I could help. Power Query allows (easily) doing transformation that are complex/quite impossible with formulas...

@L z. 

Looks nice. Just in case, here is another variant for the second part of the script.

@Sergei Baklan
Your 2nd part is more straightforward and avoids Pivoting, a tranformation that can be slow with large dataset. Thanks for sharing it & Liked it

@JTMoneyBest 

 

With LAMBDA functions (there's probably a better way...):

Screenshot.png

- Range A2:I12 named Data

- In K1: ="S" & SEQUENCE(,4)

- In K2:

=LET(
    src,    TRANSPOSE(FILTER(Data,INDEX(Data,,1)<>"")),
    rws,    ROWS(src),
    cls,    COLUMNS(src),
    sqv,    SEQUENCE(rws*cls)-1,
    sqc,    1+QUOTIENT(sqv, rws),
    Stack,  INDEX(src, 1+MOD(sqv,rws), sqc),
    Series, FILTER(Stack,MOD(sqc,2)=1),
    Values, FILTER(Stack,MOD(sqc,2)=0),
    MAKEARRAY(MAX(COUNTIF(Data,K1#)),COLUMNS(K1#),
        LAMBDA(rw,cl,
            IFERROR(
                INDEX(
                    FILTER(Values,Series=INDEX(K1#,,cl)),
                    rw
                ),
                ""
            )
        )
    )
)

 

 

Corresponding sample attached

Hey this works great! Although, I do not understand all of it.

I noticed that the "Data" needs to be defined as a single block of cells. When I tried to define Data as a custom selection of various rows, I got errors. This would be needed so I can group the same data types together, for example, Temperatures, Pressures, etc. This is not a big problem, though. As a workaround, I simply grouped all of the data types together somewhere else then defined different versions of "Data".

Many thanks for your help!
Glad I could help & Thanks for providing feedback