Transferring data from Columns to rows, not using a Pivot table

russelldt

Board Regular
Joined
Feb 27, 2021
Messages
160
Office Version
  1. 365
Platform
  1. MacOS
I am reposting this, as I have not had a workable response - probably due to me not describing the problem eloquently.

I have a excel file with 2 sheets.

Sheet 1 has "Job Number" in Column C, and empty cells for Invoice numbers, in columns M, N, O, P, Q and R

Sheet 2 has a dump from an accounting package, and the data is organized in columns. Column A has Job Number, Column B has the invoice number and Column C has the Paid flag. There are many invoices per job.


I need the invoice numbers and Paid status from Sheet 2 to go into Sheet 1against the correct job number. The first invoice number for a Job, to go in column M, the second on N, and so on. Once the invoice is flagged as paid, the invoice number must show a P after (e.g 1956, and once paid 1956P).

Any of the geniuses out there able to help?
 
If your version has Power Query (Get and Transform) then this is another way

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    tbl1 = Table.Sort(Source,{{"Invoice", Order.Ascending}}),
    tbl2 = Table.FromRecords(Table.TransformRows(tbl1, each if [Paid] then Record.TransformFields(_, {{"Invoice", (f)=> Text.From(f) & "P"}}) else _)),
    tbl3 = Table.Group(tbl2, {"Job"}, {{"All", each _[Invoice]}}),
    tbl4 = Table.Sort(tbl3,{{"Job", Order.Ascending}}),
    cols = List.Max(List.Transform(tbl4[All], each List.Count(_))),
    tbl5 = Table.TransformColumns(tbl4, {{"All", each _ & List.Repeat({null}, cols - List.Count(_))}}),
    InvoiceHeaders = List.Accumulate({1..cols}, {}, (s,c)=> s & {"Invoice." & Text.From(c)}),
    Result = Table.FromRows(List.Transform(List.Zip({tbl5[Job], tbl5[All]}), each {_{0}} & _{1}), {"Job"} & InvoiceHeaders)
in
    Result

Book2
ABCDEFGHIJK
1JobInvoicePaidJobInvoice.1Invoice.2Invoice.3Invoice.4Invoice.5
2852057749TRUE123040623P464276404975582
3123040623TRUE336218079
4671777302FALSE366738665P
5852074448FALSE671775497P77302
6123064049FALSE841655639
7852094210FALSE85201111122062P57749P7444894210
8841655639FALSE870960800P
9870960800TRUE
10852022062TRUE
11123046427FALSE
12336218079FALSE
13366738665TRUE
14123075582FALSE
15671775497TRUE
16852011111FALSE
17
Sheet1 (2)
 
Upvote 0
Solution

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,224,312
Messages
6,177,812
Members
452,806
Latest member
Workerl3ee

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