SOLVED
Home

Combine data from multiple rows into a single row

%3CLINGO-SUB%20id%3D%22lingo-sub-538677%22%20slang%3D%22en-US%22%3ECombine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-538677%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Excel%20community%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20dataset%20that%20looks%20something%20like%20this%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIncident%20%23%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BName%20of%20person%20reporting%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BRole%20of%20person%20reporting%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BLocation%20of%20Incident%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E123%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BJohn%20Smith%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20VMP%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B4W%3C%2FP%3E%3CP%3E123%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BMary%20Burns%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Nurse%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B4W%3C%2FP%3E%3CP%3E123%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BJack%20John%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BPhysio%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%204W%3C%2FP%3E%3CP%3E789%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BJoy%20Charm%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Nurse%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B3F%3C%2FP%3E%3CP%3E789%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BKevin%20Bacon%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BAdministator%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%203F%3C%2FP%3E%3CP%3E456%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BWilliam%20Hunt%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20VMP%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B2A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20only%20have%20one%20row%20per%20incident.%26nbsp%3B%20The%20real%20dataset%20has%20many%20more%20columns%2C%20most%20of%20which%20have%20unique%20results%20in%20each%20column%20but%203%20questions%20give%20the%20user%20the%20option%20of%20multiple%20answers%20for%20the%20same%20question%20(Name%20of%20reporter%2C%20Role%20of%20reporter)%20which%20forces%20the%20results%20over%20multiple%20rows.%26nbsp%3B%20The%20problem%20is%20there%20could%20be%20up%20to%2010%20people%20in%20the%20name%2Frole%20section%20so%20no%20two%20incidents%20are%20guaranteed%20to%20result%20in%20the%20same%20number%20of%20rows.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20I%20force%20the%20rows%20that%20allow%20multiple%20responses%20onto%20a%20single%20row%20with%20the%20responses%20as%20separate%20columns%20rather%20than%20rows%20(or%20even%20one%20column%20with%20Name1%20%2BRole1%3B%20Name2%20%2B%20Role2%3B%20etc.)%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-538677%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-539961%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-539961%22%20slang%3D%22en-US%22%3EIf%20you%20don't%20really%20need%20the%20information%20from%20those%20three%20columns%20which%20are%20causing%20the%20repeat%20of%20rows%2C%20you%20could%20just%20use%20Data%2C%20Remove%20Duplicates%20and%20exclude%20those%20three%20columns.%20Note%20that%20Excel%20will%20keep%20the%20FIRST%20row%20of%20every%20duplicate%2C%20so%20you%20may%20want%20to%20consider%20sorting%20the%20data%20prior%20to%20removing%20duplicates%20so%20the%20rows%20you%20want%20to%20keep%20are%20at%20the%20top.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-540262%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-540262%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F336086%22%20target%3D%22_blank%22%3E%40Jilly%3C%2FA%3E%26nbsp%3B%2C%20that%20could%20be%20combined%20to%20this%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20533px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F112437i6A29A3E7ED0B3A48%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Eby%20Power%20Query.%20Steps%20are%20in%20attached%20file.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-543999%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-543999%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%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20Sergei.%26nbsp%3B%20You%20are%20a%20genius!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-544000%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-544000%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20the%20reply.%26nbsp%3B%20Unfortunately%20I%20do%20need%20to%20keep%20all%20the%20info.%26nbsp%3B%20Sergei%20has%20given%20me%20the%20answer%20I%20need.%26nbsp%3B%20Hopefully%20helps%20others.%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-551036%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-551036%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F336086%22%20target%3D%22_blank%22%3E%40Jilly%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20again%20Serge.%26nbsp%3B%20I%20managed%20to%20follow%20the%20query%20you%20set%20up%20when%20I%20applied%20it%20to%20the%20full%20dataset.%26nbsp%3B%20I%20have%20one%20problem.%26nbsp%3B%20When%20I%20get%20to%20the%20stage%20where%20I%20split%20the%20concatenated%20column%20where%20a%20semicolon%20exists%2C%20it%20only%20splits%20the%20cell%20into%202%20columns%20even%20if%20there%20are%20more%20than%202%20semicolons%20(more%20than%202%20combinations%20of%20person%20and%20role).%26nbsp%3B%20Could%20you%20please%20tell%20me%20where%20the%20code%20is%20forcing%20the%20output%20to%202%20columns%20only%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-551043%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-551043%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%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHi%20again%20Serge.%26nbsp%3B%20I%20managed%20to%20follow%20the%20query%20you%20set%20up%20when%20I%20applied%20it%20to%20the%20full%20dataset.%26nbsp%3B%20I%20have%20one%20problem.%26nbsp%3B%20When%20I%20get%20to%20the%20stage%20where%20I%20split%20the%20concatenated%20column%20where%20a%20semicolon%20exists%2C%20it%20only%20splits%20the%20cell%20into%202%20columns%20even%20if%20there%20are%20more%20than%202%20semicolons%20(more%20than%202%20combinations%20of%20person%20and%20role).%26nbsp%3B%20Could%20you%20please%20tell%20me%20where%20the%20code%20is%20forcing%20the%20output%20to%202%20columns%20only%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-551053%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-551053%22%20slang%3D%22en-US%22%3EIf%20you%20click%20the%20little%20cogwheel%20next%20to%20the%20split%20step%20in%20the%20PQ%20editor%20window%20you%20should%20be%20able%20to%20change%20the%20settings%20of%20that%20step.%20Look%20near%20the%20bottom%20of%20the%20settings%20window%20to%20see%20what%20is%20selected%20for%20%22Split%20at%22%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-552393%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-552393%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Jilly%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20take%20on%20your%20query%20is%20that%20you%20need%20to%20create%20a%20second%20reporting%20worksheet%20that%20combines%20the%20data%20in%20your%20first%20sheet.%26nbsp%3B%20That%20way%2C%20your%20original%20data%20is%20able%20to%20be%20added%20to%20from%20your%20original%20database%20in%20the%20form%20you%20are%20importing%20it%2C%20and%20you%20just%20switch%20over%20to%20the%20report%20worksheet%20to%20see%20the%20information%20displayed%20as%20you%20want%20it.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20add%20a%20helper%20column%20to%20the%20right%20of%20the%20data%20in%20the%20data%20sheet%20as%20column%20E%20with%20the%20following%20formula%3C%2FP%3E%3CP%3E%3DIF(A2%26lt%3B%26gt%3BA1%2CB2%2CE1%26amp%3B%22%20%2C%20%22%26amp%3BB2)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20reporting%20sheet%2C%20list%20the%20report%20numbers%20in%20column%20A%2C%20and%20in%20column%20B%20type%20the%20formula%3C%2FP%3E%3CP%3E%3DINDEX(Sheet1!%24E%241%3A%24E%24200%2CMATCH(%24A1%2B1%2CSheet1!%24A%241%3A%24A%24200%2C0)-1%2C1)%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20add%20more%20columns%20as%20you%20need%20to%20capture%20other%20data%20if%20required%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-552646%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-552646%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F336086%22%20target%3D%22_blank%22%3E%40Jilly%3C%2FA%3E%26nbsp%3B%2C%20in%20addition%20to%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%26nbsp%3B%20comment.%20I%20assumed%20reporters%20are%20in%20one%20cell%20separated%20by%20semicolons.%20If%20you'd%20like%20to%20split%20them%20on%20separate%20cells%20you%20shall%20take%20care%20about%20variable%20number%20of%20persons%20reported%20per%20incident%20(thus%20variable%20number%20of%20columns).%20One%20option%20is%20to%20define%20number%20of%20columns%20which%20is%20more%20than%20any%20possible%20maximum.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnother%20option%2C%20to%20fit%20number%20of%20columns%20into%20actual%20current%20maximum%2C%20requires%20couple%20of%20line%20of%20additional%20M%20script%20code%3A%3C%2FP%3E%0A%3CPRE%3E%20%20%20%20%2F%2F%20Last%20step%20of%20previous%20version%0A%20%20%20%20RemoveUnused%20%3D%20Table.SelectColumns(RenameBack%2C%0A%20%20%20%20%20%20%20%20%7B%22Incident%20%23%22%2C%20%22Persons%20reporting%22%2C%20%22Location%20of%20Incident%22%7D)%2C%0A%0A%20%20%20%20%2F%2F%20Number%20of%20semicolons%20in%20each%20record%20for%20Persons%20Reporting%0A%20%20%20%20SepsPerRecord%20%3D%20Table.AddColumn(RemoveUnused%2C%20%22SepsInString%22%2C%0A%20%20%20%20%20%20%20%20each%20%20%20%20Text.Length(%5BPersons%20reporting%5D)-%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Text.Length(Text.Replace(%5BPersons%20reporting%5D%2C%22%3B%22%2C%22%22))%20)%2C%0A%0A%20%20%20%20%2F%2F%20Max%20fpr%20all%20records%20number%20of%20semicolns%20%0A%20%20%20%20MaxSeps%20%3D%20List.Max(SepsPerRecord%5BSepsInString%5D)%2C%0A%0A%20%20%20%20%2F%2F%20Generate%20list%20of%20sequental%20column%20names%0A%20%20%20%20%2F%2F%20from%20%22Reporter%201%22%20to%20%22Reporter%20%26lt%3BMaxSeps%2B1%26gt%3B%22%0A%20%20%20%20ReportersColumnNames%20%3D%20List.Transform(%7B1..MaxSeps%2B1%7D%2C%0A%20%20%20%20%20%20%20%20each%20%22Person%20%22%20%26amp%3B%20Number.ToText(_))%2C%0A%0A%20%20%20%20%2F%2F%20Make%20standard%20split%20and%20substiture%20automatically%0A%20%20%20%20%2F%2F%20generates%20list%20with%20column%20names%20on%20ReportersColumnNames%0A%20%20%20%20%2F%2F%20Another%20option%20is%20to%20set%20number%20of%20columns%20which%20is%20%0A%20%20%20%20%2F%2F%20definetelly%20more%20than%20possible%20maximum.%0A%20%20%20%20SplitReporters%20%3D%20Table.SplitColumn(RemoveUnused%2C%0A%20%20%20%20%20%20%20%20%22Persons%20reporting%22%2C%0A%20%20%20%20%20%20%20%20Splitter.SplitTextByDelimiter(%22%3B%22%2C%20QuoteStyle.Csv)%2C%0A%20%20%20%20%20%20%20%20ReportersColumnNames)%0A%0Ain%0A%20%20%20%20SplitReporters%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-555848%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-555848%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F22322%22%20target%3D%22_blank%22%3E%40Jan%20Karel%20Pieterse%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20Jan.%26nbsp%3B%20That%20was%20a%20quick%20fix%20to%20the%20problem.%26nbsp%3B%20I%20selected%20the%20advance%20option%20and%20it%20allowed%20me%20to%20say%20how%20many%20columns%20and%20the%20default%20was%202%20so%20I%20changed%20it%20to%20a%20number%20more%20than%20what%20I%20expect%20I%20will%20need%20and%20it%20has%20worked%20perfectly.%26nbsp%3B%20Thank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-560830%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-560830%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F336086%22%20target%3D%22_blank%22%3E%40Jilly%3C%2FA%3E%26nbsp%3B%2C%20nonetheless%2C%20when%20you%20have%20more%20time%20better%20to%20shift%20on%20dynamic%20number%20of%20columns%20generation.%20That's%20only%203%20lines%20of%20code.%20If%2C%20for%20example%2C%20now%20you%20have%20max%204%20persons%20who%20may%20report%20incidents%2C%20in%20a%20while%20your%20business%20will%20grow%20and%20you%20add%20couple%20of%20more%20persons%20in%20staff%26nbsp%3B%20-%20and%20have%20to%20rebuild%20the%20query.%20Or%20at%20least%20define%20max%20number%20as%20parameter%20-%20it%20will%20be%20easier%20in%20maintenance.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-805439%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-805439%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%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20hoping%20to%20achieve%20a%20similar%20outcome%2C%20however%20I%20was%20unable%20to%20edit%20your%20code%20properly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20get%20this%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20681px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127019iF1BABC4BF722A96A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22flow1.JPG%22%20title%3D%22flow1.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20become%20like%20this%3A%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%20style%3D%22width%3A%20646px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127020i206DAEC20D2C8AE1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22flow2.JPG%22%20title%3D%22flow2.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20this%20Code%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-javascript%22%3E%3CCODE%3Elet%0A%20%20%20%20Source%20%3D%20Excel.CurrentWorkbook()%7B%5BName%3D%22Table1%22%5D%7D%5BContent%5D%2C%0A%20%20%20%20GroupByEmail%20%3D%20Table.Group(%7B%22Email%22%7D%2C%20%7B%7B%22What%20Section%22%2C%20each%20_%2C%20type%20table%20%5BEmail%3Dtext%2C%20What%20Section%3Dtext%5D%7D%7D)%2C%0A%20%20%20%20ListWithInfo%20%3D%20Table.AddColumn(GroupByEmail%2C%20%22What%20Section%22%2C%20each%20%5BWhat%20Section%5D%5BWhat%20Section%5D)%2C%0A%20%20%20%20ExtractFromList%20%3D%20Table.TransformColumns(ListWithWhatSection%2C%20%7B%22What%20Section%22%2C%20each%20Text.Combine(List.Transform(_%2C%20Text.From)%2C%20%22%3B%20%22)%2C%20type%20text%7D)%2C%0A%20%20%20%20SplitEmail%20%3D%20Table.SplitColumn(ExtractFromList%2C%20%22Email%22%2C%20Splitter.SplitTextByDelimiter(%22%3B%22%2C%20QuoteStyle.Csv)%2C%20%7B%22Email.1%22%2C%20%22Email.2%22%7D)%2C%0A%20%20%20%20ToNumber%20%3D%20Table.TransformColumnTypes(SplitEmail%2C%7B%7B%22Email.1%22%2C%20Int64.Type%7D%2C%20%7B%22Email.2%22%2C%20type%20text%7D%7D)%2C%0A%20%20%20%20RemoveUnused%20%3D%20Table.SelectColumns(%22ID%22%2C%20%22Did%20They%20Finish%20Section%3F%22)%0Ain%0A%20%20%20%20RemoveUnused%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20I%20must%20have%20broken%20something%20along%20the%20way%20because%20I%20get%20this%20error%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EExpression.Error%3A%20We%20cannot%20convert%20the%20value%20%22ID%22%20to%20type%20Table.%20Details%3A%20Value%3DID%20Type%3DType%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-805710%22%20slang%3D%22en-US%22%3ERe%3A%20Combine%20data%20from%20multiple%20rows%20into%20a%20single%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-805710%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F392253%22%20target%3D%22_blank%22%3E%40wildjosher%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'd%20suggest%20bit%20different%20approach%20for%20such%20transformation%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20839px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127046i072BD0FFA91688AB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20query%20first%20pivot%20the%20table%20on%20column%20What%20Section%20with%20values%20Did%20They..%3C%2FP%3E%0A%3CP%3ERemove%20ID%20if%20you%20don't%20need%20it%20and%20Group%20by%20email.%3C%2FP%3E%0A%3CP%3EResulting%20tables%20for%20each%20record%20FillDown%2C%20FillUp%20Remove%20Duplicates%20to%20have%20only%20one%20record%20for%20each%20email.%3C%2FP%3E%0A%3CP%3EKeep%20only%20this%20resulting%20column%20and%20expand%20it.%3C%2FP%3E%0A%3CP%3EScript%20is%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Elet%0A%20%20%20%20Source%20%3D%20Excel.CurrentWorkbook()%7B%5BName%3D%22Table1%22%5D%7D%5BContent%5D%2C%0A%20%20%20%20PivotSections%20%3D%20Table.Pivot(%0A%20%20%20%20%20%20%20%20Source%2C%0A%20%20%20%20%20%20%20%20List.Distinct(Source%5B%23%22What%20Section%22%5D)%2C%0A%20%20%20%20%20%20%20%20%22What%20Section%22%2C%20%22Did%20They%20Finish%20Section%3F%22%0A%20%20%20%20)%2C%0A%20%20%20%20RemoveID%20%3D%20Table.RemoveColumns(%0A%20%20%20%20%20%20%20%20PivotSections%2C%7B%22ID%22%7D%0A%20%20%20%20)%2C%0A%20%20%20%20GroupEmails%20%3D%20Table.Group(%0A%20%20%20%20%20%20%20%20RemoveID%2C%20%7B%22Email%22%7D%2C%0A%20%20%20%20%20%20%20%20%7B%7B%22Count%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20each%20_%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20type%20table%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Email%3Dtext%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Admin%20Section%3Dtext%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Internal%20Section%3Dtext%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20External%20Section%3Dtext%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20All%20Sections%3Dtext%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%7D%7D%0A%20%20%20%20)%2C%0A%20%20%20%20FillDown%20%3D%20Table.AddColumn(%0A%20%20%20%20%20%20%20%20GroupEmails%2C%0A%20%20%20%20%20%20%20%20%22Custom%22%2C%0A%20%20%20%20%20%20%20%20each%20Table.FillDown(%5BCount%5D%2CTable.ColumnNames(%5BCount%5D))%0A%20%20%20%20)%2C%0A%20%20%20%20FillUp%20%3D%20Table.AddColumn(%0A%20%20%20%20%20%20%20%20FillDown%2C%0A%20%20%20%20%20%20%20%20%22Custom.1%22%2C%0A%20%20%20%20%20%20%20%20each%20Table.FillUp(%5BCustom%5D%2CTable.ColumnNames(%5BCustom%5D))%0A%20%20%20%20)%2C%0A%20%20%20%20KeepDistinct%20%3D%20Table.AddColumn(%0A%20%20%20%20%20%20%20%20FillUp%2C%0A%20%20%20%20%20%20%20%20%22Custom.2%22%2C%0A%20%20%20%20%20%20%20%20each%20Table.Distinct(%5BCustom.1%5D%2C%7B%22Email%22%7D)%0A%20%20%20%20)%2C%0A%20%20%20%20OnlyFinalTables%20%3D%20Table.SelectColumns(%0A%20%20%20%20%20%20%20%20KeepDistinct%2C%0A%20%20%20%20%20%20%20%20%7B%22Custom.2%22%7D%0A%20%20%20%20)%2C%0A%20%20%20%20ExpandThem%20%3D%20Table.ExpandTableColumn(%0A%20%20%20%20%20%20%20%20OnlyFinalTables%2C%0A%20%20%20%20%20%20%20%20%22Custom.2%22%2C%0A%20%20%20%20%20%20%20%20%7B%22Email%22%2C%20%22Admin%20Section%22%2C%20%22Internal%20Section%22%2C%20%22External%20Section%22%2C%20%22All%20Sections%22%7D%2C%0A%20%20%20%20%20%20%20%20%7B%22Email%22%2C%20%22Admin%20Section%22%2C%20%22Internal%20Section%22%2C%20%22External%20Section%22%2C%20%22All%20Sections%22%7D%0A%20%20%20%20)%0Ain%0A%20%20%20%20ExpandThem%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eand%20in%20attached%20file%3C%2FP%3E%3C%2FLINGO-BODY%3E
Jilly
Occasional Contributor

