Skip to content

Instantly share code, notes, and snippets.

View ImkeF's full-sized avatar

Imke Feldmann ImkeF

View GitHub Profile
let
Source = let func =
(Table as table, Operation as text, optional ColumnName, optional ReplaceColumnName, optional horizontal) =>
let
Columns = List.Buffer(Table.ColumnNames(Table)),
FunctionRecord = [Average=List.Average, Median=List.Median, Mode=List.Mode, First=List.First, Last=List.Last, Min=List.Min, Max=List.Max, Sum=List.Sum, Product=List.Sum],
AggregationFunction = Record.Field(FunctionRecord, Operation),
ReplacerFunction = (RTable as table, RColumnName) =>
Table.ReplaceValue(RTable,
let func =
(Server as text, Database as text, SQLTable as text, SQLColumn as text, FilterList as list) =>
let
/* Debug parameters
Server = "localhost",
Database = "postgres",
SQLTable = "public.mytesttable",
SQLColumn = "Col1",
FilterList = Filter[Column1],
let func =
(PeriodStartForecast as number, PeriodEndForecast as number, OriginalForecast as table) =>
let
/* Debug Parameters
PeriodEndForecast = PeriodEndForecast,
PeriodStartForecast = PeriodStartForecast,
OriginalForecast = LU_Original_Forecast_Data,
*/
let func =
(List as list) =>
let
List = List.Buffer(List),
LA =
List.Accumulate(
List.Skip(List),
[Table = Table.FromColumns({List}), Counter = 2],
let func =
(optional SelectedType as type) =>
let
/* Debug Parameters
SelectedType = type table,
End of debug parameters */
Source = #shared,
ToTable = Record.ToTable(Source),
let func =
(optional SelectedType as type, optional ExcludeList as list) =>
let
/* Debug Parameters
SelectedType = type table,
ExcludeList = null,
End of debug parameters */
//By default, the query "GetAllQueries" will be excluded, so if you name this query so, you get everything BUT this query.
let func =
(QueryText as text, optional HtmlAdress as text) =>
let
/* Debug parameters
QueryText = "// Source: https://gist.githubusercontent.com/tonmcg/c5889375a84482f2d2862d620b6f191d/raw/e576da943b79b4690c9b81494365d1f59b075b37/List.Percentile.pq #(lf) // from NIST 7.2.6.2 Percentiles#(lf)// https://www.itl.nist.gov/div898/handbook/prc/section2/prc262.htm#(lf)// Note that there are other ways of calculating percentiles in common use#(lf)// Hyndman and Fan (1996) in an American Statistician article evaluated nine different methods (R1 to R9)#(lf)// for computing percentiles relative to six desirable properties. #(lf)// Their goal was to advocate a ""standard"" definition for percentiles that would be implemented in statistical software. #(lf)// Although this has not in fact happened, most statistical and spreadsheet software use one of the methods described in Hyndman and Fan.#(lf)// The method used here is patterned after the R6, R7, and R8 methods; R7 is the default method used in Excel and R an
let
func = (JSON) =>
let
Source = JSON,
ParseJSON = try Json.Document(Source) otherwise Source,
TransformForTable =
if Value.Is(ParseJSON, type record) then
Record.ToTable(ParseJSON)
else
#table(
let func =
(Table as table, MyFunction as function) =>
let
OldColumnNames = Table.ColumnNames(Table),
NewColumnNames = List.Transform(OldColumnNames, MyFunction),
RenameList = List.Zip({OldColumnNames, NewColumnNames}),
RenameColumns = Table.RenameColumns(Table, RenameList)
in
RenameColumns ,
documentation = [
let func =
(XML as table) =>
let
Source = XML,
AddSort = Table.Buffer(Table.AddColumn(Source, "Sort", each 0)),
LG = List.Skip(List.Generate( ()=>
[Next = AddSort, Counter = 1, AddIndex= #table({"Sort"}, {{""}})],
each [AddIndex]{0}[Sort]<>"End",
each [