Power Query M

millhouse123

Active Member
Joined
Aug 22, 2006
Messages
335
I have the code/function below and I would like to remove the section of code that removes columns and everything below it if necessary but when I do I get an error that Token is expected.

can someone tell me how I can get rid of the remove columns portion of the code?

Code:
= (filepath,SheetName)=>
let
    Source = Excel.Workbook(File.Contents(filepath), null, true),
    #"1" = Source{[Name=SheetName]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(#"1",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}, {"Column9", type text}, {"Column10", type text}, {"Column11", type text}, {"Column12", type text}, {"Column13", type text}, {"Column14", type text}, {"Column15", type text}, {"Column16", type text}, {"Column17", type text}, {"Column18", type text}, {"Column19", type text}, {"Column20", type text}, {"Column21", type text}, {"Column22", type text}}),
    #"Removed Top Rows" = Table.Skip(#"Changed Type",4),
    Custom1 = Record.Field(#"Removed Top Rows"{0},"Column2"),
    Custom2 = #"Removed Top Rows",
    #"Removed Top Rows1" = Table.Skip(Custom2,2),
    #"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows1"),
    #"Removed Columns" = Table.RemoveColumns(#"Promoted Headers",{"GCREF Ln #", "Borrower", "Investor Portfolio", "Ownership %", "Beginning Balance", "Due Date", "Other Adj Princ", "Net Interest", "Late Charges", "Prepay Penalty", "Other Amts", "Next Pmt Date", "Ending Balance", "Column21", "Column22"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([CUSIP] <> null)),
    #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Investor Ln #", Order.Descending}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Sorted Rows",{"Date Pmt Rev'd", "CUSIP", "Investor Ln #", "Principal Collected", "Interest Collected", "Service Fee", "Remittance Amount"}),
    #"Added Custom" = Table.AddColumn(#"Reordered Columns", "Enter Date", each Custom1),
    #"Reordered Columns1" = Table.ReorderColumns(#"Added Custom",{"Enter Date", "Date Pmt Rev'd", "CUSIP", "Investor Ln #", "Principal Collected", "Interest Collected", "Service Fee", "Remittance Amount"})
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
The posted code won't work. Probably the error states that token in is expected (not just token).

The first =<space> shouldn't be there.

Typically, after keyword (or token) let you get a number of query steps, each ending with a comma, except for the last step that is preceding keyword (or token) in and after in you get the name of the last step.

The example code should be followed by:

Code:
in
    #"Reordered Columns1"
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,568
Members
448,972
Latest member
Shantanu2024

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