Power Query Formula

Bonstan

New Member
Joined
Jul 15, 2021
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Can somebody kindly help me with the following problem in the Excel table below? I am a new Power Query user and am trying to combine the rows in Column B for each transaction into a single cell by creating a Custom Column. What formula should I use? i.e.


Table as is

A​
B​
C​
D​
E​
1DateCommentDebitCreditBalance
218/11/2019Cheque 001
150.89​
139.24DR
3REF ZAF-003
4INSTRUCTION 007150.8911.65
629/11/2019Cheque 002
414.93​
209.9​
12GO DIRECT DEBIT
36.45​
173.45​
13TRANSFER REF



Table as I would like it to be

A​
B​
C​
D​
E​
1DateCommentDebitCreditBalance
218/11/2019Cheque 001
150.89​
139.24DR
58/11/2019REF ZAF-003 INSTRUCTION 007150.8911.65
629/11/2019Cheque 002
414.93​
209.9​
1229/11/2019GO DIRECT DEBIT TRANSFER REF
36.45​
173.45​
13

I would appreciate some advice on this. Thank you.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    res = Table.Combine(Table.Group(Source,"Date",{"n",each let a=Table.Skip(_) in Table.FillDown(Table.FromRecords({_{0},Table.SelectRows(a,(x)=>x[Balance]<>null){0}&[Comment=Text.Combine(a[Comment]," ")]}),{"Date"})},0,(x,y)=>Byte.From(y<>null))[n])
in
    res
1627346769804.png
 
Upvote 0
For your reference:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    res = Table.Combine(Table.Group(Source,"Date",{"n",each let a=Table.Skip(_) in Table.FillDown(Table.FromRecords({_{0},Table.SelectRows(a,(x)=>x[Balance]<>null){0}&[Comment=Text.Combine(_[Comment]," ")]}),{"Date"})},0,(x,y)=>Byte.From(y<>null))[n])
in
    res

View attachment 43532
 
Upvote 0
Thankyou for your formula. This seems to be working, but not completely. I refer to the Table A in the attached image:. What I would like is for the rows in Column “Comment” to be joined according to the different background colour scheme, as per the image. Each group does not have to have three rows but as many as needed.

With the formula the result I am getting, although very helpful, is not quite what I would like. Thus, If I press Get Data and load Table B, (in the attached image), what I am getting after I apply the formula and press Load Data is what appears in Table C .

Can the formula be adjusted to what I would like? The attached image contains the comments above. Hopefully the image is clear enough.

Again, Thank you for your help.
 

Attachments

Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,977
Members
452,540
Latest member
haasro02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top