Power query question

JamesBowdidge

New Member
Joined
Nov 8, 2018
Messages
46
Hi,

I have followed the below guide on setting up a folder query and it 99% solves my issue.. However the last part I cannot work out is I only want to return the 4th row from each worksheet in each workbook..

anyone suggest a way of acheiving this? I am so close!!


thanks

J
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
without seeing whole project and M-code I can suggest
Table.Range(table as table, offset as number, optional count as nullable number) as table
 
Upvote 0
thanks, I think the below is the M-code you refer too (im new to this part of excel) - this is taken from the advanced editor window..

Where should I add the code from your reply? Also do I need to replace the words with numbers in your code? IE this part "(table as table, offset as number, optional count as nullable number)"

thanks for your help!

let
Source = Folder.Files("C:\Users\jbowdidge\OneDrive - Sopra Steria\James Bowdidge\WFM\Manifest"),
#"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name], "Estate")),
#"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each Excel.Workbook(File.Contents([Folder Path]&[Name]))),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Name", "Data"}, {"Custom.Name", "Custom.Data"}),
#"Filtered Rows1" = Table.SelectRows(#"Expanded Custom", each ([Custom.Name] = "Belfast" or [Custom.Name] = "Birmingham" or [Custom.Name] = "Birmingham Premium Lounge" or [Custom.Name] = "Cardiff" or [Custom.Name] = "Cardiff Bay" or [Custom.Name] = "Croydon" or [Custom.Name] = "Glasgow" or [Custom.Name] = "Manchester" or [Custom.Name] = "Manchester (Fountain St)" or [Custom.Name] = "Manchester Premium Lounge" or [Custom.Name] = "Mark Lane Premium Lounge")),
#"Expanded Custom.Data" = Table.ExpandTableColumn(#"Filtered Rows1", "Custom.Data", {"Column4", "Column33", "Column34", "Column35"}, {"Custom.Data.Column4", "Custom.Data.Column33", "Custom.Data.Column34", "Custom.Data.Column35"})
in
#"Expanded Custom.Data"
 
Upvote 0
Post#2 contain definition of the function, if your code generate end result and you want 4th row only, I think it can be: FourthRow = Table.Range(#"Expanded Custom.Data" ,4,1) used as last line of the code.

and yes, this is M-code but would be nice if you will use CODE tags.

Code:
let
    Source = Folder.Files("C:\Users\jbowdidge\OneDrive - Sopra Steria\James Bowdidge\WFM\Manifest"),
    #"Filtered Rows" = Table.SelectRows(Source, each Text.StartsWith([Name], "Estate")),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each Excel.Workbook(File.Contents([Folder Path]&[Name]))),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Name", "Data"}, {"Custom.Name", "Custom.Data"}),
    #"Filtered Rows1" = Table.SelectRows(#"Expanded Custom", each ([Custom.Name] = "Belfast" or [Custom.Name] = "Birmingham" or [Custom.Name] = "Birmingham Premium Lounge" or [Custom.Name] = "Cardiff" or [Custom.Name] = "Cardiff Bay" or [Custom.Name] = "Croydon" or [Custom.Name] = "Glasgow" or [Custom.Name] = "Manchester" or [Custom.Name] = "Manchester (Fountain St)" or [Custom.Name] = "Manchester Premium Lounge" or [Custom.Name] = "Mark Lane Premium Lounge")),
    #"Expanded Custom.Data" = Table.ExpandTableColumn(#"Filtered Rows1", "Custom.Data", {"Column4", "Column33", "Column34", "Column35"}, {"Custom.Data.Column4", "Custom.Data.Column33", "Custom.Data.Column34", "Custom.Data.Column35"}),
    FourthRow = Table.Range(#"Expanded Custom.Data" ,4,1)
in
    FourthRow

tablerange.jpg
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,126
Messages
6,189,149
Members
453,526
Latest member
anyrandomtech

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