66let
77 // evaluates a .pq text file that's editable outside of power bi, without pasting updates. just refresh.
88 EvalQueryFunc = (filePath as text, optional options as nullable record) as any => [
9- encoding = options[Encoding]? ?? TextEncoding.Utf8,
9+ encoding = options[Encoding]? ?? TextEncoding.Utf8,
1010 environment = options[Environment]? ?? #shared,
11- bytes = File.Contents(filePath),
12- lines = Text.FromBinary( bytes, encoding ),
13- return = Expression.Evaluate( lines, environment )
11+ bytes = File.Contents(filePath),
12+ lines = Text.FromBinary( bytes, encoding ),
13+ return = Expression.Evaluate( lines, environment )
1414 ][return]
1515in
1616 EvalQueryFunc
2121
2222// with extra
2323let
24- // AsWebRequest = Web.Contents( "https://github.com", [RelativePath = "/ninmonkey/Ninmonkey.PowerQueryLib/blob/318cea1e52b2d1ab456a004dca79d235dec3f82e/build/2024-04.ninlib.pq" ]),
25-
2624 /* this is the entry point */
27- EvalQuery = (filePath as text, optional options as nullable record) as any => [
28- encoding = options[Encoding]? ?? TextEncoding.Utf8,
25+ EvalQuery = ( filePath as text, optional options as nullable record ) as any => [
26+ encoding = options[Encoding]? ?? TextEncoding.Utf8,
2927 environment = options[Environment]? ?? #shared,
3028 bytes = File.Contents(filePath),
3129 lines = Text.FromBinary( bytes, encoding ),
9492
9593// lib_meta
9694let
97- // summarize the module
9895 Source = lib,
99- top_items = Table.Buffer(
100- Table.FromValue( lib ), [ BufferMode = BufferMode.Delayed ] ),
101-
102- // Custom1 = top_items,
96+ top_items = Table.Buffer( Table.FromValue( lib ) ),
97+ Custom1 = top_items,
10398 procRow = ( source as any) as nullable record => [
104- target = Value.Metadata( Value.Type( source ) ),
99+ target = Value.Metadata( source ),
105100 hasKeys = Record.FieldCount( target ) > 0,
106101 ret = if hasKeys then source else null
107102 ][target],
108- // #"Added Custom" = Table.AddColumn(Custom1, "Custom", (row) => procRow(row), Record.Type )
109- #"Added Custom" = Table.AddColumn(top_items, "Custom", (row) => procRow( row[Value] ), type any)
103+ #"Added Custom" = Table.AddColumn(Custom1, "Custom", (row) => procRow( row[Value] ), type record)
110104in
111105 #"Added Custom"
0 commit comments