Reorganised a long format table to a wide data table

%3CLINGO-SUB%20id%3D%22lingo-sub-1530800%22%20slang%3D%22en-US%22%3EReorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1530800%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI'm%20struggling%20to%20reorganise%20a%20data%20table%20from%20long%20format%20to%20a%20wide%20format.%20my%20data%20is%20organised%20as%20follows%3A%3C%2FP%3E%3CTABLE%20border%3D%221%22%20width%3D%2281.62983425414365%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3EValue%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2231.629834254143645%25%22%3ESample%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E3456434%3C%2FTD%3E%3CTD%20width%3D%2231.629834254143645%25%22%3E1%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E56645677%3C%2FTD%3E%3CTD%20width%3D%2231.629834254143645%25%22%3E1%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E46356%3C%2FTD%3E%3CTD%20width%3D%2231.629834254143645%25%22%3E1%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E24556%3C%2FTD%3E%3CTD%20width%3D%2231.629834254143645%25%22%3E2%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E235478%3C%2FTD%3E%3CTD%20width%3D%2231.629834254143645%25%22%3E2%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3EThis%20is%20how%20the%20data%20is%20organised%20but%20for%207%20samples%20but%20hundreds%20of%20thousands%20of%20values%20per%20sample.%3C%2FP%3E%3CP%3EI'd%20like%20to%20organised%20the%20table%20like%20this%3A%3C%2FP%3E%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2216.666666666666668%25%22%3ESample%201%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3ESample%202%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3ESample%203%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3ESample%204%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3ESample%205%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3ESample%206%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E223456%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E466433%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E776543%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E77543%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E8653%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E7564%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E676543%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E76432%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E34567%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E33456%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E344567%3C%2FTD%3E%3CTD%20width%3D%2216.666666666666668%25%22%3E3345%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3ECan%20anyone%20advise%20me%20how%20to%20best%20achieve%20this%20in%20Excel%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1530800%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1530898%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1530898%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F732585%22%20target%3D%22_blank%22%3E%40GibbE155%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESince%20you%20said%20%22hundreds%20of%20thousands%22%2C%20I%20recommend%20you%20don't%20use%20formulas%20for%20this%2C%20but%20instead%20use%20Power%20Query.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESelect%20any%20cell%20in%20your%20data%20and%20use%20Data%26gt%3BGet%20%26amp%3B%20Transform%20Data%26gt%3BFrom%20Table%2FRange%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20will%20open%20the%20Power%20Query%20Editor.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%2C%20use%20Add%20Column%26gt%3BGeneral%26gt%3BCustom%20Column%20and%20use%20this%20formula%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3E%22Sample%20%22%20%26amp%3B%20Number.ToText(%5BSample%5D)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECall%20the%20new%20column%20ColumnHeader%20(not%20essential%2C%20you%20can%20call%20it%20whatever%20you%20want).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20right-click%20the%20Sample%20column%20and%20select%20Remove.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENext%2C%20select%20the%20ColumnHeader%20column%20you%20created%20above%20and%20use%20Home%26gt%3BTransform%26gt%3BGroup%20By%20and%20configure%20the%20dialog%20like%20this%3A%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%22OwenPrice_1-1595078671139.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206229i00F428C6FD3D3E11%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22OwenPrice_1-1595078671139.png%22%20alt%3D%22OwenPrice_1-1595078671139.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20use%20Add%20Column%26gt%3BGeneral%26gt%3BCustom%20Column%20with%20this%20formula%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3ETable.AddIndexColumn(%5BGroupIndex%5D%2C%20%22Index%22%2C%201%2C%201)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20called%20this%20new%20custom%20column%20DataWithGroupIndex.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20I%20have%20three%20columns%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22OwenPrice_3-1595079089309.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206231iE1E39D93F380903A%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22OwenPrice_3-1595079089309.png%22%20alt%3D%22OwenPrice_3-1595079089309.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERight-click%20GroupIndex%20and%20Remove%20that%20column%2C%20then%20click%20the%20double-arrow%20in%20the%20top%20right%20hand%20corner%20of%20the%20DataWithGroupIndex%20column%20to%20expand%20the%20data%20that%20currently%20says%20%22Table%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20expand%20field%20dialog%2C%20I've%20configured%20it%20like%20this%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22OwenPrice_4-1595079179629.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206232iCBB8D54EDA866CB3%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22OwenPrice_4-1595079179629.png%22%20alt%3D%22OwenPrice_4-1595079179629.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20know%20this%20seems%20like%20a%20lot%20of%20steps%2C%20but%20once%20done%2C%20this%20process%20will%20be%20repeatable%20and%20you%20won't%20be%20sat%20waiting%20for%207%20hundreds%20of%20thousands%20of%20formulas%20to%20recalculate.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20point%20of%20the%20steps%20leading%20up%20to%20here%20was%20to%20get%20an%20index%20column%20that%20repeats%20when%20the%20column%20header%20changes%2C%20which%20will%20be%20important%20for%20the%20next%20step.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20select%20the%20ColumnHeader%20column%20and%20use%20Transform%26gt%3BAny%20Column%26gt%3BPivot%20Column%20and%20configure%20it%20like%20this%3A%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%22OwenPrice_5-1595079333082.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206233i0EB2C163F8F97D0C%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22OwenPrice_5-1595079333082.png%22%20alt%3D%22OwenPrice_5-1595079333082.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20clicking%20OK%2C%20you'll%20see%20that%20the%20data%20are%20properly%20top-loaded%20into%20each%20Sample%20column.%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%22OwenPrice_6-1595079395181.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206234i993C2A02D2880F7C%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22OwenPrice_6-1595079395181.png%22%20alt%3D%22OwenPrice_6-1595079395181.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20right-click%20the%20Index%20and%20Remove%20it%2C%20then%20use%20Home%26gt%3BClose%20%26amp%3B%20Load%20to%20put%20the%20results%20back%20into%20the%20workbook.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20want%2C%20you%20can%20just%20open%20the%20attached%20workbook%2C%20select%20any%20cell%20in%20the%20green%20table%2C%20go%20to%20the%20Query%20Tab%2C%20select%20Edit%2C%20then%20on%20the%20Home%20Tab%20of%20the%20Power%20Query%20Editor%2C%20click%20Advanced%20Editor%20to%20see%20the%20code%20for%20the%20whole%20query%2C%20which%20you%20should%20be%20able%20to%20put%20into%20your%20own%20workbook%20with%20some%20minimal%20editing%20if%20you're%20comfortable%20with%20that.%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-1531085%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1531085%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F732585%22%20target%3D%22_blank%22%3E%40GibbE155%3C%2FA%3E%26nbsp%3B%2C%20since%20you%20already%20have%20the%20data%20in%20Excel%2C%20a%20pivot%20table%20may%20be%20a%20quick%20solution.%20Select%20the%20data%20and%20Insert%20a%20Pivot%20Table.%20Add%20Value%20to%20the%20Values%20section%20and%20Sample%20to%20the%20Columns.%20See%20attached%20file.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TheAntony_0-1595093130998.png%22%20style%3D%22width%3A%20250px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206243i7168157FE73259C1%2Fimage-dimensions%2F250x206%3Fv%3D1.0%22%20width%3D%22250%22%20height%3D%22206%22%20title%3D%22TheAntony_0-1595093130998.png%22%20alt%3D%22TheAntony_0-1595093130998.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-1531231%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1531231%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F732585%22%20target%3D%22_blank%22%3E%40GibbE155%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20with%20formulas%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%20606px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206249iE621054D4E644CFD%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%3Ethat%20could%20be%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%24C%242%20%26amp%3B%20%22%20%22%20%26amp%3B%20TRANSPOSE(UNIQUE(C3%3AC7))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Efor%20headers%20and%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DFILTER(%24B%243%3A%24B%247%2C%24C%243%3A%24C%247%3DINDEX(UNIQUE(%24C%243%3A%24C%247)%2CCOLUMN()-COLUMN(%24E%242)%2B1))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Efor%20the%20column.%3C%2FP%3E%0A%3CP%3EIf%20use%20named%20range%20same%20formulas%20could%20be%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DINDEX(Range%2C1%2C2)%20%26amp%3B%20%22%20%22%20%26amp%3B%20TRANSPOSE(UNIQUE(INDEX(Range%2C2%2C2)%3AINDEX(Range%2CROWS(Range)%2C2)))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eand%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DFILTER(INDEX(Range%2C2%2C1)%3AINDEX(Range%2CROWS(Range)%2C1)%2C%0A%20%20%20%20%20%20%20%20INDEX(Range%2C2%2C2)%3AINDEX(Range%2CROWS(Range)%2C2)%3D%0A%20%20%20%20%20%20%20%20INDEX(UNIQUE(INDEX(Range%2C2%2C2)%3AINDEX(Range%2CROWS(Range)%2C2))%2CCOLUMN()-COLUMN(%24H%242)%2B1)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EFormulas%20could%20be%20generated%20for%20pre-DA%20Excel%20as%20well.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20with%20Power%20Query%20another%20variant%20could%20be%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3Elet%0A%20%20%20%20Source%20%3D%20Excel.CurrentWorkbook()%7B%5BName%3D%22Range%22%5D%7D%5BContent%5D%2C%0A%20%20%20%20%23%22Promoted%20Headers%22%20%3D%20Table.PromoteHeaders(Source%2C%20%5BPromoteAllScalars%3Dtrue%5D)%2C%0A%20%20%20%20%23%22Grouped%20Rows%22%20%3D%20Table.Group(%23%22Promoted%20Headers%22%2C%20%7B%22Sample%22%7D%2C%20%7B%7B%22Count%22%2C%20each%20_%5BValue%20%5D%7D%7D)%2C%0A%20%20%20%20Custom1%20%3D%20Table.FromColumns(%23%22Grouped%20Rows%22%5BCount%5D%2C%0A%20%20%20%20%20%20%20%20List.Transform(%23%22Grouped%20Rows%22%5BSample%5D%2C%20each%20%22Sample%20%22%20%26amp%3B%20Text.From(_)))%0Ain%0A%20%20%20%20Custom1%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1531901%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1531901%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F383224%22%20target%3D%22_blank%22%3E%40TheAntony%3C%2FA%3E%2C%20this%20only%20appears%20to%20give%20me%20a%20value%20which%20is%26nbsp%3B%20the%20sum%20of%20all%20the%20values%20in%20the%20new%20columns%2C%20rather%20than%20listing%20each%20value%20individually.%20Would%20you%20know%20of%20a%20way%20around%20this%3F%3C%2FP%3E%3CP%3EMany%20thanks%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1531903%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1531903%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F725726%22%20target%3D%22_blank%22%3E%40OwenPrice%3C%2FA%3E%26nbsp%3B%2C%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%20this%20appears%20to%20be%20the%20best%20solution.%20How%20do%20you%20return%20the%20workbook%20to%20a%20normal%20worksheet%20after%20this%3F%20The%20power%20query%20editor%20doesn't%20appear%20to%20allow%20independent%20sorting%20of%20columns.%3C%2FP%3E%3CP%3EMany%20thanks%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1531915%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1531915%22%20slang%3D%22en-US%22%3EDo%20you%20want%20to%20sort%20each%20column%20with%20the%20largest%20value%20at%20the%20top%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1531926%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1531926%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F732585%22%20target%3D%22_blank%22%3E%40GibbE155%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdded%20sorting%20to%20my%20variant%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3Elet%0A%20%20%20%20Source%20%3D%20Excel.CurrentWorkbook()%7B%5BName%3D%22Range%22%5D%7D%5BContent%5D%2C%0A%20%20%20%20%23%22Promoted%20Headers%22%20%3D%20Table.PromoteHeaders(Source%2C%20%5BPromoteAllScalars%3Dtrue%5D)%2C%0A%20%20%20%20%23%22Grouped%20Rows%22%20%3D%20Table.Group(%23%22Promoted%20Headers%22%2C%20%7B%22Sample%22%7D%2C%0A%20%20%20%20%20%20%20%20%7B%7B%22Count%22%2C%20each%20List.Sort(_%5BValue%20%5D)%7D%7D)%2C%0A%20%20%20%20Custom1%20%3D%20Table.FromColumns(%23%22Grouped%20Rows%22%5BCount%5D%2C%0A%20%20%20%20%20%20%20%20List.Transform(%23%22Grouped%20Rows%22%5BSample%5D%2C%20each%20%22Sample%20%22%20%26amp%3B%20Text.From(_)))%0Ain%0A%20%20%20%20Custom1%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1531961%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1531961%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F732585%22%20target%3D%22_blank%22%3E%40GibbE155%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20insert%20a%20step%20to%20sort%20the%20data%20before%20it's%20transformed%20to%20ensure%20it's%20sorted%20in%20the%20output.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJust%20sort%20the%20value%20column%20either%20ascending%20or%20descending%20in%20this%20position%20in%20the%20query%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22OwenPrice_0-1595180917766.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206290iB0AEEA6C1BA8DA74%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22OwenPrice_0-1595180917766.png%22%20alt%3D%22OwenPrice_0-1595180917766.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20result%20is%20now%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22OwenPrice_1-1595180948779.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206291i6743381FED800626%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22OwenPrice_1-1595180948779.png%22%20alt%3D%22OwenPrice_1-1595180948779.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20attached%20the%20workbook%20containing%20the%20query%20that%20includes%20the%20sort%20step%20described.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20answer%20to%20your%20question%2C%20make%20sure%20you've%20used%20Home%26gt%3BClose%20%26amp%3B%20Load%20to%20put%20the%20results%20into%20the%20workbook.%20Then%20select%20any%20cell%20and%20use%20Table%20Design%26gt%3BTools%26gt%3BConvert%20to%20Range.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22OwenPrice_0-1595181161454.png%22%20style%3D%22width%3A%202407px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206292iAF0FFDF7C58140F2%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22OwenPrice_0-1595181161454.png%22%20alt%3D%22OwenPrice_0-1595181161454.png%22%20%2F%3E%3C%2FSPAN%3E%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-1858308%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1858308%22%20slang%3D%22en-US%22%3EHi!%20Thanks%20for%20taking%20the%20time%20to%20write%20out%20this%20great%20explanation.%20I%20have%20a%20similar%20data%20issue%2C%20however%20my%20values%20are%20text%20fields%20(and%20I%20have%20additional%20columns%20of%20data).%20Should%20it%20still%20be%20possible%20to%20use%20this%20method%3F%20When%20I%20tried%20to%20replicate%20I%20still%20ended%20up%20with%20two%20columns%20of%20data%20as%20I%20started...%20Thank%20you%20so%20much%20for%20your%20help!%3CBR%20%2F%3E%3CBR%20%2F%3EAnd%20if%20you%20are%20able%20to%20assist%20further%2C%20I%20can%20send%20more%20information%20about%20the%20table.%20Thanks%20again!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1858615%22%20slang%3D%22en-US%22%3ERe%3A%20Reorganised%20a%20long%20format%20table%20to%20a%20wide%20data%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1858615%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F859171%22%20target%3D%22_blank%22%3E%40Greenfire555%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYes%2C%20it's%20better%20to%20provide%20sample%20file%20and%20it's%20better%20to%20start%20new%20conversation%20with%20this%20question.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi,

