SOLVED

Merging Rows in Power Query

%3CLINGO-SUB%20id%3D%22lingo-sub-2579927%22%20slang%3D%22en-US%22%3EMerging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2579927%22%20slang%3D%22en-US%22%3E%3CDIV%3EHi%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3ENeed%20to%20learn%20how%20to%20merge%20a%20row%20in%20data%20table%20when%20a%20record%20is%20broken%20into%20two%20rows%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EAlso%20the%20record%20is%20in%20the%20incorrect%20column.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EThere%20are%20a%20number%20of%20more%20columns%20so%20the%20transpose%20option%20is%20not%20feasible%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EI%20have%20attached%20the%20excel%20file%20for%20the%20problem.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EKindly%20look%20at%20it%20and%20suggest%20a%20solution.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3ERegards%2C%3C%2FDIV%3E%3CDIV%3ESumair%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2579927%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2580621%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2580621%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1111080%22%20target%3D%22_blank%22%3E%40SumairChughtai%3C%2FA%3E%26nbsp%3BWould%20be%20helpful%20if%20you%20could%20explain%20how%20you%20would%20wan%20the%20end%20result%20to%20look%20like.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2581968%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2581968%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1111080%22%20target%3D%22_blank%22%3E%40SumairChughtai%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20you%20say%3A%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CSTRONG%3ENeed%20to%20learn%20how%20to%20merge%20a%20row%20in%20data%20table%20when%20a%20record%20is%20broken%20into%20two%20rows%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3EI%20don't%20see%20that%20in%20your%20sample%20file%3C%2FP%3E%3CP%3E(%3CFONT%20color%3D%22%23339966%22%3E%3CSTRONG%3Elooking%20at%20Transaction%20number%20and%20Reference%20fields%2Fcolumns%3C%2FSTRONG%3E%3C%2FFONT%3E)%2C%3C%2FP%3E%3CP%3Eso%20in%20what%20context%20does%20the%20above%20statement%20refer%20to%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3Bcheers%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582276%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582276%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%3EI%20would%20like%20to%20merge%20them%20as%20in%20the%20attached%20excel%20file.%3C%2FP%3E%3CP%3EThe%20red%20font%20indicates%20what%20the%20data%20is%20in%20its%20original%20form.%3C%2FP%3E%3CP%3EThe%20yellow%20highlighted%20is%20how%20I%20want%20the%20data%20to%20end%20up%20as%20one%20complete%20record.%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20interest%20in%20the%20problem.%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ESumair%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582279%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582279%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1047584%22%20target%3D%22_blank%22%3E%40Yea_So%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20merge%20them%20as%20in%20the%20attached%20excel%20file.%3C%2FP%3E%3CP%3EThe%20red%20font%20indicates%20what%20the%20data%20is%20in%20its%20original%20form.%3C%2FP%3E%3CP%3EThe%20yellow%20highlighted%20is%20how%20I%20want%20the%20data%20to%20end%20up%20as%20one%20complete%20record.%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20interest%20in%20the%20problem.%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ESumair%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582282%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582282%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1111080%22%20target%3D%22_blank%22%3E%40SumairChughtai%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20you're%20basically%20saying%20the%20report%20looks%20like%20this%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yea_So_0-1627116766269.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F298143i0D1A088BEBCCA8DC%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yea_So_0-1627116766269.png%22%20alt%3D%22Yea_So_0-1627116766269.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eam%20I%20understanding%20it%20correctly%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582284%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582284%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1111080%22%20target%3D%22_blank%22%3E%40SumairChughtai%3C%2FA%3E%26nbsp%3BPerhaps%20like%20in%20the%20attached%20file.%20I%20assumed%20that%20the%20raw%20looks%20like%20in%20the%20blue%20table.%20The%20Power%20Query%20output%20is%20in%20the%20green%20table%2C%20using%20only%20standard%20UI%20commands.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582290%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582290%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%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20like%20to%20work%20on%20a%20solution%20based%20on%20a%20guess%20premise%2C%20its%20a%20time%20waster%2C%20I'd%20rather%20be%20watching%20movies%20on%20netflix%20if%20the%20challenge%20is%20based%20on%20a%20guess.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582291%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582291%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%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eit%20kind%20of%20cracks%20me%20up%20this%20other%20user%20asking%20for%20help%20on%20a%20different%20thread%2C%20does%20not%20want%20to%20create%20at%20least%20a%2020%20to%2040%20rows%20of%20sample%20data%2C%20then%20the%20truth%20comes%20out%20...%20turns%20out%20he's%20got%207%2C000%20rows%20of%20data%20to%20organize.%20lol%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582294%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582294%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1111080%22%20target%3D%22_blank%22%3E%40SumairChughtai%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20kind%20of%20issue%20that%20definitively%20requires%20%26gt%3B%201%20example...%20Put%20together%20something%20(attached)%20with%20what%20you%20provided%20%2B%20added%20a%20couple%20of%20extra%20broken%20records%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3ENB%3C%2FSTRONG%3E%3A%20When%20a%20%5BTransaction%20Number%5D%20is%20broken%20as%202%20records%20(what%20you%20gave%20us%20with%3A%20%3CEM%3Ewhen%20a%20record%20is%20broken%20into%20two%20rows%3C%2FEM%3E)%3CBR%20%2F%3E-%20The%202%20records%20%3CU%3Emust%20be%20consecutive%3C%2FU%3E%20in%20the%20Source%20Table%2Ffile%20(otherwise%20I%20don't%20see%20how%20you're%20going%20to%20resolve%20this...)%3CBR%20%2F%3E-%20The%202nd%20partial%20record%20is%20%22added%22%20to%20the%201st%20available%20location%20in%20the%20previous%20record%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582598%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582598%22%20slang%3D%22en-US%22%3EHello%20Riny%2C%3CBR%20%2F%3E%3CBR%20%2F%3EYour%20second%20table%20in%20the%20attached%20excel%20file%20(the%20one%20in%20green)%20is%20how%20I%20would%20like%20my%20format%20to%20be%20in%20Power%20Query.%20Kindly%20enlighten%20me%20as%20to%20how%20you%20came%20up%20with%20this%20solution.%3CBR%20%2F%3EThank%20you!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582599%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582599%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%3BThat%20is%20exactly%20how%20I%20like%20the%20data%20to%20be.%20Kindly%20share%20how%20you%20were%20able%20to%20get%20to%20this%20form%20in%20Power%20Query.%3C%2FP%3E%3CP%3EThank%20You!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582601%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582601%22%20slang%3D%22en-US%22%3E%22The%202%20records%20must%20be%20consecutive%20in%20the%20Source%20Table%2Ffile%20(otherwise%20I%20don't%20see%20how%20you're%20going%20to%20resolve%20this...)%22%3CBR%20%2F%3E%3CBR%20%2F%3EYes.%20These%20are%20two%20consecutive%20records%20in%20the%20master%20data%20file%20that%20I'm%20working%20on.%3CBR%20%2F%3E%3CBR%20%2F%3E%22The%202nd%20partial%20record%20is%20%22added%22%20to%20the%201st%20available%20location%20in%20the%20previous%20record%22%3CBR%20%2F%3E%3CBR%20%2F%3EKindly%20educate%20me%20on%20how%20to%20achieve%20that%20in%20Power%20Query%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582602%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582602%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1047584%22%20target%3D%22_blank%22%3E%40Yea_So%3C%2FA%3E%26nbsp%3BThank%20you%20for%20your%20suggestion.%20But%20this%20is%20not%20how%20I%20would%20like%20the%20data%20to%20be.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20solution%20that%20Riny%20and%20L.z%20have%20come%20up%20with%20is%20what%20I'm%20after.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPerhaps%20I%20wasn't%20able%20to%20define%20the%20problem%20correctly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20input.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2582960%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2582960%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1111080%22%20target%3D%22_blank%22%3E%40SumairChughtai%3C%2FA%3E%26nbsp%3B%3C%2FP%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%3Bused%20the%20following%20table%20structure%20as%20input%2FSource%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22RynyInputTable.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F298167i1E3AD8DFC52C3C39%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22RynyInputTable.png%22%20alt%3D%22RynyInputTable.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20I%20used%20a%20different%20one%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22LzInputTable.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F298168i6DFC7D1524E4B45E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22LzInputTable.png%22%20alt%3D%22LzInputTable.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EAt%20the%20end%20we%20get%20what%20you%20expect%20BUT%20the%20approaches%20(while%20similar)%20are%20necessarily%20different%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20could%20you%20please%20clarify%202%20things%3A%3C%2FP%3E%3CP%3E-%20What's%20the%20exact%20structure%20of%20your%20input%2FSource%20table%3F%20Riny's%20one%3F%20Mine%20or%20something%20else%3F%3CBR%20%2F%3ECould%20you%20post%20a%20picture%20(a%20few%20rows%20only)%20of%20you%20actual%20input%2FSource%20table%20to%20clarify%20things%3C%2FP%3E%3CP%3E-%20What%20do%20you%20exactly%20have%20in%20mind%20when%20you%20say%20%22%3CEM%3EKindly%20educate%20me%20on%20how%20to%20achieve%20that%20in%20Power%20Query%3C%2FEM%3E%22%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%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-2583042%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2583042%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%3EIMHO%2C%20key%20question%20here%20are%20there%20any%20rules%20and%20logic%20in%20filling%20source%20data.%20If%20not%2C%20screenshot%20could%20illustrate%20current%20state%2C%20but%20next%20day%20another%20person%20adds%20data%20in%20different%20way%20-%20any%20solution%20stops%20working.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2583126%22%20slang%3D%22en-US%22%3ERe%3A%20Merging%20Rows%20in%20Power%20Query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2583126%22%20slang%3D%22en-US%22%3E100%25%20agree%20Sergei%20hence%20why%20I%20added%20a%20couple%20of%20dummy%20records%20to%20my%20sample%20to%20check%20the%20logic%20I%20implemented%20could%20handle%20a%20few%20other%20scenarios%20than%20the%20only%20one%20the%20OP%20exposed.%20Realistically%20speaking%20I%20don't%20think%20we%20can%20do%20more%20-%20at%20that%20stage%20-%20than%20providing%20some%20possible%20approaches%20as%20it%20seems%20already%20difficult%20enough%20to%20get%20an%20accurate%20baseline%20(structure%20of%20the%20Source%20table)%3C%2FLINGO-BODY%3E
Occasional Contributor
Hi,
 
