### DAX Example: Calculate Month Start Inventory Value Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/openingbalancemonth-function-dax.md An example DAX formula demonstrating how to use OPENINGBALANCEMONTH to calculate the 'Month Start Inventory Value' of product inventory. ```DAX = OPENINGBALANCEMONTH(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) ``` -------------------------------- ### List.DateTimes Example Output Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/list-datetimes.md Displays the resulting list of datetime values produced by the `List.DateTimes` function when executed with the specified `start`, `count`, and `step` parameters from the example. This output confirms the function's behavior. ```Power Query M { #datetime(2011, 12, 31, 23, 55, 0), #datetime(2011, 12, 31, 23, 56, 0), #datetime(2011, 12, 31, 23, 57, 0), #datetime(2011, 12, 31, 23, 58, 0), #datetime(2011, 12, 31, 23, 59, 0), #datetime(2012, 1, 1, 0, 0, 0), #datetime(2012, 1, 1, 0, 1, 0), #datetime(2012, 1, 1, 0, 2, 0), #datetime(2012, 1, 1, 0, 3, 0), #datetime(2012, 1, 1, 0, 4, 0) } ``` -------------------------------- ### Basic DAX Formula Examples Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/dax-syntax-reference.md Examples of valid DAX formulas demonstrating scalar constants, string literals, column references, arithmetic operations, and function calls. Each formula starts with an equal sign and evaluates to a scalar or an expression convertible to a scalar. ```DAX = 3 ``` ```DAX = "Sales" ``` ```DAX = 'Sales'[Amount] ``` ```DAX = (0.03 *[Amount]) ``` ```DAX =0.03 * [Amount] ``` ```DAX = PI() ``` -------------------------------- ### DAX START AT Parameters Reference Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/startat-statement-dax.md Details the parameters available for the START AT keyword in DAX, including their definitions and constraints. ```APIDOC START AT Parameters: value: Definition: A constant value. Cannot be an expression. parameter: Definition: The name of a parameter in an XMLA statement prefixed with an `@` character. ``` -------------------------------- ### Example: Getting Keys from a Table in Power Query M Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/table-keys.md Illustrates how to use the `Table.Keys` function in Power Query M. This example first creates a sample table, adds a primary key to it using `Table.AddKey`, and then retrieves the list of defined keys. The expected output is `{[Columns = {"Id"}, Primary = true]}`. ```powerquery-m let table = Table.FromRecords({ [Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"] }), tableWithKeys = Table.AddKey(table, {"Id"}, true), keys = Table.Keys(tableWithKeys) in keys ``` -------------------------------- ### DAX START AT Keyword Syntax Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/startat-statement-dax.md Defines the syntax for the START AT keyword used within an ORDER BY clause in DAX queries to specify the starting value for query results. ```dax [START AT {|} [, …]] ``` -------------------------------- ### DAX: START AT Clause Parameters Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/dax-queries.md Describes the parameters for the START AT clause in DAX, including 'value' for constant starting points and 'parameter' for XMLA statement parameters. ```APIDOC value: A constant value. Cannot be an expression. parameter: The name of a parameter in an XMLA statement prefixed with an '@' character. ``` -------------------------------- ### DAX: Filter Results with START AT in ORDER BY Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/dax-queries.md An example DAX query demonstrating the use of START AT within an ORDER BY clause to return sales order data starting from a specific order ID, excluding preceding rows. ```DAX EVALUATE 'Sales Order' ORDER BY 'Sales Order'[Sales Order] ASC // Start at this order, orders before this order will not be displayed START AT "SO43661" ``` -------------------------------- ### EOMONTH Example Calculation (DAX) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/eomonth-function-dax.md Demonstrates how to use the EOMONTH function with a specific start date and month offset, showing the rounding behavior of the `months` argument. ```DAX = EOMONTH("March 3, 2008",1.5) ``` -------------------------------- ### DAX: START AT Clause Syntax Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/dax-queries.md Defines the syntax for the optional START AT keyword, which is used within an ORDER BY clause to specify the starting value for query results. ```DAX EVALUATE [ORDER BY { [{ASC | DESC}]}[, …] [START AT {|} [, …]]] ``` -------------------------------- ### Pad Text Start with Default Spaces (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-padstart.md This example shows how to use `Text.PadStart` in Power Query M to pad the beginning of a text string with spaces. The function ensures the resulting string reaches a specified total length, using spaces as the default padding character. ```powerquery-m Text.PadStart("Name", 10) ``` -------------------------------- ### Split Text by Positions from Start Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/splitter-splittextbypositions.md This example demonstrates how to use `Splitter.SplitTextByPositions` to split an input string at specific character positions, starting the count from the beginning of the string. It shows the function's application and the resulting list of text segments. ```powerquery-m Splitter.SplitTextByPositions({0, 3, 4})("ABC|12345") ``` -------------------------------- ### Expected Output for List.Dates Example (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/list-dates.md Displays the resulting list of date values generated by the `List.Dates` function when provided with the specified start date, count, and daily step. ```powerquery-m { #date(2011, 12, 31), #date(2012, 1, 1), #date(2012, 1, 2), #date(2012, 1, 3), #date(2012, 1, 4) } ``` -------------------------------- ### Get Start of Week for a Date (Default Sunday) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-startofweek.md Demonstrates how to find the start of the week for a specific date and time using the default start of the week (Sunday). The example shows the input date and the resulting start of the week. ```powerquery-m Date.StartOfWeek(#datetime(2011, 10, 11, 8, 10, 32)) // Sunday, October 9th, 2011 #datetime(2011, 10, 9, 0, 0, 0) ``` -------------------------------- ### Get Start of Week with Custom First Day (Monday) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-startofweek.md Illustrates how to find the start of the week for a specific date and time, explicitly setting Monday as the first day of the week using `Day.Monday`. The example shows the input date and the resulting start of the week. ```powerquery-m Date.StartOfWeek(#datetime(2011, 10, 11, 8, 10, 32), Day.Monday) // Monday, October 10th, 2011 #datetime(2011, 10, 10, 0, 0, 0) ``` -------------------------------- ### Example: Converting a Record to a Table (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/record-totable.md Demonstrates how to apply the Record.ToTable function to a sample record, showing the input format for conversion. ```powerquery-m Record.ToTable([OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0]) ``` -------------------------------- ### Example: Convert Table to Record with Record.FromTable Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/record-fromtable.md Illustrates the practical usage of `Record.FromTable` to transform a table of key-value pairs into a structured record. The example shows how to construct the input table using `Table.FromRecords` with 'CustomerID', 'Name', and 'Phone' fields, and the resulting record output. ```powerquery-m Record.FromTable( Table.FromRecords({ [Name = "CustomerID", Value = 1], [Name = "Name", Value = "Bob"], [Name = "Phone", Value = "123-4567"] }) ) ``` -------------------------------- ### Get Start of Hour for a Datetime in Power Query M Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/time-startofhour.md Demonstrates how to use the `Time.StartOfHour` function to find the beginning of the hour for a specific datetime value in Power Query M. The example shows the input datetime and the resulting datetime at the start of that hour. ```powerquery-m Time.StartOfHour(#datetime(2011, 10, 10, 8, 10, 32)) ``` -------------------------------- ### Power Query M: Extract Substring with Start and Count Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-middle.md Demonstrates using `Text.Middle` in Power Query M to extract a substring of a specified length. This example shows how to get 5 characters starting from index 6 of "Hello World", resulting in "World". ```powerquery-m Text.Middle("Hello World", 6, 5) ``` -------------------------------- ### Simple DAX Formula Examples Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/dax-overview.md Illustrates basic DAX formulas for calculated columns, including inserting today's date, a static value, and performing arithmetic operations between columns. ```DAX = TODAY() ``` ```DAX = 3 ``` ```DAX = [Column1] + [Column2] ``` -------------------------------- ### Power Query M Example: Get Start of Quarter Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-startofquarter.md Demonstrates how to use Date.StartOfQuarter in Power Query M to find the beginning of the quarter for October 10th, 2011, 8:00AM. The function successfully identifies the start of the quarter as October 1st, 2011, returning `#datetime(2011, 10, 1, 0, 0, 0)`. ```Power Query M Date.StartOfQuarter(#datetime(2011, 10, 10, 8, 0, 0)) ``` -------------------------------- ### Example: Inferring ODBC Capabilities Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/odbc-inferoptions.md Illustrates how to call `Odbc.InferOptions` with a sample DSN to retrieve inferred SQL capabilities, demonstrating its basic usage. ```powerquery-m Odbc.InferOptions("dsn=your_dsn") ``` -------------------------------- ### DAX Example: Calculate Year Start Inventory Value Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/openingbalanceyear-function-dax.md This DAX formula creates a measure to calculate the 'Year Start Inventory Value' of product inventory. It uses SUMX to multiply UnitCost by UnitsBalance within the ProductInventory table and then applies OPENINGBALANCEYEAR to get the sum at the beginning of the year based on the DateTime[DateKey]. ```DAX = OPENINGBALANCEYEAR(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) ``` -------------------------------- ### Example: Retrieving Table Key Information (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/type-tablekeys.md Demonstrates how to use `Type.TableKeys` in Power Query M to obtain key information from a table type. This example first defines a base table type, then adds a primary key using `Type.AddTableKey`, and finally retrieves the details of the keys. ```powerquery-m let BaseType = type table [ID = number, Name = text], AddKey = Type.AddTableKey(BaseType, {"ID"}, true), DetailsOfKeys = Type.TableKeys(AddKey) in DetailsOfKeys // Expected Output: // {[Columns = {"ID"}, Primary = true]} ``` -------------------------------- ### Get Start of Year (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-functions.md Returns the start of the year. ```Power Query M Date.StartOfYear(dateTime as Date/DateTime/DateTimeZone) as datetime ``` -------------------------------- ### DAX SAMPLE Function API Reference Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/sample-function-dax.md Detailed API documentation for the DAX SAMPLE function, including definitions for its parameters, the expected return value, and important remarks for proper usage. ```APIDOC SAMPLE function parameters: n_value: Definition: The number of rows to return. It is any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). If a non-integer value (or expression) is entered, the result is cast as an integer. table: Definition: Any DAX expression that returns a table of data from where to extract the 'n' sample rows. orderBy_expression: Definition: Any scalar DAX expression where the result value is evaluated for each row of `table`. order: Definition: (Optional) A value that specifies how to sort `orderBy_expression` values, ascending or descending: 0 (zero), sorts in descending order of values of `order_by`. 1, ranks in ascending order of `order_by`. Return value: Type: Table Description: A table consisting of a sample of N rows of `table` or an empty table if `n_value` is 0 (zero) or less. Stability: If OrderBy arguments are provided, the sample will be stable and deterministic, returning the first row, the last row, and evenly distributed rows between them. If no ordering is specified, the sample will be random, not stable, and not deterministic. Remarks: - If `n_value` is 0 (zero) or less then SAMPLE returns an empty table. - In order to avoid duplicate values in the sample, the table provided as the second argument should be grouped by the column used for sorting. - Function not supported in DirectQuery mode. ``` -------------------------------- ### Get Start of Week (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-functions.md Returns the start of the week. ```Power Query M Date.StartOfWeek(dateTime as Date/DateTime/DateTimeZone) as datetime ``` -------------------------------- ### Perform a GET Request using WebAction.Request Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/webaction-request.md Illustrates how to use `WebAction.Request` to execute a simple HTTP GET request to a specified URL, demonstrating its basic usage and the resulting `Action` output. ```Power Query M WebAction.Request(WebMethod.Get, "https://bing.com") ``` -------------------------------- ### DAX BITAND Function Usage Example Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/bitand-function-dax.md Illustrates the usage of the DAX BITAND function with a practical example, showing how BITAND(13, 11) evaluates to 9. ```DAX EVALUATE { BITAND(13, 11) } ``` -------------------------------- ### Generate Email Addresses Using Text.Start Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-start.md Illustrates a practical application of Text.Start to create email addresses by combining initial characters from first and last names within a Power Query M table transformation. ```Power Query M let Source = #table(type table [First Name = text, Last Name = text], { {"Douglas", "Elis"}, {"Ana", "Jorayew"}, {"Rada", "Mihaylova"} }), EmailAddress = Table.AddColumn( Source, "Email Address", each Text.Combine({ Text.Start([First Name], 4), Text.Start([Last Name], 3), "@contoso.com" }) ) in EmailAddress ``` -------------------------------- ### Get Start of Quarter (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-functions.md Returns the start of the quarter. ```Power Query M Date.StartOfQuarter(dateTime as Date/DateTime/DateTimeZone) as datetime ``` -------------------------------- ### Get Start of Month (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-functions.md Returns the start of the month. ```Power Query M Date.StartOfMonth(dateTime as Date/DateTime/DateTimeZone) as datetime ``` -------------------------------- ### Get Start of Day (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-functions.md Returns the start of the day. ```Power Query M Date.StartOfDay(dateTime as Date/DateTime/DateTimeZone) as datetime ``` -------------------------------- ### Example: Retrieve Local XML File with Xml.Tables Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/xml-tables.md This example demonstrates how to use `Xml.Tables` to read and parse an XML file from a local path. It uses `File.Contents` to load the file, then `Xml.Tables` processes it into a table. ```M Xml.Tables(File.Contents("C:\\invoices.xml")) ``` -------------------------------- ### Table.PromoteHeaders Function API Documentation Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/table-promoteheaders.md Detailed API documentation for the `Table.PromoteHeaders` function, outlining its signature, parameters, and return type. It explains the optional `options` record, including `PromoteAllScalars` for promoting all scalar values and `Culture` for locale-specific formatting of headers. ```APIDOC Table.PromoteHeaders: Signature: Table.PromoteHeaders(table as table, optional options as nullable record) as table Parameters: table: table The input table whose first row is to be promoted to headers. options: nullable record (optional) A record of options to control header promotion. Options include: PromoteAllScalars: boolean If set to true, all scalar values in the first row are promoted to headers. For values not convertible to text, a default column name is used. Culture: string A culture name (e.g., "en-US") specifying the culture for data formatting during promotion. Returns: table A new table with the first row's values used as column headers. ``` -------------------------------- ### Pad Text Start with Custom Character (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-padstart.md This example demonstrates how to use `Text.PadStart` in Power Query M to pad the beginning of a text string with a custom character. It illustrates specifying a third argument to override the default space padding with a different character, such as '|'. ```powerquery-m Text.PadStart("Name", 10, "|") ``` -------------------------------- ### DAX Example: Calculate Quarter Start Inventory Value Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/openingbalancequarter-function-dax.md This example demonstrates how to use the OPENINGBALANCEQUARTER function in DAX to calculate the total inventory value at the beginning of a quarter. It sums the product of 'UnitCost' and 'UnitsBalance' from the 'ProductInventory' table, evaluated at the quarter's start date using 'DateTime[DateKey]'. ```DAX = OPENINGBALANCEQUARTER(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) ``` -------------------------------- ### Example: Calculate Product of List Elements (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/list-product.md Illustrates the practical application of the `List.Product` function in Power Query M by calculating the product of elements in a sample list `{1, 2, 3, 3, 4, 5, 5}`. The expected output is `1800`. ```powerquery-m List.Product({1, 2, 3, 3, 4, 5, 5}) ``` -------------------------------- ### Text.Start Function Syntax Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-start.md Defines the signature for the Text.Start function, specifying its parameters and return type. ```APIDOC Text.Start(text as nullable text, count as number) as nullable text ``` -------------------------------- ### M Language Delimited Comment Usage Example Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/m-spec-lexical-structure.md This example demonstrates a delimited comment in M, which starts with `/*` and ends with `*/`. Delimited comments can span multiple lines and are ignored by the M parser. ```powerquery-m /* Hello, world */ "Hello, world" ``` -------------------------------- ### Get Week of Year with Custom Start Day Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-weekofyear.md Determines the week number of the year for March 27th, 2011, explicitly setting Monday as the start of the week for calculation. ```Power Query M Date.WeekOfYear(#date(2011, 03, 27), Day.Monday) ``` -------------------------------- ### Partitioning a Table by Column using Hash Function (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/table-partition.md Demonstrates how to use `Table.Partition` to divide a sample table into two new tables based on the 'a' column, using the column's value as the hash function. Shows both the input usage and the resulting partitioned tables. ```powerquery-m Table.Partition( Table.FromRecords({ [a = 2, b = 4], [a = 1, b = 4], [a = 2, b = 4], [a = 1, b = 4] }), "a", 2, each _ ) ``` ```powerquery-m { Table.FromRecords({ [a = 2, b = 4], [a = 2, b = 4] }), Table.FromRecords({ [a = 1, b = 4], [a = 1, b = 4] }) } ``` -------------------------------- ### DAX STARTOFQUARTER Function Usage Example Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/startofquarter-function-dax.md An example demonstrating how to use the STARTOFQUARTER function within a DAX measure to retrieve the start of the quarter from a specified date column. ```DAX = STARTOFQUARTER(DateTime[DateKey]) ``` -------------------------------- ### Output: Reversed Table Example Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/table-reverserows.md Shows the expected output table after applying `Table.ReverseRows` to the input table from the previous example. The rows are now ordered in reverse, starting with CustomerID 4 and ending with CustomerID 1. ```Power Query M Table.FromRecords({ [CustomerID = 4, Name = "Ringo", Phone = "232-1550"], [CustomerID = 3, Name = "Paul", Phone = "543-7890"], [CustomerID = 2, Name = "Jim", Phone = "987-6543"], [CustomerID = 1, Name = "Bob", Phone = "123-4567"] }) ``` -------------------------------- ### DAX MID Function Literal String Example Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/mid-function-dax.md An example demonstrating the DAX MID function extracting a substring 'bcd' from the literal string 'abcde', starting at the second position for three characters. ```DAX MID("abcde",2,3)) ``` -------------------------------- ### Convert Contiguous Hexadecimal String to Guid Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/guid-from.md This example demonstrates how to use `Guid.From` to convert a 32-digit hexadecimal string without any separators into a standard GUID format. The function automatically inserts hyphens and converts to lowercase. ```powerquery-m Guid.From("05FE1DADC8C24F3BA4C2D194116B4967") ``` -------------------------------- ### AnalysisServices.Databases Function API Reference Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/analysisservices-databases.md Detailed API documentation for the `AnalysisServices.Databases` function, including its signature and a comprehensive list of optional parameters available in the `options` record, along with their types and descriptions. ```APIDOC AnalysisServices.Databases(server as text, optional options as nullable record) as table Parameters: server: text Description: The name of the Analysis Services instance server. options: nullable record (optional) Description: An optional record parameter to specify additional properties for the connection and query. Options Record Fields: TypedMeasureColumns: logical (default: false) Description: A logical value indicating if the types specified in the multidimensional or tabular model will be used for the types of the added measure columns. When set to false, the type "number" will be used for all measure columns. Culture: text Description: A culture name specifying the culture for the data. This corresponds to the 'Locale Identifier' connection string property. CommandTimeout: duration Description: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is driver-dependent. ConnectionTimeout: duration Description: A duration that controls how long to wait before abandoning an attempt to make a connection to the server. The default value is driver-dependent. SubQueries: number (0, 1 or 2) (default: 2) Description: A number (0, 1 or 2) that sets the value of the "SubQueries" property in the connection string. This controls the behavior of calculated members on subselects or subcubes. Implementation: any Description: (No specific description provided in the source text) ``` -------------------------------- ### DAX FIND Function Example Query Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/find-function-dax.md An example DAX query demonstrating the use of the FIND function within a CALCULATETABLE and ADDCOLUMNS expression. It finds the position of 'Bike' in reseller names, starting the search from the first character and returning BLANK() if not found. This example highlights FIND's case-sensitivity. ```DAX EVALUATE CALCULATETABLE ( ADDCOLUMNS ( TOPN ( 10, SUMMARIZE('Reseller', [Reseller], [Business Type])), "Position of Bike", FIND ( "Bike", 'Reseller'[Reseller], 1, BLANK () ) ), 'Reseller'[Business Type] IN { "Specialty Bike Shop", "Value Added Reseller", "Warehouse"} ) ``` -------------------------------- ### DAX QUOTIENT Function Usage Examples Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/quotient-function-dax.md Demonstrates practical applications of the DAX QUOTIENT function, showing how to use it with direct numerical inputs and nested expressions to achieve integer division. ```DAX = QUOTIENT(5,2) ``` ```DAX = QUOTIENT(10/2,2) ``` -------------------------------- ### DAX LOG10 Function Usage Examples Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/log10-function-dax.md Illustrative examples demonstrating how to use the LOG10 function in DAX, including its equivalence with the LOG function for base-10 calculations. ```DAX = LOG(100,10) = LOG(100) = LOG10(100) ``` -------------------------------- ### Power Query M Example: Get Number Column Names Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/table-columnsoftype.md Illustrates how to use `Table.ColumnsOfType` in Power Query M to filter columns by type. This example returns the names of columns that are of `Number.Type` from a sample table, resulting in `{"a"}`. ```powerquery-m Table.ColumnsOfType( Table.FromRecords( {[a = 1, b = "hello"]}, type table[a = Number.Type, b = Text.Type] ), {type number} ) ``` -------------------------------- ### DAX EARLIEST Function Basic Example Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/earliest-function-dax.md A simple example demonstrating the application of the EARLIEST function in a DAX expression. ```DAX = EARLIEST() ``` -------------------------------- ### Convert Parenthesized and Hyphenated Hexadecimal String to Guid Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/guid-from.md This example demonstrates `Guid.From` converting a 32-digit hexadecimal string enclosed in parentheses and separated by hyphens into a standard GUID format. The function successfully handles parenthesized input. ```powerquery-m Guid.From("(05FE1DAD-C8C2-4F3B-A4C2-D194116B4967)") ``` -------------------------------- ### Create a Basic Binary.View with Custom Length and Stream Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/binary-view.md Demonstrates how to create a Binary.View that overrides the default GetLength and GetStream behaviors. This example allows a custom length to be reported without accessing the underlying data and provides a specific binary stream, illustrating how handler functions can customize view behavior. The output of this code is Text.ToBinary("hello world!"). ```powerquery-m Binary.View( null, [ GetLength = () => 12, GetStream = () => Text.ToBinary("hello world!") ] ) ``` -------------------------------- ### Create Record from List of Values and Field Names (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/record-fromlist.md Demonstrates how to construct a record by providing a list of values and a corresponding list of text values for field names using `Record.FromList`. The output shows the resulting record with named fields. ```Power Query M Record.FromList({1, "Bob", "123-4567"}, {"CustomerID", "Name", "Phone"}) ``` -------------------------------- ### Convert Hyphenated Hexadecimal String to Guid Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/guid-from.md This example shows `Guid.From` converting a 32-digit hexadecimal string already separated by hyphens (8-4-4-4-12 blocks) into a standard GUID format. The function normalizes the case of the hexadecimal digits. ```powerquery-m Guid.From("05FE1DAD-C8C2-4F3B-A4C2-D194116B4967") ``` -------------------------------- ### DAX COMBINA Function Usage Examples Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/combina-function-dax.md Illustrates practical examples of using the DAX COMBINA function with different input values and their expected results, demonstrating how to calculate combinations with repetitions. ```DAX = COMBINA(4,3) = COMBINA(10,3) ``` -------------------------------- ### DAX REPT Function Example Output Table Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/rept-function-dax.md Shows an example output table demonstrating the results of applying the DAX REPT function to column values, illustrating how `[MyText]` is repeated `[MyNumber]` times. ```APIDOC MyText|MyNumber|CalculatedColumn1 Text|2|TextText Number|0|| 85|3|858585 ``` -------------------------------- ### Power Query M: Example Usage of Date.StartOfYear Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-startofyear.md Illustrates how to use the `Date.StartOfYear` function in Power Query M to determine the start of the year for a specific datetime. For example, for October 10th, 2011, 8:10:32AM, the function returns January 1st, 2011, 0:0:0. ```powerquery-m Date.StartOfYear(#datetime(2011, 10, 10, 8, 10, 32)) ``` -------------------------------- ### Extract Substring from Text at Offset (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-range.md Demonstrates how to use the Text.Range function to extract a substring from a given text starting at a specified character offset. This example extracts 'World' from 'Hello World' by starting at index 6. ```Power Query M Text.Range("Hello World", 6) ``` -------------------------------- ### AdoDotNet.Query Function Reference Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/adodotnet-query.md Detailed API documentation for the AdoDotNet.Query function, including its syntax, parameters, return type, and optional configuration properties. ```APIDOC AdoDotNet.Query(providerName as text, connectionString as any, query as text, optional options as nullable record) as table providerName: text connectionString: any (text or a record of property value pairs; property values can be text or number) query: text options: nullable record (optional) CommandTimeout: duration (controls how long the server-side query is allowed to run before it is canceled. Default: ten minutes.) SqlCompatibleWindowsAuth: logical (true/false) (determines whether to produce SQL Server-compatible connection string options for Windows authentication. Default: true.) ``` -------------------------------- ### Convert Braced and Hyphenated Hexadecimal String to Guid Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/guid-from.md This example illustrates using `Guid.From` to convert a 32-digit hexadecimal string enclosed in curly braces and separated by hyphens into a standard GUID format. The function correctly parses the braced input. ```powerquery-m Guid.From("{05FE1DAD-C8C2-4F3B-A4C2-D194116B4967}") ``` -------------------------------- ### DAX CALENDAR Function Example: Fixed Date Range Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/calendar-function-dax.md This example demonstrates how to use the CALENDAR function to generate a table of dates between a fixed start date (January 1st, 2015) and end date (December 31st, 2021). ```DAX = CALENDAR (DATE (2015, 1, 1), DATE (2021, 12, 31)) ``` -------------------------------- ### Create binary from list of numbers (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/sharpbinary.md Demonstrates how to create a binary value from a list of hexadecimal numbers using the #binary function in Power Query M. ```powerquery-m #binary({0x30, 0x31, 0x32}) ``` -------------------------------- ### PARTITIONBY Function API Reference (DAX) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/partitionby-function-dax.md Detailed API documentation for the DAX PARTITIONBY function, including parameters, return value, and usage remarks. ```APIDOC Function: PARTITIONBY (DAX) Syntax: PARTITIONBY ( [[, partitionBy_columnName [, …]]] ) Parameters: partitionBy_columnName (Optional) Type: Column Name Description: The name of an existing column to be used to partition the window function’s `relation`. RELATED() may also be used to refer to a column in a table related to `relation`. Return Value: None (This function does not return a value.) Remarks: This function can only be used within a window function expression. ``` -------------------------------- ### Check if text starts with substring (case-sensitive, true) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-startswith.md Illustrates the `Text.StartsWith` function checking if "Hello, World" starts with "Hello" using a case-sensitive comparison. This example correctly returns `true` as the substring matches the beginning of the text. ```powerquery-m Text.StartsWith("Hello, World", "Hello") ``` -------------------------------- ### DAX PMT Function Reference and Examples Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/pmt-function-dax.md Detailed documentation for the DAX PMT function, including its syntax, parameters, return value, important remarks, and practical usage examples for calculating loan payments or savings goals. ```APIDOC PMT Function (DAX) Syntax: PMT(, , [, [, ]]) Parameters: rate: The interest rate for the loan. nper: The total number of payments for the loan. pv: The present value, or the total amount that a series of future payments is worth now; also known as the principal. fv: (Optional) The future value, or a cash balance you want to attain after the last payment is made. If fv is omitted, it is assumed to be BLANK. type: (Optional) The number 0 or 1 which indicates when payments are due. If type is omitted, it is assumed to be 0. Accepted values for 'type': 0 or omitted: At the end of the period 1: At the beginning of the period Return Value: The amount of a single loan payment. Remarks: - The payment returned by PMT includes principal and interest but no taxes, reserve payments, or fees sometimes associated with loans. - Make sure that you are consistent about the units you use for specifying rate and nper. If you make monthly payments on a four-year loan at an annual interest rate of 12 percent, use 0.12/12 for rate and 4*12 for nper. If you make annual payments on the same loan, use 0.12 for rate and 4 for nper. - 'type' is rounded to the nearest integer. - An error is returned if: - 'nper < 1' - Tip: To find the total amount paid over the duration of the loan, multiply the returned PMT value by nper. - Not supported in DirectQuery mode. ``` ```DAX EVALUATE { PMT(0.08/12, 10, 10000, 0, 1) } ``` ```DAX EVALUATE { PMT(0.06/12, 18*12, 0, 50000) } ``` -------------------------------- ### DAX SUM Function Syntax Example Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/sum-function-dax.md Illustrates the basic syntax for using the DAX SUM function. ```DAX SUM() ``` -------------------------------- ### Extract Substring with Specified Length (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-range.md Illustrates using the Text.Range function to extract a substring with a defined length, starting from a specific offset. This example extracts 'World' (5 characters) from 'Hello World Hello' by starting at index 6. ```Power Query M Text.Range("Hello World Hello", 6, 5) ``` -------------------------------- ### Split Text by Overlapping Ranges (Start from Beginning) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/splitter-splittextbyranges.md Demonstrates how to use `Splitter.SplitTextByRanges` to split a string into parts based on a list of position and length pairs. This example shows how the function handles overlapping ranges and performs the split starting from the beginning of the input string. ```powerquery-m Splitter.SplitTextByRanges({{0, 4}, {2, 10}})("codelimiter") ``` -------------------------------- ### Extract URI Components with Uri.Parts (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/uri-parts.md Demonstrates how to use the `Uri.Parts` function to break down a simple absolute URI, "www.adventure-works.com", into its individual components such as scheme, host, and port. The output shows the structured record of these parts, including default values for unspecified components. ```Power Query M Uri.Parts("www.adventure-works.com") ``` -------------------------------- ### Example: Filtering Table Rows with Table.AlternateRows Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/table-alternaterows.md Demonstrates how to use `Table.AlternateRows` to filter a table. This example starts at the first row (offset 1), skips 1 value, and then keeps 1 value, effectively returning the first and third rows from the input table. ```Power Query M Table.AlternateRows( Table.FromRecords({ [CustomerID = 1, Name = "Bob", Phone = "123-4567"], [CustomerID = 2, Name = "Jim", Phone = "987-6543"], [CustomerID = 3, Name = "Paul", Phone = "543-7890"] }), 1, 1, 1 ) ``` ```Power Query M Table.FromRecords({ [CustomerID = 1, Name = "Bob", Phone = "123-4567"], [CustomerID = 3, Name = "Paul", Phone = "543-7890"] }) ``` -------------------------------- ### M Language: Examples of Parameter List Counts (Required, Optional) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/m-spec-functions.md This snippet demonstrates how to determine the number of required and optional parameters from different parameter list definitions in M. It shows examples ranging from no parameters to combinations of required and optional parameters, which are crucial for argument compatibility checks. ```powerquery-m () // Required = 0, Optional = 0 \n(x) // Required = 1, Optional = 0 \n(optional x) // Required = 0, Optional = 1 \n(x, optional y) // Required = 1, Optional = 1 ``` -------------------------------- ### DAX OPENINGBALANCEMONTH Function API Reference Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/openingbalancemonth-function-dax.md Detailed API documentation for the DAX OPENINGBALANCEMONTH function, including its syntax, parameters, return value, and important remarks. ```APIDOC OPENINGBALANCEMONTH(,[,]) Parameters: expression: An expression that returns a scalar value. dates: A column that contains dates. filter (optional): An expression that specifies a filter to apply to the current context. Return value: A scalar value that represents the expression evaluated at the first date of the month in the current context. Remarks: - The dates argument can be any of the following: - A reference to a date/time column. - A table expression that returns a single column of date/time values. - A Boolean expression that defines a single-column table of date/time values. - Constraints on Boolean expressions are described in the topic, CALCULATE function. - The filter expression has restrictions described in the topic, CALCULATE function. - Function not supported in DirectQuery mode. ``` -------------------------------- ### Check if text starts with substring (case-insensitive) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-startswith.md Shows how to perform a case-insensitive check using `Text.StartsWith` by providing `Comparer.OrdinalIgnoreCase` as the optional comparer. This example verifies if "Hello, World" starts with "hello", returning `true` despite the case difference. ```powerquery-m Text.StartsWith("Hello, World", "hello", Comparer.OrdinalIgnoreCase) ``` -------------------------------- ### Power Query M Example: Replacing Table Keys Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/table-replacekeys.md Demonstrates how to use `Table.ReplaceKeys` in Power Query M to replace the existing keys of a table. The example first creates a sample table, adds an initial primary key, and then replaces that key with a new definition. The output shows the resulting table after the key replacement operation. ```powerquery-m let table = Table.FromRecords({ [Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"] }), tableWithKeys = Table.AddKey(table, {"Id"}, true), resultTable = Table.ReplaceKeys(tableWithKeys, {[Columns = {"Id"}, Primary = false]}) in resultTable ``` ```powerquery-m Table.FromRecords({ [Id = 1, Name = "Hello There"], [Id = 2, Name = "Good Bye"] }) ``` -------------------------------- ### Power Query M: Get Difference of Two Lists (Example 2) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/list-difference.md Illustrates `List.Difference` when the first list's elements are all present in the second list. This example shows finding items in `{1, 2}` that do not appear in `{1, 2, 3}`, resulting in an empty list. ```powerquery-m List.Difference({1, 2}, {1, 2, 3}) ``` -------------------------------- ### Replace Rows in a Table Example (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/table-replacerows.md Illustrates how to use `Table.ReplaceRows` to replace three rows starting from the second row (offset 1) with two new records in a sample table. This example demonstrates the function's application with a list of records as input for replacement. ```powerquery-m Table.ReplaceRows( Table.FromRecords({ [Column1 = 1], [Column1 = 2], [Column1 = 3], [Column1 = 4], [Column1 = 5] }), 1, 3, {[Column1 = 6], [Column1 = 7]} ) ``` -------------------------------- ### Create binary from base 64 encoded text (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/sharpbinary.md Illustrates how to create a binary value from a base 64 encoded text string using the #binary function in Power Query M. ```powerquery-m #binary("1011") ``` -------------------------------- ### M Language Standard Library Usage Examples Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/m-spec-introduction.md These M language snippets demonstrate how to use predefined values and functions from the M standard library. The examples show accessing Euler's number (Number.E) and using the Text.PositionOf function to find the starting position of a substring within a text value. ```powerquery-m Number.E // Euler's number e (2.7182...) Text.PositionOf("Hello", "ll") // 2 ``` -------------------------------- ### Binary.Range Function API Documentation Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/binary-range.md Detailed API documentation for the Binary.Range function, including its syntax, parameters, and return type. ```APIDOC Binary.Range Function: Description: Returns a subset of the binary value beginning at a specified offset. Syntax: Binary.Range(binary as binary, offset as number, optional count as nullable number) as binary Parameters: binary (binary): The input binary value from which to extract a subset. offset (number): The zero-based starting position within the binary value. count (optional number): The maximum length of the subset to return. If omitted, the subset extends to the end of the binary value. Returns: (binary) A new binary value representing the extracted subset. ``` -------------------------------- ### Power Query M: Get Text Before First Delimiter Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-beforedelimiter.md This example demonstrates how to use `Text.BeforeDelimiter` to extract the substring before the first occurrence of a hyphen in '111-222-333', resulting in '111'. ```powerquery-m Text.BeforeDelimiter("111-222-333", "-") ``` -------------------------------- ### AdoDotNet.DataSource API Reference Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/adodotnet-datasource.md Detailed API documentation for the AdoDotNet.DataSource function, explaining its purpose, required and optional parameters, and the structure of the 'options' record with its configurable fields. ```APIDOC AdoDotNet.DataSource(providerName: text, connectionString: any, options: nullable record (optional)) Description: Returns the schema collection for the ADO.NET data source with provider name `providerName` and connection string `connectionString`. Parameters: providerName: Type: text Description: The name of the ADO.NET provider. connectionString: Type: any (text or record of property value pairs) Description: The connection string. Property values can be text or number. options (optional): Type: nullable record Description: An optional record parameter to specify additional properties. Fields: CommandTimeout: Type: duration Description: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. SqlCompatibleWindowsAuth: Type: logical (true/false) Description: A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. TypeMap: Description: (No description provided in source) Returns: table ``` -------------------------------- ### DAX SAMPLE Function Syntax Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/dax/sample-function-dax.md Provides the syntax for the DAX SAMPLE function, which returns a specified number of rows from a table based on optional ordering expressions. ```DAX SAMPLE(,
, , [[, , []]…]) ``` -------------------------------- ### Get Sign of Zero (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/number-sign.md Example demonstrating the use of Number.Sign to determine the sign of zero (0), which correctly returns 0. ```powerquery-m Number.Sign(0) ``` -------------------------------- ### Text.TrimStart Function Reference (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-trimstart.md Provides the syntax and detailed parameter descriptions for the `Text.TrimStart` function in Power Query M. This function removes leading characters from a given text, with an option to specify which characters to trim. ```APIDOC Text.TrimStart(text as nullable text, optional trim as any) as nullable text text: The text from which the leading characters are to be removed. trim: Overrides the whitespace characters that are trimmed by default. This parameter can either be a single character or a list of single characters. Each leading trim operation stops when a non-trimmed character is encountered. ``` -------------------------------- ### Get Week of Year for a Date Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/date-weekofyear.md Determines the week number of the year for a specific date (March 27th, 2011) using the default culture-dependent start of the week. ```Power Query M Date.WeekOfYear(#date(2011, 03, 27)) ``` -------------------------------- ### M Language Table Creation Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/m-spec-introduction.md Illustrates how to create a table in M using the standard `#table` function. Tables organize values into named columns and rows, as M does not provide a literal syntax for table creation. ```powerquery-m #table( {"A", "B"}, { {1, 2}, {3, 4} } ) ``` -------------------------------- ### Example Usage of List.ReplaceRange in Power Query M Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/list-replacerange.md This example demonstrates how to use `List.ReplaceRange` to replace a sub-range of elements in a list. It replaces three elements starting at index 2 (0-based) in the list `{1, 2, 7, 8, 9, 5}` with the elements `{3, 4}`, resulting in `{1, 2, 3, 4, 5}`. ```powerquery-m List.ReplaceRange({1, 2, 7, 8, 9, 5}, 2, 3, {3, 4}) ``` -------------------------------- ### Example: Reverse Rows in a Table Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/table-reverserows.md Demonstrates how to use `Table.ReverseRows` to reverse the order of rows in a sample table. The example constructs an in-memory table using `Table.FromRecords` and then applies the `Table.ReverseRows` function to it. ```Power Query M Table.ReverseRows( Table.FromRecords({ [CustomerID = 1, Name = "Bob", Phone = "123-4567"], [CustomerID = 2, Name = "Jim", Phone = "987-6543"], [CustomerID = 3, Name = "Paul", Phone = "543-7890"], [CustomerID = 4, Name = "Ringo", Phone = "232-1550"] }) ) ``` -------------------------------- ### Convert 'Hello World' to Character List (Power Query M) Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/text-tolist.md This example demonstrates how to use the Text.ToList function to convert the string "Hello World" into a list of its individual characters. The output is a list where each character, including spaces, is a separate element: ["H", "e", "l", "l", "o", " ", "W", "o", "r", "l", "d"]. ```powerquery-m Text.ToList("Hello World") ``` -------------------------------- ### Example: Get Non-Nullable Type of Nullable Number Source: https://github.com/microsoftdocs/query-docs/blob/main/query-languages/m/type-nonnullable.md Illustrates how to use the Type.NonNullable function to derive the non-nullable type from a nullable number type, resulting in a simple number type. ```powerquery-m Type.NonNullable(type nullable number) ```