I'm struggling to reorganise a data table from long format to a wide format. my data is organised as follows:

Value Sample
34564341
566456771
463561
245562
2354782

This is how the data is organised but for 7 samples but hundreds of thousands of values per sample.

I'd like to organised the table like this:

Sample 1Sample 2Sample 3Sample 4Sample 5Sample 6
2234564664337765437754386537564
6765437643234567334563445673345

Can anyone advise me how to best achieve this in Excel?

10 Replies
Highlighted

@GibbE155 

 

Since you said "hundreds of thousands", I recommend you don't use formulas for this, but instead use Power Query.

 

Select any cell in your data and use Data>Get & Transform Data>From Table/Range

 

This will open the Power Query Editor.

 

Now, use Add Column>General>Custom Column and use this formula:

 

 

"Sample " & Number.ToText([Sample])

 

 

Call the new column ColumnHeader (not essential, you can call it whatever you want).

 

Now right-click the Sample column and select Remove.

 

Next, select the ColumnHeader column you created above and use Home>Transform>Group By and configure the dialog like this:

 

OwenPrice_1-1595078671139.png

 

Now use Add Column>General>Custom Column with this formula:

 

 

Table.AddIndexColumn([GroupIndex], "Index", 1, 1)

 

 

I called this new custom column DataWithGroupIndex.

 