Need to learn how to merge a row in data table when a record is broken into two rows
 
Also the record is in the incorrect column.
 
There are a number of more columns so the transpose option is not feasible
 
I have attached the excel file for the problem.
 
Kindly look at it and suggest a solution.
 
Regards,
Sumair
28 Replies

@SumairChughtai Would be helpful if you could explain how you would wan the end result to look like.

@SumairChughtai

 

When you say:

Need to learn how to merge a row in data table when a record is broken into two rows

I don't see that in your sample file

(looking at Transaction number and Reference fields/columns),

so in what context does the above statement refer to?

 

 cheers

@Riny_van_Eekelen 

I would like to merge them as in the attached excel file.

The red font indicates what the data is in its original form.

The yellow highlighted is how I want the data to end up as one complete record.

Thank you for your interest in the problem.

Regards,

Sumair

 

@Yea_So 

I would like to merge them as in the attached excel file.

The red font indicates what the data is in its original form.

The yellow highlighted is how I want the data to end up as one complete record.

Thank you for your interest in the problem.

Regards,

Sumair

 

@SumairChughtai 

 

So you're basically saying the report looks like this:

Yea_So_0-1627116766269.png

 

am I understanding it correctly?

best response confirmed by allyreckerman (Microsoft)
Solution

@SumairChughtai Perhaps like in the attached file. I assumed that the raw looks like in the blue table. The Power Query output is in the green table, using only standard UI commands.

