MSmith
New member
- Joined
- Apr 17, 2018
- Messages
- 3
- Reaction score
- 0
- Points
- 0
- Location
- USA
- Excel Version(s)
- Excel 365 Monthly Channel
Hello,
I've Googled, looked at many blog posts and forums, and searched M is for Data Monkey, but found no answer. I've also spend several hours trying different things to accomplish. So, I'm posting here. Using Excel 365.
I have a query to pull data from a closed workbook and prep it for use in other queries.
It works fine except that the report I'm pulling from is system generated and the single worksheet has a slightly different name each time. So, the first sheet name is EFT_EFTA_ALLTRANS_29859730, Next day it might be EFT_EFTA_ALLTRANS_29895764. There isn't a particular pattern as far as I can tell. The numbers change with each.
Here's my current code. The problem is I have to change the green text every time I link to a new file. I don't really mind, but my coworkers don't know anything about PQ.
let
Source = Excel.Workbook(File.Contents("X:\filepath\AllTrans 04-13-2018.xls"), null, true),
EFT_EFTA_ALLTRANS_1 = Source{[Name="[B][COLOR=#00ff00]EFT_EFTA_[/COLOR][/B][COLOR=#00FF00][B]ALLTRANS_29859730[/B][/COLOR]"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(EFT_EFTA_ALLTRANS_1, [PromoteAllScalars=true])
in
#"Promoted Headers"
I've tried loading the file path and name into a parameter table, and pulling the sheet name. The code below loads the sheet name into a single row table called Sheet_Name, but I can't get the first query to source from that cell in step 2.
let Source = Excel.Workbook(File.Contents(fnGetParameter("File Path")), null, true),
Name = Source[Name]
in
Name
This would result in the first query pulling from the one just above. First query code now looks like this (new code in blue), but it's not working.
let
Source = Excel.Workbook(File.Contents("file path"), null, true),
Source{[Name=fnGetParameter("Sheet Name")]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(EFT_EFTA_ALLTRANS_1, [PromoteAllScalars=true])
in
#"Promoted Headers"
So, I've tried a number of things. A salient point is that I'm trying to do all this without opening the source workbook and changing the sheet name. Since it is original data, I don't want to alter it.
I'm enjoying working through M is for Data Monkey and have added PQ to many of my Excel templates. It's helping me keep ahead of my workload.
Thank you in advance.
Matthew
I've Googled, looked at many blog posts and forums, and searched M is for Data Monkey, but found no answer. I've also spend several hours trying different things to accomplish. So, I'm posting here. Using Excel 365.
I have a query to pull data from a closed workbook and prep it for use in other queries.
It works fine except that the report I'm pulling from is system generated and the single worksheet has a slightly different name each time. So, the first sheet name is EFT_EFTA_ALLTRANS_29859730, Next day it might be EFT_EFTA_ALLTRANS_29895764. There isn't a particular pattern as far as I can tell. The numbers change with each.
Here's my current code. The problem is I have to change the green text every time I link to a new file. I don't really mind, but my coworkers don't know anything about PQ.
let
Source = Excel.Workbook(File.Contents("X:\filepath\AllTrans 04-13-2018.xls"), null, true),
EFT_EFTA_ALLTRANS_1 = Source{[Name="[B][COLOR=#00ff00]EFT_EFTA_[/COLOR][/B][COLOR=#00FF00][B]ALLTRANS_29859730[/B][/COLOR]"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(EFT_EFTA_ALLTRANS_1, [PromoteAllScalars=true])
in
#"Promoted Headers"
I've tried loading the file path and name into a parameter table, and pulling the sheet name. The code below loads the sheet name into a single row table called Sheet_Name, but I can't get the first query to source from that cell in step 2.
let Source = Excel.Workbook(File.Contents(fnGetParameter("File Path")), null, true),
Name = Source[Name]
in
Name
This would result in the first query pulling from the one just above. First query code now looks like this (new code in blue), but it's not working.
let
Source = Excel.Workbook(File.Contents("file path"), null, true),
Source{[Name=fnGetParameter("Sheet Name")]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(EFT_EFTA_ALLTRANS_1, [PromoteAllScalars=true])
in
#"Promoted Headers"
So, I've tried a number of things. A salient point is that I'm trying to do all this without opening the source workbook and changing the sheet name. Since it is original data, I don't want to alter it.
I'm enjoying working through M is for Data Monkey and have added PQ to many of my Excel templates. It's helping me keep ahead of my workload.
Thank you in advance.
Matthew