From c07d8d6a0ff03c33af29c6b12c2430e4bedf2183 Mon Sep 17 00:00:00 2001 From: Jake Bolton Date: Thu, 20 Jun 2024 20:39:45 -0500 Subject: [PATCH 1/6] Create GetAbsoluteWorkbookPath.md --- source-excel/GetAbsoluteWorkbookPath.md | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 source-excel/GetAbsoluteWorkbookPath.md diff --git a/source-excel/GetAbsoluteWorkbookPath.md b/source-excel/GetAbsoluteWorkbookPath.md new file mode 100644 index 0000000..03d7241 --- /dev/null +++ b/source-excel/GetAbsoluteWorkbookPath.md @@ -0,0 +1,33 @@ +This parses `cell()` output to get the **absolute filepath of the current workbook** + +This is one way you can have powerquery autodetect absolute filepaths +``` += Cell( "filename" ) +``` +The raw output +``` +c:\data\excel\[Example Sales Table.xlsx]Sheet2 +``` +formula: +```sql += LET( + rawName, CELL("filename"), + + folder, + TEXTBEFORE( rawName, "[", 1 ), + + file, + TEXTBEFORE( + TEXTAFTER( rawName, "[", 1 ), + "]", 1 + ), + + fullName, + CONCAT(folder, file), + +fullName ) +``` +Our final output: +``` +c:\data\excel\Example Sales Table.xlsx +``` From 61187c963a94963a080d82dc6bd1f67302bdf07a Mon Sep 17 00:00:00 2001 From: Jake Bolton Date: Thu, 20 Jun 2024 20:45:01 -0500 Subject: [PATCH 2/6] Update GetAbsoluteWorkbookPath.md --- source-excel/GetAbsoluteWorkbookPath.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source-excel/GetAbsoluteWorkbookPath.md b/source-excel/GetAbsoluteWorkbookPath.md index 03d7241..8123733 100644 --- a/source-excel/GetAbsoluteWorkbookPath.md +++ b/source-excel/GetAbsoluteWorkbookPath.md @@ -19,7 +19,7 @@ formula: file, TEXTBEFORE( TEXTAFTER( rawName, "[", 1 ), - "]", 1 + "]", -1 ), fullName, From 48cf05f7830b199cd999ea4bd6f033f2e9b118c3 Mon Sep 17 00:00:00 2001 From: Jake Bolton Date: Thu, 20 Jun 2024 20:52:59 -0500 Subject: [PATCH 3/6] Update GetAbsoluteWorkbookPath.md --- source-excel/GetAbsoluteWorkbookPath.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source-excel/GetAbsoluteWorkbookPath.md b/source-excel/GetAbsoluteWorkbookPath.md index 8123733..8b4100f 100644 --- a/source-excel/GetAbsoluteWorkbookPath.md +++ b/source-excel/GetAbsoluteWorkbookPath.md @@ -1,5 +1,4 @@ This parses `cell()` output to get the **absolute filepath of the current workbook** - This is one way you can have powerquery autodetect absolute filepaths ``` = Cell( "filename" ) @@ -8,7 +7,10 @@ The raw output ``` c:\data\excel\[Example Sales Table.xlsx]Sheet2 ``` -formula: +Note: You could drop the worksheet name, then replace `[]` with ``. +I split this into steps to show how you can use intermediate calculations as variables +without polluting the scope using named cells + ```sql = LET( rawName, CELL("filename"), From b41894c92b703278b7123b6a680a4178b4fd9f9d Mon Sep 17 00:00:00 2001 From: Jake Bolton Date: Thu, 20 Jun 2024 20:53:30 -0500 Subject: [PATCH 4/6] Update GetAbsoluteWorkbookPath.md --- source-excel/GetAbsoluteWorkbookPath.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source-excel/GetAbsoluteWorkbookPath.md b/source-excel/GetAbsoluteWorkbookPath.md index 8b4100f..0a1399d 100644 --- a/source-excel/GetAbsoluteWorkbookPath.md +++ b/source-excel/GetAbsoluteWorkbookPath.md @@ -7,7 +7,7 @@ The raw output ``` c:\data\excel\[Example Sales Table.xlsx]Sheet2 ``` -Note: You could drop the worksheet name, then replace `[]` with ``. +Note: You could drop the worksheet name, then replace `[]` with `''`. I split this into steps to show how you can use intermediate calculations as variables without polluting the scope using named cells From b676d12e6469ff27ce0e693458785573ccece651 Mon Sep 17 00:00:00 2001 From: Jake Bolton Date: Sun, 18 Aug 2024 19:35:57 -0500 Subject: [PATCH 5/6] Create Table.AutoExpandTableColumn.pq --- source/Xml/Table.AutoExpandTableColumn.pq | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 source/Xml/Table.AutoExpandTableColumn.pq diff --git a/source/Xml/Table.AutoExpandTableColumn.pq b/source/Xml/Table.AutoExpandTableColumn.pq new file mode 100644 index 0000000..8b70aad --- /dev/null +++ b/source/Xml/Table.AutoExpandTableColumn.pq @@ -0,0 +1,13 @@ + +// Someone asked for a way to auto expand xml columns +// hard coded example filter +Table.AutoExpandTableColumn = (source as table, columnName as text ) => + let + allNames = Table.ColumnNames( source ), + filteredNames = List.Select( allNames, (item) => + not Text.StartsWith( item, "http://", Comparer.OrdinalIgnoreCase ) ), + + prefixedNames = List.Transform( filteredNames, each expandColumnName & "." & _ ), + return = Table.ExpandTableColumn( source, columnName, allNames, filteredNames ) + in + return From 64a7eaef1f41a812b05d2fd106693ecf13809d3e Mon Sep 17 00:00:00 2001 From: Jake Bolton Date: Sun, 18 Aug 2024 19:40:21 -0500 Subject: [PATCH 6/6] Update Table.AutoExpandTableColumn.pq --- source/Xml/Table.AutoExpandTableColumn.pq | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Xml/Table.AutoExpandTableColumn.pq b/source/Xml/Table.AutoExpandTableColumn.pq index 8b70aad..c3eabdd 100644 --- a/source/Xml/Table.AutoExpandTableColumn.pq +++ b/source/Xml/Table.AutoExpandTableColumn.pq @@ -8,6 +8,6 @@ Table.AutoExpandTableColumn = (source as table, columnName as text ) => not Text.StartsWith( item, "http://", Comparer.OrdinalIgnoreCase ) ), prefixedNames = List.Transform( filteredNames, each expandColumnName & "." & _ ), - return = Table.ExpandTableColumn( source, columnName, allNames, filteredNames ) + return = Table.ExpandTableColumn( source, columnName, filteredNames, prefixedNames ) in - return + return,