Skip to main content Svelte Highlight v7.21.1

Power Query M language preview

1. A basic query

let/in, quoted identifiers, and library functions
horizon-dark
let
    // load the source table
    Source = Csv.Document(File.Contents("data.csv")),
    #"Changed Type" = Table.TransformColumnTypes(Source, {{"Amount", Int64.Type}}),
    Total = List.Sum(Table.Column(#"Changed Type", "Amount"))
in
    each if Total > 0 then Total else 0
atom-one-dark
let
    // load the source table
    Source = Csv.Document(File.Contents("data.csv")),
    #"Changed Type" = Table.TransformColumnTypes(Source, {{"Amount", Int64.Type}}),
    Total = List.Sum(Table.Column(#"Changed Type", "Amount"))
in
    each if Total > 0 then Total else 0
github-dark
let
    // load the source table
    Source = Csv.Document(File.Contents("data.csv")),
    #"Changed Type" = Table.TransformColumnTypes(Source, {{"Amount", Int64.Type}}),
    Total = List.Sum(Table.Column(#"Changed Type", "Amount"))
in
    each if Total > 0 then Total else 0
dracula
let
    // load the source table
    Source = Csv.Document(File.Contents("data.csv")),
    #"Changed Type" = Table.TransformColumnTypes(Source, {{"Amount", Int64.Type}}),
    Total = List.Sum(Table.Column(#"Changed Type", "Amount"))
in
    each if Total > 0 then Total else 0
nord
let
    // load the source table
    Source = Csv.Document(File.Contents("data.csv")),
    #"Changed Type" = Table.TransformColumnTypes(Source, {{"Amount", Int64.Type}}),
    Total = List.Sum(Table.Column(#"Changed Type", "Amount"))
in
    each if Total > 0 then Total else 0
github
let
    // load the source table
    Source = Csv.Document(File.Contents("data.csv")),
    #"Changed Type" = Table.TransformColumnTypes(Source, {{"Amount", Int64.Type}}),
    Total = List.Sum(Table.Column(#"Changed Type", "Amount"))
in
    each if Total > 0 then Total else 0

2. Hash built-ins and record access

#table, #date, and [Field] record access
horizon-dark
let
    Orders = #table({"Id", "Placed"}, {{1, #date(2026, 1, 15)}}),
    FirstOrder = Orders{0},
    PlacedDate = FirstOrder[Placed]
in
    PlacedDate
atom-one-dark
let
    Orders = #table({"Id", "Placed"}, {{1, #date(2026, 1, 15)}}),
    FirstOrder = Orders{0},
    PlacedDate = FirstOrder[Placed]
in
    PlacedDate
github-dark
let
    Orders = #table({"Id", "Placed"}, {{1, #date(2026, 1, 15)}}),
    FirstOrder = Orders{0},
    PlacedDate = FirstOrder[Placed]
in
    PlacedDate
dracula
let
    Orders = #table({"Id", "Placed"}, {{1, #date(2026, 1, 15)}}),
    FirstOrder = Orders{0},
    PlacedDate = FirstOrder[Placed]
in
    PlacedDate
nord
let
    Orders = #table({"Id", "Placed"}, {{1, #date(2026, 1, 15)}}),
    FirstOrder = Orders{0},
    PlacedDate = FirstOrder[Placed]
in
    PlacedDate
github
let
    Orders = #table({"Id", "Placed"}, {{1, #date(2026, 1, 15)}}),
    FirstOrder = Orders{0},
    PlacedDate = FirstOrder[Placed]
in
    PlacedDate

3. Types and error handling

typed parameters, try/otherwise, and string escapes
horizon-dark
let
    Divide = (x as number, y as number) as number =>
        try x / y otherwise 0,
    Label = "Result: " & Text.From(Divide(10, 2)) & " (100% ""safe"")"
in
    Label
atom-one-dark
let
    Divide = (x as number, y as number) as number =>
        try x / y otherwise 0,
    Label = "Result: " & Text.From(Divide(10, 2)) & " (100% ""safe"")"
in
    Label
github-dark
let
    Divide = (x as number, y as number) as number =>
        try x / y otherwise 0,
    Label = "Result: " & Text.From(Divide(10, 2)) & " (100% ""safe"")"
in
    Label
dracula
let
    Divide = (x as number, y as number) as number =>
        try x / y otherwise 0,
    Label = "Result: " & Text.From(Divide(10, 2)) & " (100% ""safe"")"
in
    Label
nord
let
    Divide = (x as number, y as number) as number =>
        try x / y otherwise 0,
    Label = "Result: " & Text.From(Divide(10, 2)) & " (100% ""safe"")"
in
    Label
github
let
    Divide = (x as number, y as number) as number =>
        try x / y otherwise 0,
    Label = "Result: " & Text.From(Divide(10, 2)) & " (100% ""safe"")"
in
    Label