@Riny_van_Eekelen 

 

I don't like to work on a solution based on a guess premise, its a time waster, I'd rather be watching movies on netflix if the challenge is based on a guess.

@Riny_van_Eekelen 

 

it kind of cracks me up this other user asking for help on a different thread, does not want to create at least a 20 to 40 rows of sample data, then the truth comes out ... turns out he's got 7,000 rows of data to organize. lol

@SumairChughtai 

The kind of issue that definitively requires > 1 example... Put together something (attached) with what you provided + added a couple of extra broken records

 

NB: When a [Transaction Number] is broken as 2 records (what you gave us with: when a record is broken into two rows)
- The 2 records must be consecutive in the Source Table/file (otherwise I don't see how you're going to resolve this...)
- The 2nd partial record is "added" to the 1st available location in the previous record

Hello Riny,

Your second table in the attached excel file (the one in green) is how I would like my format to be in Power Query. Kindly enlighten me as to how you came up with this solution.
Thank you!

@L z. That is exactly how I like the data to be. Kindly share how you were able to get to this form in Power Query.

Thank You!

"The 2 records must be consecutive in the Source Table/file (otherwise I don't see how you're going to resolve this...)"

Yes. These are two consecutive records in the master data file that I'm working on.

"The 2nd partial record is "added" to the 1st available location in the previous record"

