This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
// fetches the first N rows in all tables from a database at once and presents them in a compact form | |
(Server as text, Database as text, NumberOfRows as number) as table => | |
let | |
Source = Sql.Database(Server, Database, [CreateNavigationProperties=false]), | |
#"Filtered Rows" = Table.SelectRows(Source, each Value.Is([Data], type table)), | |
#"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each Table.Transpose(Table.DemoteHeaders(Table.Buffer(Table.FirstN([Data],NumberOfRows))))), | |
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", Table.ColumnNames(#"Added Custom"[Custom]{0})) | |
in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///* | |
let func = | |
(ParChTable as table, | |
ChildKey as text, | |
ParentKey as text, | |
LevelColumnName as text) => | |
//*/ | |
let |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(PQTable as table) => | |
let | |
#"Added Index" = Table.AddIndexColumn(PQTable, "Index", 0, 1), | |
#"Duplicated Column" = Table.DuplicateColumn(#"Added Index", "Column1", "Column1 - Copy"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Filename as text) => | |
let | |
// Unz-function from: https://querypower.com/2017/03/22/extracting-power-queries-in-m/ | |
Unz = (binaryZip,fileName) => | |
let | |
//shorthand | |
UInt32 = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger32,ByteOrder.LittleEndian), | |
UInt16 = BinaryFormat.ByteOrder(BinaryFormat.UnsignedInteger16,ByteOrder.LittleEndian), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(URL as text) => | |
let | |
MyJsonRecord = Json.Document(Web.Contents(URL)), | |
MyJsonTable= Table.FromRecords( { MyJsonRecord } ) | |
in | |
MyJsonTable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
// Fetches your function library from a csv-file: 3 columns "Column1" is autogenerated and will be removed, "GetCode" hold code and "Name" the name of the function | |
// Adjust "Path" to your own machine: | |
Path = "C:\Users\imkef\Desktop\ImkesFunctions.csv", | |
// The Encoding parameters might need to be adjusted to local settings | |
Source = Csv.Document(File.Contents(Path),[Delimiter=",", Columns=3, Encoding=1252, QuoteStyle=QuoteStyle.Csv]), | |
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", type text}, {"Column3", type text}}), | |
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]), | |
#"Removed Columns" = Table.RemoveColumns(#"Promoted Headers",{"Column1"}), | |
EvaluateFunction = Table.AddColumn(#"Removed Columns", "Value", each Expression.Evaluate([GetCode], #shared)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
(TableWithCode as table, CodeColumnName as text) => | |
let | |
Source= TableWithCode, | |
EvaluateFunction = Table.AddColumn(Source, "Value", each Expression.Evaluate(Record.Field(_, CodeColumnName), #shared)), | |
Cleanup = Table.RemoveColumns(EvaluateFunction,{CodeColumnName}), | |
ToRecord = Record.FromTable(Cleanup) | |
in | |
ToRecord |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
(MasterPath as text, BlobPath as text) => | |
let | |
/* debug parameters | |
MasterPath = "https://github.com/ImkeF/RM/tree/master", | |
BlobPath = "https://github.com/ImkeF/RM/blob/master", | |
*/ | |
FileEndings = {".rm", ".m"}, | |
Source = Web.Page(Web.Contents(MasterPath)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
(FunctionRecord as record) => | |
let | |
Source = Record.ToTable(FunctionRecord), | |
Meta = Table.AddColumn(Source, "Meta", each Value.Metadata(Value.Type([Value]))), | |
ColNames1 = Record.FieldNames(Record.Combine(Meta[Meta])), | |
#"Expanded Meta" = Table.ExpandRecordColumn(Meta, "Meta", ColNames1), | |
Expand1 = Table.ExpandListColumn(#"Expanded Meta", "Documentation.Examples"), | |
ColNames2 = Record.FieldNames(Record.Combine(List.Select(Expand1[Documentation.Examples], each _<>null))), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
// fnStat.Trend | |
// Author: Imke Feldmann - http://www.thebiccountant.com/ - Link to blogpost: http://wp.me/p6lgsG-Fd | |
(Actuals as table, FCPeriods as list) => | |
let | |
FCPeriods = Table.FromList(FCPeriods, Splitter.SplitByNothing()), | |
#"Run R Script" = R.Execute("y <- as.matrix(Actuals[1]) | |
x <- as.matrix(Actuals[2]) | |
trendline <- fitted(lm(y ~ x)) |