Skip to content

Commit 86ed7db

Browse files
committed
Merge branch 'main' of github.com:ninmonkey/Ninmonkey.PowerQueryLib
2 parents a818852 + 64a7eae commit 86ed7db

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
This parses `cell()` output to get the **absolute filepath of the current workbook**
2+
This is one way you can have powerquery autodetect absolute filepaths
3+
```
4+
= Cell( "filename" )
5+
```
6+
The raw output
7+
```
8+
c:\data\excel\[Example Sales Table.xlsx]Sheet2
9+
```
10+
Note: You could drop the worksheet name, then replace `[]` with `''`.
11+
I split this into steps to show how you can use intermediate calculations as variables
12+
without polluting the scope using named cells
13+
14+
```sql
15+
= LET(
16+
rawName, CELL("filename"),
17+
18+
folder,
19+
TEXTBEFORE( rawName, "[", 1 ),
20+
21+
file,
22+
TEXTBEFORE(
23+
TEXTAFTER( rawName, "[", 1 ),
24+
"]", -1
25+
),
26+
27+
fullName,
28+
CONCAT(folder, file),
29+
30+
fullName )
31+
```
32+
Our final output:
33+
```
34+
c:\data\excel\Example Sales Table.xlsx
35+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
// Someone asked for a way to auto expand xml columns
3+
// hard coded example filter
4+
Table.AutoExpandTableColumn = (source as table, columnName as text ) =>
5+
let
6+
allNames = Table.ColumnNames( source ),
7+
filteredNames = List.Select( allNames, (item) =>
8+
not Text.StartsWith( item, "http://", Comparer.OrdinalIgnoreCase ) ),
9+
10+
prefixedNames = List.Transform( filteredNames, each expandColumnName & "." & _ ),
11+
return = Table.ExpandTableColumn( source, columnName, filteredNames, prefixedNames )
12+
in
13+
return,

0 commit comments

Comments
 (0)