Parameter types

D

T

The M Code Behind the Power Query M function Parameter types

This article will focus on the M code behind Power Query’s parameter types. Understanding the different parameter types available can help you more effectively work with and manipulate data.

The Three Main Parameter Types

The M language has three main parameter types: text, number, and any. Here’s a brief overview of each type:

Text Parameters

Text parameters refer to any input that consists of text, such as words, phrases, and sentences. Text parameters are typically used when working with text-based data, such as names, addresses, and descriptions.

When using text parameters, it’s important to consider how the input data might be formatted. For example, if you’re working with names, you may want to account for cases where the first and last names are separated by a comma or middle initial.

Number Parameters

Number parameters refer to any input consisting of a numerical value. This could include integers, decimals, or percentages. Number parameters are commonly used when working with financial data, such as sales figures or budgets.

When working with number parameters, it’s important to consider how the data is formatted. For example, you may need to account for currency symbols or decimal points. Additionally, you may need to convert data from one unit of measurement to another, such as from pounds to kilograms.

Any Parameters

Any parameters refer to inputs that can be either text or numeric. This is the most flexible parameter type, as it can accommodate a wide range of data types.

When using any parameters, it’s important to consider the potential for ambiguous data. For example, if you’re working with a column that could contain either text or numbers, you may need to specify how the data should be interpreted.

Additional Parameter Types

In addition to the three main parameter types, there are several additional parameter types that can be used in M function code. Here’s a brief overview:

Logical Parameters

Logical parameters refer to inputs that represent a true or false value. This could include inputs such as “yes” or “no”, “true” or “false”, or “1” or “0”. Logical parameters are commonly used in functions such as IF statements.

Date/Time Parameters

Date/time parameters refer to inputs that represent a specific date or time. This could include inputs such as “January 1, 2021” or “12:00 PM”. Date/time parameters are commonly used when working with time-based data, such as sales figures over a certain period.

Duration Parameters

Duration parameters refer to inputs that represent a specific amount of time. This could include inputs such as “5 minutes” or “2 hours”. Duration parameters are commonly used when calculating time-based metrics, such as average response time.

List Parameters

List parameters refer to inputs that contain multiple values. This could include a list of names, a list of sales figures, or a list of dates. List parameters are commonly used when working with data that is organized into multiple values.

Understanding the different parameter types available in Power Query’s M function language can help you more effectively work with and manipulate data. Whether you’re working with text-based data, numerical data, or a combination of both, knowing which parameter type to use can help you achieve better results.

In summary, text parameters are best used for text-based data, number parameters are best used for numerical data, and any parameters are best used when the input data could be either text or numerical. Additionally, there are several other parameter types available, including logical, date/time, duration, and list parameters. By understanding which type of parameter to use in different situations, you can more effectively clean and shape your data in Power Query.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)