diff --git a/Functions/List/List.DotProduct.pq b/Functions/List/List.DotProduct.pq
new file mode 100644
index 0000000..287738b
--- /dev/null
+++ b/Functions/List/List.DotProduct.pq
@@ -0,0 +1,34 @@
+let
+ // Define metadata for the function, describing its purpose and usage.
+ metaDocumentation = type function (
+ list1 as (type list),
+ list2 as (type list)
+ ) as number meta [
+ Documentation.Name = "List.DotProduct",
+ Documentation.Author = "Alexis Olson",
+ Documentation.LongDescription =
+ // This is the description of the documentation, it only accepts a handful of HTML tags for formatting.
+ "
+ Returns the dot product of two lists.
+
+ Author: Alexis Olson
+ LinkedIn: https://www.linkedin.com/in/alexis-olson-81726818/
+ ",
+ Documentation.Examples = {
+ [
+ Description = " Compute the dot product of {1, 3, -5} and {4, -2, -1}.",
+ Code = "List.DotProduct({1, 3, -5}, {4, -2, -1})",
+ Result = "3 = (1 * 4) + (3 * -2) + (-5 * -1)"
+ ]
+ }
+ ],
+ myFunction =
+ (list1 as list, list2 as list) as number =>
+ let
+ Zip = List.Zip({list1, list2}),
+ Result = List.Sum(List.Transform(Zip, List.Product))
+ in
+ Result
+in
+ // Apply the function metadata to myFunction.
+ Value.ReplaceType(myFunction, metaDocumentation)
\ No newline at end of file
diff --git a/Functions/List/List.Norm.pq b/Functions/List/List.Norm.pq
new file mode 100644
index 0000000..3196cd8
--- /dev/null
+++ b/Functions/List/List.Norm.pq
@@ -0,0 +1,53 @@
+let
+ // Define metadata for the function, describing its purpose and usage.
+ metaDocumentation = type function (
+ inputList as (type list meta [
+ Documentation.FieldCaption = "List input"
+ ]),
+ optional p as (type number meta [
+ Documentation.FieldCaption = "Select any p > 0 to use the Lp norm"
+ ])
+ ) as number meta [
+ Documentation.Name = "List.Norm",
+ Documentation.Author = "Alexis Olson",
+ Documentation.LongDescription =
+ // This is the description of the documentation, it only accepts a handful of HTML tags for formatting.
+ "
+ Returns the norm of the list.
+ The default is the standard L² Euclidean norm but the optional argument allows any Lp norm.
+ Author: Alexis Olson
+ LinkedIn: https://www.linkedin.com/in/alexis-olson-81726818/
+ ",
+ Documentation.Examples = {
+ [
+ Description = " Default L² (Euclidean) norm. ",
+ Code = "List.Norm({1, 2, 3})",
+ Result = "3.7416573867739413 = √(1² + 2² + 3²)"
+ ],
+ [
+ Description = " L¹ (Taxicab or Manhattan) norm. ",
+ Code = "List.Norm({1, -1, 1, 0}, 1)",
+ Result = "3 = |1| + |-1| + |1| + |0|"
+ ],
+ [
+ Description = " L∞ (infinity or maximum) norm. ",
+ Code = "List.Norm({3, -4}, Number.PositiveInfinity)",
+ Result = "4"
+ ]
+ }
+ ],
+ myFunction =
+ (L as list, optional p as number) as number =>
+ let
+ AbsL = List.Transform(L, Number.Abs),
+ PowerP = List.Transform(AbsL, each Number.Power(_, p ?? 2)),
+ RootP = Number.Power(List.Sum(PowerP), 1 / (p ?? 2)),
+ Result =
+ if p = Number.PositiveInfinity
+ then List.Max(AbsL)
+ else RootP
+ in
+ Result
+in
+ // Apply the function metadata to myFunction.
+ Value.ReplaceType(myFunction, metaDocumentation)
\ No newline at end of file
diff --git a/M.pq b/M.pq
index bdaa16b..39bc009 100644
--- a/M.pq
+++ b/M.pq
@@ -103,20 +103,27 @@ let
List.Count = List.Count,
List.Dates = List.Dates,
List.Distinct = List.Distinct,
+ List.DotProduct = List.DotProduct,
List.First = List.First,
List.IsEmpty = List.IsEmpty,
List.MatchesAny = List.MatchesAny,
List.Max = List.Max,
List.Median = List.Median,
List.Min = List.Min,
+ List.Product = List.Product,
List.RemoveItems = List.RemoveItems,
List.RemoveNulls = List.RemoveNulls,
List.StandardDeviation = List.StandardDeviation,
+ List.Sum = List.Sum,
List.Transform = List.Transform,
List.Type = List.Type,
+ List.Zip = List.Zip,
Logical.Type = Logical.Type,
+ Number.Abs = Number.Abs,
Number.From = Number.From,
Number.IntegerDivide = Number.IntegerDivide,
+ Number.PositiveInfinity = Number.PositiveInfinity,
+ Number.Power = Number.Power,
Number.Type = Number.Type,
Order.Descending = Order.Descending,
Record.Field = Record.Field,
@@ -157,7 +164,8 @@ let
Time.Type = Time.Type,
Type.Is = Type.Is,
Value.ReplaceType = Value.ReplaceType,
- Value.Type = Value.Type
+ Value.Type = Value.Type,
+ microsoft.com = microsoft.com
]
)
in
diff --git a/M_Creator.py b/M_Creator.py
index d0400b6..a87994e 100644
--- a/M_Creator.py
+++ b/M_Creator.py
@@ -20,6 +20,8 @@
'Formatting.IsMultiLine',
'gorilla.bi',
'List.Flatten',
+ 'List.Norm',
+ 'List.DotProduct'
'microsoft.com',
'odata.nextLink',
'Table.ToM',
diff --git a/README.md b/README.md
index 0cac4a2..af76424 100644
--- a/README.md
+++ b/README.md
@@ -31,15 +31,22 @@ This library is "imported" into Power Query by following these steps:
Please contribute in the folder category that best suits. If the folder does not exist, create it.
The functions you create will only work if all the Power Query native functions used are declared in the [**M.pq**](M.pq) file. You can run the [M_Creator.py](M_Creator.py) Python script to locate all the functions via regex and rewrite an M.pq file.
+### How can you contribute?
+
+ - New functions.
+ - Upgrading existing functions.
+ - Adding documentation to existing functions.
+ - Solve open issues.
### Contributing guidelines
1. Make sure to add the corresponding credits to your code. Plagiarism will not be tolerated.
2. **Document your functions,** for this you can use the file [M_FxDocTemplate.pq](https://github.com/OscarValerock/PowerQueryFunctions/blob/main/M_FxDocTemplate.pq "M_FxDocTemplate.pq")
-3. Comment your code.
-4. Have fun! 🎉
+3. Do not duplicate code. Example: if you have a better date table, upgrade the existing instead of creating a new one.
+4. Comment your code.
+5. Have fun! 🎉
## Other libraries
-Below, you will find other handy PowerQuery libraries that could come in handy:
+Below, you will find other handy PowerQuery libraries:
1. [M-tools](https://github.com/acaprojects/m-tools/tree/master) by Kim Burgess
2. [M](https://github.com/ImkeF/M) by Imke Feldmann
3. [M Custom Functions](https://github.com/tirnovar/m-custom-functions) by Štěpán Rešl
@@ -48,8 +55,9 @@ Below, you will find other handy PowerQuery libraries that could come in handy:
## License
This project is licensed under the [MIT License](LICENSE).
\ No newline at end of file