Skip to content

Instantly share code, notes, and snippets.

@ninmonkey
Last active February 21, 2025 16:05
Let expressions are synactic sugar for record expressions

I used pseudocode to shorten the example. The structure is good.

Using nested let

let
    Source1 =
        let 
            Workbook = File.Contents(...),
            Final    = Table.SelectColumns( ... )
        in 
            Final,

        
    Source2 =
        let 
            Workbook = File.Contents(...),
            Final    = Table.SelectColumns( ... )
        in 
            Final,
    // You can use append or join, or whichever function the UI was using to merge them
    FinalMerge = Table.Combine({ Source1, Source2 }, ... )

in
    FinalMerge        

the Same code, using record expressions

let
    Source1 = 
        [        
            Workbook = File.Contents(...),
            Return   = Table.SelectColumns( ... )
        ][Return],

    Source2 = 
        [        
            Workbook = File.Contents(...),
            Return   = Table.SelectColumns( ... )
        ][Return],
        
    // You can use append or join, or whichever function the UI was using to merge them
    FinalMerge = Table.Combine({ Source1, Source2 }, ... )

in
    FinalMerge

To debug records, skip the column lookup part [Return]

If you return the full record, you can drill down into each step. If you need to debug one.

let
    Source1 = 
        [        
            Workbook = File.Contents(...),
            Return   = Table.SelectColumns( ... )
        ],
        
   DrillDown = Source1
in 
   DrillDown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment