Forum Discussion
Need to extract values from named cells (Get and Transform)
- Nov 29, 2019
If so your filepath shall be
C:\Users\Jema\Veidekke\NO-ENT-GLENCORE Cu-Bygg - Teamdokumenter\Intern Prosjekt Dokumenter\10 Økonomi\10.04 Endringer\Endringsmeldinger (EM)\EMAttached file works if another 3 folders are under above one.
As variant:
- create custom function which extract all named values from defined file:
(pFilePath as text) =>
let
Source = Excel.Workbook(File.Contents(pFilePath), null, true),
DefinedNamesOnly = Table.SelectRows(
Source,
each ([Kind] = "DefinedName")
),
ExpandThem = Table.ExpandTableColumn(
DefinedNamesOnly,
"Data",
{"Column1"}, {"Column1"}
),
RemoveUnused = Table.SelectColumns(
ExpandThem,
{"Name", "Column1"}
),
TransposeTable = Table.Transpose(RemoveUnused),
PromotHeaders = Table.PromoteHeaders(
TransposeTable,
[PromoteAllScalars=true]
),
ProperType = Table.TransformColumnTypes(
PromotHeaders,
{
{"Beskrivelse", type text},
{"EM", Int64.Type},
{"Total", Int64.Type}
}
)
in
ProperType
In another query use From folder connection, add column with full path\filename for each file, when another custom column with call of above function with previous value as parameter. Remove all other columns and expand this one.
I copy your source file and test with folder c:\test. Please check attached.
- JEMagnussenNov 29, 2019Brass Contributor
Hi Sergei,
I'm sure Your suggestion Works, but for unknown reason the editor freezes when I try to open the Query to change the file path.
If I have an empty file, I'm also not able to use the editor.
I uploaded a New files, as the first file did not have any table in it.
The New file has the right file path, colud you please try to insert the correct file path and upload it again then I can test it.
Best regards
Jesper
- SergeiBaklanNov 29, 2019Diamond Contributor
In attached file I added FilePath table to have filepath as parameter. It extracted within the script as
let SourcePath = Excel.CurrentWorkbook(), GetFolderPath = Table.SelectRows(SourcePath, each ([Name] = "FilePath")){0}[Content]{0}[FilePath], Source = Folder.Files(GetFolderPath),I guess in your case that will be
C:\Users\Jema\Veidekke\NO-ENT-GLENCORE Cu-Bygg - Teamdokumenter\Intern Prosjekt Dokumenter\10 Økonomi\10.04 Endringer\Endringsmeldinger (EM)\EM\EM001 - Tilleggsarbeid med kranfundament(without the slash at the end compare to your test file)
- JEMagnussenNov 29, 2019Brass Contributor
Hi Sergei,
Managed to get the editor up and running on the "fx GetFileFields" and here I saw the error, have Attached a screenshot of the error Message.
Best regards
Jesper
- JEMagnussenNov 29, 2019Brass Contributor
This is a screenshot of an earlier attemt that failed due to an [DataFormat.Error] File contain corrupted data...