| 1 | <h2>Comments</h2> |
| 2 | <pre><code>// This is a comment</code></pre> |
| 3 | <h2>Simple example</h2> |
| 4 | <pre><code> |
| 5 | let |
| 6 | x = 1 + 1, |
| 7 | y = 2 + 2, |
| 8 | z = y + 1 |
| 9 | in |
| 10 | x + y + z |
| 11 | </code></pre> |
| 12 | <h2>Another example</h2> |
| 13 | <pre><code> |
| 14 | let Orders = Table.FromRecords({ |
| 15 | [OrderID = 1, CustomerID = 1, Item = "fishing rod", Price = 100.0], |
| 16 | [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0], |
| 17 | [OrderID = 3, CustomerID = 2, Item = "fishing net", Price = 25.0]}), |
| 18 | #"Capitalized Each Word" = Table.TransformColumns(Orders, {"Item", Text.Proper}) |
| 19 | in |
| 20 | #"Capitalized Each Word" |
| 21 | </code></pre> |
| 22 | <h2>Full example</h2> |
| 23 | <pre><code> |
| 24 | let |
| 25 | Source = Sales, |
| 26 | LookupTable = #table( |
| 27 | type table |
| 28 | [ |
| 29 | #"FROM"=text, |
| 30 | #"TO"=text |
| 31 | ], |
| 32 | { |
| 33 | {"CEE","Central & Eastern Europe"}, |
| 34 | {"WE","Western Europe"} |
| 35 | } |
| 36 | ), |
| 37 | |
| 38 | JT = Table.NestedJoin( |
| 39 | Source, |
| 40 | {"Area"}, |
| 41 | LookupTable, |
| 42 | {"FROM"}, |
| 43 | "Map", |
| 44 | JoinKind.LeftOuter |
| 45 | ), |
| 46 | |
| 47 | #"Expanded Map" = Table.ExpandTableColumn( |
| 48 | JT, |
| 49 | "Map", |
| 50 | {"TO"}, |
| 51 | {"TO"} |
| 52 | ), |
| 53 | |
| 54 | #"Replace non-matches with original value" = Table.AddColumn( |
| 55 | #"Expanded Map", |
| 56 | "Replaced", |
| 57 | each |
| 58 | if [TO] = null then [Area] |
| 59 | else [TO] |
| 60 | ), |
| 61 | |
| 62 | #"Remove original column" = Table.RemoveColumns( |
| 63 | #"Replace non-matches with original value", |
| 64 | {"Area", "TO"} |
| 65 | ), |
| 66 | |
| 67 | #"Renamed replace column to original name" = Table.RenameColumns( |
| 68 | #"Remove original column", |
| 69 | {{"Replaced", "Area"}} |
| 70 | ) |
| 71 | |
| 72 | in |
| 73 | #"Renamed replace column to original name" |
| 74 | </code></pre> |