1. 程式人生 > >38 Power Query-背後的賢內助 M 語言

38 Power Query-背後的賢內助 M 語言

 

This topic applies to the Power Query Formula Language which can be used with Power Query and Power BI Desktop to build queries that mashup data. See the list of function categories.

About

The following tables describe the Power Query formula categories that can be used to manually create or modify queries. These formula functions can also be used in the Power BI Designer, in the Query view.

Constants

FunctionDescription
Returns the smallest possible number.
Returns 2.7182818284590451, the value of e up to 16 decimal digits.
Returns 3.1415926535897931, the value for Pi up to 16 decimal digits.

Information

FunctionDescription
Returns true if a value is Number.NaN.
Returns true if a value is an even number.
Returns true if a value is an odd number.

Conversion and formatting

FunctionDescription
Returns a number value from a text value.
Returns a text value from a number value.
Returns a number value from a value.
Returns a 8-bit integer number value from the given value.
Returns a signed 8-bit integer number value from the given value.
Returns a 16-bit integer number value from the given value.
Returns a 32-bit integer number value from the given value.
Returns a 64-bit integer number value from the given value.
Returns a Single number value from the given value.
Returns a Double number value from the given value.
Returns a decimal number value from the given value.
Returns a currency value from the given value.
Returns a percentage value from the given value.

Rounding

FunctionDescription
Returns the largest integer less than or equal to a number value.
Returns the larger integer greater than or equal to a number value.
Returns Number.RoundDown(x) when x >= 0 and Number.RoundUp(x) when x < 0.
Returns Number.RoundUp(value) when value >= 0 and Number.RoundDown(value) when value < 0.
Returns a nullable number (n) if value is an integer.

Operations

FunctionDescription
Returns the absolute value of a number.
Returns 1 for positive numbers, -1 for negative numbers or 0 for zero.
Divides two numbers and returns the whole part of the resulting number.
Divides two numbers and returns the remainder of the resulting number.
Returns a number raised by a power.
Returns the square root of a number.
Returns a number representing e raised to a power.
Returns the natural logarithm of a number.
Returns the logarithm of a number to the base.
Returns the base-10 logarithm of a number.
Returns the factorial of a number.
Returns the number of combinations of a given number of items for the optional combination size.
Returns the number of total permutatons of a given number of items for the optional permutation size.

Random

FunctionDescription
Returns a random fractional number between 0 and 1.
Returns a random number between the two given number values.

Trigonometry

FunctionDescription
Returns the arccosine of a number.
Returns the arcsine of a number.
Returns the arctangent of a number.
Returns the arctangent of the division of two numbers.
Returns the cosine of a number.
Returns the hyperbolic cosine of a number.
Returns the sine of a number.
Returns the hyperbolic sine of a number.
Returns the tangent of a number.
Returns the hyperbolic tangent of a number.

Bytes

FunctionDescription
Returns the result of a bitwise AND operation on the provided operands.
Returns the result of a bitwise NOT operation on the provided operands.
Returns the result of a bitwise OR operation on the provided operands.
Returns the result of a bitwise shift left operation on the operands.
Returns the result of a bitwise shift right operation on the operands.
Returns the result of a bitwise XOR operation on the provided operands.

Text

Information

FunctionDescription
Returns the number of characters in a text value.

Text Comparisons

FunctionDescription
Returns a number to its character value.
Returns a character to its number value.
Returns the text representation of a number, date, time, datetime, datetimezone, logical, duration or binary value. If a value is null, Text.From returns null. The optional culture parameter is used to format the text value according to the given culture.
Decodes data from a binary value in to a text value using an encoding.
Returns a Guid value as a text value.
Encodes a text value into binary value using an encoding.
Returns a list of characters from a text value.
Decodes a value from a textual representation, value, and interprets it as a value with an appropriate type. Value.FromText takes a text value and returns a number, a logical value, a null value, a DateTime value, a Duration value, or a text value. The empty text value is interpreted as a null value.

Extraction

FunctionDescription
Returns a character starting at a zero-based offset.
Returns a number of characters from a text value starting at a zero-based offset and for count number of characters.
Returns the count of characters from the start of a text value.
FunctionDescription
Returns the number of characters from the end of a text value.

Modification

FunctionDescription
Returns a text value with newValue inserted into a text value starting at a zero-based offset.
Removes all occurrences of a character or list of characters from a text value. The removeChars parameter can be a character value or a list of character values.
Removes count characters at a zero-based offset from a text value.
Replaces all occurrences of a substring with a new text value.
Replaces length characters in a text value starting at a zero-based offset with the new text value.

Membership

FunctionDescription
Returns true if a text value substring was found within a text value string; otherwise, false.
Returns a logical value indicating whether a text value substring was found at the end of a string.
Returns the first occurrence of substring in a string and returns its position starting at startOffset.
Returns the first occurrence of a text value in list and returns its position starting at startOffset.
Returns a logical value indicating whether a text value substring was found at the beginning of a string.

Transformations

FunctionDescription
Returns the original text value with non-printable characters removed.
Returns a text value that is the result of joining all text values with each value separated by a separator.
Returns the lowercase of a text value.