Hi Excel community

 

I have a dataset that looks something like this

 

Incident #             Name of person reporting           Role of person reporting             Location of Incident  

123                       John Smith                                    VMP                                             4W

123                       Mary Burns                                    Nurse                                           4W

123                       Jack John                                       Physio                                          4W

789                       Joy Charm                                      Nurse                                           3F

789                       Kevin Bacon                                   Administator                                3F

456                       William Hunt                                  VMP                                             2A

 

I would like to only have one row per incident.  The real dataset has many more columns, most of which have unique results in each column but 3 questions give the user the option of multiple answers for the same question (Name of reporter, Role of reporter) which forces the results over multiple rows.  The problem is there could be up to 10 people in the name/role section so no two incidents are guaranteed to result in the same number of rows.

 

How can I force the rows that allow multiple responses onto a single row with the responses as separate columns rather than rows (or even one column with Name1 +Role1; Name2 + Role2; etc.)?

13 Replies
If you don't really need the information from those three columns which are causing the repeat of rows, you could just use Data, Remove Duplicates and exclude those three columns. Note that Excel will keep the FIRST row of every duplicate, so you may want to consider sorting the data prior to removing duplicates so the rows you want to keep are at the top.
Solution

@Jilly , that could be combined to this

image.png

by Power Query. Steps are in attached file.

