Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ninmonkey/Ninmonkey.PowerQueryLib
Browse files Browse the repository at this point in the history
  • Loading branch information
ninmonkey committed Sep 7, 2024
2 parents a818852 + 64a7eae commit 86ed7db
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
35 changes: 35 additions & 0 deletions source-excel/GetAbsoluteWorkbookPath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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
```
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"),

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
```
13 changes: 13 additions & 0 deletions source/Xml/Table.AutoExpandTableColumn.pq
Original file line number Diff line number Diff line change
@@ -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, filteredNames, prefixedNames )
in
return,

0 comments on commit 86ed7db

Please sign in to comment.