Skip to content
VirtualLP Virtual Learning Platform

M Language, Parameters and Reusable Functions

8 min read Topic 7 of 38

Understand it in simple language

M is the Power Query transformation language. A let expression names intermediate steps and in chooses the final result. Steps normally refer to previous steps. Parameters make source paths and dates reusable; they are not a secure secret store.

Example:

let
    Source = #table({"Region"}, {{" North "}, {"South"}}),
    Clean = Table.TransformColumns(Source, {{"Region", Text.Trim, type text}})
in
    Clean

This standalone example creates two rows and trims spaces. Custom functions package repeatable transformations, but a function invoked once per row can be expensive.

Do it step by step

Open a blank query > Advanced Editor and paste the example. Verify North has no spaces. Create a text parameter DataFolder, then use it as the folder input of your training query. Duplicate the file and change only the parameter to test portability. Build a function (region as text) as text => Text.Upper(Text.Trim(region)) and invoke it on Region.

Check your result

Why is a parameter better than editing five source paths independently?

If something goes wrong

If a step name has spaces, reference it as #"Step Name". Check privacy levels when combining sources; do not disable privacy to bypass an unexplained error.

Practice data and learning method

Industry practice collection: downloadable retail, finance, HR and operations datasets, dictionaries, full walkthroughs and answer sheets. The cases contain multiple years, multiple related tables, deliberate data defects and known-answer checks. Progress from the small foundation files below to these cases; do not reuse the foundation totals for the larger datasets.

Download Sales.csv, Products.csv, and the dataset guide. These files contain synthetic training data, not real customers. Use the Power BI virtual labs for guided browser practice. Each lab states its supported operations. Then repeat the procedure above in the actual Microsoft tools and save evidence of your result. Try another filter or an intentionally incorrect setting and explain what changed before moving on.

Guided practicals for this topic

Use the real-tool procedure above and the related case walkthroughs in the industry practice collection. This topic is not represented as a full browser simulation.

Continue learning from Microsoft

Power BI documentation · DAX reference · Power Query M reference · Power BI analyst skills map. Features, licensing, menus and availability can change; check the relevant official page for your environment.

Create a free account to track your progress and unlock virtual labs.