@Sergei Baklan 

 

Thanks Sergei.  You are a genius!

@Jan Karel Pieterse 

 

Thanks for the reply.  Unfortunately I do need to keep all the info.  Sergei has given me the answer I need.  Hopefully helps others.

Cheers

@Jilly 

 

Hi again Serge.  I managed to follow the query you set up when I applied it to the full dataset.  I have one problem.  When I get to the stage where I split the concatenated column where a semicolon exists, it only splits the cell into 2 columns even if there are more than 2 semicolons (more than 2 combinations of person and role).  Could you please tell me where the code is forcing the output to 2 columns only?

@Sergei Baklan 

 

Hi again Serge.  I managed to follow the query you set up when I applied it to the full dataset.  I have one problem.  When I get to the stage where I split the concatenated column where a semicolon exists, it only splits the cell into 2 columns even if there are more than 2 semicolons (more than 2 combinations of person and role).  Could you please tell me where the code is forcing the output to 2 columns only?

If you click the little cogwheel next to the split step in the PQ editor window you should be able to change the settings of that step. Look near the bottom of the settings window to see what is selected for "Split at"

Hi Jilly

 

My take on your query is that you need to create a second reporting worksheet that combines the data in your first sheet.  That way, your original data is able to be added to from your original database in the form you are importing it, and you just switch over to the report worksheet to see the information displayed as you want it. 

 