Now I have three columns:

OwenPrice_3-1595079089309.png

 

Right-click GroupIndex and Remove that column, then click the double-arrow in the top right hand corner of the DataWithGroupIndex column to expand the data that currently says "Table".

 

In the expand field dialog, I've configured it like this:

OwenPrice_4-1595079179629.png

 

I know this seems like a lot of steps, but once done, this process will be repeatable and you won't be sat waiting for 7 hundreds of thousands of formulas to recalculate.

 

The point of the steps leading up to here was to get an index column that repeats when the column header changes, which will be important for the next step.

 

Now select the ColumnHeader column and use Transform>Any Column>Pivot Column and configure it like this:

 

OwenPrice_5-1595079333082.png

 

After clicking OK, you'll see that the data are properly top-loaded into each Sample column.

 

OwenPrice_6-1595079395181.png

 

You can right-click the Index and Remove it, then use Home>Close & Load to put the results back into the workbook.

 

If you want, you can just open the attached workbook, select any cell in the green table, go to the Query Tab, select Edit, then on the Home Tab of the Power Query Editor, click Advanced Editor to see the code for the whole query, which you should be able to put into your own workbook with some minimal editing if you're comfortable with that.

 

 

Highlighted

@GibbE155 , since you already have the data in Excel, a pivot table may be a quick solution. Select the data and Insert a Pivot Table. Add Value to the Values section and Sample to the Columns. See attached file.

TheAntony_0-1595093130998.png

 

Highlighted

@GibbE155 

If with formulas

image.png

that could be

=$C$2 & " " & TRANSPOSE(UNIQUE(C3:C7))

for headers and

=FILTER($B$3:$B$7,$C$3:$C$7=INDEX(UNIQUE($C$3:$C$7),COLUMN()-COLUMN($E$2)+1))

for the column.

If use named range same formulas could be

=INDEX(Range,1,2) & " " & TRANSPOSE(UNIQUE(INDEX(Range,2,2):INDEX(Range,ROWS(Range),2)))

and

=FILTER(INDEX(Range,2,1):INDEX(Range,ROWS(Range),1),
        INDEX(Range,2,2):INDEX(Range,ROWS(Range),2)=
        INDEX(UNIQUE(INDEX(Range,2,2):INDEX(Range,ROWS(Range),2)),COLUMN()-COLUMN($H$2)+1)
)

Formulas could be generated for pre-DA Excel as well.

 

If with Power Query another variant could be

let
    Source = Excel.CurrentWorkbook(){[Name="Range"]}[Content],
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Grouped Rows" = Table.Group(#"Promoted Headers", {"Sample"}, {{"Count", each _[Value ]}}),
    Custom1 = Table.FromColumns(#"Grouped Rows"[Count],
        List.Transform(#"Grouped Rows"[Sample], each "Sample " & Text.From(_)))
in
    Custom1
Highlighted

Hi @TheAntony, this only appears to give me a value which is  the sum of all the values in the new columns, rather than listing each value individually. Would you know of a way around this?

Many thanks, 

 

Highlighted

Hi @OwenPrice , 

Thanks, this appears to be the best solution. How do you return the workbook to a normal worksheet after this? The power query editor doesn't appear to allow independent sorting of columns.

Many thanks  

Highlighted
Do you want to sort each column with the largest value at the top?
Highlighted

@GibbE155 

Added sorting to my variant

let
    Source = Excel.CurrentWorkbook(){[Name="Range"]}[Content],
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Grouped Rows" = Table.Group(#"Promoted Headers", {"Sample"},
        {{"Count", each List.Sort(_[Value ])}}),
    Custom1 = Table.FromColumns(#"Grouped Rows"[Count],
        List.Transform(#"Grouped Rows"[Sample], each "Sample " & Text.From(_)))
in
    Custom1

 

Highlighted

@GibbE155 

 

You can insert a step to sort the data before it's transformed to ensure it's sorted in the output.

 

Just sort the value column either ascending or descending in this position in the query:

OwenPrice_0-1595180917766.png

 

The result is now:

OwenPrice_1-1595180948779.png

 

I've attached the workbook containing the query that includes the sort step described.

 

In answer to your question, make sure you've used Home>Close & Load to put the results into the workbook. Then select any cell and use Table Design>Tools>Convert to Range.

OwenPrice_0-1595181161454.png

 

 

Highlighted
Hi! Thanks for taking the time to write out this great explanation. I have a similar data issue, however my values are text fields (and I have additional columns of data). Should it still be possible to use this method? When I tried to replicate I still ended up with two columns of data as I started... Thank you so much for your help!

And if you are able to assist further, I can send more information about the table. Thanks again!
Highlighted

@Greenfire555 

Yes, it's better to provide sample file and it's better to start new conversation with this question.