Kindly educate me on how to achieve that in Power Query

@Yea_So Thank you for your suggestion. But this is not how I would like the data to be.

 

The solution that Riny and L.z have come up with is what I'm after.

 

Perhaps I wasn't able to define the problem correctly.

 

Thank you for your input.

 

@SumairChughtai 

@Riny_van_Eekelen used the following table structure as input/Source:

RynyInputTable.png

 

and I used a different one:

LzInputTable.png

At the end we get what you expect BUT the approaches (while similar) are necessarily different

 

So could you please clarify 2 things:

- What's the exact structure of your input/Source table? Riny's one? Mine or something else?
Could you post a picture (a few rows only) of you actual input/Source table to clarify things

- What do you exactly have in mind when you say "Kindly educate me on how to achieve that in Power Query"?

 

Thanks

 

 

@L z. 

IMHO, key question here are there any rules and logic in filling source data. If not, screenshot could illustrate current state, but next day another person adds data in different way - any solution stops working.

100% agree Sergei hence why I added a couple of dummy records to my sample to check the logic I implemented could handle a few other scenarios than the only one the OP exposed. Realistically speaking I don't think we can do more - at that stage - than providing some possible approaches as it seems already difficult enough to get an accurate baseline (structure of the Source table)

@L z. @Sergei Baklan @Riny_van_Eekelen 

The data is generated by my Company's source system. There's no manual or anyother kind of intervention.

 

Obviously, I can't share more than what I have. However, it serves the purpose of defining the problem.

 

The output from the source system sometimes breaks records into two rows (as in the excel file attached), with values in incorrect columns as well.

 

Since there is a significant amount of data, I require a solution via Power Query to merge such rows and create a single record, for each transaction, with the values in the correct columns.

 

@L z. Your solution is what I'm looking for, it created a single record with all values in the correct columns.

 

@L z. @Riny_van_Eekelen Riny's solution (in the green table) merged the two rows together into a single record, with all values in the correct columns.

 

Requesting how to achieve your results in Power Query.

 

Regards,

Sumair

@L z. 

SumairChughtai_0-1627149127750.png

The structure you shared is the correct one. This structure defines my problem

 

1) Row 3 is broken into Row 3 and Row 4

 

2) The highlighted bit should be in Row 3 in the same order starting after CP Long Name i.e. after PQRST

 

I want to learn how to merge these two rows together such that all the values appear in the correct columns.

 

Regards,

Sumair

@SumairChughtai 

 

I have not made any suggestions yet, I am still trying to clarify what the source data structure/geography with you so to clarify:

Yea_So_0-1627155957613.png

1. The above image is what your source data looks like "Consistently"

The expected answer from you is either a yes consistently or no it is inconsistent.

If the answer is the former and not the later, then the approach would be a

Option 1

1. loop function in PQ evaluating each row, where the Transaction number can be had for the 2nd row for all row/records in the second row, 

2. Do a  Table.SelectRows() on the main table to create 2 tables.

first Table.SelectRows() will be the table for the first row.

second TableSelectRows() will the the table for the 2nd row

3. Do a merge query using the Transaction number to match all rows for the table on the right and table on the left

4. Remove the excess columns then rename the columns for the second table.

References:

PQ For Loops: Part 3: Programming "For-Next"-Loops using List.Accumulate() in M for Power Query - data-insights.de...

Example for PQ evaluating rows Using IF, AND, OR  and TableSelectRows()

SUMIF between 2 tables using Power Query - YouTube

 

Option 2

1. Would be to put formulas on the 2nd row referencing the Transaction Number on the first row on the source table,

2. Do a PQ on the source table the source table

3. Create a reference copy of the PQ on the source table

4. Filter out the 2nd row on the PQ to the source table

5. Filter out the 1st row on the reference table of the PQ to the source table

6. Do a merge query on PQ of source table and the reference table.

 

Option 3 Data Model:

1. Would be to put formulas on the 2nd row referencing the Transaction Number on the first row on the source table,

2. Do a PQ on the source table the source table

3. Create a reference copy of the PQ on the source table

4. Filter out the 2nd row on the PQ to the source table

5. Filter out the 1st row on the reference table of the PQ to the source table

6. Add to the data model

7. Create Relationships

8. Add columns to table 2 using the DAX RELATED() FUNCTION

9. Create a Power Pivot 

 

cheers