I would add a helper column to the right of the data in the data sheet as column E with the following formula

=IF(A2<>A1,B2,E1&" , "&B2)

 

In the reporting sheet, list the report numbers in column A, and in column B type the formula

=INDEX(Sheet1!$E$1:$E$200,MATCH($A1+1,Sheet1!$A$1:$A$200,0)-1,1) 

 

You can add more columns as you need to capture other data if required

@Jilly , in addition to @Jan Karel Pieterse  comment. I assumed reporters are in one cell separated by semicolons. If you'd like to split them on separate cells you shall take care about variable number of persons reported per incident (thus variable number of columns). One option is to define number of columns which is more than any possible maximum.

 

Another option, to fit number of columns into actual current maximum, requires couple of line of additional M script code:

    // Last step of previous version
    RemoveUnused = Table.SelectColumns(RenameBack,
        {"Incident #", "Persons reporting", "Location of Incident"}),

    // Number of semicolons in each record for Persons Reporting
    SepsPerRecord = Table.AddColumn(RemoveUnused, "SepsInString",
        each    Text.Length([Persons reporting])-
                Text.Length(Text.Replace([Persons reporting],";","")) ),

    // Max fpr all records number of semicolns 
    MaxSeps = List.Max(SepsPerRecord[SepsInString]),

    // Generate list of sequental column names
    // from "Reporter 1" to "Reporter <MaxSeps+1>"
    ReportersColumnNames = List.Transform({1..MaxSeps+1},
        each "Person " & Number.ToText(_)),

    // Make standard split and substiture automatically
    // generates list with column names on ReportersColumnNames
    // Another option is to set number of columns which is 
    // definetelly more than possible maximum.
    SplitReporters = Table.SplitColumn(RemoveUnused,
        "Persons reporting",
        Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv),
        ReportersColumnNames)

in
    SplitReporters

@Jan Karel Pieterse

 

Thanks Jan.  That was a quick fix to the problem.  I selected the advance option and it allowed me to say how many columns and the default was 2 so I changed it to a number more than what I expect I will need and it has worked perfectly.  Thank you

@Jilly , nonetheless, when you have more time better to shift on dynamic number of columns generation. That's only 3 lines of code. If, for example, now you have max 4 persons who may report incidents, in a while your business will grow and you add couple of more persons in staff  - and have to rebuild the query. Or at least define max number as parameter - it will be easier in maintenance.

@Sergei Baklan 

 

I am hoping to achieve a similar outcome, however I was unable to edit your code properly.

 

I am trying to get this:

flow1.JPG

 

To become like this: 

 

flow2.JPG

 

Using this Code:

 

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    GroupByEmail = Table.Group({"Email"}, {{"What Section", each _, type table [Email=text, What Section=text]}}),
    ListWithInfo = Table.AddColumn(GroupByEmail, "What Section", each [What Section][What Section]),
    ExtractFromList = Table.TransformColumns(ListWithWhatSection, {"What Section", each Text.Combine(List.Transform(_, Text.From), "; "), type text}),
    SplitEmail = Table.SplitColumn(ExtractFromList, "Email", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Email.1", "Email.2"}),
    ToNumber = Table.TransformColumnTypes(SplitEmail,{{"Email.1", Int64.Type}, {"Email.2", type text}}),
    RemoveUnused = Table.SelectColumns("ID", "Did They Finish Section?")
in
    RemoveUnused

 

 

But I must have broken something along the way because I get this error: 

 

Expression.Error: We cannot convert the value "ID" to type Table. Details: Value=ID Type=Type

 

@wildjosher 

I'd suggest bit different approach for such transformation

image.png

In query first pivot the table on column What Section with values Did They..

Remove ID if you don't need it and Group by email.

Resulting tables for each record FillDown, FillUp Remove Duplicates to have only one record for each email.

Keep only this resulting column and expand it.

Script is

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    PivotSections = Table.Pivot(
        Source,
        List.Distinct(Source[#"What Section"]),
        "What Section", "Did They Finish Section?"
    ),
    RemoveID = Table.RemoveColumns(
        PivotSections,{"ID"}
    ),
    GroupEmails = Table.Group(
        RemoveID, {"Email"},
        {{"Count",
            each _,
            type table
                [
                    Email=text,
                    Admin Section=text,
                    Internal Section=text,
                    External Section=text,
                    All Sections=text
                ]
        }}
    ),
    FillDown = Table.AddColumn(
        GroupEmails,
        "Custom",
        each Table.FillDown([Count],Table.ColumnNames([Count]))
    ),
    FillUp = Table.AddColumn(
        FillDown,
        "Custom.1",
        each Table.FillUp([Custom],Table.ColumnNames([Custom]))
    ),
    KeepDistinct = Table.AddColumn(
        FillUp,
        "Custom.2",
        each Table.Distinct([Custom.1],{"Email"})
    ),
    OnlyFinalTables = Table.SelectColumns(
        KeepDistinct,
        {"Custom.2"}
    ),
    ExpandThem = Table.ExpandTableColumn(
        OnlyFinalTables,
        "Custom.2",
        {"Email", "Admin Section", "Internal Section", "External Section", "All Sections"},
        {"Email", "Admin Section", "Internal Section", "External Section", "All Sections"}
    )
in
    ExpandThem

and in attached file

Related Conversations
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
2 Replies
Early preview of Microsoft Edge group policies
Sean Lyndersay in Discussions on
65 Replies
*Updated 9/3* Syncing in Microsoft Edge Preview Channels
Elliot Kirk in Articles on
203 Replies