diff --git a/.openpublishing.build.ps1 b/.openpublishing.build.ps1 deleted file mode 100644 index aadef7620..000000000 --- a/.openpublishing.build.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -param( - [string]$buildCorePowershellUrl = "https://opbuildstorageprod.blob.core.windows.net/opps1container/.openpublishing.buildcore.ps1", - [string]$parameters -) -# Main -$errorActionPreference = 'Stop' - -# Step-1: Download buildcore script to local -echo "download build core script to local with source url: $buildCorePowershellUrl" -$repositoryRoot = Split-Path -Parent $MyInvocation.MyCommand.Definition -$buildCorePowershellDestination = "$repositoryRoot\.openpublishing.buildcore.ps1" -Invoke-WebRequest $buildCorePowershellUrl -OutFile "$buildCorePowershellDestination" - -# Step-2: Run build core -echo "run build core script with parameters: $parameters" -& "$buildCorePowershellDestination" "$parameters" -exit $LASTEXITCODE diff --git a/.openpublishing.publish.config.json b/.openpublishing.publish.config.json index e7f32c4ae..0b6863595 100644 --- a/.openpublishing.publish.config.json +++ b/.openpublishing.publish.config.json @@ -34,15 +34,14 @@ } ], "notification_subscribers": [ - "owend@microsoft.com" + "dougklo@microsoft.com" ], "sync_notification_subscribers": [ - "owend@microsoft.com" + "didocs@microsoft.com" ], "branches_to_filter": [], "git_repository_url_open_to_public_contributors": "https://github.com/MicrosoftDocs/query-docs", "git_repository_branch_open_to_public_contributors": "main", - "skip_source_output_uploading": false, "need_preview_pull_request": true, "dependent_repositories": [ { @@ -70,6 +69,7 @@ } }, "docs_build_engine": {}, + "skip_source_output_uploading": false, "contribution_branch_mappings": {}, "need_generate_pdf_url_template": true -} +} \ No newline at end of file diff --git a/.openpublishing.redirection.json b/.openpublishing.redirection.json index 744cbbfbf..5c085450a 100644 --- a/.openpublishing.redirection.json +++ b/.openpublishing.redirection.json @@ -39,6 +39,96 @@ "source_path": "query-languages/dax/pre-defined-numeric-formats-for-the-format-function.md", "redirect_url": "/dax/format-function-dax", "redirect_document_id": false + }, + { + "source_path": "query-languages/m/viewfunction-tryinvoke.md", + "redirect_url": "/m/function-values", + "redirect_document_id": false + }, + { + "source_path": "query-languages/m/table-onerror.md", + "redirect_url": "/m/function-values", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/crossfilter-function.md", + "redirect_url": "/dax/containsrow-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/datatable-function.md", + "redirect_url": "/dax/datatable-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/error-function.md", + "redirect_url": "/dax/error-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/generateseries-function.md", + "redirect_url": "/dax/generateseries-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/selectedvalue-function.md", + "redirect_url": "/dax/selectedvalue-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/treatas-function.md", + "redirect_url": "/dax/treatas-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/networkdays-dax.md", + "redirect_url": "/dax/networkdays-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/norm-dist-dax.md", + "redirect_url": "/dax/norm-dist-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/norm-inv-dax.md", + "redirect_url": "/dax/norm-inv-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/norm-s-dist-dax.md", + "redirect_url": "/dax/norm-s-dist-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/norm-s-inv-dax.md", + "redirect_url": "/dax/norm-s-inv-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/t-dist-2t-dax.md", + "redirect_url": "/dax/t-dist-2t-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/t-dist-dax.md", + "redirect_url": "/dax/t-dist-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/t-dist-rt-dax.md", + "redirect_url": "/dax/t-dist-rt-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/t-inv-2t-dax.md", + "redirect_url": "/dax/t-inv-2t-function-dax", + "redirect_document_id": false + }, + { + "source_path": "query-languages/dax/t-inv-dax.md", + "redirect_url": "/dax/t-inv-function-dax", + "redirect_document_id": false } ] } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..fae7d81fb --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# Contributing to Microsoft DAX and Power Query M Reference documentation + +## Providing feedback + +Whether you have a GitHub account or not, you can use the thumb up, thumb down icons at the top-right of most articles to rate and provide feedback. Your rating and feedback is anonymous. Feedback is reviewed and changes may be made based on your feedback, but no response is provided directly to you. + +## Editing in GitHub + +Refer to the [Microsoft Docs contributor guide](https://learn.microsoft.com/contribute) to learn more about using GitHub Editor and Git and markdown tools to submit a pull request (PR) for documentation changes. + +### DAX Reference + +The DAX Reference allows Quick edits by using the in-browser GitHub editor and more detailed edits by using Git and markdown tools. + +### Power Query M Reference + +The Power Query M function reference is primarily created through an automated process from in-product help. At this time, the Power Query M function reference does not have the edit (Pencil) Quick edits button at the top-right of the main frame of each page enabled. External contributions must be made by using the GitHub editor from the or by Git and markdown tools from the root of the query-docs repo. + +### Merge and publish process + +All contributions are thoroughly vetted and must meet strict technical accuracy and grammar requirements before being merged into the public repo. Once merged, it can still take several days for changes to be shown in live documentation. + +### Recognition + +If your changes are accepted, your GitHub account ID is shown as a contributor at the top of the article. + +## Code of Conduct + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). + +For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/), or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/README.md b/README.md index 0fc9c9709..0dc52b7e9 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ -# Microsoft Data Analysis Expressions (DAX) Power Query M language references +# Microsoft Data Analysis Expressions (DAX) Power Query M language references README -Welcome to the [DAX](/dax) and [Power Query M](powerquery-m) language references. Please review this README to learn more how you can contribute to documentation on the open-source Microsoft Docs platform. +Welcome to the DAX and Power Query M language references. Please review this README to learn more about how you can contribute to documentation on the open-source Microsoft Learn platform. -## Contributing to DAX and Power Query M reference documentation +## Contribute -Thanks for your interest in contributing to the DAX or Power Query M reference. Before getting started, be sure to review the [Microsoft Docs contributor guide](/contribute). - -All pull requests are reviewed for technical accuracy and applicability. +To learn about how you can help improve documentation, see [Contributing to Microsoft DAX and Power Query M Reference documentation](https://github.com/MicrosoftDocs/query-docs-pr/blob/main/CONTRIBUTING.md). ## Code of Conduct @@ -15,4 +13,4 @@ For more information, see the [Code of Conduct FAQ](https://opensource.microsoft ## License -Refer to [LICENSE](LICENSE), [LICENSE-CODE](LICENSE-CODE) and [ThirdPartyNotices](ThirdPartyNotices.md) for all Licensing information. \ No newline at end of file +Refer to [LICENSE](LICENSE), [LICENSE-CODE](LICENSE-CODE) and [ThirdPartyNotices](ThirdPartyNotices.md) for all Licensing information. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..e138ec5d6 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,41 @@ + + +## Security + +Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). + +If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). + +If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). + +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + + * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) + * Full paths of source file(s) related to the manifestation of the issue + * The location of the affected source code (tag/branch/commit or direct URL) + * Any special configuration required to reproduce the issue + * Step-by-step instructions to reproduce the issue + * Proof-of-concept or exploit code (if possible) + * Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. + +## Preferred Languages + +We prefer all communications to be in English. + +## Policy + +Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). + + diff --git a/ThirdPartyNotices b/ThirdPartyNotices.md similarity index 94% rename from ThirdPartyNotices rename to ThirdPartyNotices.md index faceb5a52..522940634 100644 --- a/ThirdPartyNotices +++ b/ThirdPartyNotices.md @@ -12,4 +12,4 @@ Microsoft's general trademark guidelines can be found at https://go.microsoft.co Privacy information can be found at https://privacy.microsoft.com/en-us/ Microsoft and any contributors reserve all others rights, whether under their respective copyrights, patents, -or trademarks, whether by implication, estoppel or otherwise. \ No newline at end of file +or trademarks, whether by implication, estoppel or otherwise. diff --git a/query-languages/dax/abs-function-dax.md b/query-languages/dax/abs-function-dax.md index 919b34f6f..b03009702 100644 --- a/query-languages/dax/abs-function-dax.md +++ b/query-languages/dax/abs-function-dax.md @@ -1,50 +1,43 @@ --- description: "Learn more about: ABS" -title: "ABS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/21/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ABS function (DAX) " --- # ABS -Returns the absolute value of a number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the absolute value of a number. + +## Syntax + ```dax -ABS() +ABS() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number for which you want the absolute value.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number for which you want the absolute value.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -The absolute value of a number is a decimal number, whole or decimal, without its sign. You can use the ABS function to ensure that only non-negative numbers are returned from expressions when nested in functions that require a positive number. - +The absolute value of a number is a decimal number, whole or decimal, without its sign. You can use the ABS function to ensure that only non-negative numbers are returned from expressions when nested in functions that require a positive number. + ## Example -The following example returns the absolute value of the difference between the list price and the dealer price, which you might use in a new calculated column, **DealerMarkup**. - +The following example returns the absolute value of the difference between the list price and the dealer price, which you might use in a new calculated column, **DealerMarkup**. + ```dax -= ABS([DealerPrice]-[ListPrice]) += ABS([DealerPrice]-[ListPrice]) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) -[SIGN function](sign-function-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[SIGN function](sign-function-dax.md) diff --git a/query-languages/dax/accrint-function-dax.md b/query-languages/dax/accrint-function-dax.md index cbc2e6d91..732f651d9 100644 --- a/query-languages/dax/accrint-function-dax.md +++ b/query-languages/dax/accrint-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: ACCRINT" -title: "ACCRINT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "ACCRINT function (DAX) " author: jajin7 -ms.author: owend -recommendations: false - --- # ACCRINT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the accrued interest for a security that pays periodic interest. ## Syntax @@ -24,20 +18,20 @@ ACCRINT(, , , , , [, - If calc_method evaluates to TRUE or is omitted, ACCRINT returns the total accrued interest from issue to settlement.
- If calc_method evaluates to FALSE, ACCRINT returns the accrued interest from first_interest to settlement.| +|Term|Definition| +|--------|--------------| +|`issue`|The security's issue date.| +|`first_interest`|The security's first interest date.| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`rate`|The security's annual coupon rate.| +|`par`|The security's par value.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|`calc_method`|(Optional) A logical value that specifies the way to calculate the total accrued interest when the date of settlement is later than the date of first_interest. If calc_method is omitted, it is assumed to be `TRUE`.
- If calc_method evaluates to `TRUE` or is omitted, ACCRINT returns the total accrued interest from issue to settlement.
- If calc_method evaluates to `FALSE`, ACCRINT returns the accrued interest from first_interest to settlement.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/accrintm-function-dax.md b/query-languages/dax/accrintm-function-dax.md index 579bbf6ce..dca535e1a 100644 --- a/query-languages/dax/accrintm-function-dax.md +++ b/query-languages/dax/accrintm-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: ACCRINTM" -title: "ACCRINTM function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "ACCRINTM function (DAX) " author: jajin7 -ms.author: owend -recommendations: false - --- # ACCRINTM +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the accrued interest for a security that pays interest at maturity. ## Syntax @@ -24,17 +18,17 @@ ACCRINTM(, , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|issue|The security's issue date.| -|maturity|The security's maturity date.| -|rate|The security's annual coupon rate.| -|par|The security's par value.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`issue`|The security's issue date.| +|`maturity`|The security's maturity date.| +|`rate`|The security's annual coupon rate.| +|`par`|The security's par value.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/acos-function-dax.md b/query-languages/dax/acos-function-dax.md index 89ea06947..769e2c1f9 100644 --- a/query-languages/dax/acos-function-dax.md +++ b/query-languages/dax/acos-function-dax.md @@ -1,43 +1,36 @@ --- description: "Learn more about: ACOS" -title: "ACOS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ACOS function (DAX)" --- # ACOS -Returns the arccosine, or inverse cosine, of a number. The arccosine is the angle whose cosine is *number*. The returned angle is given in radians in the range 0 (zero) to pi. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the arccosine, or inverse cosine, of a number. The arccosine is the angle whose cosine is`number`. The returned angle is given in radians in the range 0 (zero) to pi. + +## Syntax + ```dax -ACOS(number) +ACOS(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Number|The cosine of the angle you want and must be from -1 to 1.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Number`|The cosine of the angle you want and must be from -1 to 1.| + ## Return value -Returns the arccosine, or inverse cosine, of a number. - +Returns the arccosine, or inverse cosine, of a number. + ## Remarks -If you want to convert the result from radians to degrees, multiply it by 180/PI() or use the DEGREES function. - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= ACOS(-0.5)|Arccosine of -0.5 in radians, 2*pi/3.|2.094395102| -|= ACOS(-0.5)*180/PI()|Arccosine of -0.5 in degrees.|120| +If you want to convert the result from radians to degrees, multiply it by 180/PI() or use the DEGREES function. + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= ACOS(-0.5)`|Arccosine of -0.5 in radians, 2*pi/3.|2.094395102| +|`= ACOS(-0.5)*180/PI()`|Arccosine of -0.5 in degrees.|120| diff --git a/query-languages/dax/acosh-function-dax.md b/query-languages/dax/acosh-function-dax.md index bc187f1c3..484ff971f 100644 --- a/query-languages/dax/acosh-function-dax.md +++ b/query-languages/dax/acosh-function-dax.md @@ -1,44 +1,37 @@ --- description: "Learn more about: ACOSH" -title: "ACOSH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ACOSH function (DAX)" --- # ACOSH -Returns the inverse hyperbolic cosine of a number. The number must be greater than or equal to 1. The inverse hyperbolic cosine is the value whose hyperbolic cosine is *number*, so ACOSH(COSH(number)) equals number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the inverse hyperbolic cosine of a number. The number must be greater than or equal to 1. The inverse hyperbolic cosine is the value whose hyperbolic cosine is `number`, so ACOSH(COSH(number)) equals number. + +## Syntax + ```dax -ACOSH(number) +ACOSH(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Any real number equal to or greater than 1.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Any real number equal to or greater than 1.| + ## Return value -Returns the inverse hyperbolic cosine of a number. +Returns the inverse hyperbolic cosine of a number. ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= ACOSH(1)|Inverse hyperbolic cosine of 1.|0| -|= ACOSH(10)|Inverse hyperbolic cosine of 10.|2.993228| - + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= ACOSH(1)`|Inverse hyperbolic cosine of 1.|0| +|`= ACOSH(10)`|Inverse hyperbolic cosine of 10.|2.993228| + diff --git a/query-languages/dax/acot-function-dax.md b/query-languages/dax/acot-function-dax.md index c98574d21..e2d5bf7fa 100644 --- a/query-languages/dax/acot-function-dax.md +++ b/query-languages/dax/acot-function-dax.md @@ -1,32 +1,25 @@ --- description: "Learn more about: ACOT" -title: "ACOT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ACOT function (DAX)" --- # ACOT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the principal value of the arccotangent, or inverse cotangent of a number. - -## Syntax - + +## Syntax + ```dax -ACOT(number) +ACOT(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Number|The cosine of the angle you want. Must be a real number.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Number`|The cosine of the angle you want. Must be a real number.| + ## Return value -A single decimal value. +A single decimal value. diff --git a/query-languages/dax/acoth-function-dax.md b/query-languages/dax/acoth-function-dax.md index ee586448c..48b750842 100644 --- a/query-languages/dax/acoth-function-dax.md +++ b/query-languages/dax/acoth-function-dax.md @@ -1,35 +1,28 @@ --- description: "Learn more about: ACOTH" -title: "ACOTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/05/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ACOTH function (DAX)" --- # ACOTH +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the inverse hyperbolic cotangent of a number. - -## Syntax - + +## Syntax + ```dax -ACOTH(number) +ACOTH(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Number|The absolute value of Number must be greater than 1.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Number`|The absolute value of Number must be greater than 1.| + ## Return value -A single decimal value. +A single decimal value. ## Remarks diff --git a/query-languages/dax/addcolumns-function-dax.md b/query-languages/dax/addcolumns-function-dax.md index f0f7d64a5..9444d5693 100644 --- a/query-languages/dax/addcolumns-function-dax.md +++ b/query-languages/dax/addcolumns-function-dax.md @@ -1,57 +1,50 @@ --- description: "Learn more about: ADDCOLUMNS" -title: "ADDCOLUMNS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ADDCOLUMNS function (DAX)" --- # ADDCOLUMNS -Adds calculated columns to the given table or table expression. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Adds calculated columns to the given table or table expression. + +## Syntax + ```dax -ADDCOLUMNS(, , [, , ]…) +ADDCOLUMNS(
, , [, , ]…) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|Any DAX expression that returns a table of data.| -|name|The name given to the column, enclosed in double quotes. | -|expression|Any DAX expression that returns a scalar expression, evaluated for each row of *table*. | - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|Any DAX expression that returns a table of data.| +|`name`|The name given to the column, enclosed in double quotes. | +|`expression`|Any DAX expression that returns a scalar expression, evaluated for each row of `table`. | + ## Return value -A table with all its original columns and the added ones. +A table with all its original columns and the added ones. ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example returns an extended version of the Product Category table that includes total sales values from the reseller channel and the internet sales. - +The following example returns an extended version of the Product Category table that includes total sales values from the reseller channel and the internet sales. + ```dax -ADDCOLUMNS(ProductCategory, - , "Internet Sales", SUMX(RELATEDTABLE(InternetSales_USD), InternetSales_USD[SalesAmount_USD]) - , "Reseller Sales", SUMX(RELATEDTABLE(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD])) +ADDCOLUMNS(ProductCategory + , "Internet Sales", SUMX(RELATEDTABLE(InternetSales_USD), InternetSales_USD[SalesAmount_USD]) + , "Reseller Sales", SUMX(RELATEDTABLE(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD])) ``` -The following table shows a preview of the data as it would be received by any function expecting to receive a table: +The following table shows a preview of the data as it would be received by any function expecting to receive a table: -|ProductCategory[ProductCategoryName]|ProductCategory[ProductCategoryAlternateKey]|ProductCategory[ProductCategoryKey]|[Internet Sales]|[Reseller Sales]| -|-----|-----|-----|-----|-----| -|Bikes|1|1|25107749.77|63084675.04| -|Components|2|2||11205837.96| -|Clothing|3|3|306157.5829|1669943.267| -|Accessories|4|4|640920.1338|534301.9888| +|ProductCategory[ProductCategoryName]|ProductCategory[ProductCategoryAlternateKey]|ProductCategory[ProductCategoryKey]|[Internet Sales]|[Reseller Sales]| +|-----|-----|-----|-----|-----| +|Bikes|1|1|25107749.77|63084675.04| +|Components|2|2||11205837.96| +|Clothing|3|3|306157.5829|1669943.267| +|Accessories|4|4|640920.1338|534301.9888| diff --git a/query-languages/dax/addmissingitems-function-dax.md b/query-languages/dax/addmissingitems-function-dax.md index 4330d6e87..74382ede3 100644 --- a/query-languages/dax/addmissingitems-function-dax.md +++ b/query-languages/dax/addmissingitems-function-dax.md @@ -1,34 +1,27 @@ --- description: "Learn more about: ADDMISSINGITEMS" -title: "ADDMISSINGITEMS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 02/28/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ADDMISSINGITEMS function (DAX)" --- # ADDMISSINGITEMS +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Adds rows with empty values to a table returned by [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md). - -## Syntax - + +## Syntax + ```dax ADDMISSINGITEMS ( [ [, [, … ] ] ],
[, [, [] [, [, [] [, … ] ] ] ] ] ] ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|showAll_columnName| (Optional) A column for which to return items with no data for the measures used. If not specified, all columns are returned.| -|table|A SUMMARIZECOLUMNS table.| -|groupBy_columnName|(Optional) A column to group by in the supplied table argument.| -|filterTable|(Optional) A table expression that defines which rows are returned.| + +### Parameters + +|Term|Definition| +|--------|--------------| +|`showAll_columnName`| (Optional) A column for which to return items with no data for the measures used. If not specified, all columns are returned.| +|`table`|A SUMMARIZECOLUMNS table.| +|`groupBy_columnName`|(Optional) A column to group by in the supplied table argument.| +|`filterTable`|(Optional) A table expression that defines which rows are returned.| ## Return value diff --git a/query-languages/dax/aggregation-functions-dax.md b/query-languages/dax/aggregation-functions-dax.md index b12d5d3e0..484efc4c8 100644 --- a/query-languages/dax/aggregation-functions-dax.md +++ b/query-languages/dax/aggregation-functions-dax.md @@ -1,14 +1,6 @@ --- description: "Learn more about: Aggregation functions" -title: "Aggregation functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/07/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Aggregation functions (DAX)" --- # Aggregation functions @@ -18,12 +10,12 @@ Aggregation functions calculate a (scalar) value such as count, sum, average, mi |Function |Description | |---------|---------| -|[APPROXIMATEDISTINCTCOUNT](approximate-distinctcount-function-dax.md) | Returns the *approximate* number of rows that contain distinct values in a column. | +|[APPROXIMATEDISTINCTCOUNT](approximate-distinctcount-function-dax.md) | Returns an *estimated* count of unique values in a column. | |[AVERAGE](average-function-dax.md) | Returns the average (arithmetic mean) of all the numbers in a column. | |[AVERAGEA](averagea-function-dax.md) | Returns the average (arithmetic mean) of the values in a column. | |[AVERAGEX](averagex-function-dax.md) | Calculates the average (arithmetic mean) of a set of expressions evaluated over a table. | -|[COUNT](count-function-dax.md) | Counts the number of rows in the specified column that contain non-blank values. | -|[COUNTA](counta-function-dax.md) | Counts the number of rows in the specified column that contain non-blank values. | +|[COUNT](count-function-dax.md) | Counts the number of rows in the specified column that contain non-blank values. Does not support Boolean values. | +|[COUNTA](counta-function-dax.md) | Counts the number of rows in the specified column that contain non-blank values. Supports Boolean values. | |[COUNTAX](countax-function-dax.md) | Counts non-blank results when evaluating the result of an expression over a table. | |[COUNTBLANK](countblank-function-dax.md) | Counts the number of blank cells in a column. | |[COUNTROWS](countrows-function-dax.md) | Counts the number of rows in the specified table, or in a table defined by an expression. | diff --git a/query-languages/dax/all-function-dax.md b/query-languages/dax/all-function-dax.md index 9b31023e6..170ebe28f 100644 --- a/query-languages/dax/all-function-dax.md +++ b/query-languages/dax/all-function-dax.md @@ -1,146 +1,139 @@ --- description: "Learn more about: ALL" -title: "ALL function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/05/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ALL function (DAX)" --- # ALL -Returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. This function is useful for clearing filters and creating calculations on all the rows in a table. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. This function is useful for clearing filters and creating calculations on all the rows in a table. + +## Syntax + ```dax -ALL( [
| [, [, [,…]]]] ) +ALL( [
| [, [, [,…]]]] ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table that you want to clear filters on.| -|column|The column that you want to clear filters on.| - -The argument to the ALL function must be either a reference to a base table or a reference to a base column. You cannot use table expressions or column expressions with the ALL function. - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table that you want to clear filters on.| +|`column`|The column that you want to clear filters on.| + +The argument to the ALL function must be either a reference to a base table or a reference to a base column. You cannot use table expressions or column expressions with the ALL function. + ## Return value -The table or column with filters removed. - +The table or column with filters removed. + ## Remarks -- This function is not used by itself, but serves as an intermediate function that can be used to change the set of results over which some other calculation is performed. +- This function is not used by itself, but serves as an intermediate function that can be used to change the set of results over which some other calculation is performed. -- The normal behavior for DAX expressions containing the ALL() function is that any filters applied will be ignored. However, there are some scenarios where this is not the case because of *auto-exist*, a DAX technology that optimizes filtering in order to reduce the amount of processing required for certain DAX queries. An example where auto-exist and ALL() provide unexpected results is when filtering on two or more columns of the same table (like when using slicers), and there is a measure on that same table that uses ALL(). In this case, auto-exist will *merge* the multiple filters into one and will only filter on existing combinations of values. Because of this merge, the measure will be calculated on the existing combinations of values and the result will be based on filtered values instead of all values as expected. To learn more about auto-exist and its effect on calculations, see Microsoft MVP Alberto Ferrari's [Understanding DAX Auto-Exist](https://www.sqlbi.com/articles/understanding-dax-auto-exist/) article on :::no-loc text="sql.bi.com":::. - -- The following table describes how you can use the ALL and ALLEXCEPT functions in different scenarios. - - |Function and usage|Description| - |----------------------|---------------| +- The normal behavior for DAX expressions containing the ALL() function is that any filters applied will be ignored. However, there are some scenarios where this is not the case because of `auto-exist`, a DAX technology that optimizes filtering in order to reduce the amount of processing required for certain DAX queries. An example where auto-exist and ALL() provide unexpected results is when filtering on two or more columns of the same table (like when using slicers), and there is a measure on that same table that uses ALL(). In this case, auto-exist will *merge* the multiple filters into one and will only filter on existing combinations of values. Because of this merge, the measure will be calculated on the existing combinations of values and the result will be based on filtered values instead of all values as expected. To learn more about auto-exist and its effect on calculations, see Microsoft MVP Alberto Ferrari's [Understanding DAX Auto-Exist](https://www.sqlbi.com/articles/understanding-dax-auto-exist/) article on :::no-loc text="sql.bi.com":::. + +- The following table describes how you can use the ALL and ALLEXCEPT functions in different scenarios. + + |Function and usage|Description| + |----------------------|---------------| |ALL()|Removes all filters everywhere. ALL() can only be used to clear filters but not to return a table.| - |ALL(Table)|Removes all filters from the specified table. In effect, ALL(Table) returns all of the values in the table, removing any filters from the context that otherwise might have been applied. This function is useful when you are working with many levels of grouping, and want to create a calculation that creates a ratio of an aggregated value to the total value. The first example demonstrates this scenario.| - |ALL (Column[, Column[, …]])|Removes all filters from the specified columns in the table; all other filters on other columns in the table still apply. All column arguments must come from the same table. The ALL(Column) variant is useful when you want to remove the context filters for one or more specific columns and to keep all other context filters. The second and third examples demonstrate this scenario.| - |ALLEXCEPT(Table, Column1 [,Column2]...)|Removes all context filters in the table except filters that are applied to the specified columns. This is a convenient shortcut for situations in which you want to remove the filters on many, but not all, columns in a table.| + |ALL(Table)|Removes all filters from the specified table. In effect, ALL(Table) returns all of the values in the table, removing any filters from the context that otherwise might have been applied. This function is useful when you are working with many levels of grouping, and want to create a calculation that creates a ratio of an aggregated value to the total value. The first example demonstrates this scenario.| + |ALL (Column[, Column[, …]])|Removes all filters from the specified columns in the table; all other filters on other columns in the table still apply. All column arguments must come from the same table. The ALL(Column) variant is useful when you want to remove the context filters for one or more specific columns and to keep all other context filters. The second and third examples demonstrate this scenario.| + |ALLEXCEPT(Table, Column1 [,Column2]...)|Removes all context filters in the table except filters that are applied to the specified columns. This is a convenient shortcut for situations in which you want to remove the filters on many, but not all, columns in a table.| - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example 1 -Calculate ratio of Category Sales to Total Sales - -Assume that you want to find the amount of sales for the current cell, in your PivotTable, divided by the total sales for all resellers. To ensure that the denominator is the same regardless of how the PivotTable user might be filtering or grouping the data, you define a formula that uses ALL to create the correct grand total. - -The following table shows the results when a new measure, **All Reseller Sales Ratio**, is created using the formula shown in the code section. To see how this works, add the field, CalendarYear, to the **Row Labels** area of the PivotTable, and add the field, ProductCategoryName, to the **Column Labels** area. Then, drag the measure, **All Reseller Sales Ratio**, to the **Values** area of the Pivot Table. To view the results as percentages, use the formatting features of Excel to apply a percentage number formatting to the cells that contains the measure. - -|Row Labels|Accessories|Bikes|Clothing|Components|Grand Total| -|----------------------|-----------------|----|----|----|----| -|2005|0.02%|9.10%|0.04%|0.75%|9.91%| -|2006|0.11%|24.71%|0.60%|4.48%|29.90%| -|2007|0.36%|31.71%|1.07%|6.79%|39.93%| -|2008|0.20%|16.95%|0.48%|2.63%|20.26%| -|Grand Total|0.70%|82.47%|2.18%|14.65%|100.00%| - +Calculate ratio of Category Sales to Total Sales + +Assume that you want to find the amount of sales for the current cell, in your PivotTable, divided by the total sales for all resellers. To ensure that the denominator is the same regardless of how the PivotTable user might be filtering or grouping the data, you define a formula that uses ALL to create the correct grand total. + +The following table shows the results when a new measure, **All Reseller Sales Ratio**, is created using the formula shown in the code section. To see how this works, add the field, CalendarYear, to the **Row Labels** area of the PivotTable, and add the field, ProductCategoryName, to the **Column Labels** area. Then, drag the measure, **All Reseller Sales Ratio**, to the **Values** area of the Pivot Table. To view the results as percentages, use the formatting features of Excel to apply a percentage number formatting to the cells that contains the measure. + +|Row Labels|Accessories|Bikes|Clothing|Components|Grand Total| +|----------------------|-----------------|----|----|----|----| +|2005|0.02%|9.10%|0.04%|0.75%|9.91%| +|2006|0.11%|24.71%|0.60%|4.48%|29.90%| +|2007|0.36%|31.71%|1.07%|6.79%|39.93%| +|2008|0.20%|16.95%|0.48%|2.63%|20.26%| +|Grand Total|0.70%|82.47%|2.18%|14.65%|100.00%| + **Formula** - + ```dax -= SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])/SUMX(ALL(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD]) += SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])/SUMX(ALL(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD]) ``` -The formula is constructed as follows: - -1. The numerator, `SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])`, is the sum of the values in ResellerSales_USD[SalesAmount_USD] for the current cell in the PivotTable, with context filters applied on CalendarYear and ProductCategoryName. - -1. For the denominator, you start by specifying a table, ResellerSales_USD, and use the ALL function to remove all context filters on the table. - -1. You then use the SUMX function to sum the values in the ResellerSales_USD[SalesAmount_USD] column. In other words, you get the sum of ResellerSales_USD[SalesAmount_USD] for all resellers sales. - +The formula is constructed as follows: + +1. The numerator, `SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])`, is the sum of the values in ResellerSales_USD[SalesAmount_USD] for the current cell in the PivotTable, with context filters applied on CalendarYear and ProductCategoryName. + +1. For the denominator, you start by specifying a table, ResellerSales_USD, and use the ALL function to remove all context filters on the table. + +1. You then use the SUMX function to sum the values in the ResellerSales_USD[SalesAmount_USD] column. In other words, you get the sum of ResellerSales_USD[SalesAmount_USD] for all resellers sales. + ## Example 2 Calculate Ratio of Product Sales to Total Sales Through Current Year -Assume that you want to create a table showing the percentage of sales compared over the years for each product category (ProductCategoryName). To obtain the percentage for each year over each value of ProductCategoryName, you need to divide the sum of sales for that particular year and product category by the sum of sales for the same product category over all years. In other words, you want to keep the filter on ProductCategoryName but remove the filter on the year when calculating the denominator of the percentage. - -The following table shows the results when a new measure, **Reseller Sales Year**, is created using the formula shown in the code section. To see how this works, add the field, CalendarYear, to the **Row Labels** area of a PivotTable, and add the field, ProductCategoryName, to the **Column Labels** area. To view the results as percentages, use Excel's formatting features to apply a percentage number format to the cells containing the measure, **Reseller Sales Year**. - -|Row labels|Accessories|Bikes|Clothing|Components|Grand Total| -|-----------------------|-----------------|----|----|----|----| -|2005|3.48%|11.03%|1.91%|5.12%|9.91%| -|2006|16.21%|29.96%|27.29%|30.59%|29.90%| -|2007|51.62%|38.45%|48.86%|46.36%|39.93%| -|2008|28.69%|20.56%|21.95%|17.92%|20.26%| -|Grand Total|100.00%|100.00%|100.00%|100.00%|100.00%| +Assume that you want to create a table showing the percentage of sales compared over the years for each product category (ProductCategoryName). To obtain the percentage for each year over each value of ProductCategoryName, you need to divide the sum of sales for that particular year and product category by the sum of sales for the same product category over all years. In other words, you want to keep the filter on ProductCategoryName but remove the filter on the year when calculating the denominator of the percentage. + +The following table shows the results when a new measure, **Reseller Sales Year**, is created using the formula shown in the code section. To see how this works, add the field, CalendarYear, to the **Row Labels** area of a PivotTable, and add the field, ProductCategoryName, to the **Column Labels** area. To view the results as percentages, use Excel's formatting features to apply a percentage number format to the cells containing the measure, **Reseller Sales Year**. + +|Row labels|Accessories|Bikes|Clothing|Components|Grand Total| +|-----------------------|-----------------|----|----|----|----| +|2005|3.48%|11.03%|1.91%|5.12%|9.91%| +|2006|16.21%|29.96%|27.29%|30.59%|29.90%| +|2007|51.62%|38.45%|48.86%|46.36%|39.93%| +|2008|28.69%|20.56%|21.95%|17.92%|20.26%| +|Grand Total|100.00%|100.00%|100.00%|100.00%|100.00%| **Formula** ```dax -= SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])/CALCULATE( SUM( ResellerSales_USD[SalesAmount_USD]), ALL(DateTime[CalendarYear])) += SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])/CALCULATE( SUM( ResellerSales_USD[SalesAmount_USD]), ALL(DateTime[CalendarYear])) ``` -The formula is constructed as follows: - -1. The numerator, `SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])`, is the sum of the values in ResellerSales_USD[SalesAmount_USD] for the current cell in the pivot table, with context filters applied on the columns CalendarYear and ProductCategoryName. - -1. For the denominator, you remove the existing filter on CalendarYear by using the ALL(Column) function. This calculates the sum over the remaining rows on the ResellerSales_USD table, after applying the existing context filters from the column labels. The net effect is that for the denominator the sum is calculated over the selected ProductCategoryName (the implied context filter) and for all values in Year. - +The formula is constructed as follows: + +1. The numerator, `SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])`, is the sum of the values in ResellerSales_USD[SalesAmount_USD] for the current cell in the pivot table, with context filters applied on the columns CalendarYear and ProductCategoryName. + +1. For the denominator, you remove the existing filter on CalendarYear by using the ALL(Column) function. This calculates the sum over the remaining rows on the ResellerSales_USD table, after applying the existing context filters from the column labels. The net effect is that for the denominator the sum is calculated over the selected ProductCategoryName (the implied context filter) and for all values in Year. + ## Example 3 Calculate Contribution of Product Categories to Total Sales Per Year - -Assume that you want to create a table that shows the percentage of sales for each product category, on a year-by-year basis. To obtain the percentage for each product category in a particular year, you need to calculate the sum of sales for that particular product category (ProductCategoryName) in year n, and then divide the resulting value by the sum of sales for the year n over all product categories. In other words, you want to keep the filter on year but remove the filter on ProductCategoryName when calculating the denominator of the percentage. - -The following table shows the results when a new measure, **Reseller Sales CategoryName**, is created using the formula shown in the code section. To see how this works, add the field, CalendarYear to the **Row Labels** area of the PivotTable, and add the field, ProductCategoryName, to the **Column Labels** area. Then add the new measure to the **Values** area of the PivotTable. To view the results as percentages, use Excel's formatting features to apply a percentage number format to the cells that contain the new measure, **Reseller Sales CategoryName**. - -|Row Labels|Accessories|Bikes|Clothing|Components|Grand Total| -|-------------------------------|-----------------|----|----|----|----| -|2005|0.25%|91.76%|0.42%|7.57%|100.00%| -|2006|0.38%|82.64%|1.99%|14.99%|100.00%| -|2007|0.90%|79.42%|2.67%|17.01%|100.00%| -|2008|0.99%|83.69%|2.37%|12.96%|100.00%| -|Grand Total|0.70%|82.47%|2.18%|14.65%|100.00%| - + +Assume that you want to create a table that shows the percentage of sales for each product category, on a year-by-year basis. To obtain the percentage for each product category in a particular year, you need to calculate the sum of sales for that particular product category (ProductCategoryName) in year n, and then divide the resulting value by the sum of sales for the year n over all product categories. In other words, you want to keep the filter on year but remove the filter on ProductCategoryName when calculating the denominator of the percentage. + +The following table shows the results when a new measure, **Reseller Sales CategoryName**, is created using the formula shown in the code section. To see how this works, add the field, CalendarYear to the **Row Labels** area of the PivotTable, and add the field, ProductCategoryName, to the **Column Labels** area. Then add the new measure to the **Values** area of the PivotTable. To view the results as percentages, use Excel's formatting features to apply a percentage number format to the cells that contain the new measure, **Reseller Sales CategoryName**. + +|Row Labels|Accessories|Bikes|Clothing|Components|Grand Total| +|-------------------------------|-----------------|----|----|----|----| +|2005|0.25%|91.76%|0.42%|7.57%|100.00%| +|2006|0.38%|82.64%|1.99%|14.99%|100.00%| +|2007|0.90%|79.42%|2.67%|17.01%|100.00%| +|2008|0.99%|83.69%|2.37%|12.96%|100.00%| +|Grand Total|0.70%|82.47%|2.18%|14.65%|100.00%| + **Formula** - + ```dax -= SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])/CALCULATE( SUM( ResellerSales_USD[SalesAmount_USD]), ALL(ProductCategory[ProductCategoryName])) += SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])/CALCULATE( SUM( ResellerSales_USD[SalesAmount_USD]), ALL(ProductCategory[ProductCategoryName])) ``` -The formula is constructed as follows: - -1. The numerator, `SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])`, is the sum of the values in ResellerSales_USD[SalesAmount_USD] for the current cell in the PivotTable, with context filters applied on the fields, CalendarYear and ProductCategoryName. - -1. For the denominator, you use the function, ALL(Column), to remove the filter on ProductCategoryName and calculate the sum over the remaining rows on the ResellerSales_USD table, after applying the existing context filters from the row labels. The net effect is that, for the denominator, the sum is calculated over the selected Year (the implied context filter) and for all values of ProductCategoryName. - -## See also - -[Filter functions](filter-functions-dax.md) -[ALL function](all-function-dax.md) -[ALLEXCEPT function](allexcept-function-dax.md) -[FILTER function](filter-function-dax.md) - +The formula is constructed as follows: + +1. The numerator, `SUMX(ResellerSales_USD, ResellerSales_USD[SalesAmount_USD])`, is the sum of the values in ResellerSales_USD[SalesAmount_USD] for the current cell in the PivotTable, with context filters applied on the fields, CalendarYear and ProductCategoryName. + +1. For the denominator, you use the function, ALL(Column), to remove the filter on ProductCategoryName and calculate the sum over the remaining rows on the ResellerSales_USD table, after applying the existing context filters from the row labels. The net effect is that, for the denominator, the sum is calculated over the selected Year (the implied context filter) and for all values of ProductCategoryName. + +## Related content + +[Filter functions](filter-functions-dax.md) +[ALL function](all-function-dax.md) +[ALLEXCEPT function](allexcept-function-dax.md) +[FILTER function](filter-function-dax.md) + diff --git a/query-languages/dax/allcrossfiltered-function-dax.md b/query-languages/dax/allcrossfiltered-function-dax.md index 78470bef8..aaa828a17 100644 --- a/query-languages/dax/allcrossfiltered-function-dax.md +++ b/query-languages/dax/allcrossfiltered-function-dax.md @@ -1,43 +1,36 @@ --- description: "Learn more about: ALLCROSSFILTERED" -title: "ALLCROSSFILTERED function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ALLCROSSFILTERED function (DAX)" --- # ALLCROSSFILTERED +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Clear all filters which are applied to a table. - -## Syntax - + +## Syntax + ```dax ALLCROSSFILTERED(
) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table that you want to clear filters on. | - -## Return value + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table that you want to clear filters on. | + +## Return value N/A. See remarks. - -## Remarks + +## Remarks - ALLCROSSFILTERED can only be used to clear filters but not to return a table. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example ```dax DEFINE diff --git a/query-languages/dax/allexcept-function-dax.md b/query-languages/dax/allexcept-function-dax.md index aaffb3298..f3b878268 100644 --- a/query-languages/dax/allexcept-function-dax.md +++ b/query-languages/dax/allexcept-function-dax.md @@ -1,65 +1,58 @@ --- description: "Learn more about: ALLEXCEPT" -title: "ALLEXCEPT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/30/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ALLEXCEPT function (DAX)" --- # ALLEXCEPT -Removes all context filters in the table except filters that have been applied to the specified columns. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Removes all context filters in the table except filters that have been applied to the specified columns. + +## Syntax + ```dax -ALLEXCEPT(
,[,[,…]]) +ALLEXCEPT(
,[,[,…]]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table over which all context filters are removed, except filters on those columns that are specified in subsequent arguments.| -|column|The column for which context filters must be preserved.| - -The first argument to the ALLEXCEPT function must be a reference to a base table. All subsequent arguments must be references to base columns. You cannot use table expressions or column expressions with the ALLEXCEPT function. - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table over which all context filters are removed, except filters on those columns that are specified in subsequent arguments.| +|`column`|The column for which context filters must be preserved.| + +The first argument to the ALLEXCEPT function must be a reference to a base table. All subsequent arguments must be references to base columns. You cannot use table expressions or column expressions with the ALLEXCEPT function. + ## Return value -A table with all filters removed except for the filters on the specified columns. - +A table with all filters removed except for the filters on the specified columns. + ## Remarks -- This function is not used by itself, but serves as an intermediate function that can be used to change the set of results over which some other calculation is performed. - -- ALL and ALLEXCEPT can be used in different scenarios: - - |Function and usage|Description| - |----------------------|---------------| - |ALL(Table)|Removes all filters from the specified table. In effect, ALL(Table) returns all of the values in the table, removing any filters from the context that otherwise might have been applied. This function is useful when you are working with many levels of grouping, and want to create a calculation that creates a ratio of an aggregated value to the total value.| - |ALL (Column[, Column[, …]])|Removes all filters from the specified columns in the table; all other filters on other columns in the table still apply. All column arguments must come from the same table. The ALL(Column) variant is useful when you want to remove the context filters for one or more specific columns and to keep all other context filters.| - |ALLEXCEPT(Table, Column1 [,Column2]...)|Removes all context filters in the table except filters that are applied to the specified columns. This is a convenient shortcut for situations in which you want to remove the filters on many, but not all, columns in a table.| +- This function is not used by itself, but serves as an intermediate function that can be used to change the set of results over which some other calculation is performed. + +- ALL and ALLEXCEPT can be used in different scenarios: + + |Function and usage|Description| + |----------------------|---------------| + |ALL(Table)|Removes all filters from the specified table. In effect, ALL(Table) returns all of the values in the table, removing any filters from the context that otherwise might have been applied. This function is useful when you are working with many levels of grouping, and want to create a calculation that creates a ratio of an aggregated value to the total value.| + |ALL (Column[, Column[, …]])|Removes all filters from the specified columns in the table; all other filters on other columns in the table still apply. All column arguments must come from the same table. The ALL(Column) variant is useful when you want to remove the context filters for one or more specific columns and to keep all other context filters.| + |ALLEXCEPT(Table, Column1 [,Column2]...)|Removes all context filters in the table except filters that are applied to the specified columns. This is a convenient shortcut for situations in which you want to remove the filters on many, but not all, columns in a table.| - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example - -The following measure formula sums SalesAmount_USD and uses the ALLEXCEPT function to remove any context filters on the DateTime table except if the filter has been applied to the CalendarYear column. - + +The following measure formula sums SalesAmount_USD and uses the ALLEXCEPT function to remove any context filters on the DateTime table except if the filter has been applied to the CalendarYear column. + ```dax -= CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]), ALLEXCEPT(DateTime, DateTime[CalendarYear])) += CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]), ALLEXCEPT(DateTime, DateTime[CalendarYear])) ``` Because the formula uses ALLEXCEPT, whenever any column but CalendarYear from the table DateTime is used to slice a visualization, the formula will remove any slicer filters, providing a value equal to the sum of SalesAmount_USD. However, if the column CalendarYear is used to slice the visualization, the results are different. Because CalendarYear is specified as the argument to ALLEXCEPT, when the data is sliced on the year, a filter will be applied on years at the row level - -## See also -[Filter functions](filter-functions-dax.md) -[ALL function](all-function-dax.md) -[FILTER function](filter-function-dax.md) +## Related content + +[Filter functions](filter-functions-dax.md) +[ALL function](all-function-dax.md) +[FILTER function](filter-function-dax.md) diff --git a/query-languages/dax/allnoblankrow-function-dax.md b/query-languages/dax/allnoblankrow-function-dax.md index 74b45c707..b3160520e 100644 --- a/query-languages/dax/allnoblankrow-function-dax.md +++ b/query-languages/dax/allnoblankrow-function-dax.md @@ -1,132 +1,126 @@ --- description: "Learn more about: ALLNOBLANKROW" -title: "ALLNOBLANKROW function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: "owend" - +title: "ALLNOBLANKROW function (DAX)" --- # ALLNOBLANKROW -From the parent table of a relationship, returns all rows but the blank row, or all distinct values of a column but the blank row, and disregards any context filters that might exist. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +From the parent table of a relationship, returns all rows but the blank row, or all distinct values of a column but the blank row, and disregards any context filters that might exist. + +## Syntax + ```dax ALLNOBLANKROW( {
| [, [, [,…]]]} ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table over which all context filters are removed.| -|column|A column over which all context filters are removed.| - -Only one parameter must be passed; the parameter is either a table or a column. - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table over which all context filters are removed.| +|`column`|A column over which all context filters are removed.| + +Only one parameter must be passed; the parameter is either a table or a column. + ## Return value -A table, when the passed parameter was a table, or a column of values, when the passed parameter was a column. - +A table, when the passed parameter was a table, or a column of values, when the passed parameter was a column. + ## Remarks -- The ALLNOBLANKROW function only filters the blank row that a parent table, in a relationship, will show when there are one or more rows in the child table that have non-matching values to the parent column. See the example below for a thorough explanation. - -- The following table summarizes the variations of ALL that are provided in DAX, and their differences: - - |Function and usage|Description| - |----------------------|---------------| - |ALL(Column)|Removes all filters from the specified column in the table; all other filters in the table, over other columns, still apply.| - |ALL(Table)|Removes all filters from the specified table.| - |ALLEXCEPT(Table,Col1,Col2...)|Overrides all context filters in the table except over the specified columns.| - |ALLNOBLANK(table|column)|From the parent table of a relationship, returns all rows but the blank row, or all distinct values of a column but the blank row, and disregards any context filters that might exist| +- The ALLNOBLANKROW function only filters the blank row that a parent table, in a relationship, will show when there are one or more rows in the child table that have non-matching values to the parent column. See the example below for a thorough explanation. - For a general description of how the ALL function works, together with step-by-step examples that use ALL(Table) and ALL(Column), see [ALL function](all-function-dax.md). +- The following table summarizes the variations of `ALL` that are provided in DAX, and their differences: + + |Function and usage|Description| + |----------------------|---------------| + |`ALL(Column)`|Removes all filters from the specified column in the table; all other filters in the table, over other columns, still apply.| + |`ALL(Table)`|Removes all filters from the specified table.| + |`ALLEXCEPT(Table,Col1,Col2...)`|Overrides all context filters in the table except over the specified columns.| + |`ALLNOBLANK(table|column)`| From the parent table of a relationship, returns all rows but the blank row, or all distinct values of a column but the blank row, and disregards any context filters that might exist| + + For a general description of how the ALL function works, together with step-by-step examples that use ALL(Table) and ALL(Column), see [ALL function](all-function-dax.md). - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -In the sample data, the ResellerSales_USD table contains one row that has no values and therefore cannot be related to any of the parent tables in the relationships within the workbook. You will use this table in a PivotTable so that you can see the blank row behavior and how to handle counts on unrelated data. - +In the sample data, the ResellerSales_USD table contains one row that has no values and therefore cannot be related to any of the parent tables in the relationships within the workbook. You will use this table in a PivotTable so that you can see the blank row behavior and how to handle counts on unrelated data. + Step 1: Verify the unrelated data - -Open the **Power Pivot window**, then select the ResellerSales_USD table. In the ProductKey column, filter for blank values. One row will remain. In that row, all column values should be blank except for SalesOrderLineNumber. - -Step 2: Create a PivotTable - -Create a new PivotTable, then drag the column, datetime.[Calendar Year], to the Row Labels pane. The following table shows the expected results: - -|Row Labels| -|--------------| -|2005| -|2006| -|2007| -|2008| -|| -|Grand Total| - -Note the blank label between **2008** and **Grand Total**. This blank label represents the Unknown member, which is a special group that is created to account for any values in the child table that have no matching value in the parent table, in this example the datetime.[Calendar Year] column. - -When you see this blank label in the PivotTable, you know that in some of the tables that are related to the column, datetime.[Calendar Year], there are either blank values or non-matching values. The parent table is the one that shows the blank label, but the rows that do not match are in one or more of the child tables. - -The rows that get added to this blank label group are either values that do not match any value in the parent table-- for example, a date that does not exist in the datetime table-- or null values, meaning no value for date at all. In this example we have placed a blank value in all columns of the child sales table. Having more values in the parent table than in the children tables does not cause a problem. - + +Open the **Power Pivot window**, then select the ResellerSales_USD table. In the ProductKey column, filter for blank values. One row will remain. In that row, all column values should be blank except for SalesOrderLineNumber. + +Step 2: Create a PivotTable + +Create a new PivotTable, then drag the column, datetime.[Calendar Year], to the Row Labels pane. The following table shows the expected results: + +|Row Labels| +|--------------| +|2005| +|2006| +|2007| +|2008| +|| +|Grand Total| + +Note the blank label between **2008** and **Grand Total**. This blank label represents the Unknown member, which is a special group that is created to account for any values in the child table that have no matching value in the parent table, in this example the datetime.[Calendar Year] column. + +When you see this blank label in the PivotTable, you know that in some of the tables that are related to the column, datetime.[Calendar Year], there are either blank values or non-matching values. The parent table is the one that shows the blank label, but the rows that do not match are in one or more of the child tables. + +The rows that get added to this blank label group are either values that do not match any value in the parent table-- for example, a date that does not exist in the datetime table-- or null values, meaning no value for date at all. In this example we have placed a blank value in all columns of the child sales table. Having more values in the parent table than in the children tables does not cause a problem. + Step 3: Count rows using ALL and ALLNOBLANK - -Add the following two measures to the datetime table, to count the table rows: **Countrows ALLNOBLANK of datetime**, **Countrows ALL of datetime**. The formulas that you can use to define these measures are: + +Add the following two measures to the datetime table, to count the table rows: **Countrows ALLNOBLANK of datetime**, **Countrows ALL of datetime**. The formulas that you can use to define these measures are: ```dax -// Countrows ALLNOBLANK of datetime -= COUNTROWS(ALLNOBLANKROW('DateTime')) - -// Countrows ALL of datetime -= COUNTROWS(ALL('DateTime')) - -// Countrows ALLNOBLANKROW of ResellerSales_USD -= COUNTROWS(ALLNOBLANKROW('ResellerSales_USD')) - -// Countrows ALL of ResellerSales_USD -= COUNTROWS(ALL('ResellerSales_USD')) +// Countrows ALLNOBLANK of datetime += COUNTROWS(ALLNOBLANKROW('DateTime')) + +// Countrows ALL of datetime += COUNTROWS(ALL('DateTime')) + +// Countrows ALLNOBLANKROW of ResellerSales_USD += COUNTROWS(ALLNOBLANKROW('ResellerSales_USD')) + +// Countrows ALL of ResellerSales_USD += COUNTROWS(ALL('ResellerSales_USD')) ``` - -On a blank PivotTable add datetime.[Calendar Year] column to the row labels, and then add the newly created measures. The results should look like the following table: - -|Row Labels|Countrows ALLNOBLANK of datetime|Countrows ALL of datetime| -|--------------|------------------------------------|-----------------------------| -|2005|1280|1281| -|2006|1280|1281| -|2007|1280|1281| -|2008|1280|1281| -||1280|1281| -|Grand Total|1280|1281| - -The results show a difference of 1 row in the table rows count. However, if you open the **Power Pivot window** and select the datetime table, you cannot find any blank row in the table because the special blank row mentioned here is the Unknown member. - + +On a blank PivotTable add datetime.[Calendar Year] column to the row labels, and then add the newly created measures. The results should look like the following table: + +|Row Labels|Countrows ALLNOBLANK of datetime|Countrows ALL of datetime| +|--------------|------------------------------------|-----------------------------| +|2005|1280|1281| +|2006|1280|1281| +|2007|1280|1281| +|2008|1280|1281| +||1280|1281| +|Grand Total|1280|1281| + +The results show a difference of 1 row in the table rows count. However, if you open the **Power Pivot window** and select the datetime table, you cannot find any blank row in the table because the special blank row mentioned here is the Unknown member. + Step 4: Verify that the count is accurate - -In order to prove that the ALLNOBLANKROW does not count any truly blank rows, and only handles the special blank row on the parent table only, add the following two measures to the ResellerSales_USD table: **Countrows ALLNOBLANKROW of ResellerSales_USD**, **Countrows ALL of ResellerSales_USD**. - -Create a new PivotTable, and drag the column, datetime.[Calendar Year], to the Row Labels pane. Now add the measures that you just created. The results should look like the following: - -|Row Labels|Countrows ALLNOBLANKROW of ResellerSales_USD|Countrows ALL of ResellerSales_USD| -|--------------|-------------------------------------------------|---------------------------------------| -|2005|60856|60856| -|2006|60856|60856| -|2007|60856|60856| -|2008|60856|60856| -||60856|60856| -|Grand Total|60856|60856| - -Now the two measures have the same results. That is because the ALLNOBLANKROW function does not count truly blank rows in a table, but only handles the blank row that is a special case generated in a parent table, when one or more of the child tables in the relationship contain non-matching values or blank values. - -## See also - -[Filter functions](filter-functions-dax.md) -[ALL function](all-function-dax.md) -[FILTER function](filter-function-dax.md) + +In order to prove that the ALLNOBLANKROW does not count any truly blank rows, and only handles the special blank row on the parent table only, add the following two measures to the ResellerSales_USD table: **Countrows ALLNOBLANKROW of ResellerSales_USD**, **Countrows ALL of ResellerSales_USD**. + +Create a new PivotTable, and drag the column, datetime.[Calendar Year], to the Row Labels pane. Now add the measures that you just created. The results should look like the following: + +|Row Labels|Countrows ALLNOBLANKROW of ResellerSales_USD|Countrows ALL of ResellerSales_USD| +|--------------|-------------------------------------------------|---------------------------------------| +|2005|60856|60856| +|2006|60856|60856| +|2007|60856|60856| +|2008|60856|60856| +||60856|60856| +|Grand Total|60856|60856| + +Now the two measures have the same results. That is because the ALLNOBLANKROW function does not count truly blank rows in a table, but only handles the blank row that is a special case generated in a parent table, when one or more of the child tables in the relationship contain non-matching values or blank values. + +## Related content + +[Filter functions](filter-functions-dax.md) +[ALL function](all-function-dax.md) +[FILTER function](filter-function-dax.md) diff --git a/query-languages/dax/allselected-function-dax.md b/query-languages/dax/allselected-function-dax.md index 8a66e3f42..3cdf95540 100644 --- a/query-languages/dax/allselected-function-dax.md +++ b/query-languages/dax/allselected-function-dax.md @@ -1,130 +1,123 @@ --- description: "Learn more about: ALLSELECTED" -title: "ALLSELECTED function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ALLSELECTED function (DAX)" --- # ALLSELECTED -Removes context filters from columns and rows in the current query, while retaining all other context filters or explicit filters. - -The ALLSELECTED function gets the context that represents all rows and columns in the query, while keeping explicit filters and contexts other than row and column filters. This function can be used to obtain visual totals in queries. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns all rows in a table, or all the values in a columns, ignoring any filters that might have been applied inside the query, but keeping filters that come from outside. + +The ALLSELECTED function gets the context that represents all rows and columns in the query, while keeping explicit filters and contexts other than row and column filters. This function can be used to obtain visual totals in queries. + +## Syntax + ```dax ALLSELECTED([ | [, [, [,…]]]] ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|tableName|The name of an existing table, using standard DAX syntax. This parameter cannot be an expression. This parameter is optional. | -|columnName|The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. This parameter is optional. | - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`tableName`|The name of an existing table, using standard DAX syntax. This parameter cannot be an expression. This parameter is optional. | +|`columnName`|The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. This parameter is optional. | + ## Return value -The context of the query without any column and row filters. - -## Remarks - -- If there is one argument, the argument is either *tableName* or *columnName*. If there is more than one argument, they must be columns from the same table. - -- This function is different from ALL() because it retains all filters explicitly set within the query, and it retains all context filters other than row and column filters. +The context of the query without any column and row filters. + +## Remarks + +- If there is one argument, the argument is either `tableName` or `columnName`. If there is more than one argument, they must be columns from the same table. + +- This function is different from ALL() because it retains all filters explicitly set within the query, and it retains all context filters other than row and column filters. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example shows how to generate different levels of visual totals in a table report using DAX expressions. In the report two (2) previous filters have been applied to the Reseller Sales data; one on Sales Territory Group = *Europe* and the other on Promotion Type = *Volume Discount*. Once filters have been applied, visual totals can be calculated for the entire report, for All Years, or for All Product Categories. Also, for illustration purposes the grand total for All Reseller Sales is obtained too, removing all filters in the report. Evaluating the following DAX expression results in a table with all the information needed to build a table with Visual Totals. - +The following example shows how to generate different levels of visual totals in a table report using DAX expressions. In the report two (2) previous filters have been applied to the Reseller Sales data; one on Sales Territory Group = *Europe* and the other on Promotion Type = *Volume Discount*. Once filters have been applied, visual totals can be calculated for the entire report, for All Years, or for All Product Categories. Also, for illustration purposes the grand total for All Reseller Sales is obtained too, removing all filters in the report. Evaluating the following DAX expression results in a table with all the information needed to build a table with Visual Totals. + ```dax -define -measure 'Reseller Sales'[Reseller Sales Amount]=sum('Reseller Sales'[Sales Amount]) -measure 'Reseller Sales'[Reseller Grand Total]=calculate(sum('Reseller Sales'[Sales Amount]), ALL('Reseller Sales')) -measure 'Reseller Sales'[Reseller Visual Total]=calculate(sum('Reseller Sales'[Sales Amount]), ALLSELECTED()) -measure 'Reseller Sales'[Reseller Visual Total for All of Calendar Year]=calculate(sum('Reseller Sales'[Sales Amount]), ALLSELECTED('Date'[Calendar Year])) -measure 'Reseller Sales'[Reseller Visual Total for All of Product Category Name]=calculate(sum('Reseller Sales'[Sales Amount]), ALLSELECTED('Product Category'[Product Category Name])) -evaluate -CalculateTable( - //CT table expression +define +measure 'Reseller Sales'[Reseller Sales Amount]=sum('Reseller Sales'[Sales Amount]) +measure 'Reseller Sales'[Reseller Grand Total]=calculate(sum('Reseller Sales'[Sales Amount]), ALL('Reseller Sales')) +measure 'Reseller Sales'[Reseller Visual Total]=calculate(sum('Reseller Sales'[Sales Amount]), ALLSELECTED()) +measure 'Reseller Sales'[Reseller Visual Total for All of Calendar Year]=calculate(sum('Reseller Sales'[Sales Amount]), ALLSELECTED('Date'[Calendar Year])) +measure 'Reseller Sales'[Reseller Visual Total for All of Product Category Name]=calculate(sum('Reseller Sales'[Sales Amount]), ALLSELECTED('Product Category'[Product Category Name])) +evaluate +CalculateTable( + //CT table expression summarize( -//summarize table expression -crossjoin(distinct('Product Category'[Product Category Name]), distinct('Date'[Calendar Year])) -//First Group by expression -, 'Product Category'[Product Category Name] -//Second Group by expression -, 'Date'[Calendar Year] -//Summary expressions -, "Reseller Sales Amount", [Reseller Sales Amount] -, "Reseller Grand Total", [Reseller Grand Total] -, "Reseller Visual Total", [Reseller Visual Total] -, "Reseller Visual Total for All of Calendar Year", [Reseller Visual Total for All of Calendar Year] -, "Reseller Visual Total for All of Product Category Name", [Reseller Visual Total for All of Product Category Name] -) -//CT filters -, 'Sales Territory'[Sales Territory Group]="Europe", 'Promotion'[Promotion Type]="Volume Discount" -) -order by [Product Category Name], [Calendar Year] +//summarize table expression +crossjoin(distinct('Product Category'[Product Category Name]), distinct('Date'[Calendar Year])) +//First Group by expression +, 'Product Category'[Product Category Name] +//Second Group by expression +, 'Date'[Calendar Year] +//Summary expressions +, "Reseller Sales Amount", [Reseller Sales Amount] +, "Reseller Grand Total", [Reseller Grand Total] +, "Reseller Visual Total", [Reseller Visual Total] +, "Reseller Visual Total for All of Calendar Year", [Reseller Visual Total for All of Calendar Year] +, "Reseller Visual Total for All of Product Category Name", [Reseller Visual Total for All of Product Category Name] +) +//CT filters +, 'Sales Territory'[Sales Territory Group]="Europe", 'Promotion'[Promotion Type]="Volume Discount" +) +order by [Product Category Name], [Calendar Year] ``` -After executing the above expression in SQL Server Management Studio against AdventureWorks DW Tabular Model, you obtain the following results: - -|[Product Category Name]|[Calendar Year]|[Reseller Sales Amount]|[Reseller Grand Total]|[Reseller Visual Total]|[Reseller Visual Total for All of Calendar Year]|[Reseller Visual Total for All of Product Category Name]| -|----------------------------|--------------------|----------------------------|---------------------------|----------------------------|-----------------------------------------------------|-------------------------------------------------------------| -|Accessories|2000||80450596.9823|877006.7987|38786.018|| -|Accessories|2001||80450596.9823|877006.7987|38786.018|| -|Accessories|2002|625.7933|80450596.9823|877006.7987|38786.018|91495.3104| -|Accessories|2003|26037.3132|80450596.9823|877006.7987|38786.018|572927.0136| -|Accessories|2004|12122.9115|80450596.9823|877006.7987|38786.018|212584.4747| -|Accessories|2005||80450596.9823|877006.7987|38786.018|| -|Accessories|2006||80450596.9823|877006.7987|38786.018|| -|Bikes|2000||80450596.9823|877006.7987|689287.7939|| -|Bikes|2001||80450596.9823|877006.7987|689287.7939|| -|Bikes|2002|73778.938|80450596.9823|877006.7987|689287.7939|91495.3104| -|Bikes|2003|439771.4136|80450596.9823|877006.7987|689287.7939|572927.0136| -|Bikes|2004|175737.4423|80450596.9823|877006.7987|689287.7939|212584.4747| -|Bikes|2005||80450596.9823|877006.7987|689287.7939|| -|Bikes|2006||80450596.9823|877006.7987|689287.7939|| -|Clothing|2000||80450596.9823|877006.7987|95090.7757|| -|Clothing|2001||80450596.9823|877006.7987|95090.7757|| -|Clothing|2002|12132.4334|80450596.9823|877006.7987|95090.7757|91495.3104| -|Clothing|2003|58234.2214|80450596.9823|877006.7987|95090.7757|572927.0136| -|Clothing|2004|24724.1209|80450596.9823|877006.7987|95090.7757|212584.4747| -|Clothing|2005||80450596.9823|877006.7987|95090.7757|| -|Clothing|2006||80450596.9823|877006.7987|95090.7757|| -|Components|2000||80450596.9823|877006.7987|53842.2111|| -|Components|2001||80450596.9823|877006.7987|53842.2111|| -|Components|2002|4958.1457|80450596.9823|877006.7987|53842.2111|91495.3104| -|Components|2003|48884.0654|80450596.9823|877006.7987|53842.2111|572927.0136| -|Components|2004||80450596.9823|877006.7987|53842.2111|212584.4747| -|Components|2005||80450596.9823|877006.7987|53842.2111|| -|Components|2006||80450596.9823|877006.7987|53842.2111|| - -The columns in the report are: - -Reseller Sales Amount -The actual value of Reseller Sales for the year and product category. This value appears in a cell in the center of your report, at the intersection of year and catergory. - -Reseller Visual Total for All of Calendar Year -The total value for a product category across all years. This value appears at the end of a column or row for a given product category and across all years in the report. - -Reseller Visual Total for All of Product Category Name -The total value for a year across all product categories. This value appears at the end of a column or row for a given year and across all product categories in the report. - -Reseller Visual Total -The total value for all years and product categories. This value usually appears in the bottom rightmost corner of the table. - -Reseller Grand Total -This is the grand total for all reseller sales, before any filter has been applied; you should notice the difference with [Reseller Visual Total]. You do remember that this report includes two (2) filters, one on Product Category Group and the other in Promotion Type. - +After executing the above expression in SQL Server Management Studio against AdventureWorks DW Tabular Model, you obtain the following results: + +|[Product Category Name]|[Calendar Year]|[Reseller Sales Amount]|[Reseller Grand Total]|[Reseller Visual Total]|[Reseller Visual Total for All of Calendar Year]|[Reseller Visual Total for All of Product Category Name]| +|----------------------------|--------------------|----------------------------|---------------------------|----------------------------|-----------------------------------------------------|-------------------------------------------------------------| +|Accessories|2000||80450596.9823|877006.7987|38786.018|| +|Accessories|2001||80450596.9823|877006.7987|38786.018|| +|Accessories|2002|625.7933|80450596.9823|877006.7987|38786.018|91495.3104| +|Accessories|2003|26037.3132|80450596.9823|877006.7987|38786.018|572927.0136| +|Accessories|2004|12122.9115|80450596.9823|877006.7987|38786.018|212584.4747| +|Accessories|2005||80450596.9823|877006.7987|38786.018|| +|Accessories|2006||80450596.9823|877006.7987|38786.018|| +|Bikes|2000||80450596.9823|877006.7987|689287.7939|| +|Bikes|2001||80450596.9823|877006.7987|689287.7939|| +|Bikes|2002|73778.938|80450596.9823|877006.7987|689287.7939|91495.3104| +|Bikes|2003|439771.4136|80450596.9823|877006.7987|689287.7939|572927.0136| +|Bikes|2004|175737.4423|80450596.9823|877006.7987|689287.7939|212584.4747| +|Bikes|2005||80450596.9823|877006.7987|689287.7939|| +|Bikes|2006||80450596.9823|877006.7987|689287.7939|| +|Clothing|2000||80450596.9823|877006.7987|95090.7757|| +|Clothing|2001||80450596.9823|877006.7987|95090.7757|| +|Clothing|2002|12132.4334|80450596.9823|877006.7987|95090.7757|91495.3104| +|Clothing|2003|58234.2214|80450596.9823|877006.7987|95090.7757|572927.0136| +|Clothing|2004|24724.1209|80450596.9823|877006.7987|95090.7757|212584.4747| +|Clothing|2005||80450596.9823|877006.7987|95090.7757|| +|Clothing|2006||80450596.9823|877006.7987|95090.7757|| +|Components|2000||80450596.9823|877006.7987|53842.2111|| +|Components|2001||80450596.9823|877006.7987|53842.2111|| +|Components|2002|4958.1457|80450596.9823|877006.7987|53842.2111|91495.3104| +|Components|2003|48884.0654|80450596.9823|877006.7987|53842.2111|572927.0136| +|Components|2004||80450596.9823|877006.7987|53842.2111|212584.4747| +|Components|2005||80450596.9823|877006.7987|53842.2111|| +|Components|2006||80450596.9823|877006.7987|53842.2111|| + +The columns in the report are: + +Reseller Sales Amount +The actual value of Reseller Sales for the year and product category. This value appears in a cell in the center of your report, at the intersection of year and catergory. + +Reseller Visual Total for All of Calendar Year +The total value for a product category across all years. This value appears at the end of a column or row for a given product category and across all years in the report. + +Reseller Visual Total for All of Product Category Name +The total value for a year across all product categories. This value appears at the end of a column or row for a given year and across all product categories in the report. + +Reseller Visual Total +The total value for all years and product categories. This value usually appears in the bottom rightmost corner of the table. + +Reseller Grand Total +This is the grand total for all reseller sales, before any filter has been applied; you should notice the difference with [Reseller Visual Total]. You do remember that this report includes two (2) filters, one on Product Category Group and the other in Promotion Type. + > [!NOTE] -> if you have explicit filters in your expression, those filters are also applied to the expression. +> if you have explicit filters in your expression, those filters are also applied to the expression. diff --git a/query-languages/dax/allselectedapply-function-dax.md b/query-languages/dax/allselectedapply-function-dax.md new file mode 100644 index 000000000..fb2d5e704 --- /dev/null +++ b/query-languages/dax/allselectedapply-function-dax.md @@ -0,0 +1,37 @@ +--- +description: "Learn more about: ALLSELECTEDAPPLY" +title: "ALLSELECTEDAPPLY function (DAX) | Microsoft Docs" +--- +# ALLSELECTEDAPPLY + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Modifies how filters are applied while evaluating a GROUPCROSSAPPLY or GROUPCROSSAPPLYTABLE function. + +## Syntax + +```dax +ALLSELECTEDAPPLY(
) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|table expression|Any table expression.| + +## Return value + +A table of values. + +## Remarks + +- You use ALLSELECTEDAPPLY within the context GROUPCROSSAPPLY and GROUPCROSSAPPLYTABLE functions, to override the standard behavior of those functions. + +- When a filter is specified as ALLSELECTEDAPPLY, it is initially hidden in the filter context. Upon an ALLSELECTED inside CALCULATE or CALCULATETABLE, this table expression is enabled in fliter context. + +## Related content + +[Filter functions](filter-functions-dax.md) +[GROUPCROSSAPPLY function](groupcrossapply-function-dax.md) +[GROUPCROSSAPPLYTABLE function](groupcrossapplytable-function-dax.md) diff --git a/query-languages/dax/allselectedremove-function-dax.md b/query-languages/dax/allselectedremove-function-dax.md new file mode 100644 index 000000000..b052bb795 --- /dev/null +++ b/query-languages/dax/allselectedremove-function-dax.md @@ -0,0 +1,40 @@ +--- +description: "Learn more about: ALLSELECTEDREMOVE" +title: "ALLSELECTEDREMOVE function (DAX) | Microsoft Docs" +--- +# ALLSELECTEDREMOVE + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Modifies how filters are applied while evaluating a GROUPCROSSAPPLY or GROUPCROSSAPPLYTABLE function. + +## Syntax + +```dax +ALLSELECTEDREMOVE(
[, [, [,…]]]) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|table expression|Any table expression.| +|column|Column in the table expression.| + +## Return value + +A table of values. + +## Remarks + +- You use ALLSELECTEDREMOVE within the context GROUPCROSSAPPLY and GROUPCROSSAPPLYTABLE functions, to override the standard behavior of those functions. + +- When doing ALLSELECTED on a column that appears on the list of ALLSELECTEDREMOVE column parameter, then this column from this table expression will not participate in the filter context. The same column from other table expression in the filter context is not changed. + +- It is possible to specify a subset of columns of the table expression. When no column is supplied, then it's equivalent to supplying all columns of the table expression to ALLSELECTEDREMOVE + +## Related content + +[Filter functions](filter-functions-dax.md) +[GROUPCROSSAPPLY function](groupcrossapply-function-dax.md) +[GROUPCROSSAPPLYTABLE function](groupcrossapplytable-function-dax.md) diff --git a/query-languages/dax/alwaysapply-function-dax.md b/query-languages/dax/alwaysapply-function-dax.md new file mode 100644 index 000000000..9c93f3efb --- /dev/null +++ b/query-languages/dax/alwaysapply-function-dax.md @@ -0,0 +1,37 @@ +--- +description: "Learn more about: ALWAYSAPPLY" +title: "ALWAYSAPPLY function (DAX) | Microsoft Docs" +--- +# ALWAYSAPPLY + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Modifies how filters are applied while evaluating a GROUPCROSSAPPLY or GROUPCROSSAPPLYTABLE function. + +## Syntax + +```dax +ALWAYSAPPLY(
) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|table expression|Any table expression.| + +## Return value + +A table of values. + +## Remarks + +- You use ALWAYSAPPLY within the context GROUPCROSSAPPLY and GROUPCROSSAPPLYTABLE functions, to override the standard behavior of those functions. + +- By default, a value filter does not affect measure if it doesn't change filter context. This behavior can be controlled by ALWAYSAPPLY function so that an empty table can still affect measure even if it doesn't change filter context. + +## Related content + +[Filter functions](filter-functions-dax.md) +[GROUPCROSSAPPLY function](groupcrossapply-function-dax.md) +[GROUPCROSSAPPLYTABLE function](groupcrossapplytable-function-dax.md) diff --git a/query-languages/dax/amordegrc-function-dax.md b/query-languages/dax/amordegrc-function-dax.md index 51ec66a86..25a0ab99b 100644 --- a/query-languages/dax/amordegrc-function-dax.md +++ b/query-languages/dax/amordegrc-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: AMORDEGRC" -title: "AMORDEGRC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "AMORDEGRC function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # AMORDEGRC +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the depreciation for each accounting period. This function is provided for the French accounting system. If an asset is purchased in the middle of the accounting period, the prorated depreciation is taken into account. The function is similar to AMORLINC, except that a depreciation coefficient is applied in the calculation depending on the life of the assets. ## Syntax @@ -24,19 +18,19 @@ AMORDEGRC(, , , , , [ ### Parameters -|Term|Definition| -|--------|--------------| -|cost|The cost of the asset.| -|date_purchased|The date of the purchase of the asset.| -|first_period|The date of the end of the first period.| -|salvage|The salvage value at the end of the life of the asset.| -|period|The period.| -|rate|The rate of depreciation.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`cost`|The cost of the asset.| +|`date_purchased`|The date of the purchase of the asset.| +|`first_period`|The date of the end of the first period.| +|`salvage`|The salvage value at the end of the life of the asset.| +|`period`|The period.| +|`rate`|The rate of depreciation.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Date system** | +| `Basis` | **Date system** | | ------------ | ------------------------------------ | | 0 or omitted | 360 days (NASD method) | | 1 | Actual | diff --git a/query-languages/dax/amorlinc-function-dax.md b/query-languages/dax/amorlinc-function-dax.md index 200fe849a..3fe105294 100644 --- a/query-languages/dax/amorlinc-function-dax.md +++ b/query-languages/dax/amorlinc-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: AMORLINC" -title: "AMORLINC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "AMORLINC function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # AMORLINC +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the depreciation for each accounting period. This function is provided for the French accounting system. If an asset is purchased in the middle of the accounting period, the prorated depreciation is taken into account. ## Syntax @@ -24,19 +18,19 @@ AMORLINC(, , , , , [, ### Parameters -|Term|Definition| -|--------|--------------| -|cost|The cost of the asset.| -|date_purchased|The date of the purchase of the asset.| -|first_period|The date of the end of the first period.| -|salvage|The salvage value at the end of the life of the asset.| -|period|The period.| -|rate|The rate of depreciation.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`cost`|The cost of the asset.| +|`date_purchased`|The date of the purchase of the asset.| +|`first_period`|The date of the end of the first period.| +|`salvage`|The salvage value at the end of the life of the asset.| +|`period`|The period.| +|`rate`|The rate of depreciation.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Date system** | +| `Basis` | **Date system** | | ------------ | ------------------------------------ | | 0 or omitted | 360 days (NASD method) | | 1 | Actual | @@ -54,13 +48,13 @@ The depreciation for each accounting period. - period and basis are rounded to the nearest integer. - An error is returned if: - - cost < 0. - - first_period or date_purchased is not a valid date. - - date_purchased > first_period. - - salvage < 0 or salvage > cost. - - period < 0. - - rate ≤ 0. - - basis is any number other than 0, 1, 3, or 4. + - `cost` < 0. + - `first_period` or `date_purchased` is not a valid date. + - `date_purchased` > `first_period`. + - `salvage` < 0 or `salvage` > `cost`. + - `period` < 0. + - `rate` ≤ 0. + - `basis` is any number other than 0, 1, 3, or 4. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/and-function-dax.md b/query-languages/dax/and-function-dax.md index ad798273f..fb48e0d1c 100644 --- a/query-languages/dax/and-function-dax.md +++ b/query-languages/dax/and-function-dax.md @@ -1,109 +1,102 @@ --- description: "Learn more about: AND" -title: "AND function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "AND function (DAX)" --- # AND -Checks whether both arguments are TRUE, and returns TRUE if both arguments are TRUE. Otherwise returns false. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks whether both arguments are `TRUE`, and returns `TRUE` if both arguments are `TRUE`. Otherwise returns `FALSE`. + +## Syntax + ```dax -AND(,) +AND(,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|logical_1, logical_2|The logical values you want to test.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`logical_1, logical_2`|The logical values you want to test.| + ## Return value -Returns true or false depending on the combination of values that you test. - +Returns true or false depending on the combination of values that you test. + ## Remarks -The **AND** function in DAX accepts only two (2) arguments. If you need to perform an AND operation on multiple expressions, you can create a series of calculations or, better, use the AND operator (**&&**) to join all of them in a simpler expression. - +The `AND` function in DAX accepts only two (2) arguments. If you need to perform an AND operation on multiple expressions, you can create a series of calculations or, better, use the `AND` operator (`&&`) to join all of them in a simpler expression. + ## Example 1 -The following formula shows the syntax of the AND function. - +The following formula shows the syntax of the `AND` function. + ```dax -= IF(AND(10 > 9, -10 < -1), "All true", "One or more false" += IF(AND(10 > 9, -10 < -1), "All true", "One or more false" ``` -Because both conditions, passed as arguments, to the AND function are true, the formula returns "All True". - +Because both conditions, passed as arguments, to the `AND` function are true, the formula returns "All True". + ## Example 2 -The following sample uses the AND function with nested formulas to compare two sets of calculations at the same time. For each product category, the formula determines if the current year sales and previous year sales of the Internet channel are larger than the Reseller channel for the same periods. If both conditions are true, for each category the formula returns the value, "Internet hit". +The following sample uses the `AND` function with nested formulas to compare two sets of calculations at the same time. For each product category, the formula determines if the current year sales and previous year sales of the Internet channel are larger than the Reseller channel for the same periods. If both conditions are true, for each category the formula returns the value, "Internet hit". ```dax -= IF( AND( SUM( 'InternetSales_USD'[SalesAmount_USD]) - >SUM('ResellerSales_USD'[SalesAmount_USD]) - , CALCULATE(SUM('InternetSales_USD'[SalesAmount_USD]), PREVIOUSYEAR('DateTime'[DateKey] )) - >CALCULATE(SUM('ResellerSales_USD'[SalesAmount_USD]), PREVIOUSYEAR('DateTime'[DateKey] )) - ) - , "Internet Hit" - , "" - ) += IF( AND( SUM( 'InternetSales_USD'[SalesAmount_USD]) + >SUM('ResellerSales_USD'[SalesAmount_USD]) + , CALCULATE(SUM('InternetSales_USD'[SalesAmount_USD]), PREVIOUSYEAR('DateTime'[DateKey] )) + >CALCULATE(SUM('ResellerSales_USD'[SalesAmount_USD]), PREVIOUSYEAR('DateTime'[DateKey] )) + ) + , "Internet Hit" + , "" + ) ``` Returns - -|Row Labels|2005|2006|2007|2008|-|Grand Total| -|----------------|-----------------|----|----|----|----|----| -|Bib-Shorts||||||| -|Bike Racks||||||| -|Bike Stands||||Internet Hit||| -|Bottles and Cages||||Internet Hit||| -|Bottom Brackets||||||| -|Brakes||||||| -|Caps||||||| -|Chains||||||| -|Cleaners||||||| -|Cranksets||||||| -|Derailleurs||||||| -|Fenders||||Internet Hit||| -|Forks||||||| -|Gloves||||||| -|Handlebars||||||| -|Headsets||||||| -|Helmets||||||| -|Hydration Packs||||||| -|Jerseys||||||| -|Lights||||||| -|Locks||||||| -|Mountain Bikes||||||| -|Mountain Frames||||||| -|Panniers||||||| -|Pedals||||||| -|Pumps||||||| -|Road Bikes||||||| -|Road Frames||||||| -|Saddles||||||| -|Shorts||||||| -|Socks||||||| -|Tights||||||| -|Tires and Tubes||||Internet Hit||| -|Touring Bikes||||||| -|Touring Frames||||||| -|Vests||||||| -|Wheels||||||| -|||||||| -|Grand Total||||||| - -## See also - -[Logical functions](logical-functions-dax.md) + +|Row Labels|2005|2006|2007|2008|-|Grand Total| +|----------------|-----------------|----|----|----|----|----| +|Bib-Shorts||||||| +|Bike Racks||||||| +|Bike Stands||||Internet Hit||| +|Bottles and Cages||||Internet Hit||| +|Bottom Brackets||||||| +|Brakes||||||| +|Caps||||||| +|Chains||||||| +|Cleaners||||||| +|Cranksets||||||| +|Derailleurs||||||| +|Fenders||||Internet Hit||| +|Forks||||||| +|Gloves||||||| +|Handlebars||||||| +|Headsets||||||| +|Helmets||||||| +|Hydration Packs||||||| +|Jerseys||||||| +|Lights||||||| +|Locks||||||| +|Mountain Bikes||||||| +|Mountain Frames||||||| +|Panniers||||||| +|Pedals||||||| +|Pumps||||||| +|Road Bikes||||||| +|Road Frames||||||| +|Saddles||||||| +|Shorts||||||| +|Socks||||||| +|Tights||||||| +|Tires and Tubes||||Internet Hit||| +|Touring Bikes||||||| +|Touring Frames||||||| +|Vests||||||| +|Wheels||||||| +|||||||| +|Grand Total||||||| + +## Related content + +[Logical functions](logical-functions-dax.md) diff --git a/query-languages/dax/approximate-distinctcount-function-dax.md b/query-languages/dax/approximate-distinctcount-function-dax.md index 32262d3de..5ac71dc65 100644 --- a/query-languages/dax/approximate-distinctcount-function-dax.md +++ b/query-languages/dax/approximate-distinctcount-function-dax.md @@ -1,36 +1,29 @@ --- description: "Learn more about: APPROXIMATEDISTINCTCOUNT" -title: "APPROXIMATEDISTINCTCOUNT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "APPROXIMATEDISTINCTCOUNT function (DAX)" --- # APPROXIMATEDISTINCTCOUNT -Returns the *approximate* number of rows that contain distinct values in a column. This function can query large amounts of data with potentially better performance than DISTINCTCOUNT, with slight deviation from the exact result. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Returns an *estimated* count of unique values in a column. This function invokes a corresponding aggregation operation in the data source, which is optimized for query performance, but with slightly reduced accuracy. This function can be used with the following data sources: Azure SQL, Azure Synapse dedicated SQL pool, BigQuery, Databricks, and Snowflake. This function requires DirectQuery mode. Import mode and dual storage mode are not supported. + +## Syntax + ```dax APPROXIMATEDISTINCTCOUNT() ``` - -### Parameters -|Term |Description| +### Parameters + +|Term |Description| |---------|---------| -|column | The column that contains the values to be counted. This cannot be an expression. | +|`column` | The column that contains the values to be counted. This cannot be an expression. | ## Return value -The approximate number of distinct values in *column*. - -## Remarks +The approximate number of distinct values in `column`. + +## Remarks The only argument to this function is a column. You can use columns containing any type of data. When the function finds no rows to count, it returns a BLANK, otherwise it returns the count of distinct values. diff --git a/query-languages/dax/asin-function-dax.md b/query-languages/dax/asin-function-dax.md index 6e074d00d..e58d1641b 100644 --- a/query-languages/dax/asin-function-dax.md +++ b/query-languages/dax/asin-function-dax.md @@ -1,44 +1,37 @@ --- description: "Learn more about: ASIN" -title: "ASIN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ASIN function (DAX)" --- # ASIN -Returns the arcsine, or inverse sine, of a number. The arcsine is the angle whose sine is *number*. The returned angle is given in radians in the range -pi/2 to pi/2. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the arcsine, or inverse sine, of a number. The arcsine is the angle whose sine is `number`. The returned angle is given in radians in the range -pi/2 to pi/2. + +## Syntax + ```dax -ASIN(number) +ASIN(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The sine of the angle you want and must be from -1 to 1.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The sine of the angle you want and must be from -1 to 1.| + ## Return value -Returns the arcsine, or inverse sine, of a number. - +Returns the arcsine, or inverse sine, of a number. + ## Remarks -To express the arcsine in degrees, multiply the result by 180/PI( ) or use the DEGREES function. - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= ASIN(-0.5)|Arcsine of -0.5 in radians, -pi/6|-0.523598776| -|= ASIN(-0.5)*180/PI()|Arcsine of -0.5 in degrees|-30| -|= DEGREES(ASIN(-0.5))|Arcsine of -0.5 in degrees|-30| +To express the arcsine in degrees, multiply the result by 180/PI( ) or use the DEGREES function. + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= ASIN(-0.5)`|Arcsine of -0.5 in radians, -pi/6|-0.523598776| +|`= ASIN(-0.5)*180/PI()`|Arcsine of -0.5 in degrees|-30| +|`= DEGREES(ASIN(-0.5))`|Arcsine of -0.5 in degrees|-30| diff --git a/query-languages/dax/asinh-function-dax.md b/query-languages/dax/asinh-function-dax.md index 514b4d4bb..801622fd4 100644 --- a/query-languages/dax/asinh-function-dax.md +++ b/query-languages/dax/asinh-function-dax.md @@ -1,43 +1,36 @@ --- description: "Learn more about: ASINH" -title: "ASINH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ASINH function (DAX)" --- # ASINH -Returns the inverse hyperbolic sine of a number. The inverse hyperbolic sine is the value whose hyperbolic sine is *number*, so ASINH(SINH(number)) equals *number*. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the inverse hyperbolic sine of a number. The inverse hyperbolic sine is the value whose hyperbolic sine is `number`, so ASINH(SINH(number)) equals `number`. + +## Syntax + ```dax -ASINH(number) +ASINH(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Any real number.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Any real number.| + ## Return value -Returns the inverse hyperbolic sine of a number. +Returns the inverse hyperbolic sine of a number. ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= ASINH(-2.5)|Inverse hyperbolic sine of -2.5|-1.647231146| -|= ASINH(10)|Inverse hyperbolic sine of 10|2.99822295| +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= ASINH(-2.5)`|Inverse hyperbolic sine of -2.5|-1.647231146| +|`= ASINH(10)`|Inverse hyperbolic sine of 10|2.99822295| diff --git a/query-languages/dax/atan-function-dax.md b/query-languages/dax/atan-function-dax.md index 09c9a1368..65a39bed1 100644 --- a/query-languages/dax/atan-function-dax.md +++ b/query-languages/dax/atan-function-dax.md @@ -1,43 +1,36 @@ --- description: "Learn more about: ATAN" -title: "ATAN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ATAN function (DAX)" --- # ATAN -Returns the arctangent, or inverse tangent, of a number. The arctangent is the angle whose tangent is *number*. The returned angle is given in radians in the range -pi/2 to pi/2. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the arctangent, or inverse tangent, of a number. The arctangent is the angle whose tangent is `number`. The returned angle is given in radians in the range -pi/2 to pi/2. + +## Syntax + ```dax -ATAN(number) +ATAN(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The tangent of the angle you want.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The tangent of the angle you want.| + ## Return value -Returns the inverse hyperbolic tangent of a number. - +Returns the inverse tangent of a number. + ## Remarks -To express the arctangent in degrees, multiply the result by 180/PI( ) or use the DEGREES function. - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= ATAN(1)|Arctangent of 1 in radians, pi/4|0.785398163| -|= ATAN(1)*180/PI()|Arctangent of 1 in degrees|45| +To express the arctangent in degrees, multiply the result by 180/PI( ) or use the DEGREES function. + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= ATAN(1)`|Arctangent of 1 in radians, pi/4|0.785398163| +|`= ATAN(1)*180/PI()`|Arctangent of 1 in degrees|45| diff --git a/query-languages/dax/atanh-function-dax.md b/query-languages/dax/atanh-function-dax.md index 2e44dc233..a67ce3c7f 100644 --- a/query-languages/dax/atanh-function-dax.md +++ b/query-languages/dax/atanh-function-dax.md @@ -1,48 +1,40 @@ --- description: "Learn more about: ATANH" -title: "ATANH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ATANH function (DAX)" --- # ATANH -Returns the inverse hyperbolic tangent of a number. Number must be between -1 and 1 (excluding -1 and 1). The inverse hyperbolic tangent is the value whose hyperbolic tangent is *number*, so ATANH(TANH(number)) equals *number*. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the inverse hyperbolic tangent of a number. Number must be between -1 and 1 (excluding -1 and 1). The inverse hyperbolic tangent is the value whose hyperbolic tangent is `number`, so ATANH(TANH(number)) equals `number`. + +## Syntax + ```dax -ATANH(number) +ATANH(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Any real number between 1 and -1.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Any real number between 1 and -1.| + ## Return value -Returns the inverse hyperbolic tangent of a number. +Returns the inverse hyperbolic tangent of a number. ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= ATANH(0.76159416)|Inverse hyperbolic tangent of 0.76159416|1.00000001| -|= ATANH(-0.1)||-0.100335348| -|||| - -## See also - -[ATAN function](atan-function-dax.md) + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= ATANH(0.76159416)`|Inverse hyperbolic tangent of 0.76159416|1.00000001| +|`= ATANH(-0.1)`||-0.100335348| + +## Related content + +[ATAN function](atan-function-dax.md) diff --git a/query-languages/dax/average-function-dax.md b/query-languages/dax/average-function-dax.md index ca4d05c83..3337f6df6 100644 --- a/query-languages/dax/average-function-dax.md +++ b/query-languages/dax/average-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: AVERAGE" -title: "AVERAGE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "AVERAGE function (DAX)" --- # AVERAGE -Returns the average (arithmetic mean) of all the numbers in a column. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the average (arithmetic mean) of all the numbers in a column. + +## Syntax + ```dax -AVERAGE() +AVERAGE() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column that contains the numbers for which you want the average.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that contains the numbers for which you want the average.| + ## Return value -Returns a decimal number that represents the arithmetic mean of the numbers in the column. - +Returns a decimal number that represents the arithmetic mean of the numbers in the column. + ## Remarks -- This function takes the specified column as an argument and finds the average of the values in that column. If you want to find the average of an expression that evaluates to a set of numbers, use the AVERAGEX function instead. +- This function takes the specified column as an argument and finds the average of the values in that column. If you want to find the average of an expression that evaluates to a set of numbers, use the AVERAGEX function instead. -- Nonnumeric values in the column are handled as follows: +- Nonnumeric values in the column are handled as follows: - If the column contains text, no aggregation can be performed, and the functions returns blanks. - - If the column contains logical values or empty cells, those values are ignored. + - If the column contains logical values or empty cells, those values are ignored. - Cells with the value zero are included. - -- When you average cells, you must keep in mind the difference between an empty cell and a cell that contains the value 0 (zero). When a cell contains 0, it is added to the sum of numbers and the row is counted among the number of rows used as the divisor. However, when a cell contains a blank, the row is not counted. - -- Whenever there are no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0. Excel also returns a zero if no rows are found that meet the conditions. + +- When you average cells, you must keep in mind the difference between an empty cell and a cell that contains the value 0 (zero). When a cell contains 0, it is added to the sum of numbers and the row is counted among the number of rows used as the divisor. However, when a cell contains a blank, the row is not counted. + +- Whenever there are no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0. Excel also returns a zero if no rows are found that meet the conditions. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following formula returns the average of the values in the column, ExtendedSalesAmount, in the table, InternetSales. - +The following formula returns the average of the values in the column, ExtendedSalesAmount, in the table, InternetSales. + ```dax -= AVERAGE(InternetSales[ExtendedSalesAmount]) += AVERAGE(InternetSales[ExtendedSalesAmount]) ``` - + ## Related functions -The AVERAGEX function can take as its argument an expression that is evaluated for each row in a table. This enables you to perform calculations and then take the average of the calculated values. - -The AVERAGEA function takes a column as its argument, but otherwise is like the Excel function of the same name. By using the AVERAGEA function, you can calculate a mean on a column that contains empty values. +The AVERAGEX function can take as its argument an expression that is evaluated for each row in a table. This enables you to perform calculations and then take the average of the calculated values. + +The AVERAGEA function takes a column as its argument, but otherwise is like the Excel function of the same name. By using the AVERAGEA function, you can calculate a mean on a column that contains empty values. diff --git a/query-languages/dax/averagea-function-dax.md b/query-languages/dax/averagea-function-dax.md index 434f2555e..230258ab6 100644 --- a/query-languages/dax/averagea-function-dax.md +++ b/query-languages/dax/averagea-function-dax.md @@ -1,69 +1,62 @@ --- description: "Learn more about: AVERAGEA" -title: "AVERAGEA function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "AVERAGEA function (DAX)" --- # AVERAGEA -Returns the average (arithmetic mean) of the values in a column. Handles text and non-numeric values. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the average (arithmetic mean) of the values in a column. Handles text and non-numeric values. + +## Syntax + ```dax -AVERAGEA() +AVERAGEA() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|A column that contains the values for which you want the average.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A column that contains the values for which you want the average.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- The AVERAGEA function takes a column and averages the numbers in it, but also handles non-numeric data types according to the following rules: - - - Values that evaluates to TRUE count as 1. - - Values that evaluate to FALSE count as 0 (zero). - - Values that contain non-numeric text count as 0 (zero). - - Empty text ("") counts as 0 (zero). - -- If you do not want to include logical values and text representations of numbers in a reference as part of the calculation, use the AVERAGE function. - -- Whenever there are no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0. Microsoft Excel also returns a zero if no rows are found that meet the conditions. +- The AVERAGEA function takes a column and averages the numbers in it, but also handles non-numeric data types according to the following rules: + + - Values that evaluates to `TRUE` count as 1. + - Values that evaluate to `FALSE` count as 0 (zero). + - Values that contain non-numeric text count as 0 (zero). + - Empty text ("") counts as 0 (zero). + +- If you do not want to include logical values and text representations of numbers in a reference as part of the calculation, use the AVERAGE function. + +- Whenever there are no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0. Microsoft Excel also returns a zero if no rows are found that meet the conditions. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example returns the average of non-blank cells in the referenced column, given the following table. If you used the AVERAGE function, the mean would be 21/2; with the AVERAGEA function, the result is 22/5. - -|Transaction ID|Amount|Result| -|------------------|----------|----------| -|0000123|1|Counts as 1| -|0000124|20|Counts as 20| -|0000125|n/a|Counts as 0| -|0000126||Counts as 0| -|0000126|TRUE|Counts as 1| - +The following example returns the average of non-blank cells in the referenced column, given the following table. If you used the AVERAGE function, the mean would be 21/2; with the AVERAGEA function, the result is 22/5. + +|Transaction ID|Amount|Result| +|------------------|----------|----------| +|0000123|1|Counts as 1| +|0000124|20|Counts as 20| +|0000125|n/a|Counts as 0| +|0000126||Counts as 0| +|0000126|``TRUE``|Counts as 1| + ```dax -= AVERAGEA([Amount]) += AVERAGEA([Amount]) ``` - -## See also -[AVERAGE function](average-function-dax.md) -[AVERAGEX function](averagex-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[AVERAGE function](average-function-dax.md) +[AVERAGEX function](averagex-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/averagex-function-dax.md b/query-languages/dax/averagex-function-dax.md index 0d1fc420a..466848cf4 100644 --- a/query-languages/dax/averagex-function-dax.md +++ b/query-languages/dax/averagex-function-dax.md @@ -1,59 +1,52 @@ --- description: "Learn more about: AVERAGEX" -title: "AVERAGEX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "AVERAGEX function (DAX)" --- # AVERAGEX -Calculates the average (arithmetic mean) of a set of expressions evaluated over a table. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Calculates the average (arithmetic mean) of a set of expressions evaluated over a table. + +## Syntax + ```dax -AVERAGEX(
,) +AVERAGEX(
,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|Name of a table, or an expression that specifies the table over which the aggregation can be performed.| -|expression|An expression with a scalar result, which will be evaluated for each row of the table in the first argument.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|Name of a table, or an expression that specifies the table over which the aggregation can be performed.| +|`expression`|An expression with a scalar result, which will be evaluated for each row of the table in the first argument.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- The AVERAGEX function enables you to evaluate expressions for each row of a table, and then take the resulting set of values and calculate its arithmetic mean. Therefore, the function takes a table as its first argument, and an expression as the second argument. - -- In all other respects, AVERAGEX follows the same rules as AVERAGE. You cannot include non-numeric or null cells. Both the table and expression arguments are required. - -- When there are no rows to aggregate, the function returns a blank. When there are rows, but none of them meet the specified criteria, then the function returns 0. +- The AVERAGEX function enables you to evaluate expressions for each row of a table, and then take the resulting set of values and calculate its arithmetic mean. Therefore, the function takes a table as its first argument, and an expression as the second argument. + +- In all other respects, AVERAGEX follows the same rules as AVERAGE. You cannot include non-numeric or null cells. Both the table and expression arguments are required. + +- When there are no rows to aggregate, the function returns a blank. When there are rows, but none of them meet the specified criteria, then the function returns 0. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example calculates the average freight and tax on each order in the InternetSales table, by first summing Freight plus TaxAmt in each row, and then averaging those sums. - +The following example calculates the average freight and tax on each order in the InternetSales table, by first summing Freight plus TaxAmt in each row, and then averaging those sums. + ```dax -= AVERAGEX(InternetSales, InternetSales[Freight]+ InternetSales[TaxAmt]) += AVERAGEX(InternetSales, InternetSales[Freight]+ InternetSales[TaxAmt]) ``` -If you use multiple operations in the expression used as the second argument, you must use parentheses to control the order of calculations. For more information, see [DAX Syntax Reference](dax-syntax-reference.md). - -## See also +If you use multiple operations in the expression used as the second argument, you must use parentheses to control the order of calculations. For more information, see [DAX Syntax Reference](dax-syntax-reference.md). + +## Related content -[AVERAGE function](average-function-dax.md) -[AVERAGEA function](averagea-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +[AVERAGE function](average-function-dax.md) +[AVERAGEA function](averagea-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/best-practices/dax-avoid-avoid-filter-as-filter-argument.md b/query-languages/dax/best-practices/dax-avoid-avoid-filter-as-filter-argument.md index e81fb9ca8..530642a2b 100644 --- a/query-languages/dax/best-practices/dax-avoid-avoid-filter-as-filter-argument.md +++ b/query-languages/dax/best-practices/dax-avoid-avoid-filter-as-filter-argument.md @@ -2,13 +2,9 @@ title: "Avoid using FILTER as a filter argument in DAX" description: Best practices for using the FILTER function as a filter argument. author: peter-myers -ms.author: owend -ms.reviewer: owend -ms.service: powerbi -ms.subservice: dax ms.topic: conceptual ms.date: 08/25/2021 -recommendations: false + --- # Avoid using FILTER as a filter argument @@ -46,29 +42,14 @@ It's recommended you pass filter arguments as Boolean expressions, whenever poss There are, however, restrictions that apply to Boolean expressions when they're used as filter arguments. They: -- Cannot compare columns to other columns +- Cannot reference columns from multiple tables - Cannot reference a measure - Cannot use nested CALCULATE functions - Cannot use functions that scan or return a table It means that you'll need to use table expressions for more complex filter requirements. -Consider now a different measure definition. - -```dax -High Margin Product Sales = -CALCULATE( - [Sales], - FILTER( - 'Product', - 'Product'[ListPrice] > 'Product'[StandardCost] * 2 - ) -) -``` - -The definition of a _high margin product_ is one that has a list price exceeding double its standard cost. In this example, the FILTER function must be used. It's because the filter expression is too complex for a Boolean expression. - -Here's one more example. The requirement this time is to calculate sales, but only for months that have achieved a profit. +Consider now a different measure definition. The requirement is to calculate sales, but only for months that have achieved a profit. ```dax Sales for Profitable Months = @@ -76,12 +57,12 @@ CALCULATE( [Sales], FILTER( VALUES('Date'[Month]), - [Profit] > 0) + [Profit] > 0 ) ) ``` -In this example, the FILTER function must also be used. It's because it requires evaluating the **Profit** measure to eliminate those months that didn't achieve a profit. It's not possible to use a measure in a Boolean expression when it's used as a filter argument. +In this example, the FILTER function must be used. It's because it requires evaluating the **Profit** measure to eliminate those months that didn't achieve a profit. It's not possible to use a measure in a Boolean expression when it's used as a filter argument. ## Recommendations @@ -93,9 +74,9 @@ Therefore, the FILTER function should only be used when necessary. You can use i - Other columns - Using the [OR](../or-function-dax.md) DAX function, or the OR logical operator (||) -## See also +## Related content - [Filter functions (DAX)](../filter-function-dax.md) -- Learning path: [Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) +- Learning path: [Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) - Questions? [Try asking the Power BI Community](https://community.powerbi.com/) -- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) \ No newline at end of file +- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) diff --git a/query-languages/dax/best-practices/dax-avoid-converting-blank.md b/query-languages/dax/best-practices/dax-avoid-converting-blank.md index 78f0b99c4..6c4404293 100644 --- a/query-languages/dax/best-practices/dax-avoid-converting-blank.md +++ b/query-languages/dax/best-practices/dax-avoid-converting-blank.md @@ -2,13 +2,9 @@ title: "Avoid converting BLANKs to values in DAX" description: Best practices for converting BLANKs to values. author: peter-myers -ms.author: owend -ms.reviewer: owend -ms.service: powerbi -ms.subservice: dax ms.topic: conceptual ms.date: 08/25/2021 -recommendations: false + --- # Avoid converting BLANKs to values @@ -70,8 +66,8 @@ It's recommended that your measures return BLANK when a meaningful value cannot This design approach is efficient, allowing Power BI to render reports faster. Also, returning BLANK is better because report visuals—by default—eliminate groupings when summarizations are BLANK. -## See also +## Related content -- Learning path: [Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) +- Learning path: [Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) - Questions? [Try asking the Power BI Community](https://community.powerbi.com/) -- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) \ No newline at end of file +- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) diff --git a/query-languages/dax/best-practices/dax-column-measure-references.md b/query-languages/dax/best-practices/dax-column-measure-references.md index 35d763c9f..c98eb15e3 100644 --- a/query-languages/dax/best-practices/dax-column-measure-references.md +++ b/query-languages/dax/best-practices/dax-column-measure-references.md @@ -2,13 +2,8 @@ title: "Column and measure references in DAX" description: Best practices when referring to columns in measures in your DAX expressions. author: peter-myers -ms.author: owend -ms.reviewer: owend -ms.service: powerbi -ms.subservice: dax ms.topic: conceptual ms.date: 08/25/2021 -recommendations: false --- # Column and measure references @@ -58,8 +53,8 @@ Here's why: - **Robustness**: Expressions will continue to work, even when you change a measure home table property. - **Readability**: Expressions will be quick and easy to understand—you'll quickly determine that it's a column or measure, based on whether it's fully qualified or not. -## See also +## Related content -- Learning path: [Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) +- Learning path: [Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) - Questions? [Try asking the Power BI Community](https://community.powerbi.com/) -- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) \ No newline at end of file +- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) diff --git a/query-languages/dax/best-practices/dax-countrows.md b/query-languages/dax/best-practices/dax-countrows.md index b4d0931ce..ac9bf96e1 100644 --- a/query-languages/dax/best-practices/dax-countrows.md +++ b/query-languages/dax/best-practices/dax-countrows.md @@ -2,13 +2,8 @@ title: "Use COUNTROWS instead of COUNT in DAX" description: Best practices for using the COUNTROWS functions. author: peter-myers -ms.author: owend -ms.reviewer: owend -ms.service: powerbi -ms.subservice: dax ms.topic: conceptual ms.date: 08/25/2021 -recommendations: false --- # Use COUNTROWS instead of COUNT @@ -43,8 +38,8 @@ There are three reasons why the second measure definition is better: When it's your intention to count table rows, it's recommended you always use the COUNTROWS function. -## See also +## Related content -- Learning path: [Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) +- Learning path: [Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) - Questions? [Try asking the Power BI Community](https://community.powerbi.com/) -- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) \ No newline at end of file +- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) diff --git a/query-languages/dax/best-practices/dax-divide-function-operator.md b/query-languages/dax/best-practices/dax-divide-function-operator.md index fea6e5565..0832d9919 100644 --- a/query-languages/dax/best-practices/dax-divide-function-operator.md +++ b/query-languages/dax/best-practices/dax-divide-function-operator.md @@ -2,13 +2,8 @@ title: "DIVIDE function vs divide operator (/) in DAX" description: Best practices for using the DAX DIVIDE function. author: peter-myers -ms.author: owend -ms.reviewer: owend -ms.service: powerbi -ms.subservice: dax ms.topic: conceptual ms.date: 08/25/2021 -recommendations: false --- # DIVIDE function vs. divide operator (/) @@ -56,8 +51,8 @@ In the case that the denominator is a constant value, we recommend that you use Carefully consider whether the DIVIDE function should return an alternate value. For measures, it's usually a better design that they return BLANK. Returning BLANK is better because report visuals—by default—eliminate groupings when summarizations are BLANK. It allows the visual to focus attention on groups where data exists. When necessary, in Power BI, you can configure the visual to display all groups (that return values or BLANK) within the filter context by enabling the [Show items with no data](/power-bi/create-reports/desktop-show-items-no-data) option. -## See also +## Related content -- Learning path: [Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) +- Learning path: [Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) - Questions? [Try asking the Power BI Community](https://community.powerbi.com/) -- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) \ No newline at end of file +- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) diff --git a/query-languages/dax/best-practices/dax-error-functions.md b/query-languages/dax/best-practices/dax-error-functions.md index 43453809d..57bc1f607 100644 --- a/query-languages/dax/best-practices/dax-error-functions.md +++ b/query-languages/dax/best-practices/dax-error-functions.md @@ -2,13 +2,8 @@ title: "Appropriate use of error functions in DAX" description: Best practices for using the DAX error functions. author: peter-myers -ms.author: owend -ms.reviewer: owend -ms.service: powerbi -ms.subservice: dax ms.topic: conceptual ms.date: 08/25/2021 -recommendations: false --- # Appropriate use of error functions @@ -55,8 +50,8 @@ Profit Margin = DIVIDE([Profit], [Sales]) ``` -## See also +## Related content -- Learning path: [Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) +- Learning path: [Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) - Questions? [Try asking the Power BI Community](https://community.powerbi.com/) -- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) \ No newline at end of file +- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) diff --git a/query-languages/dax/best-practices/dax-selectedvalue.md b/query-languages/dax/best-practices/dax-selectedvalue.md index 13923f3cd..34947aaec 100644 --- a/query-languages/dax/best-practices/dax-selectedvalue.md +++ b/query-languages/dax/best-practices/dax-selectedvalue.md @@ -2,13 +2,8 @@ title: "Use SELECTEDVALUE instead of VALUES in DAX" description: Best practices for using the SELECTEDVALUE functions. author: peter-myers -ms.author: owend -ms.reviewer: owend -ms.service: powerbi -ms.subservice: dax ms.topic: conceptual ms.date: 08/25/2021 -recommendations: false --- # Use SELECTEDVALUE instead of VALUES @@ -34,7 +29,7 @@ The use of the HASONEVALUE is a defensive technique. It's required because it's ## Recommendation -It's recommended that you use the [SELECTEDVALUE](../selectedvalue-function.md) function. It achieves the same outcome as the pattern described in this article, yet more efficiently and elegantly. +It's recommended that you use the [SELECTEDVALUE](../selectedvalue-function-dax.md) function. It achieves the same outcome as the pattern described in this article, yet more efficiently and elegantly. Using the SELECTEDVALUE function, the example measure definition is now rewritten. @@ -49,8 +44,8 @@ IF( > [!TIP] > It's possible to pass an _alternate result_ value into the SELECTEDVALUE function. The alternate result value is returned when either no filters—or multiple filters—are applied to the column. -## See also +## Related content -- Learning path: [Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) +- Learning path: [Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) - Questions? [Try asking the Power BI Community](https://community.powerbi.com/) -- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) \ No newline at end of file +- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) diff --git a/query-languages/dax/best-practices/dax-understand-orderby.md b/query-languages/dax/best-practices/dax-understand-orderby.md new file mode 100644 index 000000000..f6512fb07 --- /dev/null +++ b/query-languages/dax/best-practices/dax-understand-orderby.md @@ -0,0 +1,493 @@ +--- +title: "Understanding ORDERBY, PARTITIONBY, and MATCHBY functions in DAX" +description: Best practices for using ORDERBY, PARTITIONBY, and MATCHBY functions. +author: jeroenterheerdt +ms.topic: conceptual +ms.date: 07/07/2023 +--- + +# Understanding ORDERBY, PARTITIONBY, and MATCHBY functions + +The [ORDERBY](../orderby-function-dax.md), [PARTITIONBY](../partitionby-function-dax.md), and [MATCHBY](../matchby-function-dax.md) functions in DAX are special functions that can only be used along with DAX Window functions: [INDEX](../index-function-dax.md), [OFFSET](../offset-function-dax.md), [WINDOW](../window-function-dax.md), [RANK](../rank-function-dax.md), [ROWNUMBER](../rownumber-function-dax.md). + +Understanding ORDERBY, PARTITIONBY, and MATCHBY is critical to successfully using the Window functions. The examples provided here use OFFSET, but are similarly applicable to the other Window functions. + +## Scenario + +Let’s start with an example that doesn't use Window functions at all. Shown below is a table that returns total sales, per color, per calendar year. There are multiple ways to define this table, but since we're interested in understanding what happens in DAX, we'll use a calculated table. Here's the table expression: + +```dax +BasicTable = + SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + +``` + +You'll see this calculated table expression uses [SUMMARIZECOLUMNS](../summarizecolumns-function-dax.md) to calculate the SUM of the SalesAmount column in the FactInternetSales table, by the Color column from the DimProduct table, and the CalendarYear column from the DimDate table. Here's The result: + +| Color | CalendarYear | CurrentYearSales | +|----------|--------------|------------------| +| "Black" | 2017 | 393885 | +| "Black" | 2018 | 1818835 | +| "Black" | 2019 | 3981638 | +| "Black" | 2020 | 2644054 | +| "Blue" | 2019 | 994448 | +| "Blue" | 2020 | 1284648 | +| "Multi" | 2019 | 48622 | +| "Multi" | 2020 | 57849 | +| "NA" | 2019 | 207822 | +| "NA" | 2020 | 227295 | +| "Red" | 2017 | 2961198 | +| "Red" | 2018 | 3686935 | +| "Red" | 2019 | 900175 | +| "Red" | 2020 | 176022 | +| "Silver" | 2017 | 326399 | +| "Silver" | 2018 | 750026 | +| "Silver" | 2019 | 2165176 | +| "Silver" | 2020 | 1871788 | +| "White" | 2019 | 2517 | +| "White" | 2020 | 2589 | +| "Yellow" | 2018 | 163071 | +| "Yellow" | 2019 | 2072083 | +| "Yellow" | 2020 | 2621602 | + +Now, let’s imagine we're trying to solve the business question of calculating the difference in sales, year-over-year for each color. Effectively, we need a way to find sales for the same color in the previous year and subtract that from the sales in the current year, in context. For example, for the combination [Red, 2019] we're looking for sales for [Red, 2018]. Once we have that, we can then subtract it from the current sales and return the required value. + +### Using OFFSET + +OFFSET is perfect for the typical *compare with previous* types of calculations required to answer the business question described above, as it allows us to do a relative movement. Our first attempt might be: + +```dax +1stAttempt = + VAR vRelation = SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + RETURN + ADDCOLUMNS ( + vRelation, + "PreviousColorSales", + SELECTCOLUMNS ( + OFFSET ( + -1, + vRelation + ), + [CurrentYearSales] + ) + ) + +``` + +A lot is happening with this expression. We used [ADDCOLUMNS](../addcolumns-function-dax.md) to expand the table from before with a column called PreviousColorSales. The contents of that column are set to the CurrentYearSales, which is SUM(FactInternetSales[SalesAmount]), for the previous Color (retrieved using OFFSET). + +The result is: + +| Color | CalendarYear | CurrentYearSales | PreviousColorSales | +|----------|--------------|------------------|--------------------| +| "Black" | 2017 | 393885 | | +| "Black" | 2018 | 1818835 | 393885 | +| "Black" | 2019 | 3981638 | 1818835 | +| "Black" | 2020 | 2644054 | 3981638 | +| "Blue" | 2019 | 994448 | 2644054 | +| "Blue" | 2020 | 1284648 | 994448 | +| "Multi" | 2019 | 48622 | 1284648 | +| "Multi" | 2020 | 57849 | 48622 | +| "NA" | 2019 | 207822 | 57849 | +| "NA" | 2020 | 227295 | 207822 | +| "Red" | 2017 | 2961198 | 227295 | +| "Red" | 2018 | 3686935 | 2961198 | +| "Red" | 2019 | 900175 | 3686935 | +| "Red" | 2020 | 176022 | 900175 | +| "Silver" | 2017 | 326399 | 176022 | +| "Silver" | 2018 | 750026 | 326399 | +| "Silver" | 2019 | 2165176 | 750026 | +| "Silver" | 2020 | 1871788 | 2165176 | +| "White" | 2019 | 2517 | 1871788 | +| "White" | 2020 | 2589 | 2517 | +| "Yellow" | 2018 | 163071 | 2589 | +| "Yellow" | 2019 | 2072083 | 163071 | +| "Yellow" | 2020 | 2621602 | 2072083 | + +This is one step closer to our goal, but if we look closely it doesn't match exactly what we're after. For example, for [Silver, 2017] the PreviousColorSales is set to [Red, 2020]. + +### Adding ORDERBY + +That definition above is equivalent to: + +```dax +1stAttemptWithORDERBY = + VAR vRelation = SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + RETURN + ADDCOLUMNS ( + vRelation, + "PreviousColorSales", + SELECTCOLUMNS ( + OFFSET ( + -1, + vRelation, + ORDERBY ([Color], ASC, [CalendarYear], ASC, [CurrentYearSales], ASC) + ), + [CurrentYearSales] + ) + ) + +``` + +In this case, the call to OFFSET uses ORDERBY to order the table by Color and CalendarYear in ascending order, which determines what is considered the previous row that's returned. + +The reason these two results are equivalent is because ORDERBY automatically contains all columns from the relation that aren't in PARTITIONBY. Since PARTITIONBY wasn't specified, ORDERBY is set to Color, CalendarYear, and CurrentYearSales. However, since the Color and CalendarYear pairs in the relation are unique, adding CurrentYearSales doesn't change the result. In fact, even if we were to only specify Color in ORDERBY, the results are the same since CalendarYear would be automatically added. This is because the function will add as many columns as needed to ORDERBY in order to ensure each row can be uniquely identified by the ORDERBY and PARTITIONBY columns: + +```dax +1stAttemptWithORDERBY = + VAR vRelation = SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + RETURN + ADDCOLUMNS( + vRelation, + "PreviousColorSales", + SELECTCOLUMNS ( + OFFSET ( + -1, + vRelation, + ORDERBY ([Color]) + ), + [CurrentYearSales] + ) + ) + +``` + +### Adding PARTITIONBY + +Now, to *almost* get the result we're after we can use PARTITIONBY, as shown in the following calculated table expression: + +```dax +UsingPARTITIONBY = + VAR vRelation = SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + RETURN + ADDCOLUMNS ( + vRelation, + "PreviousColorSales", + SELECTCOLUMNS ( + OFFSET ( + -1, + vRelation, + ORDERBY ([CalendarYear]), + PARTITIONBY ([Color]) + ), + [CurrentYearSales] + ) + ) + +``` + +Notice that specifying ORDERBY is optional here because ORDERBY automatically contains all the columns from the relation that aren't specified in PARTITIONBY. So, the following expression returns the same results because ORDERBY is set to CalendarYear and CurrentYearSales automatically: + +```dax +UsingPARTITIONBYWithoutORDERBY = + VAR vRelation = SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + RETURN + ADDCOLUMNS ( + vRelation, + "PreviousColorSales", + SELECTCOLUMNS ( + OFFSET ( + -1, + vRelation, + PARTITIONBY ([Color]) + ), + [CurrentYearSales] + ) + ) +``` + +> [!NOTE] +> While ORDERBY is set to CalendarYear and CurrentYearSales automatically, no guarantee is given as to what order in which they'll be added. If CurrentYearSales is added before CalendarYear, the resulting order isn't inline with what's expected. **Be explicit when specifying ORDERBY and PARTITIONBY to avoid confusion and unexpected results**. + +Both expressions return the result we're after: + +| Color | CalendarYear | CurrentYearSales | PreviousYearSalesForSameColor | +|----------|--------------|------------------|-------------------------------| +| "Black" | 2017 | 393885 | | +| "Black" | 2018 | 1818835 | 393885 | +| "Black" | 2019 | 3981638 | 1818835 | +| "Black" | 2020 | 2644054 | 3981638 | +| "Blue" | 2019 | 994448 | | +| "Blue" | 2020 | 1284648 | 994448 | +| "Multi" | 2019 | 48622 | | +| "Multi" | 2020 | 57849 | 48622 | +| "NA" | 2019 | 207822 | | +| "NA" | 2020 | 227295 | 207822 | +| "Red" | 2017 | 2961198 | | +| "Red" | 2018 | 3686935 | 2961198 | +| "Red" | 2019 | 900175 | 3686935 | +| "Red" | 2020 | 176022 | 900175 | +| "Silver" | 2017 | 326399 | | +| "Silver" | 2018 | 750026 | 326399 | +| "Silver" | 2019 | 2165176 | 750026 | +| "Silver" | 2020 | 1871788 | 2165176 | +| "White" | 2019 | 2517 | | +| "White" | 2020 | 2589 | 2517 | +| "Yellow" | 2018 | 163071 | | +| "Yellow" | 2019 | 2072083 | 163071 | +| "Yellow" | 2020 | 2621602 | 2072083 | + +As you see in this table, the PreviousYearSalesForSameColor column shows the sales for the previous year for the same color. For [Red, 2020], it returns the sales for [Red, 2019], and so on. If there's no previous year, for example in the case of [Red, 2017], no value is returned. + +You can think of PARTITIONBY as a way to divide the table into parts in which to execute the OFFSET calculation. In the example above, the table is divided into as many parts as there are colors, one for each color. Then, within each part, the OFFSET is calculated, sorted by CalendarYear. + +Visually, what's happening is this: + +:::image type="content" source="media/dax-understand-orderby/offset-by-calendar-year.png" border="false" alt-text="Table showing OFFSET by Calendar Year"::: + +First, the call to PARTITIONBY results in the table getting divided into parts, one for each Color. This is represented by the light blue boxes in the table image. Next, ORDERBY makes sure that each part is sorted by CalendarYear (represented by the orange arrows). Finally, within each sorted part, for each row, OFFSET finds the row above it and returns that value in the PreviousYearSalesForSameColor column. Since for every first row in each part there is no previous row in that same part, the result in that row for the PreviousYearSalesForSameColor column is empty. + +To achieve the final result, we simply have to subtract CurrentYearSales from the previous year sales for the same color returned by the call to OFFSET. Since we're not interested in showing the previous year sales for the same color, but only in the current year sales and the year over year difference. Here's the final calculated table expression: + +```dax +FinalResult = + VAR vRelation = SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + RETURN + ADDCOLUMNS ( + vRelation, + "YoYSalesForSameColor", + [CurrentYearSales] - + SELECTCOLUMNS ( + OFFSET ( + -1, + vRelation, + ORDERBY ([CalendarYear]), + PARTITIONBY ([Color]) + ), + [CurrentYearSales] + ) + ) + +``` + +And here's the result of that expression: + +| Color | CalendarYear | CurrentYearSales | YoYSalesForSameColor | +|----------|--------------|------------------|----------------------| +| "Black" | 2017 | 393885 | 393885 | +| "Black" | 2018 | 1818835 | 1424950 | +| "Black" | 2019 | 3981638 | 2162803 | +| "Black" | 2020 | 2644054 | -1337584 | +| "Blue" | 2019 | 994448 | 994448 | +| "Blue" | 2020 | 1284648 | 290200 | +| "Multi" | 2019 | 48622 | 48622 | +| "Multi" | 2020 | 57849 | 9227 | +| "NA" | 2019 | 207822 | 207822 | +| "NA" | 2020 | 227295 | 19473 | +| "Red" | 2017 | 2961198 | 2961198 | +| "Red" | 2018 | 3686935 | 725737 | +| "Red" | 2019 | 900175 | -2786760 | +| "Red" | 2020 | 176022 | -724153 | +| "Silver" | 2017 | 326399 | 326399 | +| "Silver" | 2018 | 750026 | 423627 | +| "Silver" | 2019 | 2165176 | 1415150 | +| "Silver" | 2020 | 1871788 | -293388 | +| "White" | 2019 | 2517 | 2517 | +| "White" | 2020 | 2589 | 72 | +| "Yellow" | 2018 | 163071 | 163071 | +| "Yellow" | 2019 | 2072083 | 1909012 | +| "Yellow" | 2020 | 2621602 | 549519 | + +### Using MATCHBY + +You might have noticed we didn't specify MATCHBY at all. In this case, it isn't necessary. The columns in ORDERBY and PARTITIONBY (for as far as they were specified in the examples above) are sufficient to uniquely identify each row. Since we didn't specify MATCHBY, the columns specified in ORDERBY and PARTITIONBY are used to uniquely identify each row so they can be compared to enable OFFSET to give a meaningful result. If the columns in ORDERBY and PARTITIONBY can’t uniquely identify each row, additional columns can be added to the ORDERBY clause if those extra columns allow each row to be uniquely identified. If that's not possible, an error is returned. In this last case, specifying MATCHBY may help to resolve the error. + +If MATCHBY is specified, the columns in MATCHBY and PARTITIONBY are used to uniquely identify each row. If that's not possible, an error is returned. Even if MATCHBY isn't required, consider explicitly specifying MATCHBY to avoid any confusion. + +Continuing from the examples above, here's the last expression: + +```dax +FinalResult = + VAR vRelation = SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + RETURN + ADDCOLUMNS ( + vRelation, + "YoYSalesForSameColor", + [CurrentYearSales] - + SELECTCOLUMNS ( + OFFSET ( + -1, + vRelation, + ORDERBY ([CalendarYear]), + PARTITIONBY ([Color]) + ), + [CurrentYearSales] + ) + ) + +``` + +If we want to be explicit about how rows should be uniquely identified, we can specify MATCHBY as shown in the following equivalent expression: + +```dax +FinalResultWithExplicitMATCHBYOnColorAndCalendarYear = + VAR vRelation = SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + RETURN + ADDCOLUMNS ( + vRelation, + "YoYSalesForSameColor", + [CurrentYearSales] - + SELECTCOLUMNS ( + OFFSET ( + -1, + vRelation, + ORDERBY ([CalendarYear]), + PARTITIONBY ([Color]), + MATCHBY ([Color], [CalendarYear]) + ), + [CurrentYearSales] + ) + ) + +``` + +Since MATCHBY is specified, both the columns specified in MATCHBY as well as in PARTITIONBY are used to uniquely identify rows. Since Color is specified in both MATCHBY and PARTITIONBY, the following expression is equivalent to the previous expression: + +```dax +FinalResultWithExplicitMATCHBYOnCalendarYear = + VAR vRelation = SUMMARIZECOLUMNS ( + DimProduct[Color], + DimDate[CalendarYear], + "CurrentYearSales", ROUND ( SUM ( FactInternetSales[SalesAmount] ), 0 ) + ) + RETURN + ADDCOLUMNS ( + vRelation, + "YoYSalesForSameColor", + [CurrentYearSales] - + SELECTCOLUMNS ( + OFFSET ( + -1, + vRelation, + ORDERBY ([CalendarYear]), + PARTITIONBY ([Color]), + MATCHBY ([CalendarYear]) + ), + [CurrentYearSales] + ) + ) + +``` + +Since specifying MATCHBY isn't necessary in the examples we've looked at so far, let’s look at a slightly different example that does require MATCHBY. In this case, we have a list of order lines. Each row represents an order line for an order. An order can have multiple order lines and order line 1 appears on many orders. In addition, for each order line we have a ProductKey and a SalesAmount. A sample of the relevant columns on the table looks like this: + +| SalesOrderNumber | SalesOrderLineNumber | ProductKey | SalesAmount | +|------------------|----------------------|------------|-------------| +| SO51900 | 1 | 528 | 4.99 | +| SO51948 | 1 | 528 | 5.99 | +| SO52043 | 1 | 528 | 4.99 | +| SO52045 | 1 | 528 | 4.99 | +| SO52094 | 1 | 528 | 4.99 | +| SO52175 | 1 | 528 | 4.99 | +| SO52190 | 1 | 528 | 4.99 | +| SO52232 | 1 | 528 | 4.99 | +| SO52234 | 1 | 528 | 4.99 | +| SO52234 | 2 | 529 | 3.99 | + +Notice SalesOrderNumber and SalesOrderLineNumber are both required to uniquely identify rows. + +For each order, we want to return the previous sales amount of the same product (represented by the ProductKey) ordered by the SalesAmount in descending order. The following expression won't work because there are potentially multiple rows in vRelation as it's passed into OFFSET: + +```dax +ThisExpressionFailsBecauseMATCHBYIsMissing = + ADDCOLUMNS ( + FactInternetSales, + "Previous Sales Amount", + SELECTCOLUMNS ( + OFFSET ( + -1, + FactInternetSales, + ORDERBY ( FactInternetSales[SalesAmount], DESC ), + PARTITIONBY ( FactInternetSales[ProductKey] ) + ), + FactInternetSales[SalesAmount] + ) + ) + +``` + +This expression returns an error: "OFFSET's Relation parameter may have duplicate rows, which isn't allowed." + +In order to make this expression work, MATCHBY must be specified and must include all columns that uniquely define a row. MATCHBY is required here because the relation, FactInternetSales, doesn't contain any explicit keys or unique columns. However, the columns SalesOrderNumber and SalesOrderLineNumber together form a *composite key*, where their existence together is unique in the relation and can therefore uniquely identify each row. Just specifying SalesOrderNumber or SalesOrderLineNumber isn't enough as both columns contain repeating values. The following expression solves the problem: + +```dax +ThisExpressionWorksBecauseOfMATCHBY = + ADDCOLUMNS ( + FactInternetSales, + "Previous Sales Amount", + SELECTCOLUMNS ( + OFFSET ( + -1, + FactInternetSales, + ORDERBY ( FactInternetSales[SalesAmount], DESC ), + PARTITIONBY ( FactInternetSales[ProductKey] ), + MATCHBY ( FactInternetSales[SalesOrderNumber], + FactInternetSales[SalesOrderLineNumber] ) + ), + FactInternetSales[SalesAmount] + ) + ) + +``` + +And this expression does indeed return the results we're after: + +| SalesOrderNumber | SalesOrderLineNumber | ProductKey | SalesAmount | Previous Sales Amount | +|---------------------|----------------------|------------|-------------|-----------------------| +| SO51900 | 1 | 528 | 5.99 | | +| SO51948 | 1 | 528 | 4.99 | 5.99 | +| SO52043 | 1 | 528 | 4.99 | 4.99 | +| SO52045 | 1 | 528 | 4.99 | 4.99 | +| SO52094 | 1 | 528 | 4.99 | 4.99 | +| SO52175 | 1 | 528 | 4.99 | 4.99 | +| SO52190 | 1 | 528 | 4.99 | 4.99 | +| SO52232 | 1 | 528 | 4.99 | 4.99 | +| SO52234 | 1 | 528 | 4.99 | 4.99 | +| SO52234 | 2 | 529 | 3.99 | | + +## Related content + +[ORDERBY](../orderby-function-dax.md) +[PARTITIONBY](../partitionby-function-dax.md) +[MATCHBY](../matchby-function-dax.md) +[INDEX](../index-function-dax.md) +[OFFSET](../offset-function-dax.md) +[WINDOW](../window-function-dax.md) +[RANK](../rank-function-dax.md) +[ROWNUMBER](../rownumber-function-dax.md) diff --git a/query-languages/dax/best-practices/dax-variables.md b/query-languages/dax/best-practices/dax-variables.md index 0ba5f0f24..ba993eadf 100644 --- a/query-languages/dax/best-practices/dax-variables.md +++ b/query-languages/dax/best-practices/dax-variables.md @@ -2,22 +2,17 @@ title: "Use variables to improve your DAX formulas" description: Best practices for using variables in DAX expressions. author: peter-myers -ms.author: owend -ms.reviewer: owend -ms.service: powerbi -ms.subservice: dax ms.topic: conceptual ms.date: 08/25/2021 -recommendations: false --- # Use variables to improve your DAX formulas As a data modeler, writing and debugging some DAX calculations can be challenging. It's common that complex calculation requirements often involve writing compound or complex expressions. Compound expressions can involve the use of many nested functions, and possibly the reuse of expression logic. -Using variables in your DAX formulas can help you write more complex and efficient calculations. Variables can improve performance and reliability, and readability, and reduce complexity. +Using variables in your DAX formulas can help you write more complex and efficient calculations. Variables can improve performance, reliability, readability, and reduce complexity. -In this article, we'll demonstrate the first three benefits by using an example measure for year-over-year (YoY) sales growth. (The formula for YoY sales growth is: period sales *fewer sales for the same period last year, divided by* sales for the same period last year.) +In this article, we'll demonstrate the first three benefits by using an example measure for year-over-year (YoY) sales growth. (The formula for YoY sales growth is period sales, minus sales for the same period last year, divided by sales for the same period last year.) Let's start with the following measure definition. @@ -100,8 +95,8 @@ RETURN ) + 1 ``` -## See also +## Related content - [VAR](../var-dax.md) DAX article -- Learning path: [Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) -- Questions? [Try asking the Power BI Community](https://community.powerbi.com/) \ No newline at end of file +- Learning path: [Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) +- Questions? [Try asking the Power BI Community](https://community.powerbi.com/) diff --git a/query-languages/dax/best-practices/media/dax-understand-orderby/offset-by-calendar-year.png b/query-languages/dax/best-practices/media/dax-understand-orderby/offset-by-calendar-year.png new file mode 100644 index 000000000..95734ff8f Binary files /dev/null and b/query-languages/dax/best-practices/media/dax-understand-orderby/offset-by-calendar-year.png differ diff --git a/query-languages/dax/beta-dist-function-dax.md b/query-languages/dax/beta-dist-function-dax.md index 11e6a67d3..6569c47f4 100644 --- a/query-languages/dax/beta-dist-function-dax.md +++ b/query-languages/dax/beta-dist-function-dax.md @@ -1,50 +1,43 @@ --- description: "Learn more about: BETA.DIST" -title: "BETA.DIST function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "BETA.DIST function (DAX)" --- # BETA.DIST -Returns the beta distribution. The beta distribution is commonly used to study variation in the percentage of something across samples, such as the fraction of the day people spend watching television. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the beta distribution. The beta distribution is commonly used to study variation in the percentage of something across samples, such as the fraction of the day people spend watching television. + +## Syntax + ```dax -BETA.DIST(x,alpha,beta,cumulative,[A],[B]) +BETA.DIST(x,alpha,beta,cumulative,[A],[B]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|x|The value between A and B at which to evaluate the function| -|Alpha|A parameter of the distribution.| -|Beta|A parameter of the distribution.| -|A|Optional. A lower bound to the interval of x.| -|B|Optional. An upper bound to the interval of x.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`x`|The value between A and B at which to evaluate the function| +|`Alpha`|A parameter of the distribution.| +|`Beta`|A parameter of the distribution.| +|`A`|Optional. A lower bound to the interval of x.| +|`B`|Optional. An upper bound to the interval of x.| + ## Return value -Returns the beta distribution. - +Returns the beta distribution. + ## Remarks -- If any argument is nonnumeric, BETA.DIST returns the #VALUE! error value. +- If any argument is nonnumeric, BETA.DIST returns the `#VALUE!` error value. - If any argument is not an integer, it is rounded. - -- If alpha ≤ 0 or beta ≤ 0, BETA.DIST returns the #NUM! error value. - -- If x < A, x > B, or A = B, BETA.DIST returns the #NUM! error value. - -- If you omit values for A and B, BETA.DIST uses the standard cumulative beta distribution, so that A = 0 and B = 1. + +- If `alpha ≤ 0` or beta ≤ 0, BETA.DIST returns the`#NUM!` error value. + +- If x < A, x > B, or A = B, BETA.DIST returns the`#NUM!` error value. + +- If you omit values for A and B, BETA.DIST uses the standard cumulative beta distribution, so that A = 0 and B = 1. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/beta-inv-function-dax.md b/query-languages/dax/beta-inv-function-dax.md index 39e5fe807..7c4cde214 100644 --- a/query-languages/dax/beta-inv-function-dax.md +++ b/query-languages/dax/beta-inv-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: BETA.INV" -title: "BETA.INV function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "BETA.INV function (DAX)" --- # BETA.INV -Returns the inverse of the beta cumulative probability density function (BETA.DIST). - -If probability = BETA.DIST(x,...TRUE), then BETA.INV(probability,...) = x. The beta distribution can be used in project planning to model probable completion times given an expected completion time and variability. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the inverse of the beta cumulative probability density function (BETA.DIST). + +If probability `= BETA.DIST(x,...TRUE)`, then `BETA.INV(probability,...) = x`. The beta distribution can be used in project planning to model probable completion times given an expected completion time and variability. + +## Syntax + ```dax -BETA.INV(probability,alpha,beta,[A],[B]) +BETA.INV(probability,alpha,beta,[A],[B]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Probability|A probability associated with the beta distribution.| -|Alpha|A parameter of the distribution.| -|Beta|A parameter the distribution.| -|A|Optional. A lower bound to the interval of x.| -|B|Optional. An upper bound to the interval of x.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Probability`|A probability associated with the beta distribution.| +|`Alpha`|A parameter of the distribution.| +|`Beta`|A parameter the distribution.| +|`A`|Optional. A lower bound to the interval of x.| +|`B`|Optional. An upper bound to the interval of x.| + ## Return value -Returns the inverse of the beta cumulative probability density function (BETA.DIST). - +Returns the inverse of the beta cumulative probability density function (BETA.DIST). + ## Remarks -- If any argument is nonnumeric, BETA.INV returns the #VALUE! error value. +- If any argument is nonnumeric, `BETA.INV` returns the `#VALUE!` error value. - If any argument is not an integer, it is rounded. - -- If alpha ≤ 0 or beta ≤ 0, BETA.INV returns the #NUM! error value. - -- If probability ≤ 0 or probability > 1, BETA.INV returns the #NUM! error value. - -- If you omit values for A and B, BETA.INV uses the standard cumulative beta distribution, so that A = 0 and B = 1. + +- If `alpha` ≤ 0 or `beta` ≤ 0, `BETA.INV` returns the `#NUM!` error value. + +- If probability ≤ 0 or probability > 1, `BETA.INV` returns the #NUM! error value. + +- If you omit values for A and B, `BETA.INV` uses the standard cumulative beta distribution, so that A = 0 and B = 1. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/bitand-function-dax.md b/query-languages/dax/bitand-function-dax.md index 724774957..d6ba3f24c 100644 --- a/query-languages/dax/bitand-function-dax.md +++ b/query-languages/dax/bitand-function-dax.md @@ -1,22 +1,15 @@ --- description: "Learn more about: BITAND" -title: "BITAND function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 10/11/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "BITAND function (DAX)" --- # BITAND +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns a bitwise AND of two numbers. - -## Syntax - + +## Syntax + ```dax BITAND(, ) ``` @@ -25,12 +18,12 @@ BITAND(, ) |Term|Definition| |--------|--------------| -|Number|Any scalar expression that returns number. If not an integer, it is truncated.| - +|`Number`|Any scalar expression that returns number. If not an integer, it is truncated.| + ## Return value A bitwise AND of two numbers. - + ## Remarks - This function supports both positive and negative numbers. @@ -45,9 +38,9 @@ EVALUATE { BITAND(13, 11) } Returns 9. -## See also +## Related content -[BITLSHIFT](bitlshift-function-dax.md) -[BITRSHIFT](bitrshift-function-dax.md) -[BITOR](bitor-function-dax.md) +[BITLSHIFT](bitlshift-function-dax.md) +[BITRSHIFT](bitrshift-function-dax.md) +[BITOR](bitor-function-dax.md) [BITXOR](bitxor-function-dax.md) diff --git a/query-languages/dax/bitlshift-function-dax.md b/query-languages/dax/bitlshift-function-dax.md index d02bc287a..03d62a7e3 100644 --- a/query-languages/dax/bitlshift-function-dax.md +++ b/query-languages/dax/bitlshift-function-dax.md @@ -1,22 +1,15 @@ --- description: "Learn more about: BITLSHIFT" -title: "BITLSHIFT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 10/11/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "BITLSHIFT function (DAX)" --- # BITLSHIFT -Returns a number shifted left by the specified number of bits. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a number shifted left by the specified number of bits. + +## Syntax + ```dax BITLSHIFT(, ) ``` @@ -25,13 +18,13 @@ BITLSHIFT(, ) |Term|Definition| |--------|--------------| -|Number|Any DAX expression that returns an integer expression.| -|Shift_Amount|Any DAX expression that returns an integer expression.| +|`Number`|Any DAX expression that returns an integer expression.| +|`Shift_Amount`|Any DAX expression that returns an integer expression.| ## Return value An integer value. - + ## Remarks - Be sure to understand the nature of bitshift operations and overflow/underflow of integers before using DAX bitshift functions. @@ -81,9 +74,9 @@ SUMMARIZECOLUMNS( Shifts left each sales amount with 3 bits and returns the bit-shifted sales amount. -## See also +## Related content -[BITRSHIFT](bitrshift-function-dax.md) -[BITAND](bitand-function-dax.md) -[BITOR](bitor-function-dax.md) +[BITRSHIFT](bitrshift-function-dax.md) +[BITAND](bitand-function-dax.md) +[BITOR](bitor-function-dax.md) [BITXOR](bitxor-function-dax.md) diff --git a/query-languages/dax/bitor-function-dax.md b/query-languages/dax/bitor-function-dax.md index 70db08619..8a8d67d70 100644 --- a/query-languages/dax/bitor-function-dax.md +++ b/query-languages/dax/bitor-function-dax.md @@ -1,22 +1,15 @@ --- description: "Learn more about: BITOR" -title: "BITOR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 10/11/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "BITOR function (DAX)" --- # BITOR +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns a bitwise OR of two numbers. - -## Syntax - + +## Syntax + ```dax BITOR(, ) ``` @@ -25,12 +18,12 @@ BITOR(, ) |Term|Definition| |--------|--------------| -|Number|Any scalar expression that returns number. If not an integer, it is truncated.| - +|`Number`|Any scalar expression that returns number. If not an integer, it is truncated.| + ## Return value A bitwise OR of two numbers. - + ## Remarks - This function supports both positive and negative numbers. @@ -46,9 +39,9 @@ EVALUATE Returns 11. -## See also +## Related content -[BITAND](bitand-function-dax.md) -[BITXOR](bitxor-function-dax.md) -[BITLSHIFT](bitlshift-function-dax.md) -[BITRSHIFT](bitrshift-function-dax.md) +[BITAND](bitand-function-dax.md) +[BITXOR](bitxor-function-dax.md) +[BITLSHIFT](bitlshift-function-dax.md) +[BITRSHIFT](bitrshift-function-dax.md) diff --git a/query-languages/dax/bitrshift-function-dax.md b/query-languages/dax/bitrshift-function-dax.md index 4c17c6bbb..a2696828d 100644 --- a/query-languages/dax/bitrshift-function-dax.md +++ b/query-languages/dax/bitrshift-function-dax.md @@ -1,22 +1,15 @@ --- description: "Learn more about: BITRSHIFT" -title: "BITRSHIFT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 10/11/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "BITRSHIFT function (DAX)" --- # BITRSHIFT -Returns a number shifted right by the specified number of bits. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a number shifted right by the specified number of bits. + +## Syntax + ```dax BITRSHIFT(, ) ``` @@ -25,20 +18,20 @@ BITRSHIFT(, ) |Term|Definition| |--------|--------------| -|Number|Any DAX expression that returns an integer expression.| -|Shift_Amount|Any DAX expression that returns an integer expression.| - +|`Number`|Any DAX expression that returns an integer expression.| +|`Shift_Amount`|Any DAX expression that returns an integer expression.| + ## Return value An integer value. - + ## Remarks - Be sure to understand the nature of bitshift operations and overflow/underflow of integers before using DAX bitshift functions. - If Shift_Amount is negative, it will shift in the opposite direction. - If absolute value of Shift_Amount is larger than 64, there will be no error but will result in overflow/underflow. - There’s no limit on Number, but the result may overflow/underflow. - + ## Examples ### Example 1 @@ -81,9 +74,9 @@ SUMMARIZECOLUMNS( Shifts right each sales amount with 3 bits and returns the bit-shifted sales amount. -## See also +## Related content -[BITLSHIFT](bitlshift-function-dax.md) -[BITAND](bitand-function-dax.md) -[BITOR](bitor-function-dax.md) +[BITLSHIFT](bitlshift-function-dax.md) +[BITAND](bitand-function-dax.md) +[BITOR](bitor-function-dax.md) [BITXOR](bitxor-function-dax.md) diff --git a/query-languages/dax/bitxor-function-dax.md b/query-languages/dax/bitxor-function-dax.md index e5b9cfbb7..e8b477eea 100644 --- a/query-languages/dax/bitxor-function-dax.md +++ b/query-languages/dax/bitxor-function-dax.md @@ -1,22 +1,15 @@ --- description: "Learn more about: BITXOR" -title: "BITXOR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 10/11/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "BITXOR function (DAX)" --- # BITXOR +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns a bitwise XOR of two numbers. - -## Syntax - + +## Syntax + ```dax BITXOR(, ) ``` @@ -25,12 +18,12 @@ BITXOR(, ) |Term|Definition| |--------|--------------| -|Number|Any scalar expression that returns number. If not an integer, it is truncated.| - +|`Number`|Any scalar expression that returns number. If not an integer, it is truncated.| + ## Return value A bitwise XOR of two numbers. - + ## Remarks - This function supports both positive and negative numbers. @@ -45,9 +38,9 @@ EVALUATE { BITXOR(9, 10) } Returns 3. -## See also +## Related content -[BITOR](bitor-function-dax.md) -[BITAND](bitand-function-dax.md) -[BITLSHIFT](bitlshift-function-dax.md) -[BITRSHIFT](bitrshift-function-dax.md) +[BITOR](bitor-function-dax.md) +[BITAND](bitand-function-dax.md) +[BITLSHIFT](bitlshift-function-dax.md) +[BITRSHIFT](bitrshift-function-dax.md) diff --git a/query-languages/dax/blank-function-dax.md b/query-languages/dax/blank-function-dax.md index b40473224..1820585fb 100644 --- a/query-languages/dax/blank-function-dax.md +++ b/query-languages/dax/blank-function-dax.md @@ -1,58 +1,51 @@ --- description: "Learn more about: BLANK" -title: "BLANK function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/05/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "BLANK function (DAX)" --- # BLANK -Returns a blank. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a blank. + +## Syntax + ```dax -BLANK() +BLANK() ``` - + ## Return value -A blank. - +A blank. + ## Remarks -- Blanks are not equivalent to nulls. DAX uses blanks for both database nulls and for blank cells in Excel. - +- Blanks are not equivalent to nulls. DAX uses blanks for both database nulls and for blank cells in Excel. + - Some DAX functions treat blank cells somewhat differently from Microsoft Excel. Blanks and empty strings ("") are not always equivalent, but some operations may treat them as such. - + ## Example -The following example illustrates how you can work with blanks in formulas. The formula calculates the ratio of sales between the Resellers and the Internet channels. However, before attempting to calculate the ratio the denominator should be checked for zero values. If the denominator is zero then a blank value should be returned; otherwise, the ratio is calculated. - +The following example illustrates how you can work with blanks in formulas. The formula calculates the ratio of sales between the Resellers and the Internet channels. However, before attempting to calculate the ratio the denominator should be checked for zero values. If the denominator is zero then a blank value should be returned; otherwise, the ratio is calculated. + ```dax -= IF( SUM(InternetSales_USD[SalesAmount_USD])= 0 , BLANK() , SUM(ResellerSales_USD[SalesAmount_USD])/SUM(InternetSales_USD[SalesAmount_USD]) ) += IF( SUM(InternetSales_USD[SalesAmount_USD])= 0 , BLANK() , SUM(ResellerSales_USD[SalesAmount_USD])/SUM(InternetSales_USD[SalesAmount_USD]) ) ``` -The table shows the expected results when this formula is used to create a table visualization. - +The table shows the expected results when this formula is used to create a table visualization. + |Row Labels|Accessories|Bikes|Clothing|Grand Total| |------------------------------------|-----------------|----|----|----| -|2005||2.65||2.89| -|2006||3.33||4.03| -|2007|1.04|2.92|6.63|3.51| -|2008|0.41|1.53|2.00|1.71| -|Grand Total|0.83|2.51|5.45|2.94| - -In the original data source, the column evaluated by the BLANK function might have included text, empty strings, or nulls. If the original data source was a SQL Server database, nulls and empty strings are different kinds of data. However, for this operation an implicit type cast is performed and DAX treats them as the same. - -## See also - -[Text functions](text-functions-dax.md) -[ISBLANK function](isblank-function-dax.md) - +|2005||2.65||2.89| +|2006||3.33||4.03| +|2007|1.04|2.92|6.63|3.51| +|2008|0.41|1.53|2.00|1.71| +|Grand Total|0.83|2.51|5.45|2.94| + +In the original data source, the column evaluated by the BLANK function might have included text, empty strings, or nulls. If the original data source was a SQL Server database, nulls and empty strings are different kinds of data. However, for this operation an implicit type cast is performed and DAX treats them as the same. + +## Related content + +[Text functions](text-functions-dax.md) +[ISBLANK function](isblank-function-dax.md) + diff --git a/query-languages/dax/breadcrumb/toc.yml b/query-languages/dax/breadcrumb/toc.yml index 61d8fca61..940b253a1 100644 --- a/query-languages/dax/breadcrumb/toc.yml +++ b/query-languages/dax/breadcrumb/toc.yml @@ -1,3 +1,3 @@ -- name: Docs - tocHref: / - topicHref: / \ No newline at end of file +- name: Data Analysis Expressions (DAX) + tocHref: /dax/ + topicHref: /dax/index diff --git a/query-languages/dax/calculate-function-dax.md b/query-languages/dax/calculate-function-dax.md index 06e839cc4..b21f1ad11 100644 --- a/query-languages/dax/calculate-function-dax.md +++ b/query-languages/dax/calculate-function-dax.md @@ -1,18 +1,11 @@ --- description: "Learn more about: CALCULATE" -title: "CALCULATE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/09/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CALCULATE function (DAX)" --- # CALCULATE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Evaluates an expression in a modified filter context. > [!NOTE] @@ -30,8 +23,8 @@ CALCULATE([, [, [, …]]]) |Term|Definition| |--------|--------------| -|expression|The expression to be evaluated.| -|filter1, filter2,…|(Optional) Boolean expressions or table expressions that defines filters, or filter modifier functions.| +|`expression`|The expression to be evaluated.| +|`filter1, filter2,…`|(Optional) Boolean expressions or table expressions that defines filters, or filter modifier functions.| The expression used as the first parameter is essentially the same as a measure. @@ -41,11 +34,11 @@ Filters can be: - Table filter expressions - Filter modification functions -When there are multiple filters, they can be evaluated by using the AND (&&) [logical operator](dax-operator-reference.md#logical-operators), meaning all conditions must be TRUE, or by the OR (||) logical operator, meaning either condition can be true. +When there are multiple filters, they can be evaluated by using the AND (`&&`) [logical operator](dax-operator-reference.md#logical-operators), meaning all conditions must be `TRUE`, or by the OR (`||`) logical operator, meaning either condition can be true. #### Boolean filter expressions -A Boolean expression filter is an expression that evaluates to TRUE or FALSE. There are several rules that they must abide by: +A Boolean expression filter is an expression that evaluates to `TRUE` or `FALSE`. There are several rules that they must abide by: - They can reference columns from a single table. - They cannot reference measures. @@ -77,7 +70,7 @@ Filter modifier functions allow you to do more than simply add filters. They pro |[ALL](all-function-dax.md) 1, [ALLEXCEPT](allexcept-function-dax.md), [ALLNOBLANKROW](allnoblankrow-function-dax.md)|Remove filters from one or more columns, or from all columns of a single table.| |[KEEPFILTERS](keepfilters-function-dax.md)|Add filter without removing existing filters on the same columns.| |[USERELATIONSHIP](userelationship-function-dax.md)|Engage an inactive relationship between related columns, in which case the active relationship will automatically become inactive.| -|[CROSSFILTER](crossfilter-function.md)|Modify filter direction (from both to single, or from single to both) or disable a relationship.| +|[CROSSFILTER](crossfilter-function-dax.md)|Modify filter direction (from both to single, or from single to both) or disable a relationship.| 1 The ALL function and its variants behave as both filter modifiers and as functions that return table objects. If the REMOVEFILTERS function is supported by your tool, it's better to use it to remove filters. @@ -121,7 +114,7 @@ The CALCULATE function evaluates the sum of the **Sales** table **Sales Amount** The following **Sales** table measure definition produces a ratio of sales over sales for all sales channels. -|Channel|Sales Amount|Revenue % Total Channel| +|Channel|Sales Amount|Revenue % Total Channel| |-------|------------|-----------------------| |Internet|$29,358,677.22|26.74%| |Reseller|$80,450,596.98|73.26%| @@ -153,9 +146,9 @@ IF( In this example, row context is converted to the filter context. It's known as _context transition_. The [ALLEXCEPT](allexcept-function-dax.md) function removes filters from all **Customer** table columns except the **CustomerKey** column. -## See also +## Related content -[Filter context](dax-overview.md#filter-context) -[Row context](dax-overview.md#row-context) -[CALCULATETABLE function](calculatetable-function-dax.md) -[Filter functions](filter-functions-dax.md) +[Filter context](dax-overview.md#filter-context) +[Row context](dax-overview.md#row-context) +[CALCULATETABLE function](calculatetable-function-dax.md) +[Filter functions](filter-functions-dax.md) diff --git a/query-languages/dax/calculatetable-function-dax.md b/query-languages/dax/calculatetable-function-dax.md index d3366f9f8..9610890d5 100644 --- a/query-languages/dax/calculatetable-function-dax.md +++ b/query-languages/dax/calculatetable-function-dax.md @@ -1,18 +1,11 @@ --- description: "Learn more about: CALCULATETABLE" -title: "CALCULATETABLE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/09/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CALCULATETABLE function (DAX)" --- # CALCULATETABLE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Evaluates a table expression in a modified filter context. > [!NOTE] @@ -20,7 +13,7 @@ Evaluates a table expression in a modified filter context. > > -## Syntax +## Syntax ```dax CALCULATETABLE([, [, [, …]]]) @@ -28,10 +21,10 @@ CALCULATETABLE([, [, [, …]]]) ### Parameters -|Term|Definition| -|--------|--------------| -|expression|The table expression to be evaluated.| -|filter1, filter2,…|(Optional) Boolean expressions or table expressions that defines filters, or filter modifier functions.| +|Term|Definition| +|--------|--------------| +|`expression`|The table expression to be evaluated.| +|`filter1, filter2,…`|(Optional) Boolean expressions or table expressions that defines filters, or filter modifier functions.| The expression used as the first parameter must be a model table or a function that returns a table. @@ -41,11 +34,11 @@ Filters can be: - Table filter expressions - Filter modification functions -When there are multiple filters, they're evaluated by using the AND [logical operator](dax-operator-reference.md#logical-operators). That means all conditions must be TRUE at the same time. +When there are multiple filters, they're evaluated by using the AND [logical operator](dax-operator-reference.md#logical-operators). That means all conditions must be `TRUE` at the same time. #### Boolean filter expressions -A Boolean expression filter is an expression that evaluates to TRUE or FALSE. There are several rules that they must abide by: +A Boolean expression filter is an expression that evaluates to `TRUE` or `FALSE`. There are several rules that they must abide by: - They can reference only a single column. - They cannot reference measures. @@ -70,7 +63,7 @@ Filter modifier functions allow you to do more than simply add filters. They pro |[ALL](all-function-dax.md) 1, [ALLEXCEPT](allexcept-function-dax.md), [ALLNOBLANKROW](allnoblankrow-function-dax.md)|Remove filters from one or more columns, or from all columns of a single table.| |[KEEPFILTERS](keepfilters-function-dax.md)|Add filter without removing existing filters on the same columns.| |[USERELATIONSHIP](userelationship-function-dax.md)|Engage an inactive relationship between related columns, in which case the active relationship will automatically become inactive.| -|[CROSSFILTER](crossfilter-function.md)|Modify filter direction (from both to single, or from single to both) or disable a relationship.| +|[CROSSFILTER](crossfilter-function-dax.md)|Modify filter direction (from both to single, or from single to both) or disable a relationship.| 1 The ALL function and its variants behave as both filter modifiers and as functions that return table objects. If the REMOVEFILTERS function is supported by your tool, it's better to use it to remove filters. @@ -88,7 +81,7 @@ A table of values. ## Example -The following example uses the CALCULATETABLE function to get the sum of Internet sales for 2006. This value is later used to calculate the ratio of Internet sales compared to all sales for the year 2006. +The following example uses the CALCULATETABLE function to get the sum of Internet sales for 2006. This value is later used to calculate the ratio of Internet sales compared to all sales for the year 2006. The following formula: @@ -99,20 +92,20 @@ The following formula: 'DateTime'[CalendarYear] = 2006 ), [SalesAmount_USD] -) +) ``` It results in the following table: -|Row Labels|Internet SalesAmount_USD|CalculateTable 2006 Internet Sales|Internet Sales to 2006 ratio| -|--------------|-----------------------------|--------------------------------------|--------------------------------| -|2005|$2,627,031.40|$5,681,440.58|0.46| -|2006|$5,681,440.58|$5,681,440.58|1.00| -|2007|$8,705,066.67|$5,681,440.58|1.53| -|2008|$9,041,288.80|$5,681,440.58|1.59| -|Grand Total|$26,054,827.45|$5,681,440.58|4.59| +|Row Labels|Internet SalesAmount_USD|CalculateTable 2006 Internet Sales|Internet Sales to 2006 ratio| +|--------------|-----------------------------|--------------------------------------|--------------------------------| +|2005|$2,627,031.40|$5,681,440.58|0.46| +|2006|$5,681,440.58|$5,681,440.58|1.00| +|2007|$8,705,066.67|$5,681,440.58|1.53| +|2008|$9,041,288.80|$5,681,440.58|1.59| +|Grand Total|$26,054,827.45|$5,681,440.58|4.59| -## See also +## Related content - [Filter context](dax-overview.md#filter-context) - [CALCULATE function (DAX)](calculate-function-dax.md) diff --git a/query-languages/dax/calendar-function-dax.md b/query-languages/dax/calendar-function-dax.md index b06c55cc3..3bfc5bdb8 100644 --- a/query-languages/dax/calendar-function-dax.md +++ b/query-languages/dax/calendar-function-dax.md @@ -1,53 +1,46 @@ --- description: "Learn more about: CALENDAR" -title: "CALENDAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/07/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CALENDAR function (DAX)" --- # CALENDAR - -Returns a table with a single column named "Date" that contains a contiguous set of dates. The range of dates is from the specified start date to the specified end date, inclusive of those two dates. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table with a single column named "Date" that contains a contiguous set of dates. The range of dates is from the specified start date to the specified end date, inclusive of those two dates. + +## Syntax + ```dax -CALENDAR(, ) +CALENDAR(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|start_date|Any DAX expression that returns a datetime value.| -|end_date|Any DAX expression that returns a datetime value.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`start_date`|Any DAX expression that returns a datetime value.| +|`end_date`|Any DAX expression that returns a datetime value.| + ## Return value -Returns a table with a single column named "Date" containing a contiguous set of dates. The range of dates is from the specified start date to the specified end date, inclusive of those two dates. - +Returns a table with a single column named "Date" containing a contiguous set of dates. The range of dates is from the specified start date to the specified end date, inclusive of those two dates. + ## Remarks -- An error is returned if start_date is greater than end_date. +- An error is returned if start_date is greater than end_date. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Examples -The following formula returns a table with dates between January 1st, 2015 and December 31st, 2021. - +The following formula returns a table with dates between January 1st, 2015 and December 31st, 2021. + ```dax = CALENDAR (DATE (2015, 1, 1), DATE (2021, 12, 31)) ``` - -For a data model which includes actual sales data and future sales forecasts, the following expression returns a date table covering the range of dates in both the Sales and Forecast tables. - + +For a data model which includes actual sales data and future sales forecasts, the following expression returns a date table covering the range of dates in both the Sales and Forecast tables. + ```dax = CALENDAR (MINX (Sales, [Date]), MAXX (Forecast, [Date])) -``` +``` diff --git a/query-languages/dax/calendarauto-function-dax.md b/query-languages/dax/calendarauto-function-dax.md index 09147048c..986f85917 100644 --- a/query-languages/dax/calendarauto-function-dax.md +++ b/query-languages/dax/calendarauto-function-dax.md @@ -1,52 +1,55 @@ --- description: "Learn more about: CALENDARAUTO" -title: "CALENDARAUTO function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 04/19/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CALENDARAUTO function (DAX)" --- # CALENDARAUTO - -Returns a table with a single column named "Date" that contains a contiguous set of dates. The range of dates is calculated automatically based on data in the model. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table with a single column named "Date" that contains a contiguous set of dates. The range of dates is calculated automatically based on data in the model. + +## Syntax + ```dax -CALENDARAUTO([fiscal_year_end_month]) +CALENDARAUTO([fiscal_year_end_month]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|fiscal_year_end_month|Any DAX expression that returns an integer from 1 to 12. If omitted, defaults to the value specified in the calendar table template for the current user, if present; otherwise, defaults to 12.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`fiscal_year_end_month`|Any DAX expression that returns an integer from 1 to 12. If omitted, defaults to the value specified in the calendar table template for the current user, if present; otherwise, defaults to 12.| + ## Return value -Returns a table with a single column named "Date" that contains a contiguous set of dates. The range of dates is calculated automatically based on data in the model. - +Returns a table with a single column named "Date" that contains a contiguous set of dates. The range of dates is calculated automatically based on data in the model. + ## Remarks -- The date range is calculated as follows: - +- The date range is calculated as follows: + - The earliest date in the model which is not in a calculated column or calculated table is taken as the MinDate. - The latest date in the model which is not in a calculated column or calculated table is taken as the MaxDate. - - The date range returned is dates between the beginning of the fiscal year associated with MinDate and the end of the fiscal year associated with MaxDate. - -- An error is returned if the model does not contain any datetime values which are not in calculated columns or calculated tables. + - The date range returned is dates between the beginning of the fiscal year associated with MinDate and the end of the fiscal year associated with MaxDate. + +- An error is returned if the model does not contain any datetime values which are not in calculated columns or calculated tables. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -In this example, the MinDate and MaxDate in the data model are July 1, 2010 and June 30, 2011. - -`CALENDARAUTO()` will return all dates between January 1, 2010 and December 31, 2011. - -`CALENDARAUTO(3)` will return all dates between March 1, 2010 and March 31, 2012. +In this example, the MinDate and MaxDate in the data model are July 1, 2018 and June 30, 2019. This model contains two calculated tables: + +- **CalendarAuto**. Defined as `CALENDARAUTO()`. Returns all dates between January 1, 2018 and December 31, 2019. +- **CalendarAuto3**. Defined as `CALENDARAUTO(3)`. Returns all dates between April 1, 2018 and March 31, 2020. As in this example `fiscal_year_end_month` is 3, the first years starts on April 1st and ends on March 31st. As a result, the range is determined by selecting the first day of the fiscal year on or before the MinDate's year (April 1, 2018) and the last day of the fiscal year after or within the MaxDate's year (March 31, 2020). + +Below are measure definitions and their return values on the example model: + +```dax +MinDate = MIN('Date'[Date]) //returns July 1, 2018 +MaxDate = MAX('Date'[Date]) //returns June 30, 2019 +MinCalendarAuto = MIN('CalendarAuto'[Date]) //returns January 1, 2018 +MaxCalendarAuto = MAX('CalendarAuto'[Date]) //returns December 31, 2019 +MinCalendarAuto3 = MIN('CalendarAuto3'[Date]) //returns April 1, 2018 +MaxCalendarAuto3 = MAX('CalendarAuto3'[Date]) //returns March 31, 2020 +``` diff --git a/query-languages/dax/ceiling-function-dax.md b/query-languages/dax/ceiling-function-dax.md index 9bb7a960a..8b1d68381 100644 --- a/query-languages/dax/ceiling-function-dax.md +++ b/query-languages/dax/ceiling-function-dax.md @@ -1,72 +1,65 @@ --- description: "Learn more about: CEILING" -title: "CEILING function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CEILING function (DAX)" --- # CEILING -Rounds a number up, to the nearest integer or to the nearest multiple of significance. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Rounds a number up, to the nearest integer or to the nearest multiple of significance. + +## Syntax + ```dax -CEILING(, ) +CEILING(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number you want to round, or a reference to a column that contains numbers.| -|significance|The multiple of significance to which you want to round. For example, to round to the nearest integer, type 1.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number you want to round, or a reference to a column that contains numbers.| +|`significance`|The multiple of significance to which you want to round. For example, to round to the nearest integer, type 1.| + ## Return value -A number rounded as specified. - +A number rounded as specified. + ## Remarks -- There are two CEILING functions in DAX, with the following differences: - - - The CEILING function emulates the behavior of the CEILING function in Excel. - - The ISO.CEILING function follows the ISO-defined behavior for determining the ceiling value. - -- The two functions return the same value for positive numbers, but different values for negative numbers. When using a positive multiple of significance, both CEILING and ISO.CEILING round negative numbers upward (toward positive infinity). When using a negative multiple of significance, CEILING rounds negative numbers downward (toward negative infinity), while ISO.CEILING rounds negative numbers upward (toward positive infinity). - -- The return type is usually of the same type of the significant argument, with the following exceptions: - - - If the number argument type is currency, the return type is currency. - - If the significance argument type is Boolean, the return type is integer. - - If the significance argument type is non-numeric, the return type is real. - +- There are two CEILING functions in DAX, with the following differences: + + - The CEILING function emulates the behavior of the CEILING function in Excel. + - The ISO.CEILING function follows the ISO-defined behavior for determining the ceiling value. + +- The two functions return the same value for positive numbers, but different values for negative numbers. When using a positive multiple of significance, both CEILING and ISO.CEILING round negative numbers upward (toward positive infinity). When using a negative multiple of significance, CEILING rounds negative numbers downward (toward negative infinity), while ISO.CEILING rounds negative numbers upward (toward positive infinity). + +- The return type is usually of the same type of the significant argument, with the following exceptions: + + - If the number argument type is currency, the return type is currency. + - If the significance argument type is Boolean, the return type is integer. + - If the significance argument type is non-numeric, the return type is real. + ## Example 1 -The following formula returns 4.45. This might be useful if you want to avoid using smaller units in your pricing. If an existing product is priced at $4.42, you can use CEILING to round prices up to the nearest unit of five cents. - +The following formula returns 4.45. This might be useful if you want to avoid using smaller units in your pricing. If an existing product is priced at $4.42, you can use CEILING to round prices up to the nearest unit of five cents. + ```dax -= CEILING(4.42,0.05) += CEILING(4.42,0.05) ``` - + ## Example 2 -The following formula returns similar results as the previous example, but uses numeric values stored in the column, **ProductPrice**. - +The following formula returns similar results as the previous example, but uses numeric values stored in the column, **ProductPrice**. + ```dax -= CEILING([ProductPrice],0.05) += CEILING([ProductPrice],0.05) ``` - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[FLOOR function](floor-function-dax.md) -[ISO.CEILING function](iso-ceiling-function-dax.md) -[ROUNDUP function](roundup-function-dax.md) - + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[FLOOR function](floor-function-dax.md) +[ISO.CEILING function](iso-ceiling-function-dax.md) +[ROUNDUP function](roundup-function-dax.md) + diff --git a/query-languages/dax/chisq-dist-function-dax.md b/query-languages/dax/chisq-dist-function-dax.md index 6902b726d..346ae9cc0 100644 --- a/query-languages/dax/chisq-dist-function-dax.md +++ b/query-languages/dax/chisq-dist-function-dax.md @@ -1,56 +1,49 @@ --- description: "Learn more about: CHISQ.DIST" -title: "CHISQ.DIST function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CHISQ.DIST function (DAX)" --- # CHISQ.DIST +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the chi-squared distribution. - + The chi-squared distribution is commonly used to study variation in the percentage of something across samples, such as the fraction of the day people spend watching television. - -## Syntax - + +## Syntax + ```dax CHISQ.DIST(, , ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|x|The value at which you want to evaluate the distribution.| -|Deg_freedom|The number of degrees of freedom.| -|cumulative|A logical value that determines the form of the function. If cumulative is TRUE, CHISQ.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`x`|The value at which you want to evaluate the distribution.| +|`Deg_freedom`|The number of degrees of freedom.| +|`cumulative`|A logical value that determines the form of the function. If cumulative is `TRUE`, CHISQ.DIST returns the cumulative distribution function; if `FALSE`, it returns the probability density function.| + ## Return value -The chi-squared distribution. - +The chi-squared distribution. + ## Remarks -- If x or deg_freedom is nonnumeric, an error is returned. - -- If deg_freedom is not an integer, it is rounded. - -- If x < 0, an error is returned. +- If `x` or `deg_freedom` is nonnumeric, an error is returned. + +- If `deg_freedom` is not an integer, it is rounded. -- If deg_freedom < 1 or deg_freedom > 10^10, an error is returned. +- If `x` < 0, an error is returned. + +- If `deg_freedom` < 1 or `deg_freedom` > 10^10, an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - +## Example + The following DAX query, - + ```dax EVALUATE { CHISQ.DIST(2, 2, TRUE) } ``` diff --git a/query-languages/dax/chisq-dist-rt-function-dax.md b/query-languages/dax/chisq-dist-rt-function-dax.md index ddf932792..0d585d0e3 100644 --- a/query-languages/dax/chisq-dist-rt-function-dax.md +++ b/query-languages/dax/chisq-dist-rt-function-dax.md @@ -1,54 +1,48 @@ --- description: "Learn more about: CHISQ.DIST.RT" -title: "CHISQ.DIST.RT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "CHISQ.DIST.RT function (DAX)" --- # CHISQ.DIST.RT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the right-tailed probability of the chi-squared distribution. - + The chi-squared distribution is associated with a chi-squared test. Use the chi-squared test to compare observed and expected values. For example, a genetic experiment might hypothesize that the next generation of plants will exhibit a certain set of colors. By comparing the observed results with the expected ones, you can decide whether your original hypothesis is valid. - -## Syntax - + +## Syntax + ```dax CHISQ.DIST.RT(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|x|The value at which you want to evaluate the distribution.| -|Deg_freedom|The number of degrees of freedom.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`x`|The value at which you want to evaluate the distribution.| +|`Deg_freedom`|The number of degrees of freedom.| + ## Return value The right-tailed probability of the chi-squared distribution. - + ## Remarks -- If x or deg_freedom is nonnumeric, an error is returned. +- If `x` or `deg_freedom` is nonnumeric, an error is returned. -- If deg_freedom is not an integer, it is rounded. +- If `deg_freedom` is not an integer, it is rounded. -- If x < 0, an error is returned. +- If `x` < 0, an error is returned. -- If deg_freedom < 1 or deg_freedom > 10^10, an error is returned. +- If `deg_freedom` < 1 or `deg_freedom` > 10^10, an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - +## Example + The following DAX query, - + ```dax EVALUATE { CHISQ.DIST.RT(2, 5) } ``` diff --git a/query-languages/dax/chisq-inv-function-dax.md b/query-languages/dax/chisq-inv-function-dax.md index 3f9218456..51e6c5d52 100644 --- a/query-languages/dax/chisq-inv-function-dax.md +++ b/query-languages/dax/chisq-inv-function-dax.md @@ -1,54 +1,47 @@ --- description: "Learn more about: CHISQ.INV" -title: "CHISQ.INV function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CHISQ.INV function (DAX)" --- # CHISQ.INV -Returns the inverse of the left-tailed probability of the chi-squared distribution. - -The chi-squared distribution is commonly used to study variation in the percentage of something across samples, such as the fraction of the day people spend watching television. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the inverse of the left-tailed probability of the chi-squared distribution. + +The chi-squared distribution is commonly used to study variation in the percentage of something across samples, such as the fraction of the day people spend watching television. + +## Syntax + ```dax -CHISQ.INV(probability,deg_freedom) +CHISQ.INV(probability,deg_freedom) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Probability|A probability associated with the chi-squared distribution.| -|Deg_freedom|The number of degrees of freedom.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Probability`|A probability associated with the chi-squared distribution.| +|`Deg_freedom`|The number of degrees of freedom.| + ## Return value -Returns the inverse of the left-tailed probability of the chi-squared distribution. - +Returns the inverse of the left-tailed probability of the chi-squared distribution. + ## Remarks -- If argument is nonnumeric, CHISQ.INV returns the #VALUE! error value. - -- If probability \< 0 or probability > 1, CHISQ.INV returns the #NUM! error value. - -- If deg_freedom is not an integer, it is rounded. - -- If deg_freedom \< 0 or deg_freedom > 10^10, CHISQ.INV returns the #NUM! error value. +- If argument is nonnumeric, CHISQ.INV returns the `#VALUE!` error value. + +- If probability \< 0 or probability > 1, CHISQ.INV returns the `#NUM!` error value. + +- If `deg_freedom` is not an integer, it is rounded. + +- If `deg_freedom` \< 0 or `deg_freedom` > 10^10, CHISQ.INV returns the `#NUM!` error value. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= CHISQ.INV(0.93,1)|Inverse of the left-tailed probability of the chi-squared distribution for 0.93, using 1 degree of freedom.|5.318520074| -|= CHISQ.INV(0.6,2)|Inverse of the left-tailed probability of the chi-squared distribution for 0.6, using 2 degrees of freedom.|1.832581464| +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= CHISQ.INV(0.93,1)`|Inverse of the left-tailed probability of the chi-squared distribution for 0.93, using 1 degree of freedom.|5.318520074| +|`= CHISQ.INV(0.6,2)`|Inverse of the left-tailed probability of the chi-squared distribution for 0.6, using 2 degrees of freedom.|1.832581464| diff --git a/query-languages/dax/chisq-inv-rt-function-dax.md b/query-languages/dax/chisq-inv-rt-function-dax.md index f52f072b0..c5e6a05ef 100644 --- a/query-languages/dax/chisq-inv-rt-function-dax.md +++ b/query-languages/dax/chisq-inv-rt-function-dax.md @@ -1,49 +1,42 @@ --- description: "Learn more about: CHISQ.INV.RT" -title: "CHISQ.INV.RT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CHISQ.INV.RT function (DAX)" --- # CHISQ.INV.RT -Returns the inverse of the right-tailed probability of the chi-squared distribution. - -If probability = CHISQ.DIST.RT(x,...), then CHISQ.INV.RT(probability,...) = x. Use this function to compare observed results with expected ones in order to decide whether your original hypothesis is valid. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the inverse of the right-tailed probability of the chi-squared distribution. + +If probability = CHISQ.DIST.RT(x,...), then CHISQ.INV.RT(probability,...) = x. Use this function to compare observed results with expected ones in order to decide whether your original hypothesis is valid. + +## Syntax + ```dax -CHISQ.INV.RT(probability,deg_freedom) +CHISQ.INV.RT(probability,deg_freedom) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Probability|A probability associated with the chi-squared distribution.| -|Deg_freedom|The number of degrees of freedom.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Probability`|A probability associated with the chi-squared distribution.| +|`Deg_freedom`|The number of degrees of freedom.| + ## Return value -Returns the inverse of the right-tailed probability of the chi-squared distribution. - +Returns the inverse of the right-tailed probability of the chi-squared distribution. + ## Remarks -- If either argument is nonnumeric, CHISQ.INV.RT returns the #VALUE! error value. - -- If probability < 0 or probability > 1, CHISQ.INV.RT returns the #NUM! error value. - -- If deg_freedom is not an integer, it is rounded. - -- If deg_freedom < 1, CHISQ.INV.RT returns the #NUM! error value. - -- Given a value for probability, CHISQ.INV.RT seeks that value x such that CHISQ.DIST.RT(x, deg_freedom) = probability. Thus, precision of CHISQ.INV.RT depends on precision of CHISQ.DIST.RT. CHISQ.INV.RT uses an iterative search technique. If the search has not converged after 64 iterations, the function returns the #N/A error value. +- If either argument is nonnumeric, CHISQ.INV.RT returns the `#VALUE!` error value. + +- If `probability` < 0 or `probability` > 1, CHISQ.INV.RT returns the `#NUM!` error value. + +- If `deg_freedom` is not an integer, it is rounded. + +- If `deg_freedom` < 1, CHISQ.INV.RT returns the `#NUM!` error value. + +- Given a value for probability, CHISQ.INV.RT seeks that value x such that CHISQ.DIST.RT(x, deg_freedom) = probability. Thus, precision of CHISQ.INV.RT depends on precision of CHISQ.DIST.RT. CHISQ.INV.RT uses an iterative search technique. If the search has not converged after 64 iterations, the function returns the #N/A error value. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/closingbalancemonth-function-dax.md b/query-languages/dax/closingbalancemonth-function-dax.md index 07785993f..cfe38fc18 100644 --- a/query-languages/dax/closingbalancemonth-function-dax.md +++ b/query-languages/dax/closingbalancemonth-function-dax.md @@ -1,66 +1,59 @@ --- description: "Learn more about: CLOSINGBALANCEMONTH" -title: "CLOSINGBALANCEMONTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/15/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CLOSINGBALANCEMONTH function (DAX)" --- # CLOSINGBALANCEMONTH -Evaluates the **expression** at the last date of the month in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Evaluates the `expression` at the last date of the month in the current context. + +## Syntax + ```dax -CLOSINGBALANCEMONTH(,[,]) +CLOSINGBALANCEMONTH(,[,]) ``` - -### Parameters - -|Parameter|Definition| -|-------------|--------------| -|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.| - + +### Parameters + +|Parameter|Definition| +|-------------|--------------| +|`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 last date of the month in the current context. - +A scalar value that represents the `expression` evaluated at the last 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. - - > [!NOTE] - > Constraints on Boolean expressions are described in [CALCULATE function](calculate-function-dax.md). - - > [!NOTE] - > The **filter** expression has restrictions described in [CALCULATE function](calculate-function-dax.md). - +- 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. + + > [!NOTE] + > Constraints on Boolean expressions are described in [CALCULATE function](calculate-function-dax.md). + + > [!NOTE] + > The `filter` expression has restrictions described in [CALCULATE function](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'Month End Inventory Value' of the product inventory. - +The following sample formula creates a measure that calculates the 'Month End Inventory Value' of the product inventory. + ```dax -= CLOSINGBALANCEMONTH(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) += CLOSINGBALANCEMONTH(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) ``` - -## See also -[Time intelligence functions](time-intelligence-functions-dax.md) -[CLOSINGBALANCEYEAR function](closingbalanceyear-function-dax.md) -[CLOSINGBALANCEQUARTER function](closingbalancequarter-function-dax.md) +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[CLOSINGBALANCEYEAR function](closingbalanceyear-function-dax.md) +[CLOSINGBALANCEQUARTER function](closingbalancequarter-function-dax.md) diff --git a/query-languages/dax/closingbalancequarter-function-dax.md b/query-languages/dax/closingbalancequarter-function-dax.md index 66fa562b0..fee14572d 100644 --- a/query-languages/dax/closingbalancequarter-function-dax.md +++ b/query-languages/dax/closingbalancequarter-function-dax.md @@ -1,66 +1,59 @@ --- description: "Learn more about: CLOSINGBALANCEQUARTER" -title: "CLOSINGBALANCEQUARTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CLOSINGBALANCEQUARTER function (DAX)" --- # CLOSINGBALANCEQUARTER -Evaluates the **expression** at the last date of the quarter in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Evaluates the `expression` at the last date of the quarter in the current context. + +## Syntax + ```dax -CLOSINGBALANCEQUARTER(,[,]) +CLOSINGBALANCEQUARTER(,[,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|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.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`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 last date of the quarter in the current context. - +A scalar value that represents the `expression` evaluated at the last date of the quarter 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. - - > [!NOTE] - > Constraints on Boolean expressions are described in [CALCULATE function](calculate-function-dax.md). - - > [!NOTE] - > The **filter** expression has restrictions described in [CALCULATE function](calculate-function-dax.md). - +- 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. + + > [!NOTE] + > Constraints on Boolean expressions are described in [CALCULATE function](calculate-function-dax.md). + + > [!NOTE] + > The `filter` expression has restrictions described in [CALCULATE function](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'Quarter End Inventory Value' of the product inventory. - +The following sample formula creates a measure that calculates the 'Quarter End Inventory Value' of the product inventory. + ```dax -= CLOSINGBALANCEQUARTER(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) += CLOSINGBALANCEQUARTER(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) ``` - -## See also -[Time intelligence functions](time-intelligence-functions-dax.md) -[CLOSINGBALANCEYEAR function](closingbalanceyear-function-dax.md) +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[CLOSINGBALANCEYEAR function](closingbalanceyear-function-dax.md) [CLOSINGBALANCEMONTH function](closingbalancemonth-function-dax.md) diff --git a/query-languages/dax/closingbalanceyear-function-dax.md b/query-languages/dax/closingbalanceyear-function-dax.md index d665bc4c7..2204ba642 100644 --- a/query-languages/dax/closingbalanceyear-function-dax.md +++ b/query-languages/dax/closingbalanceyear-function-dax.md @@ -1,70 +1,63 @@ --- description: "Learn more about: CLOSINGBALANCEYEAR" -title: "CLOSINGBALANCEYEAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CLOSINGBALANCEYEAR function (DAX)" --- # CLOSINGBALANCEYEAR -Evaluates the **expression** at the last date of the year in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Evaluates the `expression` at the last date of the year in the current context. + +## Syntax + ```dax -CLOSINGBALANCEYEAR(,[,][,]) +CLOSINGBALANCEYEAR(,[,][,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|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.| -|year_end_date|(optional) A literal string with a date that defines the year-end date. The default is December 31.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`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.| +|`year_end_date`|(optional) A literal string with a date that defines the year-end date. The default is December 31.| + ## Return value -A scalar value that represents the **expression** evaluated at the last date of the year in the current context. - -## Remarks - -- The **year_end_date** parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. - -- 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. - - > [!NOTE] - > Constraints on Boolean expressions are described in [CALCULATE function](calculate-function-dax.md). - - > [!NOTE] - > The **filter** expression has restrictions described in [CALCULATE function](calculate-function-dax.md). - +A scalar value that represents the `expression` evaluated at the last date of the year in the current context. + +## Remarks + +- The `year_end_date` parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. + +- 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. + + > [!NOTE] + > Constraints on Boolean expressions are described in [CALCULATE function](calculate-function-dax.md). + + > [!NOTE] + > The `filter` expression has restrictions described in [CALCULATE function](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following sample formula creates a measure that calculates the 'Year End Inventory Value' of the product inventory. - +The following sample formula creates a measure that calculates the 'Year End Inventory Value' of the product inventory. + ```dax -= CLOSINGBALANCEYEAR(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) += CLOSINGBALANCEYEAR(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) ``` - -## See also -[Time intelligence functions](time-intelligence-functions-dax.md) -[CLOSINGBALANCEYEAR function](closingbalanceyear-function-dax.md) -[CLOSINGBALANCEQUARTER function](closingbalancequarter-function-dax.md) -[CLOSINGBALANCEMONTH function](closingbalancemonth-function-dax.md) +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[CLOSINGBALANCEYEAR function](closingbalanceyear-function-dax.md) +[CLOSINGBALANCEQUARTER function](closingbalancequarter-function-dax.md) +[CLOSINGBALANCEMONTH function](closingbalancemonth-function-dax.md) diff --git a/query-languages/dax/coalesce-function-dax.md b/query-languages/dax/coalesce-function-dax.md index 1576339f4..bb9ca69e2 100644 --- a/query-languages/dax/coalesce-function-dax.md +++ b/query-languages/dax/coalesce-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: COALESCE" -title: "COALESCE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 03/09/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COALESCE function (DAX)" --- # COALESCE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the first expression that does not evaluate to BLANK. If all expressions evaluate to BLANK, BLANK is returned. - -## Syntax - + +## Syntax + ```dax COALESCE(, [, ]…) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|expression|Any DAX expression that returns a scalar expression.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression`|Any DAX expression that returns a scalar expression.| + ## Return value A scalar value coming from one of the expressions or BLANK if all expressions evaluate to BLANK. - + ## Remarks Input expressions may be of different data types. - + ## Example 1 - + The following DAX query: ```dax EVALUATE { COALESCE(BLANK(), 10, DATE(2008, 3, 3)) } ``` - Returns `10`, which is the first expression that does not evaluate to BLANK. + Returns `10`, which is the first expression that does not evaluate to BLANK. ## Example 2 - + The following DAX expression: ```dax diff --git a/query-languages/dax/collapse-function-dax.md b/query-languages/dax/collapse-function-dax.md new file mode 100644 index 000000000..9b1f8e5a6 --- /dev/null +++ b/query-languages/dax/collapse-function-dax.md @@ -0,0 +1,77 @@ +--- +description: "Learn more about: COLLAPSE" +title: "COLLAPSE function (DAX)" +ms.service: powerbi +ms.subservice: dax +ms.date: 02/20/2024 +ms.topic: reference +author: jewang-msft +ms.author: jewang +recommendations: false + +--- + +# COLLAPSE + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Retrieves a context at a higher level compared to the current context. If an expression is provided, returns its value in the new context, allowing for navigation in hierarchies and calculation at a higher level. + +## Syntax + +The syntaxes that perform both navigation and calculation. +```dax +COLLAPSE ( , [, N] ) +COLLAPSE ( , [, ] ... ) +``` + +The syntaxes that perform navigation only. +```dax +COLLAPSE ( [, N] ) +COLLAPSE ( [, ] ... ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression`|The expression to be evaluated in the new context.| +|`axis`|An axis reference.| +|`column`|A column in the data grid.| +|`N`|(Optional) The number of levels to collapse. If omitted, the default value is 1.| + +## Return value + +For versions that perform both navigation and calculation, the function returns the value of the expression in the new context after navigating to a new level. +For versions that perform navigation only, the function modifies the evaluation context by navigating to a new level. + +## Remarks + +* This function can be used only in visual calculations. +* The navigation-only versions of the function can be used inside the CALCULATE function. +* The levels of the hierarchy are determined by all columns in each axis referenced by the axis reference. +* When columns are specified, the axes are determined by including each column's axis the first time it is encountered. +* When N is specified, the function navigates up the hierarchy N levels from the current level or the topmost level, whichever comes first. +* When multiple columns are specified, the function navigates up the hierarchy until it reaches the first level at which none of the specified columns is present. +* Navigation begins at the current cell in the data matrix, ascending up the hierarchy. If a specified column is at a level lower than the current cell, it will be disregarded. + +## Example + +Given a table that summarizes the total sales for a hierarchy with levels for total, year, quarter and month, the following DAX calculations fetch the value of [SalesAmount] at the parent level, the grandparent level, and the year or self level, respectively. + +```dax +ParentValue = COLLAPSE([SalesAmount], ROWS) +GrandParentValue = COLLAPSE([SalesAmount], ROWS, 2) +QuarterOrSelfValue = COLLAPSE([SalesAmount], [Month]) +``` + +The screenshot below shows the matrix with the three visual calculations. + +![DAX visual calculation](media/dax-queries/dax-visualcalc-collapse.png) + +## See also + +[EXPAND](expand-function-dax.md) +[EXPANDALL](expandall-function-dax.md) +[COLLAPSEALL](collapseall-function-dax.md) + diff --git a/query-languages/dax/collapseall-function-dax.md b/query-languages/dax/collapseall-function-dax.md new file mode 100644 index 000000000..c46521a54 --- /dev/null +++ b/query-languages/dax/collapseall-function-dax.md @@ -0,0 +1,67 @@ +--- +description: "Learn more about: COLLAPSEALL" +title: "COLLAPSEALL function (DAX)" +ms.service: powerbi +ms.subservice: dax +ms.date: 02/20/2024 +ms.topic: reference +author: jewang-msft +ms.author: jewang +recommendations: false + +--- + +# COLLAPSEALL + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Retrieves a context at the highest level compared to the current context. If an expression is provided, returns its value in the new context, allowing for navigation in hierarchies and calculation at the highest level. + +## Syntax + +The syntax that performs both navigation and calculation. +```dax +COLLAPSEALL ( , ) +``` + +The syntax that performs navigation only. +```dax +COLLAPSEALL ( ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression`|The expression to be evaluated in the new context.| +|`axis`|An axis reference.| + +## Return value + +For the version that performs both navigation and calculation, the function returns the value of the expression in the new context after navigating to the highest level. +For the version that performs navigation only, the function modifies the evaluation context by navigating to the highest level. + +## Remarks + +* This function can be used only in visual calculations. +* The navigation-only versions of the function can be used inside the CALCULATE function. +* The levels of the hierarchy are determined by all columns in each axis referenced by the axis reference. + +## Example + +Given a table that summarizes the total sales for a hierarchy with levels for total, year, quarter and month, the following DAX calculation fetches the value of [SalesAmount] at the highest level, total. + +```dax +TotalValue = COLLAPSEALL([SalesAmount], ROWS) +``` + +The screenshot below shows the matrix with the visual calculation. + +![DAX visual calculation](media/dax-queries/dax-visualcalc-collapseall.png) + +## See also + +[EXPAND](expand-function-dax.md) +[EXPANDALL](expandall-function-dax.md) +[COLLAPSE](collapse-function-dax.md) + diff --git a/query-languages/dax/columnstatistics-function-dax.md b/query-languages/dax/columnstatistics-function-dax.md new file mode 100644 index 000000000..f54388478 --- /dev/null +++ b/query-languages/dax/columnstatistics-function-dax.md @@ -0,0 +1,68 @@ +--- +description: "Learn more about: COLUMNSTATISTICS" +title: "COLUMNSTATISTICS function (DAX)" +ms.custom: sfi-image-nochange +--- +# COLUMNSTATISTICS + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table of statistics regarding every column in every table in the model. + +## Syntax + +```dax +COLUMNSTATISTICS () +``` + +### Parameters + +This function does not take any parameters. + +## Return value + +A table of statistics. Each row of this table represents a different column in the model. Table columns include: + +- `Table Name`: The current column’s table. +- `Column Name`: The current column’s name. +- `Min`: The minimum value found within the current column. +- `Max`: The maximum value found within the current column. +- `Cardinality`: The number of distinct values found within the current column. +- `Max Length`: The length of the longest string found within the current column (only applicable for string columns). + +## Remarks + +- Columns in an error state and columns from query-scope calculated tables do not appear in the result table. + +- If a filter from the filter context is applied to COLUMNSTATISTICS(), an error is returned. + +- For binary-typed columns, the Min and Max statistics will have BLANK values. + +## Example + +[!INCLUDE [power-bi-dax-sample-model](includes/power-bi-dax-sample-model.md)] + +The following DAX query: + +```dax +DEFINE + TABLE FilteredProduct = + FILTER ( + Product, + [Color] == "Blue" + ) + COLUMN Customer[Location] = [State-Province] & " " & [Country-Region] + +EVALUATE +COLUMNSTATISTICS () + +``` + +Returns a table with statistics regarding all columns from all tables in the model. The table also includes statistics for the query-scope calculated column, Customer[Location]. However, the table does not include the columns from the query-scope calculated table, FilteredProduct. + +:::image type="content" source="media/columnstatistics-function-dax/columnstatistics-result-table.png" alt-text="COLUMNSTATISTICS result table"::: + +## Related content + +[Filter context](dax-overview.md#filter-context) +[CALCULATETABLE function](calculatetable-function-dax.md) diff --git a/query-languages/dax/combin-function-dax.md b/query-languages/dax/combin-function-dax.md index 679a08863..e12721b84 100644 --- a/query-languages/dax/combin-function-dax.md +++ b/query-languages/dax/combin-function-dax.md @@ -1,60 +1,53 @@ --- description: "Learn more about: COMBIN" -title: "COMBIN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COMBIN function (DAX)" --- # COMBIN -Returns the number of combinations for a given number of items. Use COMBIN to determine the total possible number of groups for a given number of items. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the number of combinations for a given number of items. Use COMBIN to determine the total possible number of groups for a given number of items. + +## Syntax + ```dax -COMBIN(number, number_chosen) +COMBIN(number, number_chosen) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number of items.| -|number_chosen|The number of items in each combination.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number of items.| +|`number_chosen`|The number of items in each combination.| + ## Return value -Returns the number of combinations for a given number of items. - +Returns the number of combinations for a given number of items. + ## Remarks -- Numeric arguments are truncated to integers. +- Numeric arguments are truncated to integers. -- If either argument is nonnumeric, COMBIN returns the #VALUE! error value. +- If either argument is nonnumeric, COMBIN returns the `#VALUE!` error value. -- If number < 0, number_chosen < 0, or number < number_chosen, COMBIN returns the #NUM! error value. +- If number < 0, number_chosen < 0, or number < number_chosen, COMBIN returns the `#NUM!` error value. -- A combination is any set or subset of items, regardless of their internal order. Combinations are distinct from permutations, for which the internal order is significant. +- A combination is any set or subset of items, regardless of their internal order. Combinations are distinct from permutations, for which the internal order is significant. -- The number of combinations is as follows, where number = $n$ and number_chosen = $k$: +- The number of combinations is as follows, where number = $n$ and number_chosen = $k$: $${n \choose k} = \frac{P\_{k,n}}{k!} = \frac{n!}{k!(n-k)!}$$ - Where + Where $$P\_{k,n} = \frac{n!}{(n-k)!}$$ - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= COMBIN(8,2)|Possible two-person teams that can be formed from 8 candidates.|28| +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= COMBIN(8,2)`|Possible two-person teams that can be formed from 8 candidates.|28| diff --git a/query-languages/dax/combina-function-dax.md b/query-languages/dax/combina-function-dax.md index 30d291435..8c921e023 100644 --- a/query-languages/dax/combina-function-dax.md +++ b/query-languages/dax/combina-function-dax.md @@ -1,53 +1,46 @@ --- description: "Learn more about: COMBINA" -title: "COMBINA function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COMBINA function (DAX)" --- # COMBINA -Returns the number of combinations (with repetitions) for a given number of items. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the number of combinations (with repetitions) for a given number of items. + +## Syntax + ```dax -COMBINA(number, number_chosen) +COMBINA(number, number_chosen) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Must be greater than or equal to 0, and greater than or equal to Number_chosen. Non-integer values are truncated.| -|number_chosen|Must be greater than or equal to 0. Non-integer values are truncated.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Must be greater than or equal to 0, and greater than or equal to Number_chosen. Non-integer values are truncated.| +|`number_chosen`|Must be greater than or equal to 0. Non-integer values are truncated.| + ## Return value -Returns the number of combinations (with repetitions) for a given number of items. - +Returns the number of combinations (with repetitions) for a given number of items. + ## Remarks -- If the value of either argument is outside of its constraints, COMBINA returns the #NUM! error value. +- If the value of either argument is outside of its constraints, COMBINA returns the `#NUM!` error value. -- If either argument is a non-numeric value, COMBINA returns the #VALUE! error value. +- If either argument is a non-numeric value, COMBINA returns the `#VALUE!` error value. -- The following equation is used, where $N$ is Number and $M$ is Number_chosen: +- The following equation is used, where $N$ is Number and $M$ is Number_chosen: $${N+M-1 \choose N-1}$$ - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= COMBINA(4,3)|Returns the number of combinations (with repetitions) for 4 and 3.|20| -|= COMBINA(10,3)|Returns the number of combinations (with repetitions) for 10 and 3.|220| +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= COMBINA(4,3)`|Returns the number of combinations (with repetitions) for 4 and 3.|20| +|`= COMBINA(10,3)`|Returns the number of combinations (with repetitions) for 10 and 3.|220| diff --git a/query-languages/dax/combinevalues-function-dax.md b/query-languages/dax/combinevalues-function-dax.md index b2aa4af94..dc4805f55 100644 --- a/query-languages/dax/combinevalues-function-dax.md +++ b/query-languages/dax/combinevalues-function-dax.md @@ -1,40 +1,34 @@ --- description: "Learn more about: COMBINEVALUES" -title: "COMBINEVALUES function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 03/16/2022 -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COMBINEVALUES function (DAX)" --- # COMBINEVALUES -Joins two or more text strings into one text string. The primary purpose of this function is to support multi-column relationships in DirectQuery models. See **Remarks** for details. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Joins two or more text strings into one text string. The primary purpose of this function is to support multi-column relationships in DirectQuery models. See [remarks](#remarks) for details. + +## Syntax + ```dax COMBINEVALUES(, , [, ]…) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|delimiter|A separator to use during concatenation. Must be a constant value.| -|expression|A DAX expression whose value will be be joined into a single text string.| - -## Return value - -A concatenated string. - -## Remarks - -- The COMBINEVALUES function assumes, but does not validate, that when the input values are different, the output strings are also different. Based on this assumption, when COMBINEVALUES is used to create calculated columns in order to build a relationship that joins multiple columns from two DirectQuery tables, an optimized join condition is generated at query time. For example, if users want to create a relationship between Table1(Column1, Column2) and Table2(Column1, Column2), they can create two calculated columns, one on each table, as: + +### Parameters + +|Term|Definition| +|--------|--------------| +|`delimiter`|A separator to use during concatenation. Must be a constant value.| +|`expression`|A DAX expression whose value will be joined into a single text string.| + +## Return value + +A concatenated string. + +## Remarks + +- The COMBINEVALUES function assumes, but does not validate, that when the input values are different, the output strings are also different. Based on this assumption, when COMBINEVALUES is used to create calculated columns in order to build a relationship that joins multiple columns from two DirectQuery tables, an optimized join condition is generated at query time. For example, if users want to create a relationship between Table1(Column1, Column2) and Table2(Column1, Column2), they can create two calculated columns, one on each table, as: ```dax Table1[CalcColumn] = COMBINEVALUES(",", Table1[Column1], Table1[Column2]) @@ -56,16 +50,16 @@ A concatenated string. ```dax (Table1.Column2 = Table2.Column2 OR Table1.Column2 IS NULL AND Table2.Column2 IS NULL) - ``` + ``` - The join predicate can potentially deliver much better query performance than one that involves complex SQL operators and functions. - The COMBINEVALUES function relies on users to choose the appropriate delimiter to ensure that unique combinations of input values produce distinct output strings but it does not validate that the assumption is true. For example, if users choose `"| "` as the delimiter, but one row in Table1 has `Table1[Column1] = "| "` and `Table2 [Column2] = " "`, while one row in Table2 has `Table2[Column1] = " "` and `Table2[Column2] = "| "`, the two concatenated outputs will be the same `"|| "`, which seem to indicate that the two rows are a match in the join operation. The two rows are not joined together if both tables are from the same DirectQuery source although they are joined together if both tables are imported. -## Example +## Example The following DAX query: - + ```dax EVALUATE DISTINCT ( diff --git a/query-languages/dax/concatenate-function-dax.md b/query-languages/dax/concatenate-function-dax.md index 19d18663b..cefa0403d 100644 --- a/query-languages/dax/concatenate-function-dax.md +++ b/query-languages/dax/concatenate-function-dax.md @@ -1,92 +1,85 @@ --- description: "Learn more about: CONCATENATE" -title: "CONCATENATE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 03/16/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CONCATENATE function (DAX)" --- # CONCATENATE -Joins two text strings into one text string. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Joins two text strings into one text string. + +## Syntax + ```dax -CONCATENATE(, ) +CONCATENATE(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text1|The first text string to be joined into a single text string. The string can include text or numbers. You can also use column references.| -|text2|The second text string to be joined into a single text string. The string can include text or numbers. You can also use column references.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text1`|The first text string to be joined into a single text string. The string can include text or numbers. You can also use column references.| +|`text2`|The second text string to be joined into a single text string. The string can include text or numbers. You can also use column references.| + ## Return value -A concatenated string. - +A concatenated string. + ## Remarks -- The CONCATENATE function joins two text strings into one text string. The joined items can be text, numbers, Boolean values represented as text, or a combination of those items. You can also use a column reference if the column contains appropriate values. - -- The CONCATENATE function in DAX accepts only two arguments, whereas the Excel CONCATENATE function accepts up to 255 arguments. If you need to concatenate multiple columns, you can create a series of calculations or use the concatenation operator (**&**) to join all of them in a simpler expression. - -- If you want to use text strings directly, rather than using a column reference, you must enclose each string in double quotation marks. - +- The CONCATENATE function joins two text strings into one text string. The joined items can be text, numbers, Boolean values represented as text, or a combination of those items. You can also use a column reference if the column contains appropriate values. + +- The CONCATENATE function in DAX accepts only two arguments, whereas the Excel CONCATENATE function accepts up to 255 arguments. If you need to concatenate multiple columns, you can create a series of calculations or use the concatenation operator (`&`) to join all of them in a simpler expression. + +- If you want to use text strings directly, rather than using a column reference, you must enclose each string in double quotation marks. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example: Concatenation of Literals - -The sample formula creates a new string value by combining two string values that you provide as arguments. + +## Example: Concatenation of Literals + +The sample formula creates a new string value by combining two string values that you provide as arguments. ```dax = CONCATENATE("Hello ", "World") ``` - -## Example: Concatenation of strings in columns -The sample formula returns the customer's full name as listed in a phone book. Note how a nested function is used as the second argument. This is one way to concatenate multiple strings when you have more than two values that you want to use as arguments. +## Example: Concatenation of strings in columns + +The sample formula returns the customer's full name as listed in a phone book. Note how a nested function is used as the second argument. This is one way to concatenate multiple strings when you have more than two values that you want to use as arguments. ```dax = CONCATENATE(Customer[LastName], CONCATENATE(", ", Customer[FirstName])) ``` - -## Example: Conditional concatenation of strings in columns - -The sample formula creates a new calculated column in the Customer table with the full customer name as a combination of first name, middle initial, and last name. If there is no middle name, the last name comes directly after the first name. If there is a middle name, only the first letter of the middle name is used and the initial letter is followed by a period. + +## Example: Conditional concatenation of strings in columns + +The sample formula creates a new calculated column in the Customer table with the full customer name as a combination of first name, middle initial, and last name. If there is no middle name, the last name comes directly after the first name. If there is a middle name, only the first letter of the middle name is used and the initial letter is followed by a period. ```dax -= CONCATENATE( [FirstName]&" ", CONCATENATE( IF( LEN([MiddleName])>1, LEFT([MiddleName],1)&" ", ""), [LastName])) += CONCATENATE( [FirstName]&" ", CONCATENATE( IF( LEN([MiddleName])>1, LEFT([MiddleName],1)&". ", ""), [LastName])) ``` - -This formula uses nested CONCATENATE and IF functions, together with the ampersand (**&**) operator, to conditionally concatenate three string values and add spaces as separators. - + +This formula uses nested CONCATENATE and IF functions, together with the ampersand (`&`) operator, to conditionally concatenate three string values and add spaces as separators. + ## Example: Concatenation of columns with different data types -The following example demonstrates how to concatenate values in columns that have different data types. If the value that you are concatenating is numeric, the value will be implicitly converted to text. If both values are numeric, both values will be cast to text and concatenated as if they were strings. - -|Product description|Product abbreviation (column 1 of composite key)|Product number (column 2 of composite key)|New generated key column| -|-----------------------|----------------------------------------------------|----------------------------------------------|----------------------------| -|Mountain bike|MTN|40|MTN40| -|Mountain bike|MTN|42|MTN42| +The following example demonstrates how to concatenate values in columns that have different data types. If the value that you are concatenating is numeric, the value will be implicitly converted to text. If both values are numeric, both values will be cast to text and concatenated as if they were strings. + +|Product description|Product abbreviation (column 1 of composite key)|Product number (column 2 of composite key)|New generated key column| +|-----------------------|----------------------------------------------------|----------------------------------------------|----------------------------| +|Mountain bike|MTN|40|MTN40| +|Mountain bike|MTN|42|MTN42| ```dax -= CONCATENATE('Products'[Product abbreviation],'Products'[Product number]) += CONCATENATE('Products'[Product abbreviation],'Products'[Product number]) ``` - -The CONCATENATE function in DAX accepts only two arguments, whereas the Excel CONCATENATE function accepts up to 255 arguments. If you need to add more arguments, you can use the ampersand (&) operator. For example, the following formula produces the results, MTN-40 and MTN-42. - + +The CONCATENATE function in DAX accepts only two arguments, whereas the Excel CONCATENATE function accepts up to 255 arguments. If you need to add more arguments, you can use the ampersand (&) operator. For example, the following formula produces the results, MTN-40 and MTN-42. + ```dax -= [Product abbreviation] & "-" & [Product number] += [Product abbreviation] & "-" & [Product number] ``` - -## See also -[CONCATENATEX](concatenatex-function-dax.md) +## Related content + +[CONCATENATEX](concatenatex-function-dax.md) diff --git a/query-languages/dax/concatenatex-function-dax.md b/query-languages/dax/concatenatex-function-dax.md index 04fa6a889..12c53d5e3 100644 --- a/query-languages/dax/concatenatex-function-dax.md +++ b/query-languages/dax/concatenatex-function-dax.md @@ -1,69 +1,62 @@ --- description: "Learn more about: CONCATENATEX" -title: "CONCATENATEX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 03/16/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CONCATENATEX function (DAX)" --- # CONCATENATEX - -Concatenates the result of an expression evaluated for each row in a table. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Concatenates the result of an expression evaluated for each row in a table. + +## Syntax + ```dax -CONCATENATEX(
, [, [, [, ]]...]) +CONCATENATEX(
, [, [, [, ]]...]) ``` - -### Parameters - -|Term|Definition| -|-----|-----| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of *table*.| -|delimiter|(Optional) A separator to use during concatenation.| -|orderBy_expression|(Optional) Any DAX expression where the result value is used to sort the concatenated values in the output string. It is evaluated for each row of *table*.| -|order|(Optional) A value that specifies how to sort *orderBy_expression* values, ascending or descending.| - -The optional **order** parameter accepts the following values: + +### Parameters + +|Term|Definition| +|-----|-----| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of `table`.| +|`delimiter`|(Optional) A separator to use during concatenation.| +|`orderBy_expression`|(Optional) Any DAX expression where the result value is used to sort the concatenated values in the output string. It is evaluated for each row of `table`.| +|`order`|(Optional) A value that specifies how to sort `orderBy_expression` values, ascending or descending.| + +The optional `order` parameter accepts the following values: |Value|Alternate Values|Description| |-----|-----|-----| -|0 (zero)|FALSE, DESC|Sorts in descending order of values of *orderBy_expression*. This is the default value when the *order* parameter is omitted.| -|1|TRUE, ASC|Sorts in ascending order of values of *orderBy_expression*.| +|0 (zero)|`FALSE`, `DESC`|Sorts in descending order of values of `orderBy_expression`. This is the default value when the `order` parameter is omitted.| +|1|`TRUE`, `ASC`|Sorts in ascending order of values of `orderBy_expression`.| ## Return value A concatenated string. - + ## Remarks -- This function takes as its first argument a table or an expression that returns a table. The second argument is a column that contains the values you want to concatenate, or an expression that returns a value. +- This function takes as its first argument a table or an expression that returns a table. The second argument is a column that contains the values you want to concatenate, or an expression that returns a value. -- Concatenated values are not necessarily sorted in any particular order, unless *orderBy_expression* is specified. +- Concatenated values are not necessarily sorted in any particular order, unless `orderBy_expression` is specified. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -Employees table - -|FirstName|LastName| -|-------------|------------| -|Alan|Brewer| -|Michael|Blythe| +Employees table -The following formula: +|FirstName|LastName| +|-------------|------------| +|Alan|Brewer| +|Michael|Blythe| + +The following formula: ```dax -= CONCATENATEX(Employees, [FirstName] & " " & [LastName], ",") += CONCATENATEX(Employees, [FirstName] & " " & [LastName], ",") ``` - -Returns: -"Alan Brewer, Michael Blythe" + +Returns: +"Alan Brewer, Michael Blythe" diff --git a/query-languages/dax/confidence-norm-function-dax.md b/query-languages/dax/confidence-norm-function-dax.md index ee8ebb22e..919e7c229 100644 --- a/query-languages/dax/confidence-norm-function-dax.md +++ b/query-languages/dax/confidence-norm-function-dax.md @@ -1,51 +1,44 @@ --- description: "Learn more about: CONFIDENCE.NORM" -title: "CONFIDENCE.NORM function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CONFIDENCE.NORM function (DAX)" --- # CONFIDENCE.NORM -The confidence interval is a range of values. Your sample mean, x, is at the center of this range and the range is x ± CONFIDENCE.NORM. For example, if x is the sample mean of delivery times for products ordered through the mail, x ± CONFIDENCE.NORM is a range of population means. For any population mean, μ0, in this range, the probability of obtaining a sample mean further from μ0 than x is greater than alpha; for any population mean, μ0, not in this range, the probability of obtaining a sample mean further from μ0 than x is less than alpha. In other words, assume that we use x, standard_dev, and size to construct a two-tailed test at significance level alpha of the hypothesis that the population mean is μ0. Then we will not reject that hypothesis if μ0 is in the confidence interval and will reject that hypothesis if μ0 is not in the confidence interval. The confidence interval does not allow us to infer that there is probability 1 – alpha that our next package will take a delivery time that is in the confidence interval. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +The confidence interval is a range of values. Your sample mean, x, is at the center of this range and the range is x ± CONFIDENCE.NORM. For example, if x is the sample mean of delivery times for products ordered through the mail, x ± CONFIDENCE.NORM is a range of population means. For any population mean, μ0, in this range, the probability of obtaining a sample mean further from μ0 than x is greater than alpha; for any population mean, μ0, not in this range, the probability of obtaining a sample mean further from μ0 than x is less than alpha. In other words, assume that we use x, standard_dev, and size to construct a two-tailed test at significance level alpha of the hypothesis that the population mean is μ0. Then we will not reject that hypothesis if μ0 is in the confidence interval and will reject that hypothesis if μ0 is not in the confidence interval. The confidence interval does not allow us to infer that there is probability 1 – alpha that our next package will take a delivery time that is in the confidence interval. + +## Syntax + ```dax -CONFIDENCE.NORM(alpha,standard_dev,size) +CONFIDENCE.NORM(alpha,standard_dev,size) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|alpha|The significance level used to compute the confidence level. The confidence level equals 100*(1 - alpha)%, or in other words, an alpha of 0.05 indicates a 95 percent confidence level.| -|standard_dev|The population standard deviation for the data range and is assumed to be known.| -|standard_dev,size|The sample size.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`alpha`|The significance level used to compute the confidence level. The confidence level equals 100*(1 - alpha)%, or in other words, an alpha of 0.05 indicates a 95 percent confidence level.| +|`standard_dev`|The population standard deviation for the data range and is assumed to be known.| +|`standard_dev,size`|The sample size.| + ## Return value -A range of values - +A range of values + ## Remarks -- If any argument is nonnumeric, CONFIDENCE.NORM returns the #VALUE! error value. +- If any argument is nonnumeric, CONFIDENCE.NORM returns the `#VALUE!` error value. -- If alpha ≤ 0 or alpha ≥ 1, CONFIDENCE.NORM returns the #NUM! error value. +- If `alpha ≤ 0` or `alpha ≥ 1`, CONFIDENCE.NORM returns the `#NUM!` error value. -- If standard_dev ≤ 0, CONFIDENCE.NORM returns the #NUM! error value. +- If `standard_dev ≤ 0`, CONFIDENCE.NORM returns the `#NUM!` error value. -- If size is not an integer, it is rounded. +- If `size` is not an integer, it is rounded. -- If size < 1, CONFIDENCE.NORM returns the #NUM! error value. +- If `size < 1`, CONFIDENCE.NORM returns the `#NUM!` error value. -- If we assume alpha equals 0.05, we need to calculate the area under the standard normal curve that equals (1 - alpha), or 95 percent. This value is ± 1.96. The confidence interval is therefore: +- If we assume alpha equals 0.05, we need to calculate the area under the standard normal curve that equals (1 - alpha), or 95 percent. This value is ± 1.96. The confidence interval is therefore: $$\overline{x} \pm 1.96 \bigg( \frac{\sigma}{\sqrt{n}} \bigg) $$ diff --git a/query-languages/dax/confidence-t-function-dax.md b/query-languages/dax/confidence-t-function-dax.md index 862050ca6..31b52393c 100644 --- a/query-languages/dax/confidence-t-function-dax.md +++ b/query-languages/dax/confidence-t-function-dax.md @@ -1,54 +1,47 @@ --- description: "Learn more about: CONFIDENCE.T" -title: "CONFIDENCE.T function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CONFIDENCE.T function (DAX)" --- # CONFIDENCE.T -Returns the confidence interval for a population mean, using a Student's t distribution. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the confidence interval for a population mean, using a Student's t distribution. + +## Syntax + ```dax -CONFIDENCE.T(alpha,standard_dev,size) +CONFIDENCE.T(alpha,standard_dev,size) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|alpha|The significance level used to compute the confidence level. The confidence level equals 100*(1 - alpha)%, or in other words, an alpha of 0.05 indicates a 95 percent confidence level.| -|standard_dev|The population standard deviation for the data range and is assumed to be known.| -|size|The sample size.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`alpha`|The significance level used to compute the confidence level. The confidence level equals 100*(1 - alpha)%, or in other words, an alpha of 0.05 indicates a 95 percent confidence level.| +|`standard_dev`|The population standard deviation for the data range and is assumed to be known.| +|`size`|The sample size.| + ## Return value -Returns the confidence interval for a population mean, using a Student's t distribution. - +Returns the confidence interval for a population mean, using a Student's t distribution. + ## Remarks -- If any argument is nonnumeric, CONFIDENCE.T returns the #VALUE! error value. - -- If alpha ≤ 0 or alpha ≥ 1, CONFIDENCE.T returns the #NUM! error value. - -- If standard_dev ≤ 0, CONFIDENCE.T returns the #NUM! error value. - -- If size is not an integer, it is rounded. - -- If size equals 1, CONFIDENCE.T returns #DIV/0! error value. +- If any argument is nonnumeric, CONFIDENCE.T returns the `#VALUE!` error value. + +- If `alpha ≤ 0` or `alpha ≥ 1`, CONFIDENCE.T returns the `#NUM!` error value. + +- If `standard_dev ≤ 0`, CONFIDENCE.T returns the `#NUM!` error value. + +- If size is not an integer, it is rounded. + +- If size equals 1, CONFIDENCE.T returns #DIV/0! error value. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= CONFIDENCE.T(0.05,1,50)|Confidence interval for the mean of a population based on a sample size of 50, with a 5% significance level and a standard deviation of 1. This is based on a Student's t-distribution.|0.284196855| +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= CONFIDENCE.T(0.05,1,50)`|Confidence interval for the mean of a population based on a sample size of 50, with a 5% significance level and a standard deviation of 1. This is based on a Student's t-distribution.|0.284196855| diff --git a/query-languages/dax/contains-function-dax.md b/query-languages/dax/contains-function-dax.md index b695e40ba..6d02cf204 100644 --- a/query-languages/dax/contains-function-dax.md +++ b/query-languages/dax/contains-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: CONTAINS" -title: "CONTAINS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CONTAINS function (DAX)" --- # CONTAINS -Returns true if values for all referred columns exist, or are contained, in those columns; otherwise, the function returns false. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns true if values for all referred columns exist, or are contained, in those columns; otherwise, the function returns false. + +## Syntax + ```dax -CONTAINS(
, , [, , ]…) +CONTAINS(
, , [, , ]…) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -|table|Any DAX expression that returns a table of data.| -|columnName|The name of an existing column, using standard DAX syntax. It cannot be an expression. | -|value|Any DAX expression that returns a single scalar value, that is to be sought in *columnName*. The expression is to be evaluated exactly once and before it is passed to the argument list. | +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|Any DAX expression that returns a table of data.| +|`columnName`|The name of an existing column, using standard DAX syntax. It cannot be an expression. | +|`value`|Any DAX expression that returns a single scalar value, that is to be sought in `columnName`. The expression is to be evaluated exactly once and before it is passed to the argument list. | ## Return value -A value of **TRUE** if each specified *value* can be found in the corresponding *columnName*, or are contained, in those columns; otherwise, the function returns **FALSE**. - -## Remarks - -- The arguments *columnName* and *value* must come in pairs; otherwise an error is returned. - -- *columnName* must belong to the specified *table*, or to a table that is related to *table*. - -- If *columnName* refers to a column in a related table then it must be fully qualified; otherwise, an error is returned. +A value of `TRUE` if each specified `value` can be found in the corresponding `columnName`, or are contained, in those columns; otherwise, the function returns `FALSE`. + +## Remarks + +- The arguments `columnName` and `value` must come in pairs; otherwise an error is returned. + +- `columnName` must belong to the specified `table`, or to a table that is related to `table`. + +- If `columnName` refers to a column in a related table then it must be fully qualified; otherwise, an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example creates a measure that tells you whether there were any Internet sales of product 214 and to customer 11185 at the same time. - +The following example creates a measure that tells you whether there were any Internet sales of product 214 and to customer 11185 at the same time. + ```dax -= CONTAINS(InternetSales, [ProductKey], 214, [CustomerKey], 11185) += CONTAINS(InternetSales, [ProductKey], 214, [CustomerKey], 11185) ``` diff --git a/query-languages/dax/containsrow-function-dax.md b/query-languages/dax/containsrow-function-dax.md index f304d27a9..824d581e4 100644 --- a/query-languages/dax/containsrow-function-dax.md +++ b/query-languages/dax/containsrow-function-dax.md @@ -1,41 +1,34 @@ --- description: "Learn more about: CONTAINSROW function" -title: "CONTAINSROW function | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/07/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CONTAINSROW function" --- # CONTAINSROW function -Returns TRUE if there exists at least one row where all columns have specified values. +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` if there exists at least one row where all columns have specified values. ## Syntax ```dax CONTAINSROW(
, [, [, …] ] ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Table|A table to test.| -|Value|Any valid DAX expression that returns a scalar value.| + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Table`|A table to test.| +|`Value`|Any valid DAX expression that returns a scalar value.| ## Return value -TRUE or FALSE. - + `TRUE` or `FALSE`. + ## Remarks -- Except syntax, the **IN** operator and CONTAINSROW function are functionally equivalent. - +- Except syntax, the `IN` operator and CONTAINSROW function are functionally equivalent. + ```dax IN ( , , … ) IN @@ -136,13 +129,13 @@ Return the following table with a single column: ---------|--------- Black | Grey | -Multi | +Multi | NA | Silver | Silver\Black | White | -## See also +## Related content -[IN operator](dax-operator-reference.md#logical-operators) +[IN operator](dax-operator-reference.md#logical-operators) [DAX queries](dax-queries.md) diff --git a/query-languages/dax/containsstring-function-dax.md b/query-languages/dax/containsstring-function-dax.md index 71494fdbc..5211da960 100644 --- a/query-languages/dax/containsstring-function-dax.md +++ b/query-languages/dax/containsstring-function-dax.md @@ -1,36 +1,29 @@ --- description: "Learn more about: CONTAINSSTRING" -title: "CONTAINSSTRING function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CONTAINSSTRING function (DAX)" --- # CONTAINSSTRING -Returns TRUE or FALSE indicating whether one string contains another string. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` or `FALSE` indicating whether one string contains another string. + +## Syntax + ```dax CONTAINSSTRING(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|within_text|The text in which you want to search for find_text.| -|find_text|The text you want to find.| - -## Return value - -TRUE if find_text is a substring of within_text; otherwise FALSE. + +### Parameters + +|Term|Definition| +|--------|--------------| +|`within_text`|The text in which you want to search for find_text.| +|`find_text`|The text you want to find.| + +## Return value + + `TRUE` if find_text is a substring of within_text; otherwise `FALSE`. ## Remarks @@ -38,7 +31,7 @@ TRUE if find_text is a substring of within_text; otherwise FALSE. - You can use `?` and `*` wildcard characters. Use `~` to escape wildcard characters. -## Example +## Example DAX query @@ -56,4 +49,4 @@ Returns |[Case 1] |[Case 2] |[Case 3] |[Case 4] | |---------|---------|---------|---------| -|TRUE | TRUE | TRUE |FALSE | +|`TRUE` | `TRUE` | `TRUE` |`FALSE` | diff --git a/query-languages/dax/containsstringexact-function-dax.md b/query-languages/dax/containsstringexact-function-dax.md index c22ef3f7a..dc35ec8f1 100644 --- a/query-languages/dax/containsstringexact-function-dax.md +++ b/query-languages/dax/containsstringexact-function-dax.md @@ -1,42 +1,35 @@ --- description: "Learn more about: CONTAINSSTRINGEXACT" -title: "CONTAINSSTRINGEXACT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CONTAINSSTRINGEXACT function (DAX)" --- # CONTAINSSTRINGEXACT -Returns TRUE or FALSE indicating whether one string contains another string. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` or `FALSE` indicating whether one string contains another string. + +## Syntax + ```dax CONTAINSSTRINGEXACT(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|within_text|The text in which you want to search for find_text.| -|find_text|The text you want to find.| - -## Return value - -TRUE if find_text is a substring of within_text; otherwise FALSE. + +### Parameters + +|Term|Definition| +|--------|--------------| +|`within_text`|The text in which you want to search for find_text.| +|`find_text`|The text you want to find.| + +## Return value + + `TRUE` if find_text is a substring of within_text; otherwise `FALSE`. ## Remarks CONTAINSSTRINGEXACT is case-sensitive. -## Example +## Example DAX query @@ -55,4 +48,4 @@ Returns |[Case 1] |[Case 2] |[Case 3] |[Case 4] | |---------|---------|---------|---------| -|TRUE | FALSE | FALSE |FALSE | +|`TRUE` | `FALSE` | `FALSE` |`FALSE` | diff --git a/query-languages/dax/convert-function-dax.md b/query-languages/dax/convert-function-dax.md index d401e9827..e3fdf0d32 100644 --- a/query-languages/dax/convert-function-dax.md +++ b/query-languages/dax/convert-function-dax.md @@ -1,53 +1,46 @@ --- description: "Learn more about: CONVERT" -title: "CONVERT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CONVERT function (DAX)" --- # CONVERT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Converts an expression of one data type to another. - -## Syntax - + +## Syntax + ```dax -CONVERT(, ) +CONVERT(, ) ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|Expression|Any valid expression.| -|Datatype|An enumeration that includes: INTEGER(Whole Number), DOUBLE(Decimal Number), STRING(Text), BOOLEAN(True/False), CURRENCY(Fixed Decimal Number), DATETIME(Date, Time, etc).| - + +|Term|Definition| +|--------|--------------| +|`Expression`|Any valid expression.| +|`Datatype`|An enumeration that includes: INTEGER(Whole Number), DOUBLE(Decimal Number), STRING(Text), BOOLEAN(True/False), CURRENCY(Fixed Decimal Number), DATETIME(Date, Time, etc).| + ## Return value -Returns the value of \, translated to \. - -## Remarks +Returns the value of `Expression`, translated to `Datatype`. + +## Remarks - The function returns an error when a value cannot be converted to the specified data type. - DAX calculated columns must be of a single data type. Since MEDIAN and MEDIANX functions over an integer column return mixed data types, either integer or double, the following calculated column expression will return an error as a result: `MedianNumberCarsOwned = MEDIAN(DimCustomer[NumberCarsOwned])`. -- To avoid mixed data types, change the expression to always return the double data type, for example: +- To avoid mixed data types, change the expression to always return the double data type, for example: `MedianNumberCarsOwned = MEDIANX(DimCustomer, CONVERT([NumberCarsOwned], DOUBLE))`. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example DAX query ```dax -EVALUATE { CONVERT(DATE(1900, 1, 1), INTEGER) } +EVALUATE { CONVERT(DATE(1900, 1, 1), INTEGER) } ``` Returns diff --git a/query-languages/dax/cos-function-dax.md b/query-languages/dax/cos-function-dax.md index a990360ee..93c6f4ea1 100644 --- a/query-languages/dax/cos-function-dax.md +++ b/query-languages/dax/cos-function-dax.md @@ -1,44 +1,37 @@ --- description: "Learn more about: COS" -title: "COS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COS function (DAX)" --- # COS -Returns the cosine of the given angle. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the cosine of the given angle. + +## Syntax + ```dax -COS(number) +COS(number) ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|number|Required. The angle in radians for which you want the cosine.| - + +|Term|Definition| +|--------|--------------| +|`number`|Required. The angle in radians for which you want the cosine.| + ## Return value -Returns the cosine of the given angle. - +Returns the cosine of the given angle. + ## Remarks -If the angle is in degrees, either multiply the angle by PI()/180 or use the RADIANS function to convert the angle to radians. - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= COS(1.047)|Cosine of 1.047 radians|0.5001711| -|= COS(60*PI()/180)|Cosine of 60 degrees|0.5| -|= COS(RADIANS(60))|Cosine of 60 degrees|0.5| +If the angle is in degrees, either multiply the angle by PI()/180 or use the RADIANS function to convert the angle to radians. + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= COS(1.047)`|Cosine of 1.047 radians|0.5001711| +|`= COS(60*PI()/180)`|Cosine of 60 degrees|0.5| +|`= COS(RADIANS(60))`|Cosine of 60 degrees|0.5| diff --git a/query-languages/dax/cosh-function-dax.md b/query-languages/dax/cosh-function-dax.md index 8db111eea..b154326fd 100644 --- a/query-languages/dax/cosh-function-dax.md +++ b/query-languages/dax/cosh-function-dax.md @@ -1,47 +1,40 @@ --- description: "Learn more about: COSH" -title: "COSH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COSH function (DAX)" --- # COSH -Returns the hyperbolic cosine of a number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the hyperbolic cosine of a number. + +## Syntax + ```dax -COSH(number) +COSH(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Required. Any real number for which you want to find the hyperbolic cosine.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Required. Any real number for which you want to find the hyperbolic cosine.| + ## Return value -The hyperbolic cosine of a number. - +The hyperbolic cosine of a number. + ## Remarks -- The formula for the hyperbolic cosine is: +- The formula for the hyperbolic cosine is: $$\text{COSH}(z) = \frac{e^{z} + e^{-z}}{2}$$ - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= COSH(4)|Hyperbolic cosine of 4|27.308233| -|= COSH(EXP(1))|Hyperbolic cosine of the base of the natural logarithm.|7.6101251| +## Example + +|DAX expression|Description|Result| +|-----------|---------------|----------| +|`= COSH(4)`|Hyperbolic cosine of 4|27.308233| +|`= COSH(EXP(1))`|Hyperbolic cosine of the base of the natural logarithm.|7.6101251| diff --git a/query-languages/dax/cot-function-dax.md b/query-languages/dax/cot-function-dax.md index df56836eb..347f1b1a9 100644 --- a/query-languages/dax/cot-function-dax.md +++ b/query-languages/dax/cot-function-dax.md @@ -1,36 +1,29 @@ --- description: "Learn more about: COT" -title: "COT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COT function (DAX)" --- # COT -Returns the cotangent of an angle specified in radians. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the cotangent of an angle specified in radians. + +## Syntax + ```dax COT () ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|number|The angle in radians for which you want the cotangent.| - + +|Term|Definition| +|--------|--------------| +|`number`|The angle in radians for which you want the cotangent.| + ## Return value -The cotangent of the given angle. - +The cotangent of the given angle. + ## Remarks - The absolute value of number must be less than 2^27 and cannot be 0. @@ -39,10 +32,10 @@ The cotangent of the given angle. - If number is a non-numeric value, an error is returned. -## Example - +## Example + The following DAX query, - + ```dax EVALUATE { COT(30) } ``` diff --git a/query-languages/dax/coth-function-dax.md b/query-languages/dax/coth-function-dax.md index b4c4f288a..f93faa488 100644 --- a/query-languages/dax/coth-function-dax.md +++ b/query-languages/dax/coth-function-dax.md @@ -1,36 +1,29 @@ --- description: "Learn more about: COTH" -title: "COTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COTH function (DAX)" --- # COTH +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the hyperbolic cotangent of a hyperbolic angle. - -## Syntax - + +## Syntax + ```dax COTH () ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|number|The hyperbolic angle in radians for which you want the hyperbolic cotangent.| - + +|Term|Definition| +|--------|--------------| +|`number`|The hyperbolic angle in radians for which you want the hyperbolic cotangent.| + ## Return value -The hyperbolic cotangent of the given angle. - +The hyperbolic cotangent of the given angle. + ## Remarks - The hyperbolic cotangent is an analog of the ordinary (circular) cotangent. @@ -47,10 +40,10 @@ The hyperbolic cotangent of the given angle. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - +## Example + The following DAX query, - + ```dax EVALUATE { COTH(2) } ``` diff --git a/query-languages/dax/count-function-dax.md b/query-languages/dax/count-function-dax.md index 9b1e3671c..01573c2da 100644 --- a/query-languages/dax/count-function-dax.md +++ b/query-languages/dax/count-function-dax.md @@ -1,49 +1,42 @@ --- description: "Learn more about: COUNT" -title: "COUNT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/07/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COUNT function (DAX)" --- # COUNT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Counts the number of rows in the specified column that contain non-blank values. - -## Syntax - + +## Syntax + ```dax -COUNT() +COUNT() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column that contains the values to be counted.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that contains the values to be counted.| + ## Return value -A whole number. - +A whole number. + ## Remarks -- The only argument allowed to this function is a column. The COUNT function counts rows that contain the following kinds of values: - - - Numbers - - Dates +- The only argument allowed to this function is a column. The COUNT function counts rows that contain the following kinds of values: + + - Numbers + - Dates - Strings - + - When the function finds no rows to count, it returns a blank. -- Blank values are skipped. TRUE/FALSE values are not supported. +- Blank values are skipped. `TRUE`/`FALSE` values are not supported. -- If you want to evaluate a column of TRUE/FALSE values, use the COUNTA function. +- If you want to evaluate a column of `TRUE`/`FALSE` values, use the COUNTA function. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] @@ -51,17 +44,17 @@ A whole number. ## Example -The following example shows how to count the number of values in the column, ShipDate. - +The following example shows how to count the number of values in the column, ShipDate. + ```dax -= COUNT([ShipDate]) += COUNT([ShipDate]) ``` -To count logical values or text, use the COUNTA or COUNTAX functions. - -## See also +To count logical values or text, use the COUNTA or COUNTAX functions. + +## Related content -[COUNTA function](counta-function-dax.md) -[COUNTAX function](countax-function-dax.md) -[COUNTX function](countx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +[COUNTA function](counta-function-dax.md) +[COUNTAX function](countax-function-dax.md) +[COUNTX function](countx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/counta-function-dax.md b/query-languages/dax/counta-function-dax.md index 43df23819..a4ec78ae0 100644 --- a/query-languages/dax/counta-function-dax.md +++ b/query-languages/dax/counta-function-dax.md @@ -1,54 +1,47 @@ --- description: "Learn more about: COUNTA" -title: "COUNTA function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/07/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COUNTA function (DAX)" --- # COUNTA +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Counts the number of rows in the specified column that contain non-blank values. - -## Syntax - + +## Syntax + ```dax -COUNTA() +COUNTA() ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column that contains the values to be counted.| - + +|Term|Definition| +|--------|--------------| +|`column`|The column that contains the values to be counted.| + ## Return value -A whole number. - -## Remarks - +A whole number. + +## Remarks + - When the function does not find any rows to count, the function returns a blank. - Unlike [COUNT](count-function-dax.md), COUNTA supports Boolean data type. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example returns all rows in the `Reseller` table that have any kind of value in the column that stores phone numbers. - +The following example returns the number of all rows in the `Reseller` table that have any kind of value in the column that stores phone numbers. + ```dax -= COUNTA(Reseller[Phone]) += COUNTA(Reseller[Phone]) ``` - -## See also -[COUNT function](count-function-dax.md) -[COUNTAX function](countax-function-dax.md) -[COUNTX function](countx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[COUNT function](count-function-dax.md) +[COUNTAX function](countax-function-dax.md) +[COUNTX function](countx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/countax-function-dax.md b/query-languages/dax/countax-function-dax.md index 47c6c4ec3..54c87e5d6 100644 --- a/query-languages/dax/countax-function-dax.md +++ b/query-languages/dax/countax-function-dax.md @@ -1,56 +1,49 @@ --- description: "Learn more about: COUNTAX" -title: "COUNTAX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COUNTAX function (DAX)" --- # COUNTAX -The COUNTAX function counts non-blank results when evaluating the result of an expression over a table. That is, it works just like the COUNTA function, but is used to iterate through the rows in a table and count rows where the specified expressions results in a non-blank result. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +The COUNTAX function counts non-blank results when evaluating the result of an expression over a table. That is, it works just like the COUNTA function, but is used to iterate through the rows in a table and count rows where the specified expressions results in a non-blank result. + +## Syntax + ```dax -COUNTAX(
,) +COUNTAX(
,) ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of the table.| - + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of the table.| + ## Return value -A whole number. - +A whole number. + ## Remarks -- Like the COUNTA function, the COUNTAX function counts cells containing any type of information, including other expressions. For example, if the column contains an expression that evaluates to an empty string, the COUNTAX function treats that result as non-blank. Usually the COUNTAX function does not count empty cells but in this case the cell contains a formula, so it is counted. - +- Like the COUNTA function, the COUNTAX function counts cells containing any type of information, including other expressions. For example, if the column contains an expression that evaluates to an empty string, the COUNTAX function treats that result as non-blank. Usually the COUNTAX function does not count empty cells but in this case the cell contains a formula, so it is counted. + - Whenever the function finds no rows to aggregate, the function returns a blank. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example counts the number of nonblank rows in the column, Phone, using the table that results from filtering the Reseller table on [Status] = **Active**. - +The following example counts the number of nonblank rows in the column, Phone, using the table that results from filtering the Reseller table on `[Status] = Active`. + ```dax -= COUNTAX(FILTER('Reseller',[Status]="Active"),[Phone]) += COUNTAX(FILTER('Reseller',[Status]="Active"),[Phone]) ``` - -## See also -[COUNT function](count-function-dax.md) -[COUNTA function](counta-function-dax.md) -[COUNTX function](countx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[COUNT function](count-function-dax.md) +[COUNTA function](counta-function-dax.md) +[COUNTX function](countx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/countblank-function-dax.md b/query-languages/dax/countblank-function-dax.md index 7aa3dc134..671565490 100644 --- a/query-languages/dax/countblank-function-dax.md +++ b/query-languages/dax/countblank-function-dax.md @@ -1,60 +1,53 @@ --- description: "Learn more about: COUNTBLANK" -title: "COUNTBLANK function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COUNTBLANK function (DAX)" --- # COUNTBLANK -Counts the number of blank cells in a column. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Counts the number of blank cells in a column. + +## Syntax + ```dax -COUNTBLANK() +COUNTBLANK() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column that contains the blank cells to be counted.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that contains the blank cells to be counted.| + ## Return value -A whole number. If no rows are found that meet the condition, blanks are returned. - +A whole number. If no rows are found that meet the condition, blanks are returned. + ## Remarks -- The only argument allowed to this function is a column. You can use columns containing any type of data, but only blank cells are counted. Cells that have the value zero (0) are not counted, as zero is considered a numeric value and not a blank. - -- Whenever there are no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0. Microsoft Excel also returns a zero if no rows are found that meet the conditions. - -- In other words, if the COUNTBLANK function finds no blanks, the result will be zero, but if there are no rows to check, the result will be blank. - +- The only argument allowed to this function is a column. You can use columns containing any type of data, but only blank cells are counted. Cells that have the value zero (0) are not counted, as zero is considered a numeric value and not a blank. + +- Whenever there are no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0. Microsoft Excel also returns a zero if no rows are found that meet the conditions. + +- In other words, if the COUNTBLANK function finds no blanks, the result will be zero, but if there are no rows to check, the result will be blank. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows how to count the number of rows in the table Reseller that have blank values for BankName. - +The following example shows how to count the number of rows in the table Reseller that have blank values for BankName. + ```dax -= COUNTBLANK(Reseller[BankName]) += COUNTBLANK(Reseller[BankName]) ``` -To count logical values or text, use the COUNTA or COUNTAX functions. - -## See also +To count logical values or text, use the COUNTA or COUNTAX functions. + +## Related content -[COUNT function](count-function-dax.md) -[COUNTA function](counta-function-dax.md) -[COUNTAX function](countax-function-dax.md) -[COUNTX function](countx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +[COUNT function](count-function-dax.md) +[COUNTA function](counta-function-dax.md) +[COUNTAX function](countax-function-dax.md) +[COUNTX function](countx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/countrows-function-dax.md b/query-languages/dax/countrows-function-dax.md index 7160d54c7..c04bee395 100644 --- a/query-languages/dax/countrows-function-dax.md +++ b/query-languages/dax/countrows-function-dax.md @@ -1,76 +1,69 @@ --- description: "Learn more about: COUNTROWS" -title: "COUNTROWS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/13/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COUNTROWS function (DAX)" --- # COUNTROWS -The COUNTROWS function counts the number of rows in the specified table, or in a table defined by an expression. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +The COUNTROWS function counts the number of rows in the specified table, or in a table defined by an expression. + +## Syntax + ```dax -COUNTROWS([
]) +COUNTROWS([
]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|(Optional) The name of the table that contains the rows to be counted, or an expression that returns a table. When not provided, the default value is the home table of the current expression. | - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|(Optional) The name of the table that contains the rows to be counted, or an expression that returns a table. When not provided, the default value is the home table of the current expression. | + ## Return value -A whole number. - +A whole number. + ## Remarks -- This function can be used to count the number of rows in a base table, but more often is used to count the number of rows that result from filtering a table, or applying context to a table. - -- Whenever there are no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0. Microsoft Excel also returns a zero if no rows are found that meet the conditions. +- This function can be used to count the number of rows in a base table, but more often is used to count the number of rows that result from filtering a table, or applying context to a table. + +- When the table argument contains no rows, the function returns BLANK. - To learn more about best practices when using COUNT and COUNTROWS, see [Use COUNTROWS instead of COUNT in DAX](best-practices/dax-countrows.md). - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example 1 -The following example shows how to count the number of rows in the table Orders. The expected result is 52761. - +The following example shows how to count the number of rows in the table Orders. The expected result is 52761. + ```dax -= COUNTROWS('Orders') += COUNTROWS('Orders') ``` - + ## Example 2 -The following example demonstrates how to use COUNTROWS with a row context. In this scenario, there are two sets of data that are related by order number. The table Reseller contains one row for each reseller; the table ResellerSales contains multiple rows for each order, each row containing one order for a particular reseller. The tables are connected by a relationship on the column, ResellerKey. - -The formula gets the value of ResellerKey and then counts the number of rows in the related table that have the same reseller ID. The result is output in the column, **CalculatedColumn1**. - +The following example demonstrates how to use COUNTROWS with a row context. In this scenario, there are two sets of data that are related by order number. The table Reseller contains one row for each reseller; the table ResellerSales contains multiple rows for each order, each row containing one order for a particular reseller. The tables are connected by a relationship on the column, ResellerKey. + +The formula gets the value of ResellerKey and then counts the number of rows in the related table that have the same reseller ID. The result is output in the column, **CalculatedColumn1**. + ```dax -= COUNTROWS(RELATEDTABLE(ResellerSales)) += COUNTROWS(RELATEDTABLE(ResellerSales)) ``` -The following table shows a portion of the expected results: - -|ResellerKey|CalculatedColumn1| -|---------------|---------------------| -|1|73| -|2|70| -|3|394| - -## See also - -[COUNT function](count-function-dax.md) -[COUNTA function](counta-function-dax.md) -[COUNTAX function](countax-function-dax.md) -[COUNTX function](countx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +The following table shows a portion of the expected results: + +|ResellerKey|CalculatedColumn1| +|---------------|---------------------| +|1|73| +|2|70| +|3|394| + +## Related content + +[COUNT function](count-function-dax.md) +[COUNTA function](counta-function-dax.md) +[COUNTAX function](countax-function-dax.md) +[COUNTX function](countx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/countx-function-dax.md b/query-languages/dax/countx-function-dax.md index 70cceb962..bb105da04 100644 --- a/query-languages/dax/countx-function-dax.md +++ b/query-languages/dax/countx-function-dax.md @@ -1,66 +1,59 @@ --- description: "Learn more about: COUNTX" -title: "COUNTX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/14/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "COUNTX function (DAX)" --- # COUNTX -Counts the number of rows that contain a non-blank value or an expression that evaluates to a non-blank value, when evaluating an expression over a table. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Counts the number of rows that contain a non-blank value or an expression that evaluates to a non-blank value, when evaluating an expression over a table. + +## Syntax + ```dax -COUNTX(
,) +COUNTX(
,) ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows to be counted.| -|expression|An expression that returns the set of values that contains the values you want to count.| - + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows to be counted.| +|`expression`|An expression that returns the set of values that contains the values you want to count.| + ## Return value -An integer. - +An integer. + ## Remarks -- The COUNTX function takes two arguments. The first argument must always be a table, or any expression that returns a table. The second argument is the column or expression that is searched by COUNTX. - +- The COUNTX function takes two arguments. The first argument must always be a table, or any expression that returns a table. The second argument is the column or expression that is searched by COUNTX. + - The COUNTX function counts only values, dates, or strings. If the function finds no rows to count, it returns a blank. - -- If you want to count logical values, use the COUNTAX function. + +- If you want to count logical values, use the COUNTAX function. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example 1 -The following formula returns a count of all rows in the Product table that have a list price. - +The following formula returns a count of all rows in the Product table that have a list price. + ```dax -= COUNTX(Product,[ListPrice]) += COUNTX(Product,[ListPrice]) ``` - + ## Example 2 -The following formula illustrates how to pass a filtered table to COUNTX for the first argument. The formula uses a filter expression to get only the rows in the Product table that meet the condition, ProductSubCategory = "Caps", and then counts the rows in the resulting table that have a list price. The FILTER expression applies to the table Products but uses a value that you look up in the related table, ProductSubCategory. - +The following formula illustrates how to pass a filtered table to COUNTX for the first argument. The formula uses a filter expression to get only the rows in the Product table that meet the condition, ProductSubCategory = "Caps", and then counts the rows in the resulting table that have a list price. The FILTER expression applies to the table Products but uses a value that you look up in the related table, ProductSubCategory. + ```dax -= COUNTX(FILTER(Product,RELATED(ProductSubcategory[EnglishProductSubcategoryName])="Caps"), Product[ListPrice]) += COUNTX(FILTER(Product,RELATED(ProductSubcategory[EnglishProductSubcategoryName])="Caps"), Product[ListPrice]) ``` - -## See also -[COUNT function](count-function-dax.md) -[COUNTA function](counta-function-dax.md) -[COUNTAX function](countax-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[COUNT function](count-function-dax.md) +[COUNTA function](counta-function-dax.md) +[COUNTAX function](countax-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/coupdaybs-function-dax.md b/query-languages/dax/coupdaybs-function-dax.md index 9b762d5ee..9c8861fac 100644 --- a/query-languages/dax/coupdaybs-function-dax.md +++ b/query-languages/dax/coupdaybs-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: COUPDAYBS" -title: "COUPDAYBS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference -author: jajin7 -ms.author: owend -recommendations: false - +title: "COUPDAYBS function (DAX)" --- # COUPDAYBS +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the number of days from the beginning of a coupon period until its settlement date. ## Syntax @@ -24,16 +17,16 @@ COUPDAYBS(, , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/coupdays-function-dax.md b/query-languages/dax/coupdays-function-dax.md index 38b0310f6..5b3083f79 100644 --- a/query-languages/dax/coupdays-function-dax.md +++ b/query-languages/dax/coupdays-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: COUPDAYS" -title: "COUPDAYS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference -author: jajin7 -ms.author: owend -recommendations: false - +title: "COUPDAYS function (DAX)" --- # COUPDAYS +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the number of days in the coupon period that contains the settlement date. ## Syntax @@ -24,16 +17,16 @@ COUPDAYS(, , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/coupdaysnc-function-dax.md b/query-languages/dax/coupdaysnc-function-dax.md index 49e63e091..4a915d22d 100644 --- a/query-languages/dax/coupdaysnc-function-dax.md +++ b/query-languages/dax/coupdaysnc-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: COUPDAYSNC" -title: "COUPDAYSNC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference -author: jajin7 -ms.author: owend -recommendations: false - +title: "COUPDAYSNC function (DAX)" --- # COUPDAYSNC +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the number of days from the settlement date to the next coupon date. ## Syntax @@ -24,16 +17,16 @@ COUPDAYSNC(, , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/coupncd-function-dax.md b/query-languages/dax/coupncd-function-dax.md index 529c4f760..9f8dbc695 100644 --- a/query-languages/dax/coupncd-function-dax.md +++ b/query-languages/dax/coupncd-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: COUPNCD" -title: "COUPNCD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference -author: jajin7 -ms.author: owend -recommendations: false - +title: "COUPNCD function (DAX)" --- # COUPNCD +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the next coupon date after the settlement date. ## Syntax @@ -24,16 +17,16 @@ COUPNCD(, , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/coupnum-function-dax.md b/query-languages/dax/coupnum-function-dax.md index f6c09c57b..d856e1062 100644 --- a/query-languages/dax/coupnum-function-dax.md +++ b/query-languages/dax/coupnum-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: COUPNUM" -title: "COUPNUM function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference -author: jajin7 -ms.author: owend -recommendations: false - +title: "COUPNUM function (DAX)" --- # COUPNUM +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the number of coupons payable between the settlement date and maturity date, rounded up to the nearest whole coupon. ## Syntax @@ -24,16 +17,16 @@ COUPNUM(, , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/couppcd-function-dax.md b/query-languages/dax/couppcd-function-dax.md index 29512523d..0d9d27a43 100644 --- a/query-languages/dax/couppcd-function-dax.md +++ b/query-languages/dax/couppcd-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: COUPPCD" -title: "COUPPCD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference -author: jajin7 -ms.author: owend -recommendations: false - +title: "COUPPCD function (DAX)" --- # COUPPCD +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the previous coupon date before the settlement date. ## Syntax @@ -24,16 +17,16 @@ COUPPCD(, , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/crossfilter-function-dax.md b/query-languages/dax/crossfilter-function-dax.md new file mode 100644 index 000000000..a0516409f --- /dev/null +++ b/query-languages/dax/crossfilter-function-dax.md @@ -0,0 +1,69 @@ +--- +description: "Learn more about: CROSSFILTER" +title: "CROSSFILTER function" +--- +# CROSSFILTER + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Specifies the cross-filtering direction to be used in a calculation for a relationship that exists between two columns. + +## Syntax + +```dax +CROSSFILTER(, , ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`columnName1`|The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the many side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression.| +|`columnName2`|The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the one side or lookup side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression.| +|`Direction`|The cross-filter direction to be used. Must be one of the following:

`None` - No cross-filtering occurs along this relationship.

`Both` - Filters on either side filters the other side.

`OneWay` - Filters on the one side or the lookup side of a relationship filter the other side. This option cannot be used with a one-to-one relationship . Don’t use this option on a many-to-many relationship because it is unclear which side is the lookup side; use OneWay_LeftFiltersRight or OneWay_RightFiltersLeft instead.

`OneWay_LeftFiltersRight` - Filters on the side of `columnName1` filter the side of `columnName2`. This option cannot be used with a one-to-one or many-to-one relationship.

`OneWay_RightFiltersLeft` - Filters on the side of `columnName2` filter the side of `columnName1`. This option cannot be used with a one-to-one or many-to-one relationship.| + +## Return value + +The function returns no value; the function only sets the cross-filtering direction for the indicated relationship, for the duration of the query. + +## Remarks + +- In the case of a 1:1 relationship, there is no difference between the one and both direction. + +- CROSSFILTER can only be used in functions that take a filter as an argument, for example: CALCULATE, CALCULATETABLE, CLOSINGBALANCEMONTH, CLOSINGBALANCEQUARTER, CLOSINGBALANCEYEAR, OPENINGBALANCEMONTH, OPENINGBALANCEQUARTER, OPENINGBALANCEYEAR, TOTALMTD, TOTALQTD and TOTALYTD functions. + +- CROSSFILTER uses existing relationships in the model, identifying relationships by their ending point columns. + +- In CROSSFILTER, the cross-filtering setting of a relationship is not important; that is, whether the relationship is set to filter one, or both directions in the model does not affect the usage of the function. CROSSFILTER will override any existing cross-filtering setting. + +- An error is returned if any of the columns named as an argument is not part of a relationship or the arguments belong to different relationships. + +- If CALCULATE expressions are nested, and more than one CALCULATE expression contains a CROSSFILTER function, then the innermost CROSSFILTER is the one that prevails in case of a conflict or ambiguity. + +- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +In the following model diagram, both DimProduct and DimDate have a single direction relationship with FactInternetSales. + +![CROSSFILTER_Examp_DiagView](media/crossfilter-function/crossfilter-examp-diagview.png "CROSSFILTER_Examp_DiagView") + +By default, we cannot get the Count of Products sold by year: + +![CROSSFILTER_Examp_PivotTable1](media/crossfilter-function/crossfilter-examp-pivottable1.png "CROSSFILTER_Examp_PivotTable1") + +There are two ways to get the count of products by year: + +- Turn on bi-directional cross-filtering on the relationship. This will change how filters work for all data between these two tables. + +- Use the CROSSFILTER function to change how the relationships work for just this measure. + +When using DAX, we can use the CROSSFILTER function to change how the cross-filter direction behaves between two columns defined by a relationship. In this case, the DAX expression looks like this: + +```dax +BiDi:= CALCULATE([Distinct Count of ProductKey], CROSSFILTER(FactInternetSales[ProductKey], DimProduct[ProductKey] , Both)) +``` + +By using the CROSSFILTER function in our measure expression, we get the expected results: + +![CROSSFILTER_Examp_PivotTable2](media/crossfilter-function/crossfilter-examp-pivottable2.png "CROSSFILTER_Examp_PivotTable2") diff --git a/query-languages/dax/crossfilter-function.md b/query-languages/dax/crossfilter-function.md deleted file mode 100644 index daf819c78..000000000 --- a/query-languages/dax/crossfilter-function.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -description: "Learn more about: CROSSFILTER" -title: "CROSSFILTER function | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 04/16/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# CROSSFILTER - -Specifies the cross-filtering direction to be used in a calculation for a relationship that exists between two columns. - -## Syntax - -```dax -CROSSFILTER(, , ) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|columnName1|The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the many side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression.| -|columnName2|The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the one side or lookup side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression.| -|Direction|The cross-filter direction to be used. Must be one of the following:

**None** - No cross-filtering occurs along this relationship.

**Both** - Filters on either side filters the other side.

**OneWay** - Filters on the one side or the lookup side of a relationship filter the other side. This option cannot be used with a one-to-one relationship . Don’t use this option on a many-to-many relationship because it is unclear which side is the lookup side; use OneWay_LeftFiltersRight or OneWay_RightFiltersLeft instead.

**OneWay_LeftFiltersRight** - Filters on the side of \ filter the side of \. This option cannot be used with a one-to-one or many-to-one relationship.

**OneWay_RightFiltersLeft** - Filters on the side of \ filter the side of \. This option cannot be used with a one-to-one or many-to-one relationship.| - -## Return value - -The function returns no value; the function only sets the cross-filtering direction for the indicated relationship, for the duration of the query. - -## Remarks - -- In the case of a 1:1 relationship, there is no difference between the one and both direction. - -- CROSSFILTER can only be used in functions that take a filter as an argument, for example: CALCULATE, CALCULATETABLE, CLOSINGBALANCEMONTH, CLOSINGBALANCEQUARTER, CLOSINGBALANCEYEAR, OPENINGBALANCEMONTH, OPENINGBALANCEQUARTER, OPENINGBALANCEYEAR, TOTALMTD, TOTALQTD and TOTALYTD functions. - -- CROSSFILTER uses existing relationships in the model, identifying relationships by their ending point columns. - -- In CROSSFILTER, the cross-filtering setting of a relationship is not important; that is, whether the relationship is set to filter one, or both directions in the model does not affect the usage of the function. CROSSFILTER will override any existing cross-filtering setting. - -- An error is returned if any of the columns named as an argument is not part of a relationship or the arguments belong to different relationships. - -- If CALCULATE expressions are nested, and more than one CALCULATE expression contains a CROSSFILTER function, then the innermost CROSSFILTER is the one that prevails in case of a conflict or ambiguity. - -- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -In the following model diagram, both DimProduct and DimDate have a single direction relationship with FactOnlineSales. - -![CROSSFILTER_Examp_DiagView](media/crossfilter-examp-diagview.png "CROSSFILTER_Examp_DiagView") - -By default, we cannot get the Count of Products sold by year: - -![CROSSFILTER_Examp_PivotTable1](media/crossfilter-examp-pivottable1.png "CROSSFILTER_Examp_PivotTable1") - -There are two ways to get the count of products by year: - -- Turn on bi-directional cross-filtering on the relationship. This will change how filters work for all data between these two tables. - -- Use the CROSSFILTER function to change how the relationships work for just this measure. - -When using DAX, we can use the CROSSFILTER function to change how the cross-filter direction behaves between two columns defined by a relationship. In this case, the DAX expression looks like this: - -```dax -BiDi:= CALCULATE([Distinct Count of ProductKey], CROSSFILTER(FactInternetSales[ProductKey], DimProduct[ProductKey] , Both)) -``` - -By using the CROSSFILTER function in our measure expression, we get the expected results: - -![CROSSFILTER_Examp_PivotTable2](media/crossfilter-examp-pivottable2.png "CROSSFILTER_Examp_PivotTable2") diff --git a/query-languages/dax/crossjoin-function-dax.md b/query-languages/dax/crossjoin-function-dax.md index 002cb4c11..a9962373c 100644 --- a/query-languages/dax/crossjoin-function-dax.md +++ b/query-languages/dax/crossjoin-function-dax.md @@ -1,76 +1,69 @@ --- description: "Learn more about: CROSSJOIN" -title: "CROSSJOIN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CROSSJOIN function (DAX)" --- # CROSSJOIN -Returns a table that contains the Cartesian product of all rows from all tables in the arguments. The columns in the new table are all the columns in all the argument tables. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table that contains the Cartesian product of all rows from all tables in the arguments. The columns in the new table are all the columns in all the argument tables. + +## Syntax + ```dax -CROSSJOIN(
,
[,
]…) +CROSSJOIN(
,
[,
]…) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -|table|Any DAX expression that returns a table of data| - +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|Any DAX expression that returns a table of data| + ## Return value -A table that contains the Cartesian product of all rows from all tables in the arguments. - -## Remarks - -- Column names from *table* arguments must all be different in all tables or an error is returned. - -- The total number of rows returned by CROSSJOIN() is equal to the product of the number of rows from all tables in the arguments; also, the total number of columns in the result table is the sum of the number of columns in all tables. For example, if **TableA** has **rA** rows and **cA** columns, and **TableB** has **rB** rows and **cB** columns, and **TableC** has **rC** rows and **cC** column; then, the resulting table has **rA × rb × rC** rows and **cA + cB + cC** columns. +A table that contains the Cartesian product of all rows from all tables in the arguments. + +## Remarks + +- Column names from `table` arguments must all be different in all tables or an error is returned. + +- The total number of rows returned by CROSSJOIN() is equal to the product of the number of rows from all tables in the arguments; also, the total number of columns in the result table is the sum of the number of columns in all tables. For example, if **TableA** has **rA** rows and **cA** columns, and **TableB** has **rB** rows and **cB** columns, and **TableC** has **rC** rows and **cC** column; then, the resulting table has **rA × rb × rC** rows and **cA + cB + cC** columns. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example shows the results of applying CROSSJOIN() to two tables: **Colors** and **Stationery**. - -The table **Colors** contains colors and patterns: - -|Color|Pattern| -|---------|-----------| -|Red|Horizontal Stripe| -|Green|Vertical Stripe| -|Blue|Crosshatch| - -The table **Stationery** contains fonts and presentation: - -|Font|Presentation| -|--------|----------------| -|serif|embossed| -|sans-serif|engraved| - -The expression to generate the cross join is presented below: - +The following example shows the results of applying CROSSJOIN() to two tables: **Colors** and **Stationery**. + +The table **Colors** contains colors and patterns: + +|Color|Pattern| +|---------|-----------| +|Red|Horizontal Stripe| +|Green|Vertical Stripe| +|Blue|Crosshatch| + +The table **Stationery** contains fonts and presentation: + +|Font|Presentation| +|--------|----------------| +|serif|embossed| +|sans-serif|engraved| + +The expression to generate the cross join is presented below: + ```dax -CROSSJOIN( Colors, Stationery) +CROSSJOIN( Colors, Stationery) ``` -When the above expression is used wherever a table expression is expected, the results of the expression would be as follows: - -|Color|Pattern|Font|Presentation| -|---------|-----------|---------|-----------| -|Red|Horizontal Stripe|serif|embossed| -|Green|Vertical Stripe|serif|embossed| -|Blue|Crosshatch|serif|embossed| -|Red|Horizontal Stripe|sans-serif|engraved| -|Green|Vertical Stripe|sans-serif|engraved| -|Blue|Crosshatch|sans-serif|engraved| +When the above expression is used wherever a table expression is expected, the results of the expression would be as follows: + +|Color|Pattern|Font|Presentation| +|---------|-----------|---------|-----------| +|Red|Horizontal Stripe|serif|embossed| +|Green|Vertical Stripe|serif|embossed| +|Blue|Crosshatch|serif|embossed| +|Red|Horizontal Stripe|sans-serif|engraved| +|Green|Vertical Stripe|sans-serif|engraved| +|Blue|Crosshatch|sans-serif|engraved| diff --git a/query-languages/dax/cumipmt-function-dax.md b/query-languages/dax/cumipmt-function-dax.md index 92582cc39..089b934e1 100644 --- a/query-languages/dax/cumipmt-function-dax.md +++ b/query-languages/dax/cumipmt-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: CUMIPMT" -title: "CUMIPMT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "CUMIPMT function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # CUMIPMT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the cumulative interest paid on a loan between start_period and end_period. ## Syntax @@ -24,18 +18,18 @@ CUMIPMT(, , , , , ) ### Parameters -|Term|Definition| -|--------|--------------| -|rate|The interest rate.| -|nper|The total number of payment periods.| -|pv|The present value.| -|start_period|The first period in the calculation. Must be between 1 and end_period (inclusive).| -|end_period|The last period in the calculation. Must be between start_period and nper (inclusive).| -|type|The timing of the payment. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`rate`|The interest rate.| +|`nper`|The total number of payment periods.| +|`pv`|The present value.| +|`start_period`|The first period in the calculation. Must be between 1 and end_period (inclusive).| +|`end_period`|The last period in the calculation. Must be between start_period and nper (inclusive).| +|`type`|The timing of the payment. The accepted values are listed below this table.| -The **type** parameter accepts the following values: +The `type` parameter accepts the following values: -| **Type** | **Timing** | +| `Type` | **Timing** | | -------- | -------------------------------------- | | 0 (zero) | Payment at the end of the period | | 1 | Payment at the beginning of the period | diff --git a/query-languages/dax/cumprinc-function-dax.md b/query-languages/dax/cumprinc-function-dax.md index a691e3f73..60d38cbdb 100644 --- a/query-languages/dax/cumprinc-function-dax.md +++ b/query-languages/dax/cumprinc-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: CUMPRINC" -title: "CUMPRINC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "CUMPRINC function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # CUMPRINC +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the cumulative principal paid on a loan between start_period and end_period. ## Syntax @@ -24,18 +18,18 @@ CUMPRINC(, , , , , ) ### Parameters -|Term|Definition| -|--------|--------------| -|rate|The interest rate.| -|nper|The total number of payment periods.| -|pv|The present value.| -|start_period|The first period in the calculation. Must be between 1 and end_period (inclusive).| -|end_period|The last period in the calculation. Must be between start_period and nper (inclusive).| -|type|The timing of the payment. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`rate`|The interest rate.| +|`nper`|The total number of payment periods.| +|`pv`|The present value.| +|`start_period`|The first period in the calculation. Must be between 1 and end_period (inclusive).| +|`end_period`|The last period in the calculation. Must be between start_period and nper (inclusive).| +|`type`|The timing of the payment. The accepted values are listed below this table.| -The **type** parameter accepts the following values: +The `type` parameter accepts the following values: -| **Type** | **Timing** | +| `Type` | **Timing** | | -------- | -------------------------------------- | | 0 (zero) | Payment at the end of the period | | 1 | Payment at the beginning of the period | diff --git a/query-languages/dax/currency-function-dax.md b/query-languages/dax/currency-function-dax.md index a18a439ee..073c39909 100644 --- a/query-languages/dax/currency-function-dax.md +++ b/query-languages/dax/currency-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: CURRENCY" -title: "CURRENCY function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/08/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CURRENCY function (DAX)" --- # CURRENCY -Evaluates the argument and returns the result as currency data type. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Evaluates the argument and returns the result as currency data type. + +## Syntax + ```dax -CURRENCY() +CURRENCY() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -|value|Any DAX expression that returns a single scalar value where the expression is to be evaluated exactly once before all other operations. | +### Parameters + +|Term|Definition| +|--------|--------------| +|`value`|Any DAX expression that returns a single scalar value where the expression is to be evaluated exactly once before all other operations. | ## Return value -The value of the expression evaluated and returned as a currency type value. - -## Remarks - -- The CURRENCY function rounds up the 5th significant decimal, in value, to return the 4th decimal digit. Rounding up occurs if the 5th significant decimal is equal or larger than 5. For example, if value is 3.6666666666666 then converting to currency returns \\$3.6667. However, if value is 3.0123456789 then converting to currency returns \\$3.0123. - -- If the data type of the expression is TrueFalse then CURRENCY(\) will return \\$1.0000 for True values and \\$0.0000 for False values. - -- If the data type of the expression is Text then CURRENCY(\) will try to convert text to a number. If conversion succeeds the number will be converted to currency, otherwise an error is returned. - -- If the data type of the expression is DateTime then CURRENCY(\) will convert the datetime value to a number and that number to currency. DateTime values have an integer part that represents the number of days between the given date and 1900-03-01 and a fraction that represents the fraction of a day (where 12 hours or noon is 0.5 day). If the value of the expression is not a proper DateTime value an error is returned. - +The value of the expression evaluated and returned as a currency type value. + +## Remarks + +- The CURRENCY function rounds up the 5th significant decimal, in value, to return the 4th decimal digit. Rounding up occurs if the 5th significant decimal is equal or larger than 5. For example, if value is 3.6666666666666 then converting to currency returns \\$3.6667. However, if value is 3.0123456789 then converting to currency returns \\$3.0123. + +- If the data type of the expression is TrueFalse then CURRENCY(`TrueFalse`) will return \\$1.0000 for True values and \\$0.0000 for False values. + +- If the data type of the expression is Text then CURRENCY(`Text`) will try to convert text to a number. If conversion succeeds the number will be converted to currency, otherwise an error is returned. + +- If the data type of the expression is DateTime then CURRENCY(`DateTime`) will convert the datetime value to a number and that number to currency. DateTime values have an integer part that represents the number of days between the given date and 1900-03-01 and a fraction that represents the fraction of a day (where 12 hours or noon is 0.5 day). If the value of the expression is not a proper DateTime value an error is returned. + ## Example -Convert number 1234.56 to currency data type. - +Convert number 1234.56 to currency data type. + ```dax -= CURRENCY(1234.56) += CURRENCY(1234.56) ``` Returns value 1234.56000. diff --git a/query-languages/dax/currentgroup-function-dax.md b/query-languages/dax/currentgroup-function-dax.md index 0413838e9..68dcd809b 100644 --- a/query-languages/dax/currentgroup-function-dax.md +++ b/query-languages/dax/currentgroup-function-dax.md @@ -1,30 +1,23 @@ --- description: "Learn more about: CURRENTGROUP" -title: "CURRENTGROUP function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/09/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CURRENTGROUP function (DAX)" --- # CURRENTGROUP +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + Returns a set of rows from the table argument of a [GROUPBY](groupby-function-dax.md) expression that belong to the current row of the [GROUPBY](groupby-function-dax.md) result. -## Syntax - +## Syntax + ```dax CURRENTGROUP ( ) ``` - -### Parameters - + +### Parameters + None - + ## Return value The rows in the table argument of the [GROUPBY](groupby-function-dax.md) function corresponding to one group of values of the groupBy_columnName arguments. @@ -34,7 +27,7 @@ The rows in the table argument of the [GROUPBY](groupby-function-dax.md) functio - This function can only be used within a [GROUPBY](groupby-function-dax.md) expression. - This function takes no arguments and is only supported as the first argument to one of the following aggregation functions: [AVERAGEX](averagex-function-dax.md), [COUNTAX](countax-function-dax.md), [COUNTX](countx-function-dax.md), [GEOMEANX](geomeanx-function-dax.md), [MAXX](maxx-function-dax.md), [MINX](minx-function-dax.md), [PRODUCTX](productx-function-dax.md), [STDEVX.S](stdevx-s-function-dax.md), [STDEVX.P](stdevx-s-function-dax.md), [SUMX](sumx-function-dax.md), [VARX.S](varx-s-function-dax.md), [VARX.P](varx-p-function-dax.md). - + ## Example See [GROUPBY](groupby-function-dax.md). diff --git a/query-languages/dax/customdata-function-dax.md b/query-languages/dax/customdata-function-dax.md index 06b62f851..2a8206bd0 100644 --- a/query-languages/dax/customdata-function-dax.md +++ b/query-languages/dax/customdata-function-dax.md @@ -1,31 +1,24 @@ --- description: "Learn more about: CUSTOMDATA" -title: "CUSTOMDATA function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "CUSTOMDATA function (DAX)" --- # CUSTOMDATA -Returns the content of the **CustomData** property in the connection string. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the content of the `CustomData` property in the connection string. + +## Syntax + ```dax -CUSTOMDATA() +CUSTOMDATA() ``` - + ## Return value -The content of the **CustomData** property in the connection string. - -Blank, if **CustomData** property was not defined at connection time. +The content of the `CustomData` property in the connection string. + +Blank, if `CustomData` property was not defined at connection time. ## Remarks @@ -33,8 +26,8 @@ Blank, if **CustomData** property was not defined at connection time. ## Example -The following DAX formula verifies if the CustomData property was set to **"OK"**. - +The following DAX formula verifies if the CustomData property was set to **`OK`**. + ```dax -= IF(CUSTOMDATA()="OK", "Correct Custom data in connection string", "No custom data in connection string property or unexpected value") += IF(CUSTOMDATA()="OK", "Correct Custom data in connection string", "No custom data in connection string property or unexpected value") ``` diff --git a/query-languages/dax/datatable-function-dax.md b/query-languages/dax/datatable-function-dax.md new file mode 100644 index 000000000..668335abb --- /dev/null +++ b/query-languages/dax/datatable-function-dax.md @@ -0,0 +1,48 @@ +--- +description: "Learn more about: DATATABLE" +title: "DATATABLE function" +--- +# DATATABLE + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Provides a mechanism for declaring an inline set of data values. + +## Syntax + +```dax +DATATABLE (ColumnName1, DataType1, ColumnName2, DataType2..., {{Value1, Value2...}, {ValueN, ValueN+1...}...}) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`ColumnName`|A column name.| +|`DataType`|An enumeration that includes: INTEGER, DOUBLE, STRING, BOOLEAN, CURRENCY, DATETIME| +|`value`|A single argument using Excel syntax for a one dimensional array constant, nested to provide an array of arrays. This argument represents the set of data values that will be in the table

For example,
{ {values in row1}, {values in row2}, {values in row3}, etc. }
Where {values in row1} is a comma delimited set of constant expressions, namely a combination of constants, combined with a handful of basic functions including DATE, TIME, and BLANK, as well as a plus operator between DATE and TIME and a unary minus operator so that negative values can be expressed.

The following are all valid values: 3, -5, BLANK(), "2009-04-15 02:45:21". Values may not refer to anything outside the immediate expression, and cannot refer to columns, tables, relationships, or anything else.

A missing value will be treated identically to BLANK(). For example, the following are the same: {1,2,BLANK(),4} {1,2,,4}| + +## Return value + +A table declaring an inline set of values. + +## Remarks + +- Unlike DATATABLE, [Table Constructor](table-constructor.md) allows any scalar expressions as input values. + +- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +```dax += DataTable("Name", STRING, + "Region", STRING + ,{ + {" User1","East"}, + {" User2","East"}, + {" User3","West"}, + {" User4","West"}, + {" User4","East"} + } + ) +``` diff --git a/query-languages/dax/datatable-function.md b/query-languages/dax/datatable-function.md deleted file mode 100644 index 3f37309c0..000000000 --- a/query-languages/dax/datatable-function.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -description: "Learn more about: DATATABLE" -title: "DATATABLE function | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# DATATABLE - -Provides a mechanism for declaring an inline set of data values. - -## Syntax - -```dax -DATATABLE (ColumnName1, DataType1, ColumnName2, DataType2..., {{Value1, Value2...}, {ValueN, ValueN+1...}...}) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|ColumnName|Any DAX expression that returns a table.| -|DataType|An enumeration that includes: INTEGER, DOUBLE, STRING, BOOLEAN, CURRENCY, DATETIME| -|Value|A single argument using Excel syntax for a one dimensional array constant, nested to provide an array of arrays. This argument represents the set of data values that will be in the table

For example,
{ {values in row1}, {values in row2}, {values in row3}, etc. }
Where {values in row1} is a comma delimited set of constant expressions, namely a combination of constants, combined with a handful of basic functions including DATE, TIME, and BLANK, as well as a plus operator between DATE and TIME and a unary minus operator so that negative values can be expressed.

The following are all valid values: 3, -5, BLANK(), "2009-04-15 02:45:21". Values may not refer to anything outside the immediate expression, and cannot refer to columns, tables, relationships, or anything else.

A missing value will be treated identically to BLANK(). For example, the following are the same: {1,2,BLANK(),4} {1,2,,4}| - -## Return value - -A table declaring an inline set of values. - -## Remarks - -- Unlike DATATABLE, [Table Constructor](table-constructor.md) allows any scalar expressions as input values. - -- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -```dax -= DataTable("Name", STRING, - "Region", STRING - ,{ - {" User1","East"}, - {" User2","East"}, - {" User3","West"}, - {" User4","West"}, - {" User4","East"} - } - ) -``` diff --git a/query-languages/dax/date-and-time-functions-dax.md b/query-languages/dax/date-and-time-functions-dax.md index d60459222..176444733 100644 --- a/query-languages/dax/date-and-time-functions-dax.md +++ b/query-languages/dax/date-and-time-functions-dax.md @@ -1,19 +1,11 @@ --- description: "Learn more about: Date and time functions" -title: "Date and time functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Date and time functions (DAX)" --- # Date and time functions -These functions help you create calculations based on dates and time. Many of the functions in DAX are similar to the Excel date and time functions. However, DAX functions use a **datetime** data type, and can take values from a column as an argument. - +These functions help you create calculations based on dates and time. Many of the functions in DAX are similar to the Excel date and time functions. However, DAX functions use a `datetime` data type, and can take values from a column as an argument. + ## In this category |Function |Description | @@ -29,7 +21,7 @@ These functions help you create calculations based on dates and time. Many of th |[HOUR](hour-function-dax.md) | Returns the hour as a number from 0 (12:00 A.M.) to 23 (11:00 P.M.). | |[MINUTE](minute-function-dax.md) | Returns the minute as a number from 0 to 59, given a date and time value. | |[MONTH](month-function-dax.md) | Returns the month as a number from 1 (January) to 12 (December). | -|[NETWORKDAYS](networkdays-dax.md)| Returns the number of whole workdays between two dates. | +|[NETWORKDAYS](networkdays-function-dax.md)| Returns the number of whole workdays between two dates. | |[NOW](now-function-dax.md) | Returns the current date and time in datetime format. | |[QUARTER](quarter-function-dax.md) | Returns the quarter as a number from 1 to 4. | |[SECOND](second-function-dax.md) | Returns the seconds of a time value, as a number from 0 to 59. | diff --git a/query-languages/dax/date-function-dax.md b/query-languages/dax/date-function-dax.md index 6018649b2..5b0fcc4b8 100644 --- a/query-languages/dax/date-function-dax.md +++ b/query-languages/dax/date-function-dax.md @@ -1,94 +1,86 @@ --- description: "Learn more about: DATE" -title: "DATE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DATE function (DAX)" --- # DATE -Returns the specified date in **datetime** format. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the specified date in `datetime` format. + +## Syntax + ```dax -DATE(, , ) +DATE(, , ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|year|A number representing the year.

The value of the **year** argument can include one to four digits. The **year** argument is interpreted according to the date system used by your computer.

Dates beginning with March 1, 1900 are supported.

If you enter a number that has decimal places, the number is rounded.

For values greater than 9999 or less than zero (negative values), the function returns a **#VALUE!** error.

If the **year** value is between 0 and 1899, the value is added to 1900 to produce the final value. See the examples below. **Note:** You should use four digits for the **year** argument whenever possible to prevent unwanted results. For example, using 07 returns 1907 as the year value.| -|month|A number representing the month or a calculation according to the following rules:

Negative integers are not supported. Valid values are 1-12.

If **month** is a number from 1 to 12, then it represents a month of the year. 1 represents January, 2 represents February, and so on until 12 that represents December.

If you enter an integer larger than 12, the following computation occurs: the date is calculated by adding the value of **month** to the **year**. For example, if you have DATE( 2008, 18, 1), the function returns a datetime value equivalent to June 1st of 2009, because 18 months are added to the beginning of 2008 yielding a value of June 2009. See examples below.| -|day|A number representing the day or a calculation according to the following rules:

Negative integers are not supported. Valid values are 1-31.

If **day** is a number from 1 to the last day of the given month then it represents a day of the month.

If you enter an integer larger than last day of the given month, the following computation occurs: the date is calculated by adding the value of **day** to **month**. For example, in the formula `DATE( 2008, 3, 32)`, the DATE function returns a **datetime** value equivalent to April 1st of 2008, because 32 days are added to the beginning of March yielding a value of April 1st.

If **day** contains a decimal portion, it is rounded to the nearest integer value.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`year`|A number representing the year.

The value of the `year` argument can include one to four digits. The `year` argument is interpreted according to the date system used by your computer.

Dates beginning with March 1, 1900 are supported.

If you enter a number that has decimal places, the number is rounded.

For values greater than 9999 or less than zero (negative values), the function returns a `#VALUE!` error.

If the `year` value is between 0 and 1899, the value is added to 1900 to produce the final value. See the examples below. **Note:** You should use four digits for the `year` argument whenever possible to prevent unwanted results. For example, using 07 returns 1907 as the year value.| +|`month`|A number representing the month or a calculation according to the following rules:

Negative integers are not supported. Valid values are 1-12.

If `month` is a number from 1 to 12, then it represents a month of the year. 1 represents January, 2 represents February, and so on until 12 that represents December.

If you enter an integer larger than 12, the following computation occurs: the date is calculated by adding the value of `month` to the `year`. For example, if you have DATE( 2008, 18, 1), the function returns a datetime value equivalent to June 1st of 2009, because 18 months are added to the beginning of 2008 yielding a value of June 2009. See examples below.| +|`day`|A number representing the day or a calculation according to the following rules:

Negative integers are not supported. Valid values are 1-31.

If `day` is a number from 1 to the last day of the given month then it represents a day of the month.

If you enter an integer larger than last day of the given month, the following computation occurs: the date is calculated by adding the value of `day` to `month`. For example, in the formula `DATE( 2008, 3, 32)`, the DATE function returns a `datetime` value equivalent to April 1st of 2008, because 32 days are added to the beginning of March yielding a value of April 1st.

If `day` contains a decimal portion, it is rounded to the nearest integer value.| + ## Return value -Returns the specified date (**datetime)**. - +Returns the specified date (`datetime`). + ## Remarks -- The DATE function takes the integers that are input as arguments, and generates the corresponding date. The DATE function is most useful in situations where the year, month, and day are supplied by formulas. For example, the underlying data might contain dates in a format that is not recognized as a date, such as YYYYMMDD. You can use the DATE function in conjunction with other functions to convert the dates to a number that can be recognized as a date. - -- In contrast to Microsoft Excel, which stores dates as a serial number, DAX date functions always return a **datetime** data type. However, you can use formatting to display dates as serial numbers if you want. +- The DATE function takes the integers that are input as arguments, and generates the corresponding date. The DATE function is most useful in situations where the year, month, and day are supplied by formulas. For example, the underlying data might contain dates in a format that is not recognized as a date, such as YYYYMMDD. You can use the DATE function in conjunction with other functions to convert the dates to a number that can be recognized as a date. + +- In contrast to Microsoft Excel, which stores dates as a serial number, DAX date functions always return a `datetime` data type. However, you can use formatting to display dates as serial numbers if you want. - Date and datetime can also be specified as a literal in the format `dt"YYYY-MM-DD"`, `dt"YYYY-MM-DDThh:mm:ss"`, or `dt"YYYY-MM-DD hh:mm:ss"`. When specified as a literal, using the DATE function in the expression is not necessary. To learn more, see [DAX Syntax | Date and time](dax-syntax-reference.md#date-and-time). - + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Examples - + ### Simple Date -The following formula returns the date July 8, 2009: - +The following formula returns the date July 8, 2009: + ```dax -= DATE(2009,7,8) += DATE(2009,7,8) ``` - -### Years before 1899 -If the value that you enter for the **year** argument is between 0 (zero) and 1899 (inclusive), that value is added to 1900 to calculate the year. The following formula returns January 2, 1908: (1900+08). - +### Years before 1899 + +If the value that you enter for the `year` argument is between 0 (zero) and 1899 (inclusive), that value is added to 1900 to calculate the year. The following formula returns January 2, 1908: (1900+08). + ```dax -= DATE(08,1,2) += DATE(08,1,2) ``` - -### Years after 1899 -If **year** is between 1900 and 9999 (inclusive), that value is used as the year. The following formula returns January 2, 2008: - +### Years after 1899 + +If `year` is between 1900 and 9999 (inclusive), that value is used as the year. The following formula returns January 2, 2008: + ```dax -= DATE(2008,1,2) += DATE(2008,1,2) ``` - -### Months -If **month** is greater than 12, **month** adds that number of months to the first month in the year specified. The following formula returns the date February 2, 2009: - +### Months + +If `month` is greater than 12, `month` adds that number of months to the first month in the year specified. The following formula returns the date February 2, 2009: + ```dax -= DATE(2008,14,2) += DATE(2008,14,2) ``` - -### Days -If **day** is greater than the number of days in the month specified, **day** adds that number of days to the first day in the month. The following formula returns the date February 4, 2008: +### Days + +If `day` is greater than the number of days in the month specified, `day` adds that number of days to the first day in the month. The following formula returns the date February 4, 2008: ```dax -= DATE(2008,1,35) += DATE(2008,1,35) ``` +## Related content -## See also - -[Date and time functions](date-and-time-functions-dax.md) -[DAY function](day-function-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[DAY function](day-function-dax.md) [TODAY function](today-function-dax.md) diff --git a/query-languages/dax/dateadd-function-dax.md b/query-languages/dax/dateadd-function-dax.md index 97d19ca6f..32fa7fef5 100644 --- a/query-languages/dax/dateadd-function-dax.md +++ b/query-languages/dax/dateadd-function-dax.md @@ -1,70 +1,73 @@ --- description: "Learn more about: DATEADD" -title: "DATEADD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DATEADD function (DAX)" --- # DATEADD -Returns a table that contains a column of dates, shifted either forward or backward in time by the specified number of intervals from the dates in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of dates, shifted either forward or backward in time by the specified number of intervals from the dates in the current context. + +## Syntax + ```dax -DATEADD(,,) +DATEADD(,,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| -|number_of_intervals|An integer that specifies the number of intervals to add to or subtract from the dates.| -|interval|The interval by which to shift the dates. The value for interval can be one of the following: `year`, `quarter`, `month`, `day`| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| +|`number_of_intervals`|An integer that specifies the number of intervals to add to or subtract from the dates.| +|`interval`|The interval by which to shift the dates. The value for interval can be one of the following: `year`, `quarter`, `month`, `day`| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## 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. - - > [!NOTE] - > Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). - -- If the number specified for **number_of_intervals** is positive, the dates in **dates** are moved forward in time; if the number is negative, the dates in **dates** are shifted back in time. - -- The **interval** parameter is an enumeration, not a set of strings; therefore values should not be enclosed in quotation marks. Also, the values: `year`, `quarter`, `month`, `day` should be spelled in full when using them. - -- The result table includes only dates that exist in the **dates** column. +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. + + > [!NOTE] + > Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). + +- If the number specified for `number_of_intervals` is positive, the dates in `dates` are moved forward in time; if the number is negative, the dates in `dates` are shifted back in time. + +- The `interval` parameter is an enumeration, not a set of strings; therefore values should not be enclosed in quotation marks. Also, the values: `year`, `quarter`, `month`, `day` should be spelled in full when using them. + +- The result table includes only dates that exist in the `dates` column. - If the dates in the current context do not form a contiguous interval, the function returns an error. - + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - Shifting a set of dates - -The following formula calculates dates that are one year before the dates in the current context. + +## Example - Shifting a set of dates + +The following formula calculates dates that are one year before the dates in the current context. + +```dax += DATEADD(DateTime[DateKey],-1,year) +``` + +## Special behavior + +When the selection includes the last two days of month, DATEADD will use "extension" semantics and will include the days till the end of month. For example, when Feb 27 and 28 of 2013 are included in the selection and a month is added, DATEADD will return March 27 to 31. + +This behavior only happens when last two days of month are included in the selection. If only Feb 27 is selected, it will go to March 27. ```dax -= DATEADD(DateTime[DateKey],-1,year) += DATEADD(DateTime[DateKey], 1, month) ``` - -## See also -[Time intelligence functions](time-intelligence-functions-dax.md) +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) [Date and time functions](date-and-time-functions-dax.md) diff --git a/query-languages/dax/datediff-function-dax.md b/query-languages/dax/datediff-function-dax.md index 1180d73d4..551849f4e 100644 --- a/query-languages/dax/datediff-function-dax.md +++ b/query-languages/dax/datediff-function-dax.md @@ -1,43 +1,36 @@ --- description: "Learn more about: DATEDIFF" -title: "DATEDIFF function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/08/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DATEDIFF function (DAX)" --- # DATEDIFF - -Returns the number of interval boundaries between two dates. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the number of interval boundaries between two dates. + +## Syntax + ```dax -DATEDIFF(, , ) +DATEDIFF(, , ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Date1|A scalar datetime value.| -|Date2|A scalar datetime value.| -|Interval|The interval to use when comparing dates. The value can be one of the following:

- SECOND
- MINUTE
- HOUR
- DAY
- WEEK
- MONTH
- QUARTER
- YEAR| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Date1`|A scalar datetime value.| +|`Date2`|A scalar datetime value.| +|`Interval`|The interval to use when comparing dates. The value can be one of the following:

- SECOND
- MINUTE
- HOUR
- DAY
- WEEK
- MONTH
- QUARTER
- YEAR| + ## Return value -The count of interval boundaries between two dates. - +The count of interval boundaries between two dates. + ## Remarks A positive result is returned if Date2 is larger than Date1. A negative result is returned if Date1 is larger than Date2. - + ## Example [!INCLUDE [power-bi-dax-sample-model](includes/power-bi-dax-sample-model.md)] @@ -55,7 +48,7 @@ RETURN ( "Month", DATEDIFF ( StartDate, EndDate, MONTH ) ), ( "Week", DATEDIFF ( StartDate, EndDate, WEEK ) ), ( "Day", DATEDIFF ( StartDate, EndDate, DAY ) ) - } + } ``` Returns the following: diff --git a/query-languages/dax/datesbetween-function-dax.md b/query-languages/dax/datesbetween-function-dax.md index 2c00e3d5a..7f29d4766 100644 --- a/query-languages/dax/datesbetween-function-dax.md +++ b/query-languages/dax/datesbetween-function-dax.md @@ -1,18 +1,11 @@ --- description: "Learn more about: DATESBETWEEN" -title: "DATESBETWEEN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/08/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DATESBETWEEN function (DAX)" --- # DATESBETWEEN +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + Returns a table that contains a column of dates that begins with a specified start date and continues until a specified end date. This function is suited to pass as a filter to the [CALCULATE](calculate-function-dax.md) function. Use it to filter an expression by a custom date range. @@ -30,9 +23,9 @@ DATESBETWEEN(, , ) |Term|Definition| |--------|--------------| -|Dates|A date column.| -|StartDate|A date expression.| -|EndDate|A date expression.| +|`Dates`|A date column.| +|`StartDate`|A date expression.| +|`EndDate`|A date expression.| ## Return value @@ -40,15 +33,15 @@ A table containing a single column of date values. ## Remarks -- In the most common use case, **Dates** is a reference to the date column of a marked date table. +- In the most common use case, `dates` is a reference to the date column of a marked date table. -- If **StartDate** is BLANK, then **StartDate** will be the earliest value in the **Dates** column. +- If `StartDate` is BLANK, then `StartDate` will be the earliest value in the `dates` column. -- If **EndDate** is BLANK, then **EndDate** will be the latest value in the **Dates** column. +- If `EndDate` is BLANK, then `EndDate` will be the latest value in the `dates` column. -- Dates used as the **StartDate** and **EndDate** are inclusive. So, for example, if the **StartDate** value is July 1, 2019, then that date will be included in the returned table (providing the date exists in the **Dates** column). +- Dates used as the `StartDate` and `EndDate` are inclusive. So, for example, if the `StartDate` value is July 1, 2019, then that date will be included in the returned table (providing the date exists in the `dates` column). -- The returned table can only contain dates stored in the **Dates** column. So, for example, if the **Dates** column starts from July 1, 2017, and the **StartDate** value is July 1, 2016, the returned table will start from July 1, 2017. +- The returned table can only contain dates stored in the `Dates` column. So, for example, if the `Dates` column starts from July 1, 2017, and the `StartDate` value is July 1, 2016, the returned table will start from July 1, 2017. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] @@ -65,16 +58,16 @@ Customers LTD = CALCULATE( DISTINCTCOUNT(Sales[CustomerKey]), DATESBETWEEN( - 'Date'[Date], - BLANK(), - MAX('Date'[Date]) + 'Date'[Date], + BLANK(), + MAX('Date'[Date]) ) ) ``` Consider that the earliest date stored in the **Date** table is July 1, 2017. So, when a report filters the measure by the month of June 2020, the DATESBETWEEN function returns a date range from July 1, 2017 until June 30, 2020. -## See also +## Related content - [Time intelligence functions (DAX)](time-intelligence-functions-dax.md) - [Date and time functions (DAX)](date-and-time-functions-dax.md) diff --git a/query-languages/dax/datesinperiod-function-dax.md b/query-languages/dax/datesinperiod-function-dax.md index 49a157c52..1b05b41fd 100644 --- a/query-languages/dax/datesinperiod-function-dax.md +++ b/query-languages/dax/datesinperiod-function-dax.md @@ -1,18 +1,11 @@ --- description: "Learn more about: DATESINPERIOD" -title: "DATESINPERIOD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/06/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DATESINPERIOD function (DAX)" --- # DATESINPERIOD +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + Returns a table that contains a column of dates that begins with a specified start date and continues for the specified number and type of date intervals. This function is suited to pass as a filter to the [CALCULATE](calculate-function-dax.md) function. Use it to filter an expression by standard date intervals such as days, months, quarters, or years. @@ -27,10 +20,10 @@ DATESINPERIOD(, , , ) |Term|Definition| |--------|--------------| -|dates|A date column.| -|start_date|A date expression.| -|number_of_intervals|An integer that specifies the number of intervals to add to, or subtract from, the dates.| -|interval|The interval by which to shift the dates. The value for interval can be one of the following: `DAY`, `MONTH`, `QUARTER`, and `YEAR`| +|`dates`|A date column.| +|`start_date`|A date expression.| +|`number_of_intervals`|An integer that specifies the number of intervals to add to, or subtract from, the dates.| +|`interval`|The interval by which to shift the dates. The value for interval can be one of the following: `DAY`, `MONTH`, `QUARTER`, and `YEAR`| ## Return value @@ -38,13 +31,13 @@ A table containing a single column of date values. ## Remarks -- In the most common use case, **dates** is a reference to the date column of a marked date table. +- In the most common use case, `dates` is a reference to the date column of a marked date table. -- If the number specified for **number_of_intervals** is positive, dates are moved forward in time; if the number is negative, dates are shifted backward in time. +- If the number specified for `number_of_intervals` is positive, dates are moved forward in time; if the number is negative, dates are shifted backward in time. -- The **interval** parameter is an enumeration. Valid values are `DAY`, `MONTH`, `QUARTER`, and `YEAR`. Because it's an enumeration, values aren't passed in as strings. So don't enclose them within quotation marks. +- The `interval` parameter is an enumeration. Valid values are `DAY`, `MONTH`, `QUARTER`, and `YEAR`. Because it's an enumeration, values aren't passed in as strings. So don't enclose them within quotation marks. -- The returned table can only contain dates stored in the **dates** column. So, for example, if the **dates** column starts from July 1, 2017, and the **start_date** value is July 1, 2016, the returned table will start from July 1, 2017. +- The returned table can only contain dates stored in the `dates` column. So, for example, if the `dates` column starts from July 1, 2017, and the `start_date` value is July 1, 2016, the returned table will start from July 1, 2017. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] @@ -71,8 +64,8 @@ CALCULATE( Consider that the report is filtered by the month of June 2020. The MAX function returns June 30, 2020. The DATESINPERIOD function then returns a date range from July 1, 2019 until June 30, 2020. It's a year of date values starting from June 30, 2020 for the last year. -## See also +## Related content -[Time intelligence functions (DAX)](time-intelligence-functions-dax.md) -[Date and time functions (DAX)](date-and-time-functions-dax.md) -[DATESBETWEEN function (DAX)](datesbetween-function-dax.md) +[Time intelligence functions (DAX)](time-intelligence-functions-dax.md) +[Date and time functions (DAX)](date-and-time-functions-dax.md) +[DATESBETWEEN function (DAX)](datesbetween-function-dax.md) diff --git a/query-languages/dax/datesmtd-function-dax.md b/query-languages/dax/datesmtd-function-dax.md index 5b415b377..a87444e50 100644 --- a/query-languages/dax/datesmtd-function-dax.md +++ b/query-languages/dax/datesmtd-function-dax.md @@ -1,62 +1,55 @@ --- description: "Learn more about: DATESMTD" -title: "DATESMTD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DATESMTD function (DAX)" --- # DATESMTD -Returns a table that contains a column of the dates for the month to date, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of the dates for the month to date, in the current context. + +## Syntax + ```dax -DATESMTD() +DATESMTD() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## 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. - - > [!NOTE] - > Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). - +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. + + > [!NOTE] + > Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'Month To Date Total' for Internet Sales. - +The following sample formula creates a measure that calculates the 'Month To Date Total' for Internet Sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), DATESMTD(DateTime[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), DATESMTD(DateTime[DateKey])) ``` - -## See also -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[DATESYTD function](datesytd-function-dax.md) +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[DATESYTD function](datesytd-function-dax.md) [DATESQTD function](datesqtd-function-dax.md) diff --git a/query-languages/dax/datesqtd-function-dax.md b/query-languages/dax/datesqtd-function-dax.md index d872260b7..36894012f 100644 --- a/query-languages/dax/datesqtd-function-dax.md +++ b/query-languages/dax/datesqtd-function-dax.md @@ -1,62 +1,55 @@ --- description: "Learn more about: DATESQTD" -title: "DATESQTD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DATESQTD function (DAX)" --- # DATESQTD -Returns a table that contains a column of the dates for the quarter to date, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of the dates for the quarter to date, in the current context. + +## Syntax + ```dax -DATESQTD() +DATESQTD() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## 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. - - > [!NOTE] - > Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). - +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. + + > [!NOTE] + > Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'Quarterly Running Total' of Internet Sales. - +The following sample formula creates a measure that calculates the 'Quarterly Running Total' of Internet Sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), DATESQTD(DateTime[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), DATESQTD(DateTime[DateKey])) ``` - -## See also -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[DATESYTD function](datesytd-function-dax.md) +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[DATESYTD function](datesytd-function-dax.md) [DATESMTD function](datesmtd-function-dax.md) diff --git a/query-languages/dax/datesytd-function-dax.md b/query-languages/dax/datesytd-function-dax.md index ea1506bfb..761a0d55e 100644 --- a/query-languages/dax/datesytd-function-dax.md +++ b/query-languages/dax/datesytd-function-dax.md @@ -1,65 +1,69 @@ --- description: "Learn more about: DATESYTD" -title: "DATESYTD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DATESYTD function (DAX)" --- # DATESYTD -Returns a table that contains a column of the dates for the year to date, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of the dates for the year to date, in the current context. + +## Syntax + ```dax -DATESYTD( [,]) +DATESYTD( [,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| -|year_end_date|(optional) A literal string with a date that defines the year-end date. The default is December 31.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| +|`year_end_date`|(optional) A literal string with a date that defines the year-end date. The default is December 31.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## 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. - - > [!NOTE] - > Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). - -- The **year_end_date** parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. - +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. + + > [!NOTE] + > Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). + +- The `year_end_date` parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. Depending on locale, the format might be something like "m-dd" or "dd-m". + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'Running Total' for Internet sales. - +The following sample formula creates a measure that calculates the 'Running Total' for Internet sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), DATESYTD(DateTime[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), DATESYTD(DateTime[DateKey])) ``` - -## See also -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[DATESMTD function](datesmtd-function-dax.md) +The following sample formula creates a measure that calculates the 'Fiscal Year Running Total' for Internet sales, using a US Locale for the Date format. + +```dax += CALCULATE( + SUM(InternetSales_USD[SalesAmount_USD]), + DATESYTD(DateTime[DateKey], + "6-30" + ) +) +``` + +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[DATESMTD function](datesmtd-function-dax.md) [DATESQTD function](datesqtd-function-dax.md) diff --git a/query-languages/dax/datevalue-function-dax.md b/query-languages/dax/datevalue-function-dax.md index 2cd136b0e..54677590c 100644 --- a/query-languages/dax/datevalue-function-dax.md +++ b/query-languages/dax/datevalue-function-dax.md @@ -1,60 +1,53 @@ --- description: "Learn more about: DATEVALUE" -title: "DATEVALUE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DATEVALUE function (DAX)" --- # DATEVALUE -Converts a date in text format to a date in datetime format. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Converts a date in text format to a date in datetime format. + +## Syntax + ```dax -DATEVALUE(date_text) +DATEVALUE(date_text) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|date_text|Text that represents a date.| - -## Property Value/Return value - -A date in **datetime** format. - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`date_text`|Text that represents a date.| + +## Property Value/Return value + +A date in `datetime` format. + ## Remarks -- When converting, DATEVALUE uses the locale and date/time settings of the model to determine a date value. If the model date/time settings represent dates in the format of Month/Day/Year, then the string, "1/8/2009", is converted to a **datetime** value equivalent to January 8th of 2009. However, if the model date/time settings represent dates in the format of Day/Month/Year, the same string is converted as a **datetime** value equivalent to August 1st of 2009. +- When converting, DATEVALUE uses the locale and date/time settings of the model to determine a date value. If the model date/time settings represent dates in the format of Month/Day/Year, then the string, "1/8/2009", is converted to a `datetime` value equivalent to January 8th of 2009. However, if the model date/time settings represent dates in the format of Day/Month/Year, the same string is converted as a `datetime` value equivalent to August 1st of 2009. - If conversion using the locale and date/time settings of the model fails, DATEVALUE will attempt to use other date formats. In this case, some rows may be converted using one format and other rows are converted using a different format. For example, "5/4/2018" may convert to May 4th of 2018, and "20/4/2018" may convert to April 20th. - -- If the year portion of the **date_text** argument is omitted, the DATEVALUE function uses the current year from your computer's built-in clock. Time information in the **date_text** argument is ignored. + +- If the year portion of the `date_text` argument is omitted, the DATEVALUE function uses the current year from your computer's built-in clock. Time information in the `date_text` argument is ignored. - Model locale and data/time settings are initially determined by the application and computer when the model is created. - Date and datetime can also be specified as a literal in the format `dt"YYYY-MM-DD"`, `dt"YYYY-MM-DDThh:mm:ss"`, or `dt"YYYY-MM-DD hh:mm:ss"`. When specified as a literal, using the DATEVALUE function in the expression is not necessary. To learn more, see [DAX Syntax | Date and time](dax-syntax-reference.md#date-and-time). -## Example +## Example + +The following example returns a different `datetime` value depending on the model locale and settings for how dates and times are presented. + +- In date/time settings where the day precedes the month, the example returns a `datetime` value corresponding to January 8th of 2009. + +- In date/time settings where the month precedes the day, the example returns a `datetime` value corresponding to August 1st of 2009. -The following example returns a different **datetime** value depending on the model locale and settings for how dates and times are presented. - -- In date/time settings where the day precedes the month, the example returns a **datetime** value corresponding to January 8th of 2009. - -- In date/time settings where the month precedes the day, the example returns a **datetime** value corresponding to August 1st of 2009. - ```dax -= DATEVALUE("8/1/2009") += DATEVALUE("8/1/2009") ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) diff --git a/query-languages/dax/dax - Shortcut.lnk b/query-languages/dax/dax - Shortcut.lnk deleted file mode 100644 index 0fe2e81d2..000000000 Binary files a/query-languages/dax/dax - Shortcut.lnk and /dev/null differ diff --git a/query-languages/dax/dax-copilot.md b/query-languages/dax/dax-copilot.md new file mode 100644 index 000000000..d0c30c729 --- /dev/null +++ b/query-languages/dax/dax-copilot.md @@ -0,0 +1,201 @@ +--- +title: "Write DAX queries with Copilot" +description: Use Copilot to create a DAX queries query. Type in a prompt to describe what DAX query you would like generated, and Copilot can create it. +ms.service: powerbi +ms.date: 10/21/2024 +ms.reviewer: +ms.topic: how-to +author: DataZoeMS +ms.author: zoedouglas +no-loc: [CoPilot] +#customer intent: As a DAX query writer, I want to use Copilot to help me write DAX queries. +--- +# Write DAX queries with Copilot + +You can use Copilot to write and explain Data Analysis Expressions (DAX) queries in DAX query view of a Power BI semantic model. + +## Enable Copilot + +Check to make sure you meet the [Fabric Copilot requirements](/fabric/get-started/copilot-fabric-overview#enable-copilot). + +### Power BI Desktop +In Power BI Desktop, in the **Preview features** section of the **Options**, enable **DAX query view with Copilot**. + +1. Open Power BI Desktop. +1. Open an existing Power BI report or connect to published semantic model as live edit or live connection. Alternatively, you can add data and create a new semantic model and report. +1. Go to **DAX query view**, the fourth view available on the left side of Power BI Desktop. +1. Create a new query tab. +1. Open Copilot by clicking on the **Copilot** button or using CTRL + I. + +:::image type="content" source="media/dax-copilot/copilot-power-bi-desktop.png" alt-text="Screenshot showing Power BI Desktop with Fabric Copilot in DAX query view." lightbox="media/dax-copilot/copilot-power-bi-desktop.png"::: + +### Power BI service or workspace + +1. Choose a published semantic model in a workspace. +2. From the context menu choose **Write DAX queries**. If **Write DAX queries** is greyed out, you may need to enable **Users can edit data models in the Power BI service (preview)** in the **Power BI** **General** section of **Workspace settings**. +3. Create a new query tab. +4. Open Copilot by clicking on the Copilot button or using CTRL + I. + +:::image type="content" source="media/dax-copilot/copilot-power-bi-service-write-dax-queries.png" alt-text="Screenshot showing Power BI service with Fabric Copilot in DAX query view." lightbox="media/dax-copilot/copilot-power-bi-service-write-dax-queries.png"::: + +> [!NOTE] +> DirectQuery and Direct Lake model authors can also use DAX query view. View the data in your tables whenever you want. + +## Use Copilot + +Let’s look at what Copilot can help you with in [DAX query view](/power-bi/transform-model/dax-query-view): + +- **Natural language to DAX query**. Just ask for what you want from your semantic model and have the DAX query generated by Copilot. You can also select an existing DAX query and have Copilot modify it. +- **DAX query to natural language**. Ask Copilot to explain what any DAX query is doing. +- **Understand DAX concepts**. Maybe you heard about a certain DAX function or need to find the right DAX function for the job. Copilot can help you here too. + +To use Copilot to create a DAX query, type in a prompt to describe what DAX query you would like generated and select **Send** or press Enter. Alternatively, you can click the **Write DAX query** inspire button. To run what is returned, select **Run** or press F5 to see the results of the DAX query. To keep the query and exit Copilot, select **Keep query** to add it to query tab. + +To use Copilot to explain a DAX query, select the DAX query and click the **Explain this query** inspire button. A short explanation is shown with the option to **show more** to see a longer explanation. + +To use Copilot to explain a DAX topic, click the **Explain a DAX topic** inspire button, or type in a prompt to ask for an explanation of a DAX function or topic and select **Send** or press Enter. A short explanation is shown with the option to **show more** to see a longer explanation. + +## Features of the inline Copilot + +### 1. Run the DAX query before you keep it + +You can **Run** the DAX query then decide to **Keep** or **Discard** the DAX query. + +:::image type="content" source="media/dax-copilot/copilot-run-query.png" alt-text="Screenshot of running the DAX query before you save it." lightbox="media/dax-copilot/copilot-run-query.png"::: + +### 2. Build the DAX query conversationally + +After the initial DAX query is generated, you can simply adjust by typing in additional user prompts. + +:::image type="content" source="media/dax-copilot/copilot-explain-query.png" alt-text="Screenshot of asking DAX to explain the query." lightbox="media/dax-copilot/copilot-explain-query.png"::: + +### 3. Syntax checks on the generated DAX query + +The generated DAX query syntax is checked, and the prompt automatically retried once. If the retry is also invalid, the generated DAX query is returned with a note that there is an issue, giving you the option to rephrase your request or fix the generated DAX query: + +"This query contains errors. Rephrase your request and try again or try fixing it yourself." + +### 4. Inspire buttons to get you started with Copilot + +Type in a prompt or select any of these buttons to see quickly what you can do with Copilot. + +:::image type="content" source="media/dax-copilot/copilot-inspire-buttons-get-started.png" alt-text="Screenshot of showing Copilot offers suggestions." lightbox="media/dax-copilot/copilot-inspire-buttons-get-started.png"::: + +## Sample prompts + +These sample prompts can illustrate how to use Copilot to write DAX queries. + +- [Write a DAX query](#write-a-dax-query) +- [Add a column with the diff view](#add-a-column-with-the-diff-view) +- [Explain a DAX query](#explain-a-dax-query) +- [Explain a DAX topic](#explain-a-dax-topic) + +### Write a DAX query + +In a blank query tab, invoke Copilot with CTRL+I and enter this request: + +"Write a DAX query to show profit by product" + +:::image type="content" source="media/dax-copilot/dax-list-products.png" alt-text="Screenshot showing Copilot with the prompt Write a DAX query to show profit by product." lightbox="media/dax-copilot/dax-list-products.png"::: + +After a few moments I get a DAX query. + +:::image type="content" source="media/dax-copilot/dax-query-list-products.png" alt-text="Screenshot showing DAX query generated by Fabric Copilot." lightbox="media/dax-copilot/dax-query-list-products.png"::: + +I can select **run** to see the results before I keep the query. + +:::image type="content" source="media/dax-copilot/dax-copilot-run-query.png" alt-text="Screenshot showing Run DAX query generated by Fabric Copilot." lightbox="media/dax-copilot/dax-copilot-run-query.png"::: + +I can conversationally make updates to my initial request. Type in "Add in Orders" and hit enter and Copilot adds in the additional measure. I can again **run** the query to see the results. + +:::image type="content" source="media/dax-copilot/dax-copilot-conversational-query.png" alt-text="Screenshot showing how to build the DAX query conversationally." lightbox="media/dax-copilot/dax-copilot-conversational-query.png"::: + +When I select **keep query**, the query is added to the query tab. + +### Add a column with the diff view + +Let's now add a column to the existing DAX query. First I select the DAX query, then invoke Copilot. This time the selection is showing fitted to the text and the background shading highlights what is being sent with the request to Copilot. Type in this request, and hit enter: + +"Add a column to show profit per order" + +:::image type="content" source="media/dax-copilot/dax-copilot-show-diff.png" alt-text="Screenshot showing a selection included with the Copilot prompt." lightbox="media/dax-copilot/dax-copilot-show-diff.png"::: + +Now the diff styling in the DAX query editor shows exactly what Copilot has changed. + +:::image type="content" source="media/dax-copilot/dax-copilot-highlight-diff.png" alt-text="Screenshot showing diff styling to see what Copilot has changed." lightbox="media/dax-copilot/dax-copilot-highlight-diff.png"::: + +I select **run** to see the results, and **keep query** to add it to the query editor. + +:::image type="content" source="media/dax-copilot/dax-copilot-updated-query.png" alt-text="Screenshot showing the query in the DAX query editor." lightbox="media/dax-copilot/dax-copilot-updated-query.png"::: + +### Explain a DAX query + +Copilot can provide a detailed explanation of a DAX query. Again, select the entire DAX query and invoke Copilot. This time select the **Explain this query** button. + +:::image type="content" source="media/dax-copilot/dax-copilot-explain-query.png" alt-text="Screenshot showing Explain to me what this query does." lightbox="media/dax-copilot/dax-copilot-explain-query.png"::: + +Now, instead of writing DAX queries, it’s responding in the inline Copilot. + +:::image type="content" source="media/dax-copilot/dax-copilot-query-explanation.png" alt-text="Screenshot showing brief explanation of the query."::: + +Copilot generates a few lines. I select **Show more** to see the full explanation. + +:::image type="content" source="media/dax-copilot/dax-copilot-explain-query-more.png" alt-text="Screenshot showing a long explanation of what the query does."::: + +Now I understand each part and the DAX functions used. + +### Explain a DAX topic + +Copilot can also explain DAX functions with more detail. Let's ask about SUMMARIZECOLUMNS. In a new query tab, invoke Copilot, and sent the following request: + +"Explain what SUMMARIZECOLUMNS is for" + +:::image type="content" source="media/dax-copilot/dax-copilot-explain-summarize-columns.png" alt-text="Screenshot showing an explanation of what the SUMMARIZECOLUMNS does." lightbox="media/dax-copilot/dax-copilot-explain-summarize-columns.png"::: + +Again, Copilot generates brief description: + +:::image type="content" source="media/dax-copilot/dax-copilot-summarize-columns-brief.png" alt-text="Screenshot showing a brief description of the SUMMARIZECOLUMNS DAX function."::: + +I can select **Show more** to see a more detailed explanation with an example. + +:::image type="content" source="media/dax-copilot/dax-copilot-summarize-columns-more.png" alt-text="Screenshot showing Copilot generates a much more in-depth description."::: + +The example also uses columns in my model. + +## Fabric Copilot to help write DAX queries: Responsible AI FAQ + +### What is Fabric Copilot to help write DAX queries? +An inline Copilot found in Power BI DAX query view, available in the DAX query view of Power BI Desktop or write DAX queries in Power BI workspace, for model authors and consumers to request help creating DAX queries. The help can include explaining a DAX query and DAX topics, in addition to creating DAX queries themselves. + +### What can Fabric Copilot to help write DAX queries do? +The user request can be returned by Copilot as a DAX query the user can see, then run to see the data returned in the results grid. Additional requests can be made, and a new DAX query can be returned, creating a DAX query conversationally. If the request is about explaining a DAX query or topic, a natural language response is generated in the inline Copilot. DAX topics can include what a DAX function does or which DAX function is good for returning data in a specific way. + +### What is Fabric Copilot to help write DAX queries’ intended use? +Copilot’s intended use is to help create DAX queries on a specific semantic model the user is currently working with in Power BI. + +### How was Fabric Copilot to help write DAX queries evaluated? What metrics are used to measure performance? +DAX queries from multiple Power BI semantic models using a variety of user requests, categorized by data availability in the semantic model and/or if additional calculations were needed to create the correct response, and then graded for accuracy and performance by members of the product team. This included a semantic model adhering to best practices. Explanations from multiple DAX queries and DAX function topics, and then graded for accuracy and readability by members of the product team. + +### What are the limitations of Fabric Copilot to help write DAX queries? How can users minimize the impact of Fabric Copilot to help write DAX queries’ limitations when using the system? +- To use Copilot to help write DAX queries, you need to select a workspace with a Fabric capacity. +- Copilot uses the model metadata (tables, columns, measures), so DAX query responses will answer only in context of the current semantic model. +- Copilot uses the model metadata (tables, columns, measures), so providing rich metadata that is descriptive and understandable will yield better results. +- Copilot may use min/max to get sample values in import storage mode, but cannot use other data in the tables of the semantic model. +- Copilot may not be available or use reduced version of the model metadata (tables, columns, measures) when the number of model metadata items exceeds 500 tables, 1,000 columns or 3,000 measures in a table, 2,000 relationships, 10,000 total columns, 5,000 total measures, 5,000 characters in a single DAX expression, or 256 characters in a name. +- Copilot may use the description property on model metadata, but is limited to only the first 200 characters. +- DAX functions added recently may not be known to the Copilot, and explanations may be incorrect. +- Copilot requests include all text in the current query window, and if text is selected the selection information it is noted as selected, but all text in the query window is included. + +### What operational factors and settings allow for effective and responsible use of Fabric Copilot to help write DAX queries? +- Operational factors and settings include the current workload on a Fabric capacity and network speed. +- Copilot to help write DAX queries is contained in the [privacy, security, and responsible use of Copilot in Fabric](/fabric/get-started/copilot-privacy-security). + +### How do I provide feedback on Fabric Copilot to help write DAX queries? +- Use the thumbs up and thumbs down icons in the inline Copilot to provide feedback. +- Submit feedback using the [Power BI support](/power-bi/support/). + +## Learn more with these resources + +- [Overview of Copilot in Fabric and Power BI](/fabric/get-started/copilot-fabric-overview#enable-copilot) +- [DAX query view](/power-bi/transform-model/dax-query-view) +- [DAX queries](https://aka.ms/dax-queries) diff --git a/query-languages/dax/dax-function-reference.md b/query-languages/dax/dax-function-reference.md index f4c92f264..fd9ab9c96 100644 --- a/query-languages/dax/dax-function-reference.md +++ b/query-languages/dax/dax-function-reference.md @@ -1,57 +1,50 @@ --- description: "Learn more about: DAX function reference" -title: "DAX function reference | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 12/17/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DAX function reference" --- # DAX function reference -The DAX function reference provides detailed information including syntax, parameters, return values, and examples for each of the over 250 functions used in Data Analysis Expression (DAX) formulas. +The DAX function reference provides detailed information including syntax, parameters, return values, and examples for each of the over 250 functions used in Data Analysis Expression (DAX) formulas. > [!IMPORTANT] -> Not all DAX functions are supported or included in earlier versions of Power BI Desktop, Analysis Services, and Power Pivot in Excel. +> Not all DAX functions are supported or included in earlier versions of Power BI Desktop, Analysis Services, and Power Pivot in Excel. -## In this section +## In this section -[New DAX functions](new-dax-functions.md) - These functions are new or are existing functions that have been significantly updated. +[New DAX functions](new-dax-functions.md) - These functions are new or are existing functions that have been significantly updated. [Aggregation functions](aggregation-functions-dax.md) - These functions calculate a (scalar) value such as count, sum, average, minimum, or maximum for all rows in a column or table as defined by the expression. -[Date and time functions](date-and-time-functions-dax.md) - These functions in DAX are similar to date and time functions in Microsoft Excel. However, DAX functions are based on the datetime data types used by Microsoft SQL Server. - -[Filter functions](filter-functions-dax.md) - These functions help you return specific data types, look up values in related tables, and filter by related values. Lookup functions work by using tables and relationships between them. Filtering functions let you manipulate data context to create dynamic calculations. +[Date and time functions](date-and-time-functions-dax.md) - These functions in DAX are similar to date and time functions in Microsoft Excel. However, DAX functions are based on the datetime data types used by Microsoft SQL Server. + +[Filter functions](filter-functions-dax.md) - These functions help you return specific data types, look up values in related tables, and filter by related values. Lookup functions work by using tables and relationships between them. Filtering functions let you manipulate data context to create dynamic calculations. [Financial functions](financial-functions-dax.md) - These functions are used in formulas that perform financial calculations, such as net present value and rate of return. - -[Information functions](information-functions-dax.md) - These functions look at a table or column provided as an argument to another function and returns whether the value matches the expected type. For example, the ISERROR function returns TRUE if the value you reference contains an error. - -[Logical functions](logical-functions-dax.md) - These functions return information about values in an expression. For example, the TRUE function lets you know whether an expression that you are evaluating returns a TRUE value. - -[Math and Trig functions](math-and-trig-functions-dax.md) - Mathematical functions in DAX are similar to Excel's mathematical and trigonometric functions. However, there are some differences in the numeric data types used by DAX functions. - -[Other functions](other-functions-dax.md) - These functions perform unique actions that cannot be defined by any of the categories most other functions belong to. - -[Parent and Child functions](parent-and-child-functions-dax.md) - These functions help users manage data that is presented as a parent/child hierarchy in their data models. - -[Relationship functions](relationship-functions-dax.md) - These functions are for managing and utilizing relationships between tables. For example, you can specify a particular relationship to be used in a calculation. + +[INFO functions](info-functions-dax.md) - These functions return metadata about your semantic model, such as the tables, columns, relationships, and calculation DAX formulas. They can help you understand and document the model. They are based on the library of [Dynamic Management Views (DMVs) in Analysis Services](/analysis-services/instances/use-dynamic-management-views-dmvs-to-monitor-analysis-services), which have been modified to work as DAX functions. + +[Information functions](information-functions-dax.md) - These functions look at a table or column provided as an argument to another function and returns whether the value matches the expected type. For example, the ISERROR function returns `TRUE` if the value you reference contains an error. + +[Logical functions](logical-functions-dax.md) - These functions return information about values in an expression. For example, the `TRUE` function lets you know whether an expression that you are evaluating returns a `TRUE` value. + +[Math and Trig functions](math-and-trig-functions-dax.md) - Mathematical functions in DAX are similar to Excel's mathematical and trigonometric functions. However, there are some differences in the numeric data types used by DAX functions. + +[Other functions](other-functions-dax.md) - These functions perform unique actions that cannot be defined by any of the categories most other functions belong to. + +[Parent and Child functions](parent-and-child-functions-dax.md) - These functions help users manage data that is presented as a parent/child hierarchy in their data models. + +[Relationship functions](relationship-functions-dax.md) - These functions are for managing and utilizing relationships between tables. For example, you can specify a particular relationship to be used in a calculation. [Statistical functions](statistical-functions-dax.md) - These functions calculate values related to statistical distributions and probability, such as standard deviation and number of permutations. [Table manipulation functions](table-manipulation-functions-dax.md) - These functions return a table or manipulate existing tables. - -[Text functions](text-functions-dax.md) - With these functions, you can return part of a string, search for text within a string, or concatenate string values. Additional functions are for controlling the formats for dates, times, and numbers. -[Time intelligence functions](time-intelligence-functions-dax.md) - These functions help you create calculations that use built-in knowledge about calendars and dates. By using time and date ranges in combination with aggregations or calculations, you can build meaningful comparisons across comparable time periods for sales, inventory, and so on. - -## See also +[Text functions](text-functions-dax.md) - With these functions, you can return part of a string, search for text within a string, or concatenate string values. Additional functions are for controlling the formats for dates, times, and numbers. + +[Time intelligence functions](time-intelligence-functions-dax.md) - These functions help you create calculations that use built-in knowledge about calendars and dates. By using time and date ranges in combination with aggregations or calculations, you can build meaningful comparisons across comparable time periods for sales, inventory, and so on. + +## Related content -[DAX Syntax Reference](dax-syntax-reference.md) -[DAX Operator Reference](dax-operator-reference.md) +[DAX Syntax Reference](dax-syntax-reference.md) +[DAX Operator Reference](dax-operator-reference.md) [DAX Parameter-Naming Conventions](dax-parameter-naming-conventions.md) diff --git a/query-languages/dax/dax-glossary.md b/query-languages/dax/dax-glossary.md index 905e8a8e6..ff55a13a4 100644 --- a/query-languages/dax/dax-glossary.md +++ b/query-languages/dax/dax-glossary.md @@ -1,14 +1,7 @@ --- -title: "DAX glossary | Microsoft Docs" +title: "DAX glossary" description: Describes common terms used in the Data Analysis Expressions (DAX) language. -ms.service: powerbi -ms.subservice: dax -ms.date: 09/08/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +ms.topic: conceptual --- # DAX glossary @@ -87,7 +80,7 @@ A model table that contains at least one measure, and has no hierarchies or visi ## Model calculation -A named formula that's used to add a calculated table, calculated column, or measure to a tabular data model. Its structure is \ = \. Most calculations are added by data modelers in Power BI Desktop, but measures can also be added to a live connection report. See [Report measures](#report-measures). +A named formula that's used to add a calculated table, calculated column, or measure to a tabular data model. Its structure is `NAME` = `FORMULA`. Most calculations are added by data modelers in Power BI Desktop, but measures can also be added to a live connection report. See [Report measures](#report-measures). ## Quick measures @@ -99,7 +92,7 @@ Also called *report-level measures*. They're added to a live connection report i ## Row-level security -Also called *RLS*. Design technique to restrict access to subsets of data for specific users. In a tabular model, it's achieved by creating model roles. Roles have rules, which are DAX expressions to filter table rows. +Also called `RLS`. Design technique to restrict access to subsets of data for specific users. In a tabular model, it's achieved by creating model roles. Roles have rules, which are DAX expressions to filter table rows. ## Scalar diff --git a/query-languages/dax/dax-learn-videos.md b/query-languages/dax/dax-learn-videos.md index 676bebcf3..4f6384249 100644 --- a/query-languages/dax/dax-learn-videos.md +++ b/query-languages/dax/dax-learn-videos.md @@ -1,18 +1,11 @@ --- -title: "Learn DAX videos | Microsoft Docs" +title: "Learn DAX videos" description: Describes helpful videos used to learn Data Analysis Expressions (DAX) language. -ms.service: powerbi -ms.subservice: dax -ms.date: 06/14/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +ms.topic: conceptual --- # Videos -Whether you're using Power BI Desktop, Power Pivot in Excel, or Analysis Services, learning Data Analysis Expressions (DAX) is essential to creating effective data models. Here are some videos to help you get started using this powerful expression language. +Whether you're using Power BI Desktop, Power Pivot in Excel, or Analysis Services, learning Data Analysis Expressions (DAX) is essential to creating effective data models. Here are some videos to help you get started using this powerful expression language. ## DAX 101 @@ -24,4 +17,10 @@ In this DAX 101 video, Microsoft Partner, Alberto Ferrari introduces essential c In this advanced DAX video, Microsoft Partner, Alberto Ferrari describes DAX theory, filter and row context, and other essential concepts in DAX. -> [!VIDEO https://www.youtube.com/embed/6ncHnWMEdic] \ No newline at end of file +> [!VIDEO https://www.youtube.com/embed/6ncHnWMEdic] + +## Practical DAX for Power BI + +In this video, Microsoft Principal Program Manager, Phil Seamark, walks through some best practices for practical uses of DAX in Power BI. + +> [!VIDEO https://www.youtube.com/embed/1fGfqzS37qs] diff --git a/query-languages/dax/dax-operator-reference.md b/query-languages/dax/dax-operator-reference.md index 490c90492..987627cb4 100644 --- a/query-languages/dax/dax-operator-reference.md +++ b/query-languages/dax/dax-operator-reference.md @@ -1,141 +1,133 @@ --- description: "Learn more about: DAX operators" -title: "DAX operators | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 11/09/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DAX operators" +ms.topic: conceptual --- # DAX operators The Data Analysis Expression (DAX) language uses operators to create expressions that compare values, perform arithmetic calculations, or work with strings. - + ## Types of operators -There are four different types of calculation operators: arithmetic, comparison, text concatenation, and logical. - +There are four different types of calculation operators: arithmetic, comparison, text concatenation, and logical. + ### Arithmetic operators -To perform basic mathematical operations such as addition, subtraction, or multiplication; combine numbers; and produce numeric results, use the following arithmetic operators. - -|Arithmetic operator|Meaning|Example| -|-----------------------|-----------|-----------| -|+ (plus sign)|Addition|3+3| -|– (minus sign)|Subtraction or sign|3–1–1| -|* (asterisk)|Multiplication|3*3| -|/ (forward slash)|Division|3/3| -|^ (caret)|Exponentiation|16^4| - -> [!NOTE] -> The plus sign can function both as a *binary operator* and as a *unary operator*. A binary operator requires numbers on both sides of the operator and performs addition. When you use values in a DAX formula on both sides of the binary operator, DAX tries to cast the values to numeric data types if they are not already numbers. In contrast, the unary operator can be applied to any type of argument. The plus symbol does not affect the type or value and is simply ignored, whereas the minus operator creates a negative value, if applied to a numeric value. - +To perform basic mathematical operations such as addition, subtraction, or multiplication; combine numbers; and produce numeric results, use the following arithmetic operators. + +|Arithmetic operator|Meaning|Example| +|-----------------------|-----------|-----------| +|`+` (plus sign)|Addition|`3+3`| +|`-` (minus sign)|Subtraction or sign|`3-1-1`| +|`*` (asterisk)|Multiplication|`3*3`| +|`/` (forward slash)|Division|`3/3`| +|`^` (caret)|Exponentiation|`16^4`| + +> [!NOTE] +> The plus sign can function both as a *binary operator* and as a *unary operator*. A binary operator requires numbers on both sides of the operator and performs addition. When you use values in a DAX formula on both sides of the binary operator, DAX tries to cast the values to numeric data types if they are not already numbers. In contrast, the unary operator can be applied to any type of argument. The plus symbol does not affect the type or value and is simply ignored, whereas the minus operator creates a negative value, if applied to a numeric value. + ### Comparison operators -You can compare two values with the following operators. When two values are compared by using these operators, the result is a logical value, either TRUE or FALSE. - -|Comparison operator|Meaning|Example| -|-----------------------|-----------|-----------| -|=|Equal to|[Region] = "USA"| -|==|Strict equal to|[Region] == "USA"| -|>|Greater than|[Sales Date] > "Jan 2009"| -|<|Less than|[Sales Date] < "Jan 1 2009"| -|>=|Greater than or equal to|[Amount] >= 20000| -|<=|Less than or equal to|[Amount] <= 100| -|<>|Not equal to|[Region] <> "USA"| +You can compare two values with the following operators. When two values are compared by using these operators, the result is a logical value, either `TRUE` or `FALSE`. + +|Comparison operator|Meaning|Example| +|-----------------------|-----------|-----------| +|`=`|Equal to|[Region] = "USA"| +|`==`|Strict equal to|[Region] == "USA"| +|`>`|Greater than|[Sales Date] > "Jan 2009"| +|`<`|Less than|[Sales Date] < "Jan 1 2009"| +|`>=`|Greater than or equal to|[Amount] >= 20000| +|`<=`|Less than or equal to|[Amount] <= 100| +|`<>`|Not equal to|[Region] <> "USA"| -All comparison operators except == treat BLANK as equal to number 0, empty string "", DATE(1899, 12, 30), or FALSE. As a result, [Column] = 0 will be true when the value of [Column] is either 0 or BLANK. In contrast, [Column] == 0 is true only when the value of [Column] is 0. +All comparison operators except == treat BLANK as equal to number 0, empty string "", DATE(1899, 12, 30), or `FALSE`. As a result, [Column] = 0 will be true when the value of [Column] is either 0 or BLANK. In contrast, [Column] == 0 is true only when the value of [Column] is 0. ### Text concatenation operator -Use the ampersand (**&**) to join, or concatenate, two or more text strings to produce a single piece of text. - -|Text operator|Meaning|Example| -|-----------------|-----------|-----------| -|& (ampersand)|Connects, or concatenates, two values to produce one continuous text value|[Region] & ", " & [City]| - +Use the ampersand (`&`) to join, or concatenate, two or more text strings to produce a single piece of text. + +|Text operator|Meaning|Example| +|-----------------|-----------|-----------| +|`&` (ampersand)|Connects, or concatenates, two values to produce one continuous text value|`[Region] & ", " & [City]`| + ### Logical operators -Use logical operators (&&) and (||) to combine expressions to produce a single result. - -|Text operator|Meaning|Examples| -|-----------------|-----------|------------| -|&& (double ampersand)|Creates an AND condition between two expressions that each have a Boolean result. If both expressions return TRUE, the combination of the expressions also returns TRUE; otherwise the combination returns FALSE.|([Region] = "France") && ([BikeBuyer] = "yes"))| -||| (double pipe symbol)|Creates an OR condition between two logical expressions. If either expression returns TRUE, the result is TRUE; only when both expressions are FALSE is the result FALSE.|(([Region] = "France") || ([BikeBuyer] = "yes"))| -|IN|Creates a logical OR condition between each row being compared to a table. Note: the table constructor syntax uses curly braces.|'Product'[Color] IN { "Red", "Blue", "Black" }| - +Use logical operators (`&&`) and (`||`) to combine expressions to produce a single result. + +|Text operator|Meaning|Examples| +|-----------------|-----------|------------| +|`&&`(double ampersand)|Creates an AND condition between two expressions that each have a Boolean result. If both expressions return `TRUE`, the combination of the expressions also returns `TRUE`; otherwise the combination returns `FALSE`.|`([Region] = "France") && ([BikeBuyer] = "yes"))`| +|`||` (double pipe symbol)|Creates an OR condition between two logical expressions. If either expression returns `TRUE`, the result is `TRUE`; only when both expressions are `FALSE` is the result `FALSE`. | `(([Region] = "France") || ([BikeBuyer] = "yes"))`| +|`IN`|Creates a logical OR condition between each row being compared to a table. Note: the table constructor syntax uses curly braces.|`'Product'[Color] IN { "Red", "Blue", "Black" }`| + ## Operators and precedence order -In some cases, the order in which calculation is performed can affect the Return value; therefore, it is important to understand how the order is determined and how you can change the order to obtain the desired results. - +In some cases, the order in which calculation is performed can affect the Return value; therefore, it is important to understand how the order is determined and how you can change the order to obtain the desired results. + ### Calculation order -An expression evaluates the operators and values in a specific order. All expressions always begin with an equal sign (=). The equal sign indicates that the succeeding characters constitute an expression. - -Following the equal sign are the elements to be calculated (the operands), which are separated by calculation operators. Expressions are always read from left to right, but the order in which the elements are grouped can be controlled to some degree by using parentheses. - +An expression evaluates the operators and values in a specific order. All expressions always begin with an equal sign (=). The equal sign indicates that the succeeding characters constitute an expression. + +Following the equal sign are the elements to be calculated (the operands), which are separated by calculation operators. Expressions are always read from left to right, but the order in which the elements are grouped can be controlled to some degree by using parentheses. + ### Operator precedence -If you combine several operators in a single formula, the operations are ordered according to the following table. If the operators have equal precedence value, they are ordered from left to right. For example, if an expression contains both a multiplication and division operator, they are evaluated in the order that they appear in the expression, from left to right. - -|Operator|Description| -|------------|---------------| -|^|Exponentiation| -|–|Sign (as in –1)| -|* and /|Multiplication and division| -|+ and –|Addition and subtraction| -|&|Connects two strings of text (concatenation)| -|=,==,<,>,<=,>=,<>,IN|Comparison| -|NOT|NOT (unary operator)| - +If you combine several operators in a single formula, the operations are ordered according to the following table. If the operators have equal precedence value, they are ordered from left to right. For example, if an expression contains both a multiplication and division operator, they are evaluated in the order that they appear in the expression, from left to right. + +|Operator|Description| +|------------|---------------| +|`^`|Exponentiation| +|`–`|Sign (such as –1)| +|`*` and `/`|Multiplication and division| +|`+` and `–`|Addition and subtraction| +|`&`|Connects two strings of text (concatenation)| +|`=,==,<,>,<=,>=,<>,IN`|Comparison| +|`NOT`|`NOT` (unary operator)| + ### Using parentheses to control calculation order -To change the order of evaluation, you should enclose in parentheses that part of the formula that must be calculated first. For example, the following formula produces 11 because multiplication is calculated before addition. The formula multiplies 2 by 3, and then adds 5 to the result. - +To change the order of evaluation, you should enclose in parentheses that part of the formula that must be calculated first. For example, the following formula produces 11 because multiplication is calculated before addition. The formula multiplies 2 by 3, and then adds 5 to the result. + ```dax -=5+2*3 +=5+2*3 ``` -In contrast, if you use parentheses to change the syntax, the order is changed so that 5 and 2 are added together, and the result multiplied by 3 to produce 21. - +In contrast, if you use parentheses to change the syntax, the order is changed so that 5 and 2 are added together, and the result multiplied by 3 to produce 21. + ```dax -=(5+2)*3 +=(5+2)*3 ``` -In the following example, the parentheses around the first part of the formula force the calculation to evaluate the expression `(3 + 0.25)` first and then divide the result by the result of the expression, (`3 - 0.25)`. - +In the following example, the parentheses around the first part of the formula force the calculation to evaluate the expression `(3 + 0.25)` first and then divide the result by the result of the expression, `(3 - 0.25)`. + ```dax -=(3 + 0.25)/(3 - 0.25) +=(3 + 0.25)/(3 - 0.25) ``` -In the following example, the exponentiation operator is applied first, according to the rules of precedence for operators, and then the sign operator is applied. The result for this expression is -4. - +In the following example, the exponentiation operator is applied first, according to the rules of precedence for operators, and then the sign operator is applied. The result for this expression is -4. + ```dax -=-2^2 +=-2^2 ``` -To ensure that the sign operator is applied to the numeric value first, you can use parentheses to control operators, as shown in the following example. The result for this expression is 4. - +To ensure that the sign operator is applied to the numeric value first, you can use parentheses to control operators, as shown in the following example. The result for this expression is 4. + ```dax -= (-2)^2 += (-2)^2 ``` - + ## Compatibility -DAX easily handles and compares various data types, much like Microsoft Excel. However, the underlying computation engine is based on SQL Server Analysis Services and provides additional advanced features of a relational data store, including richer support for date and time types. Therefore, in some cases the results of calculations or the behavior of functions may not be the same as in Excel. Moreover, DAX supports more data types than does Excel. This section describes the key differences. - +DAX easily handles and compares various data types, much like Microsoft Excel. However, the underlying computation engine is based on SQL Server Analysis Services and provides additional advanced features of a relational data store, including richer support for date and time types. Therefore, in some cases the results of calculations or the behavior of functions may not be the same as in Excel. Moreover, DAX supports more data types than does Excel. This section describes the key differences. + ### Coercing data types of operands -In general, the two operands on the left and right sides of any operator should be the same data type. However, if the data types are different, DAX will convert them to a common data type to apply the operator in some cases: - +In general, the two operands on the left and right sides of any operator should be the same data type. However, if the data types are different, DAX will convert them to a common data type to apply the operator in some cases: + 1. Both operands are converted to the largest possible common data type. 1. The operator is applied, if possible. - -For example, suppose you have two numbers that you want to combine. One number results from a formula, such as =`[Price] * .20`, and the result may contain many decimal places. The other number is an integer that has been provided as a string value. + +For example, suppose you have two numbers that you want to combine. One number results from a formula, such as =`[Price] * .20`, and the result may contain many decimal places. The other number is an integer that has been provided as a string value. In this case, DAX will convert both numbers to real numbers in a numeric format, using the largest numeric format that can store both kinds of numbers. Then DAX will apply the multiplication. @@ -143,7 +135,7 @@ Depending on the data-type combination, type coercion may not be applied for com Integer, Real Number, Currency, Date/time and Blank are considered numeric for comparison purposes. Blank evaluates to zero when performing a comparison. The following data-type combinations are supported for comparison operations. -Left Side Data Type |Right Side Data Type +Left Side Data Type |Right Side Data Type ---------|--------- Numeric | Numeric Boolean | Boolean @@ -151,21 +143,21 @@ String | String Other mixed data-type comparisons will return an error. For example, a formula such as ="1" > 0 returns an error stating that *DAX comparison operations do not support comparing values of type Text with values of type Integer*. -|Data Types used in DAX|Data Types used in Excel| +|Data Types used in DAX|Data Types used in Excel| |--------------------------|----------------------------| |Numbers (I8, R8)|Numbers (R8)| |String|String| |Boolean|Boolean| |DateTime|Variant| |Currency|Currency| - + ### Differences in precedence order -The precedence order of operations in DAX formulas is basically the same as that used by Microsoft Excel, but some Excel operators are not supported, such as percent. Also, ranges are not supported. - -Therefore, whenever you copy and paste formulas from Excel, be sure to review the formula carefully, as some operators or elements in the formulas may not be valid. When there is any doubt about the order in which operations are performed, it's recommended you use parentheses to control the order of operations and remove any ambiguity about the result. - -## See also +The precedence order of operations in DAX formulas is basically the same as that used by Microsoft Excel, but some Excel operators are not supported, such as percent. Also, ranges are not supported. + +Therefore, whenever you copy and paste formulas from Excel, be sure to review the formula carefully, as some operators or elements in the formulas may not be valid. When there is any doubt about the order in which operations are performed, it's recommended you use parentheses to control the order of operations and remove any ambiguity about the result. + +## Related content -[DAX syntax](dax-syntax-reference.md) +[DAX syntax](dax-syntax-reference.md) [DAX parameter-naming](dax-parameter-naming-conventions.md) diff --git a/query-languages/dax/dax-overview.md b/query-languages/dax/dax-overview.md index a24911232..3672c1af6 100644 --- a/query-languages/dax/dax-overview.md +++ b/query-languages/dax/dax-overview.md @@ -1,14 +1,7 @@ --- -title: "DAX overview | Microsoft Docs" +title: "DAX overview" description: Describes the Data Analysis Expressions (DAX) language. -ms.service: powerbi -ms.subservice: dax -ms.date: 12/17/2021 -ms.reviewer: owend -ms.topic: overview -author: minewiskan -ms.author: owend -recommendations: false +ms.topic: conceptual --- # DAX overview @@ -18,32 +11,32 @@ This article provides only a basic introduction to the most important concepts i ## Calculations -DAX formulas are used in measures, calculated columns, calculated tables, and row-level security. +DAX formulas are used in measures, calculated columns, calculated tables, and row-level security. -### Measures +### Measures + +Measures are dynamic calculation formulas where the results change depending on context. Measures are used in reporting that support combining and filtering model data by using multiple attributes such as a Power BI report or Excel PivotTable or PivotChart. Measures are created by using the DAX formula bar in the model designer. -Measures are dynamic calculation formulas where the results change depending on context. Measures are used in reporting that support combining and filtering model data by using multiple attributes such as a Power BI report or Excel PivotTable or PivotChart. Measures are created by using the DAX formula bar in the model designer. - A formula in a measure can use standard aggregation functions automatically created by using the Autosum feature, such as COUNT or SUM, or you can define your own formula by using the DAX formula bar. Named measures can be passed as an argument to other measures. When you define a formula for a measure in the formula bar, a Tooltip feature shows a preview of what the results would be for the total in the current context, but otherwise the results are not immediately output anywhere. The reason you cannot see the (filtered) results of the calculation immediately is because the result of a measure cannot be determined without context. To evaluate a measure requires a reporting client application that can provide the context needed to retrieve the data relevant to each cell and then evaluate the expression for each cell. That client might be an Excel PivotTable or PivotChart, a Power BI report, or a table expression in a DAX query in SQL Server Management Studio (SSMS). -Regardless of the client, a separate query is run for each cell in the results. That is to say, each combination of row and column headers in a PivotTable, or each selection of slicers and filters in a Power BI report, generates a different subset of data over which the measure is calculated. For example, using this very simple measure formula: +Regardless of the client, a separate query is run for each cell in the results. That is to say, each combination of row and column headers in a PivotTable, or each selection of slicers and filters in a Power BI report, generates a different subset of data over which the measure is calculated. For example, using this very simple measure formula: ```dax Total Sales = SUM([Sales Amount]) ``` -When a user places the TotalSales measure in a report, and then places the Product Category column from a Product table into Filters, the sum of Sales Amount is calculated and displayed for each product category. - -Unlike calculated columns, the syntax for a measure includes the measure's name preceding the formula. In the example just provided, the name **Total Sales** appears preceding the formula. After you've created a measure, the name and its definition appear in the reporting client application Fields list, and depending on perspectives and roles is available to all users of the model. +When a user places the TotalSales measure in a report, and then places the Product Category column from a Product table into Filters, the sum of Sales Amount is calculated and displayed for each product category. + +Unlike calculated columns, the syntax for a measure includes the measure's name preceding the formula. In the example just provided, the name **Total Sales** appears preceding the formula. After you've created a measure, the name and its definition appear in the reporting client application Fields list, and depending on perspectives and roles is available to all users of the model. -To learn more, see: -[Measures in Power BI Desktop](/power-bi/transform-model/desktop-measures) -[Measures in Analysis Services](/analysis-services/tabular-models/measures-ssas-tabular) +To learn more, see: +[Measures in Power BI Desktop](/power-bi/transform-model/desktop-measures) +[Measures in Analysis Services](/analysis-services/tabular-models/measures-ssas-tabular) [Measures in Power Pivot](https://support.office.com/article/Measures-in-Power-Pivot-86484821-a324-4da3-803b-82fd2e5033f4) - -### Calculated columns + +### Calculated columns A calculated column is a column that you add to an existing table (in the model designer) and then create a DAX formula that defines the column's values. When a calculated column contains a valid DAX formula, values are calculated for each row as soon as the formula is entered. Values are then stored in the in-memory data model. For example, in a Date table, when the formula is entered into the formula bar: @@ -51,42 +44,42 @@ To learn more, see: = [Calendar Year] & " Q" & [Calendar Quarter] ``` -A value for each row in the table is calculated by taking values from the Calendar Year column (in the same Date table), adding a space and the capital letter Q, and then adding the values from the Calendar Quarter column (in the same Date table). The result for each row in the calculated column is calculated immediately and appears, for example, as **2017 Q1**. Column values are only recalculated if the table or any related table is processed (refresh) or the model is unloaded from memory and then reloaded, like when closing and reopening a Power BI Desktop file. - - To learn more, see: -[Calculated columns in Power BI Desktop](/power-bi/transform-model/desktop-calculated-columns) -[Calculated columns in Analysis Services](/analysis-services/tabular-models/ssas-calculated-columns) -[Calculated Columns in Power Pivot](https://support.office.com/article/calculated-columns-in-power-pivot-a0eb7167-33fc-4ade-a23f-fb9217c193af). - +A value for each row in the table is calculated by taking values from the Calendar Year column (in the same Date table), adding a space and the capital letter Q, and then adding the values from the Calendar Quarter column (in the same Date table). The result for each row in the calculated column is calculated immediately and appears, for example, as **2017 Q1**. Column values are only recalculated if the table or any related table is processed (refresh) or the model is unloaded from memory and then reloaded, like when closing and reopening a Power BI Desktop file. + + To learn more, see: +[Calculated columns in Power BI Desktop](/power-bi/transform-model/desktop-calculated-columns) +[Calculated columns in Analysis Services](/analysis-services/tabular-models/ssas-calculated-columns) +[Calculated Columns in Power Pivot](https://support.office.com/article/calculated-columns-in-power-pivot-a0eb7167-33fc-4ade-a23f-fb9217c193af). + ### Calculated tables - + A calculated table is a computed object, based on a formula expression, derived from all or part of other tables in the same model. Instead of querying and loading values into your new table's columns from a data source, a DAX formula defines the table's values. Calculated tables can be helpful in a role-playing dimension. An example is the Date table, as OrderDate, ShipDate, or DueDate, depending on the foreign key relationship. By creating a calculated table for ShipDate explicitly, you get a standalone table that is available for queries, as fully operable as any other table. Calculated tables are also useful when configuring a filtered rowset, or a subset or superset of columns from other existing tables. This allows you to keep the original table intact while creating variations of that table to support specific scenarios. Calculated tables support relationships with other tables. The columns in your calculated table have data types, formatting, and can belong to a data category. Calculated tables can be named, and surfaced or hidden just like any other table. Calculated tables are re-calculated if any of the tables it pulls data from are refreshed or updated. -To learn more, see: -[Calculated tables in Power BI Desktop](/power-bi/transform-model/desktop-calculated-tables) +To learn more, see: +[Calculated tables in Power BI Desktop](/power-bi/transform-model/desktop-calculated-tables) [Calculated tables in Analysis Services](/analysis-services/tabular-models/create-a-calculated-table-ssas-tabular). ### Row-level security -With row-level security, a DAX formula must evaluate to a Boolean TRUE/FALSE condition, defining which rows can be returned by the results of a query by members of a particular role. For example, for members of the Sales role, the Customers table with the following DAX formula: +With row-level security, a DAX formula must evaluate to a Boolean `TRUE`/`FALSE` condition, defining which rows can be returned by the results of a query by members of a particular role. For example, for members of the Sales role, the Customers table with the following DAX formula: ```dax = Customers[Country] = "USA" ``` Members of the Sales role will only be able to view data for customers in the USA, and aggregates, such as SUM are returned only for customers in the USA. Row-level security is not available in Power Pivot in Excel. - -When defining row-level secuirty by using DAX formula, you are creating an allowed row set. This does not deny access to other rows; rather, they are simply not returned as part of the allowed row set. Other roles can allow access to the rows excluded by the DAX formula. If a user is a member of another role, and that role's row-level security allows access to that particular row set, the user can view data for that row. - -Row-level security formulas apply to the specified rows as well as related rows. When a table has multiple relationships, filters apply security for the relationship that is active. Row-level security formulas will be intersected with other formulas defined for related tables. -To learn more, see: -[Row-level security (RLS) with Power BI](/power-bi/admin/service-admin-rls) -[Roles in Analysis Services](/analysis-services/tabular-models/roles-ssas-tabular) +When defining row-level secuirty by using DAX formula, you are creating an allowed row set. This does not deny access to other rows; rather, they are simply not returned as part of the allowed row set. Other roles can allow access to the rows excluded by the DAX formula. If a user is a member of another role, and that role's row-level security allows access to that particular row set, the user can view data for that row. + +Row-level security formulas apply to the specified rows as well as related rows. When a table has multiple relationships, filters apply security for the relationship that is active. Row-level security formulas will be intersected with other formulas defined for related tables. + +To learn more, see: +[Row-level security (RLS) with Power BI](/power-bi/admin/service-admin-rls) +[Roles in Analysis Services](/analysis-services/tabular-models/roles-ssas-tabular) ## Queries @@ -105,144 +98,144 @@ Returns in Results a table listing only those products with a SafetyStockLevel l You can create measures as part of the query. Measures exist only for the duration of the query. To learn more, see [DAX queries](dax-queries.md). -## Formulas - -DAX formulas are essential for creating calculations in calculated columns and measures, and securing your data by using row-level security. To create formulas for calculated columns and measures, use the formula bar along the top of the model designer window or the DAX Editor. To create formulas for row-level security, use the Role Manager or Manage roles dialog box. Information in this section is meant to get you started with understanding the basics of DAX formulas. - -### Formula basics - -DAX formulas can be very simple or quite complex. The following table shows some examples of simple formulas that could be used in a calculated column. - -|Formula|Definition| -|--------|--------------| -|`= TODAY()`|Inserts today's date in every row of a calculated column.| -|`= 3`|Inserts the value 3 in every row of a calculated column.| -|`= [Column1] + [Column2]`|Adds the values in the same row of [Column1] and [Column2] and puts the results in the calculated column of the same row.| - -Whether the formula you create is simple or complex, you can use the following steps when building a formula: - -1. Each formula must begin with an equal sign (=). - -2. You can either type or select a function name, or type an expression. - -3. Begin to type the first few letters of the function or name you want, and AutoComplete displays a list of available functions, tables, and columns. Press TAB to add an item from the AutoComplete list to the formula. - - You can also click the **Fx** button to display a list of available functions. To select a function from the dropdown list, use the arrow keys to highlight the item, and click **OK** to add the function to the formula. - -4. Supply the arguments to the function by selecting them from a dropdown list of possible tables and columns, or by typing in values. - -5. Check for syntax errors: ensure that all parentheses are closed and columns, tables and values are referenced correctly. - -6. Press ENTER to accept the formula. - -> [!NOTE] ->In a calculated column, as soon as you enter the formula and the formula is validated, the column is populated with values. In a measure, pressing ENTER saves the measure definition with the table. If a formula is invalid, an error is displayed. - - In this example, let's look at a formula in a measure named **Days in Current Quarter**: - +## Formulas + +DAX formulas are essential for creating calculations in calculated columns and measures, and securing your data by using row-level security. To create formulas for calculated columns and measures, use the formula bar along the top of the model designer window or the DAX Editor. To create formulas for row-level security, use the Role Manager or Manage roles dialog box. Information in this section is meant to get you started with understanding the basics of DAX formulas. + +### Formula basics + +DAX formulas can be very simple or quite complex. The following table shows some examples of simple formulas that could be used in a calculated column. + +|Formula|Definition| +|--------|--------------| +|`= TODAY()`|Inserts today's date in every row of a calculated column.| +|`= 3`|Inserts the value 3 in every row of a calculated column.| +|`= [Column1] + [Column2]`|Adds the values in the same row of [Column1] and [Column2] and puts the results in the calculated column of the same row.| + +Whether the formula you create is simple or complex, you can use the following steps when building a formula: + +1. Each formula must begin with an equal sign (=). + +2. You can either type or select a function name, or type an expression. + +3. Begin to type the first few letters of the function or name you want, and AutoComplete displays a list of available functions, tables, and columns. Press TAB to add an item from the AutoComplete list to the formula. + + You can also click the **Fx** button to display a list of available functions. To select a function from the dropdown list, use the arrow keys to highlight the item, and click **OK** to add the function to the formula. + +4. Supply the arguments to the function by selecting them from a dropdown list of possible tables and columns, or by typing in values. + +5. Check for syntax errors: ensure that all parentheses are closed and columns, tables and values are referenced correctly. + +6. Press ENTER to accept the formula. + +> [!NOTE] +>In a calculated column, as soon as you enter the formula and the formula is validated, the column is populated with values. In a measure, pressing ENTER saves the measure definition with the table. If a formula is invalid, an error is displayed. + + In this example, let's look at a formula in a measure named **Days in Current Quarter**: + ```dax Days in Current Quarter = COUNTROWS( DATESBETWEEN( 'Date'[Date], STARTOFQUARTER( LASTDATE('Date'[Date])), ENDOFQUARTER('Date'[Date]))) -``` - -This measure is used to create a comparison ratio between an incomplete period and the previous period. The formula must take into account the proportion of the period that has elapsed, and compare it to the same proportion in the previous period. In this case, [Days Current Quarter to Date]/[Days in Current Quarter] gives the proportion elapsed in the current period. - -This formula contains the following elements: - -|Formula element|Description| -|---------------------|-----------------| -|`Days in Current Quarter`|The name of the measure.| -|`=`|The equals sign (=) begins the formula.| -|`COUNTROWS`|[COUNTROWS](countrows-function-dax.md) counts the number of rows in the Date table| -|`()`|Open and closing parenthesis specifies arguments.| -|`DATESBETWEEN`|The DATESBETWEEN function returns the dates between the last date for each value in the Date column in the Date table.| -|`'Date'`|Specifies the Date table. Tables are in single quotes.| -|`[Date]`|Specifies the Date column in the Date table. Columns are in brackets.| -|`,`|| -|`STARTOFQUARTER`|The STARTOFQUARTER function returns the date of the start of the quarter.| -|`LASTDATE`|The LASTDATE function returns the last date of the quarter.| -|`'Date'`|Specifies the Date table.| -|`[Date]`|Specifies the Date column in the Date table.| -|`,`|| -|`ENDOFQUARTER`|The ENDOFQUARTER function| -|`'Date'`|Specifies the Date table.| -|`[Date]`|Specifies the Date column in the Date table.| - -#### Using formula AutoComplete - -AutoComplete helps you enter a valid formula syntax by providing you with options for each element in the formula. - -- You can use formula AutoComplete in the middle of an existing formula with nested functions. The text immediately before the insertion point is used to display values in the drop-down list, and all of the text after the insertion point remains unchanged. - -- AutoComplete does not add the closing parenthesis of functions or automatically match parentheses. You must make sure that each function is syntactically correct or you cannot save or use the formula. - -#### Using multiple functions in a formula +``` + +This measure is used to create a comparison ratio between an incomplete period and the previous period. The formula must take into account the proportion of the period that has elapsed, and compare it to the same proportion in the previous period. In this case, [Days Current Quarter to Date]/[Days in Current Quarter] gives the proportion elapsed in the current period. + +This formula contains the following elements: + +|Formula element|Description| +|---------------------|-----------------| +|`Days in Current Quarter`|The name of the measure.| +|`=`|The equals sign (=) begins the formula.| +|`COUNTROWS`|[COUNTROWS](countrows-function-dax.md) counts the number of rows in the Date table| +|`()`|Open and closing parenthesis specifies arguments.| +|`DATESBETWEEN`|The DATESBETWEEN function returns the dates between the last date for each value in the Date column in the Date table.| +|`'Date'`|Specifies the Date table. Tables are in single quotes.| +|`[Date]`|Specifies the Date column in the Date table. Columns are in brackets.| +|`,`|| +|`STARTOFQUARTER`|The STARTOFQUARTER function returns the date of the start of the quarter.| +|`LASTDATE`|The LASTDATE function returns the last date of the quarter.| +|`'Date'`|Specifies the Date table.| +|`[Date]`|Specifies the Date column in the Date table.| +|`,`|| +|`ENDOFQUARTER`|The ENDOFQUARTER function| +|`'Date'`|Specifies the Date table.| +|`[Date]`|Specifies the Date column in the Date table.| + +#### Using formula AutoComplete + +AutoComplete helps you enter a valid formula syntax by providing you with options for each element in the formula. + +- You can use formula AutoComplete in the middle of an existing formula with nested functions. The text immediately before the insertion point is used to display values in the drop-down list, and all of the text after the insertion point remains unchanged. + +- AutoComplete does not add the closing parenthesis of functions or automatically match parentheses. You must make sure that each function is syntactically correct or you cannot save or use the formula. + +#### Using multiple functions in a formula You can nest functions, meaning that you use the results from one function as an argument of another function. You can nest up to 64 levels of functions in calculated columns. However, nesting can make it difficult to create or troubleshoot formulas. Many functions are designed to be used solely as nested functions. These functions return a table, which cannot be directly saved as a result; it must be provided as input to a table function. For example, the functions SUMX, AVERAGEX, and MINX all require a table as the first argument. - -## Functions - -A function is a named formula within an expression. Most functions have required and optional arguments, also known as parameters, as input. When the function is executed, a value is returned. DAX includes functions you can use to perform calculations using dates and times, create conditional values, work with strings, perform lookups based on relationships, and the ability to iterate over a table to perform recursive calculations. If you are familiar with Excel formulas, many of these functions will appear very similar; however, DAX formulas are different in the following important ways: - -- A DAX function always references a complete column or a table. If you want to use only particular values from a table or column, you can add filters to the formula. - -- If you need to customize calculations on a row-by-row basis, DAX provides functions that let you use the current row value or a related value as a kind of parameter, to perform calculations that vary by context. To understand how these functions work, see [Context](#context) in this article. - -- DAX includes many functions that return a table, rather than a value. The table is not displayed in a reporting client, but is used to provide input to other functions. For example, you can retrieve a table and then count the distinct values in it, or calculate dynamic sums across filtered tables or columns. - -- DAX functions include a variety of *time intelligence* functions. These functions let you define or select date ranges, and perform dynamic calculations based on these dates or range. For example, you can compare sums across parallel periods. + +## Functions + +A function is a named formula within an expression. Most functions have required and optional arguments, also known as parameters, as input. When the function is executed, a value is returned. DAX includes functions you can use to perform calculations using dates and times, create conditional values, work with strings, perform lookups based on relationships, and the ability to iterate over a table to perform recursive calculations. If you are familiar with Excel formulas, many of these functions will appear very similar; however, DAX formulas are different in the following important ways: + +- A DAX function always references a complete column or a table. If you want to use only particular values from a table or column, you can add filters to the formula. + +- If you need to customize calculations on a row-by-row basis, DAX provides functions that let you use the current row value or a related value as a kind of parameter, to perform calculations that vary by context. To understand how these functions work, see [Context](#context) in this article. + +- DAX includes many functions that return a table, rather than a value. The table is not displayed in a reporting client, but is used to provide input to other functions. For example, you can retrieve a table and then count the distinct values in it, or calculate dynamic sums across filtered tables or columns. + +- DAX functions include a variety of *time intelligence* functions. These functions let you define or select date ranges, and perform dynamic calculations based on these dates or range. For example, you can compare sums across parallel periods. ### Aggregation functions Aggregation functions calculate a (scalar) value such as count, sum, average, minimum, or maximum for all rows in a column or table as defined by the expression. To learn more, see [Aggregation functions](aggregation-functions-dax.md). -### Date and time functions +### Date and time functions The date and time functions in DAX are similar to date and time functions in Microsoft Excel. However, DAX functions are based on a **datetime** data type starting March 1, 1900. To learn more, see [Date and time functions](date-and-time-functions-dax.md). -### Filter functions +### Filter functions -The filter functions in DAX return specific data types, look up values in related tales, and filter by related values. The lookup functions work by using tables and relationships, like a database. The filtering functions let you manipulate data context to create dynamic calculations. To learn more, see [Filter functions](filter-functions-dax.md). +The filter functions in DAX return specific data types, look up values in related tales, and filter by related values. The lookup functions work by using tables and relationships, like a database. The filtering functions let you manipulate data context to create dynamic calculations. To learn more, see [Filter functions](filter-functions-dax.md). ### Financial functions The financial functions in DAX are used in formulas that perform financial calculations, such as net present value and rate of return. These functions are similar to financial functions used in Microsoft Excel. To learn more, see [Financial functions](financial-functions-dax.md). - -### Information functions -An information function looks at the cell or row that is provided as an argument and tells you whether the value matches the expected type. For example, the ISERROR function returns TRUE if the value that you reference contains an error. To learn more, see [Information functions](information-functions-dax.md). - -### Logical functions +### Information functions -Logical functions act upon an expression to return information about the values in the expression. For example, the TRUE function lets you know whether an expression that you are evaluating returns a TRUE value. To learn more, see [Logical functions](logical-functions-dax.md). - -### Mathematical and trigonometric functions +An information function looks at the cell or row that is provided as an argument and tells you whether the value matches the expected type. For example, the ISERROR function returns `TRUE` if the value that you reference contains an error. To learn more, see [Information functions](information-functions-dax.md). -The mathematical functions in DAX are very similar to the Excel mathematical and trigonometric functions. Some minor differences exist in the numeric data types used by DAX functions. To learn more, see [Math and trig functions](math-and-trig-functions-dax.md). +### Logical functions -### Other functions +Logical functions act upon an expression to return information about the values in the expression. For example, the `TRUE` function lets you know whether an expression that you are evaluating returns a `TRUE` value. To learn more, see [Logical functions](logical-functions-dax.md). + +### Mathematical and trigonometric functions + +The mathematical functions in DAX are very similar to the Excel mathematical and trigonometric functions. Some minor differences exist in the numeric data types used by DAX functions. To learn more, see [Math and trig functions](math-and-trig-functions-dax.md). + +### Other functions These functions perform unique actions that cannot be defined by any of the categories most other functions belong to. To learn more, see [Other functions](other-functions-dax.md). ### Relationship functions Relationship functions in DAX allow you to return values from another related table, specify a particular relationship to use in an expression, and specify cross filtering direction. To learn more, see [Relationship functions](relationship-functions-dax.md). - -### Statistical functions -Statistical functions calculate values related to statistical distributions and probability, such as standard deviation and number of permutations. To learn more, see [Statistical functions](statistical-functions-dax.md). - -### Text functions +### Statistical functions + +Statistical functions calculate values related to statistical distributions and probability, such as standard deviation and number of permutations. To learn more, see [Statistical functions](statistical-functions-dax.md). + +### Text functions + +Text functions in DAX are very similar to their counterparts in Excel. You can return part of a string, search for text within a string, or concatenate string values. DAX also provides functions for controlling the formats for dates, times, and numbers. To learn more, see [Text functions](text-functions-dax.md). + +### Time intelligence functions -Text functions in DAX are very similar to their counterparts in Excel. You can return part of a string, search for text within a string, or concatenate string values. DAX also provides functions for controlling the formats for dates, times, and numbers. To learn more, see [Text functions](text-functions-dax.md). - -### Time intelligence functions +The time intelligence functions provided in DAX let you create calculations that use built-in knowledge about calendars and dates. By using time and date ranges in combination with aggregations or calculations, you can build meaningful comparisons across comparable time periods for sales, inventory, and so on. To learn more, see [Time intelligence functions (DAX)](time-intelligence-functions-dax.md). -The time intelligence functions provided in DAX let you create calculations that use built-in knowledge about calendars and dates. By using time and date ranges in combination with aggregations or calculations, you can build meaningful comparisons across comparable time periods for sales, inventory, and so on. To learn more, see [Time intelligence functions (DAX)](time-intelligence-functions-dax.md). - -### Table manipulation functions +### Table manipulation functions These functions return a table or manipulate existing tables. For example, by using ADDCOLUMNS you can add calculated columns to a specified table, or you can return a summary table over a set of groups with the SUMMARIZECOLUMNS function. To learn more, see [Table manipulation functions](table-manipulation-functions-dax.md). - + ## Variables You can create variables within an expression by using [VAR](var-dax.md). VAR is technically not a function, it's a keyword to store the result of an expression as a named variable. That variable can then be passed as an argument to other measure expressions. For example: @@ -262,161 +255,165 @@ Return In this example, TotalQty can be passed as a named variable to other expressions. Variables can be of any scalar data type, including tables. Using variables in your DAX formulas can be incredibly powerful. -## Data types - - You can import data into a model from many different data sources that might support different data types. When you import data into a model, the data is converted to one of the tabular model data types. When the model data is used in a calculation, the data is then converted to a DAX data type for the duration and output of the calculation. When you create a DAX formula, the terms used in the formula will automatically determine the value data type returned. - - DAX supports the following data types: - -|Data type in model|Data type in DAX|Description| -|------------------------|----------------------|-----------------| -|Whole Number|A 64 bit (eight-bytes) integer value 1, 2|Numbers that have no decimal places. Integers can be positive or negative numbers, but must be whole numbers between -9,223,372,036,854,775,808 (-2^63) and 9,223,372,036,854,775,807 (2^63-1).| -|Decimal Number|A 64 bit (eight-bytes) real number 1, 2|Real numbers are numbers that can have decimal places. Real numbers cover a wide range of values:

Negative values from -1.79E +308 through -2.23E -308

Zero

Positive values from 2.23E -308 through 1.79E + 308

However, the number of significant digits is limited to 17 decimal digits.| -|Boolean|Boolean|Either a True or False value.| -|Text|String|A Unicode character data string. Can be strings, numbers or dates represented in a text format.| -|Date|Date/time|Dates and times in an accepted date-time representation.

Valid dates are all dates after March 1, 1900.| -|Currency|Currency|Currency data type allows values between -922,337,203,685,477.5808 to 922,337,203,685,477.5807 with four decimal digits of fixed precision.| -|N/A|Blank|A blank is a data type in DAX that represents and replaces SQL nulls. You can create a blank by using the BLANK function, and test for blanks by using the logical function, ISBLANK.| - -Tabular data models also include the *Table* data type as the input or output to many DAX functions. For example, the FILTER function takes a table as input and outputs another table that contains only the rows that meet the filter conditions. By combining table functions with aggregation functions, you can perform complex calculations over dynamically defined data sets. - -While data types are typically automatically set, it is important to understand data types and how they apply, in-particular, to DAX formulas. Errors in formulas or unexpected results, for example, are often caused by using a particular operator that cannot be used with a data type specified in an argument. For example, the formula, `= 1 & 2`, returns a string result of 12. The formula, `= "1" + "2"`, however, returns an integer result of 3. +## Data types + + You can import data into a model from many different data sources that might support different data types. When you import data into a model, the data is converted to one of the tabular model data types. When the model data is used in a calculation, the data is then converted to a DAX data type for the duration and output of the calculation. When you create a DAX formula, the terms used in the formula will automatically determine the value data type returned. + + DAX supports the following data types: + +|Data type in model|Data type in DAX|Description| +|------------------------|----------------------|-----------------| +|`Whole Number`|A 64 bit (eight-bytes) integer value 1, 2|Numbers that have no decimal places. Integers can be positive or negative numbers, but must be whole numbers between -9,223,372,036,854,775,808 (-2^63) and 9,223,372,036,854,775,807 (2^63-1).| +|`Decimal Number`|A 64 bit (eight-bytes) real number 1, 2|Real numbers are numbers that can have decimal places. Real numbers cover a wide range of values:

Negative values from -1.79E +308 through -2.23E -308

Zero

Positive values from 2.23E -308 through 1.79E + 308

However, the number of significant digits is limited to 17 decimal digits.| +|`Boolean`|Boolean|Either a True or False value.| +|`Text`|String|A Unicode character data string. Can be strings, numbers or dates represented in a text format.| +|`Date`|Date/time|Dates and times in an accepted date-time representation.

Valid dates are all dates after March 1, 1900.| +|`Currency`|Currency|Currency data type allows values between -922,337,203,685,477.5808 to 922,337,203,685,477.5807 with four decimal digits of fixed precision.| +|`Variant`|Variant|Used for expressions, such as DAX measures, that may return different data types. For example, a DAX measure that returns either a whole number or a string will be of type variant.| +|`N/A`|Blank|A blank is a data type in DAX that represents and replaces SQL nulls. You can create a blank by using the BLANK function, and test for blanks by using the logical function, ISBLANK.| + +Tabular data models also include the *Table* data type as the input or output to many DAX functions. For example, the FILTER function takes a table as input and outputs another table that contains only the rows that meet the filter conditions. By combining table functions with aggregation functions, you can perform complex calculations over dynamically defined data sets. + +While data types are typically automatically set, it is important to understand data types and how they apply, in-particular, to DAX formulas. Errors in formulas or unexpected results, for example, are often caused by using a particular operator that cannot be used with a data type specified in an argument. For example, the formula, `= 1 & 2`, returns a string result of 12. The formula, `= "1" + "2"`, however, returns an integer result of 3. + +> [!NOTE] +> Calculations on string data types may be constrained to 64kb. ## Context -*Context* is an important concept to understand when creating DAX formulas. Context is what enables you to perform dynamic analysis, as the results of a formula change to reflect the current row or cell selection and also any related data. Understanding context and using context effectively are critical for building high-performing, dynamic analyses, and for troubleshooting problems in formulas. - -Formulas in tabular models can be evaluated in a different context, depending on other design elements: - -- Filters applied in a PivotTable or report -- Filters defined within a formula -- Relationships specified by using special functions within a formula - -There are different types of context: *row context*, *query context*, and *filter context*. - -### Row context - -*Row context* can be thought of as "the current row". If you create a formula in a calculated column, the row context for that formula includes the values from all columns in the current row. If the table is related to another table, the content also includes all the values from the other table that are related to the current row. - -For example, suppose you create a calculated column, `= [Freight] + [Tax]`, that adds together values from two columns, Freight and Tax, from the same table. This formula automatically gets only the values from the current row in the specified columns. - -Row context also follows any relationships that have been defined between tables, including relationships defined within a calculated column by using DAX formulas, to determine which rows in related tables are associated with the current row. - -For example, the following formula uses the RELATED function to fetch a tax value from a related table, based on the region that the order was shipped to. The tax value is determined by using the value for region in the current table, looking up the region in the related table, and then getting the tax rate for that region from the related table. - -```dax -= [Freight] + RELATED('Region'[TaxRate]) -``` - -This formula gets the tax rate for the current region from the Region table and adds it to the value of the Freight column. In DAX formulas, you do not need to know or specify the specific relationship that connects the tables. - -#### Multiple row context - -DAX includes functions that iterate calculations over a table. These functions can have multiple current rows, each with its own row context. In essence, these functions let you create formulas that perform operations recursively over an inner and outer loop. - -For example, suppose your model contains a **Products** table and a **Sales** table. Users might want to go through the entire sales table, which is full of transactions involving multiple products, and find the largest quantity ordered for each product in any one transaction. - -With DAX you can build a single formula that returns the correct value, and the results are automatically updated any time a user adds data to the tables. - -```dax -= MAXX(FILTER(Sales,[ProdKey] = EARLIER([ProdKey])),Sales[OrderQty]) -``` - -For a detailed example of this formula, see [EARLIER](earlier-function-dax.md). - -To summarize, the EARLIER function stores the row context from the operation that preceded the current operation. At all times, the function stores in memory two sets of context: one set of context represents the current row for the inner loop of the formula, and another set of context represents the current row for the outer loop of the formula. DAX automatically feeds values between the two loops so that you can create complex aggregates. - -### Query context - -*Query context* refers to the subset of data that is implicitly retrieved for a formula. For example, when a user places a measure or field into a report, the engine examines row and column headers, slicers, and report filters to determine the context. The necessary queries are then run against model data to get the correct subset of data, make the calculations defined by the formula, and then populate values in the report. - +*Context* is an important concept to understand when creating DAX formulas. Context is what enables you to perform dynamic analysis, as the results of a formula change to reflect the current row or cell selection and also any related data. Understanding context and using context effectively are critical for building high-performing, dynamic analyses, and for troubleshooting problems in formulas. + +Formulas in tabular models can be evaluated in a different context, depending on other design elements: + +- Filters applied in a PivotTable or report +- Filters defined within a formula +- Relationships specified by using special functions within a formula + +There are different types of context: *row context*, *query context*, and *filter context*. + +### Row context + +*Row context* can be thought of as "the current row". If you create a formula in a calculated column, the row context for that formula includes the values from all columns in the current row. If the table is related to another table, the content also includes all the values from the other table that are related to the current row. + +For example, suppose you create a calculated column, `= [Freight] + [Tax]`, that adds together values from two columns, Freight and Tax, from the same table. This formula automatically gets only the values from the current row in the specified columns. + +Row context also follows any relationships that have been defined between tables, including relationships defined within a calculated column by using DAX formulas, to determine which rows in related tables are associated with the current row. + +For example, the following formula uses the RELATED function to fetch a tax value from a related table, based on the region that the order was shipped to. The tax value is determined by using the value for region in the current table, looking up the region in the related table, and then getting the tax rate for that region from the related table. + +```dax += [Freight] + RELATED('Region'[TaxRate]) +``` + +This formula gets the tax rate for the current region from the Region table and adds it to the value of the Freight column. In DAX formulas, you do not need to know or specify the specific relationship that connects the tables. + +#### Multiple row context + +DAX includes functions that iterate calculations over a table. These functions can have multiple current rows, each with its own row context. In essence, these functions let you create formulas that perform operations recursively over an inner and outer loop. + +For example, suppose your model contains a **Products** table and a **Sales** table. Users might want to go through the entire sales table, which is full of transactions involving multiple products, and find the largest quantity ordered for each product in any one transaction. + +With DAX you can build a single formula that returns the correct value, and the results are automatically updated any time a user adds data to the tables. + +```dax += MAXX(FILTER(Sales,[ProdKey] = EARLIER([ProdKey])),Sales[OrderQty]) +``` + +For a detailed example of this formula, see [EARLIER](earlier-function-dax.md). + +To summarize, the EARLIER function stores the row context from the operation that preceded the current operation. At all times, the function stores in memory two sets of context: one set of context represents the current row for the inner loop of the formula, and another set of context represents the current row for the outer loop of the formula. DAX automatically feeds values between the two loops so that you can create complex aggregates. + +### Query context + +*Query context* refers to the subset of data that is implicitly retrieved for a formula. For example, when a user places a measure or field into a report, the engine examines row and column headers, slicers, and report filters to determine the context. The necessary queries are then run against model data to get the correct subset of data, make the calculations defined by the formula, and then populate values in the report. + Because context changes depending on where you place the formula, the results of the formula can also change. For example, suppose you create a formula that sums the values in the **Profit** column of the **Sales** table: `= SUM('Sales'[Profit])`. If you use this formula in a calculated column within the **Sales** table, the results for the formula will be the same for the entire table, because the query context for the formula is always the entire data set of the **Sales** table. Results will have profit for all regions, all products, all years, and so on. - -However, users typically don't want to see the same result hundreds of times, but instead want to get the profit for a particular year, a particular country, a particular product, or some combination of these, and then get a grand total. - -In a report, context is changed by filtering, adding or removing fields, and using slicers. For each change, the query context in which the measure is evaluated. Therefore, the same formula, used in a measure, is evaluated in a different *query context* for each cell. - -### Filter context - -*Filter context* is the set of values allowed in each column, or in the values retrieved from a related table. Filters can be applied to the column in the designer, or in the presentation layer (reports and PivotTables). Filters can also be defined explicitly by filter expressions within the formula. - -Filter context is added when you specify filter constraints on the set of values allowed in a column or table, by using arguments to a formula. Filter context applies on top of other contexts, such as row context or query context. - -In tabular models, there are many ways to create filter context. Within the context of clients that can consume the model, such as Power BI reports, users can create filters on the fly by adding slicers or report filters on the row and column headings. You can also specify filter expressions directly within the formula, to specify related values, to filter tables that are used as inputs, or to dynamically get context for the values that are used in calculations. You can also completely clear or selectively clear the filters on particular columns. This is very useful when creating formulas that calculate grand totals. - -To learn more about how to create filters within formulas, see the [FILTER Function (DAX)](filter-function-dax.md). -For an example of how filters can be cleared to create grand totals, see the [ALL Function (DAX)](all-function-dax.md). - -For examples of how to selectively clear and apply filters within formulas, see [ALLEXCEPT](allexcept-function-dax.md). - -### Determining context in formulas - - When you create a DAX formula, the formula is first tested for valid syntax, and then tested to make sure the names of the columns and tables included in the formula can be found in the current context. If any column or table specified by the formula cannot be found, an error is returned. - - Context during validation (and recalculation operations) is determined as described in the preceding sections, by using the available tables in the model, any relationships between the tables, and any filters that have been applied. - - For example, if you have just imported some data into a new table and it is not related to any other tables (and you have not applied any filters), the *current context* is the entire set of columns in the table. If the table is linked by relationships to other tables, the current context includes the related tables. If you add a column from the table to a report that has Slicers and maybe some report filters, the context for the formula is the subset of data in each cell of the report. - - Context is a powerful concept that can also make it difficult to troubleshoot formulas. We recommend that you begin with simple formulas and relationships to see how context works. The following section provides some examples of how formulas use different types of context to dynamically return results. - -## Operators - -The DAX language uses four different types of calculation operators in formulas: - -- Comparison operators to compare values and return a logical TRUE\FALSE value. -- Arithmetic operators to perform arithmetic calculations that return numeric values. -- Text concatenation operators to join two or more text strings. -- Logical operators that combine two or more expressions to return a single result. - -For detailed information about operators used in DAX formulas, see [DAX operators](dax-operator-reference.md). - -## Working with tables and columns - - Tables in tabular data models look like Excel tables, but are different in the way they work with data and with formulas: - -- Formulas work only with tables and columns, not with individual cells, range references, or arrays. -- Formulas can use relationships to get values from related tables. The values that are retrieved are always related to the current row value. -- You cannot have irregular or "ragged" data like you can in an Excel worksheet. Each row in a table must contain the same number of columns. However, you can have empty values in some columns. Excel data tables and tabular model data tables are not interchangeable. -- Because a data type is set for each column, each value in that column must be of the same type. - -### Referring to tables and columns in formulas - -You can refer to any table and column by using its name. For example, the following formula illustrates how to refer to columns from two tables by using the *fully qualified* name: - -```dax - -= SUM('New Sales'[Amount]) + SUM('Past Sales'[Amount]) - -``` - -When a formula is evaluated, the model designer first checks for general syntax, and then checks the names of columns and tables that you provide against possible columns and tables in the current context. If the name is ambiguous or if the column or table cannot be found, you will get an error on your formula (an #ERROR string instead of a data value in cells where the error occurs). To learn more about naming requirements for tables, columns, and other objects, see Naming Requirements in [DAX syntax](dax-syntax-reference.md#naming-requirements). - -### Table relationships - -By creating relationships between tables, you gain the ability for related values in other tables to be used in calculations. For example, you can use a calculated column to determine all the shipping records related to the current reseller, and then sum the shipping costs for each. In many cases, however, a relationship might not be necessary. You can use the [LOOKUPVALUE](lookupvalue-function-dax.md) function in a formula to return the value in *result_columnName* for the row that meets criteria specified in the *search_column* and *search_value* arguments. - + +However, users typically don't want to see the same result hundreds of times, but instead want to get the profit for a particular year, a particular country, a particular product, or some combination of these, and then get a grand total. + +In a report, context is changed by filtering, adding or removing fields, and using slicers. For each change, the query context in which the measure is evaluated. Therefore, the same formula, used in a measure, is evaluated in a different *query context* for each cell. + +### Filter context + +*Filter context* is the set of values allowed in each column, or in the values retrieved from a related table. Filters can be applied to the column in Desktop, or in the presentation layer (reports and PivotTables). Filters can also be defined explicitly by filter expressions within the formula. + +Filter context is added when you specify filter constraints on the set of values allowed in a column or table, by using arguments to a formula. Filter context applies on top of other contexts, such as row context or query context. + +In tabular models, there are many ways to create filter context. Within the context of clients that can consume the model, such as Power BI reports, users can create filters on the fly by adding slicers or report filters on the row and column headings. You can also specify filter expressions directly within the formula, to specify related values, to filter tables that are used as inputs, or to dynamically get context for the values that are used in calculations. You can also completely clear or selectively clear the filters on particular columns. This is very useful when creating formulas that calculate grand totals. + +To learn more about how to create filters within formulas, see the [FILTER Function (DAX)](filter-function-dax.md). +For an example of how filters can be cleared to create grand totals, see the [ALL Function (DAX)](all-function-dax.md). + +For examples of how to selectively clear and apply filters within formulas, see [ALLEXCEPT](allexcept-function-dax.md). + +### Determining context in formulas + + When you create a DAX formula, the formula is first tested for valid syntax, and then tested to make sure the names of the columns and tables included in the formula can be found in the current context. If any column or table specified by the formula cannot be found, an error is returned. + + Context during validation (and recalculation operations) is determined as described in the preceding sections, by using the available tables in the model, any relationships between the tables, and any filters that have been applied. + + For example, if you have just imported some data into a new table and it is not related to any other tables (and you have not applied any filters), the *current context* is the entire set of columns in the table. If the table is linked by relationships to other tables, the current context includes the related tables. If you add a column from the table to a report that has Slicers and maybe some report filters, the context for the formula is the subset of data in each cell of the report. + + Context is a powerful concept that can also make it difficult to troubleshoot formulas. We recommend that you begin with simple formulas and relationships to see how context works. The following section provides some examples of how formulas use different types of context to dynamically return results. + +## Operators + +The DAX language uses four different types of calculation operators in formulas: + +- Comparison operators to compare values and return a logical `TRUE`\`FALSE` value. +- Arithmetic operators to perform arithmetic calculations that return numeric values. +- Text concatenation operators to join two or more text strings. +- Logical operators that combine two or more expressions to return a single result. + +For detailed information about operators used in DAX formulas, see [DAX operators](dax-operator-reference.md). + +## Working with tables and columns + + Tables in tabular data models look like Excel tables, but are different in the way they work with data and with formulas: + +- Formulas work only with tables and columns, not with individual cells, range references, or arrays. +- Formulas can use relationships to get values from related tables. The values that are retrieved are always related to the current row value. +- You cannot have irregular or "ragged" data like you can in an Excel worksheet. Each row in a table must contain the same number of columns. However, you can have empty values in some columns. Excel data tables and tabular model data tables are not interchangeable. +- Because a data type is set for each column, each value in that column must be of the same type. + +### Referring to tables and columns in formulas + +You can refer to any table and column by using its name. For example, the following formula illustrates how to refer to columns from two tables by using the *fully qualified* name: + +```dax + += SUM('New Sales'[Amount]) + SUM('Past Sales'[Amount]) + +``` + +When a formula is evaluated, the model designer first checks for general syntax, and then checks the names of columns and tables that you provide against possible columns and tables in the current context. If the name is ambiguous or if the column or table cannot be found, you will get an error on your formula (an #ERROR string instead of a data value in cells where the error occurs). To learn more about naming requirements for tables, columns, and other objects, see Naming Requirements in [DAX syntax](dax-syntax-reference.md#naming-requirements). + +### Table relationships + +By creating relationships between tables, you gain the ability for related values in other tables to be used in calculations. For example, you can use a calculated column to determine all the shipping records related to the current reseller, and then sum the shipping costs for each. In many cases, however, a relationship might not be necessary. You can use the [LOOKUPVALUE](lookupvalue-function-dax.md) function in a formula to return the value in *result_columnName* for the row that meets criteria specified in the *search_column* and *search_value* arguments. + Many DAX functions require that a relationship exist between the tables, or among multiple tables, in order to locate the columns that you have referenced and return results that make sense. Other functions will attempt to identify the relationship; however, for best results you should always create a relationship where possible. -Tabular data models support multiple relationships among tables. To avoid confusion or incorrect results, only one relationship at a time is designated as the active relationship, but you can change the active relationship as necessary to traverse different connections in the data in calculations. [USERELATIONSHIP](userelationship-function-dax.md) function can be used to specify one or more relationships to be used in a specific calculation. - -It's important to observe these formula design rules when using relationships: - -- When tables are connected by a relationship, you must ensure the two columns used as keys have values that match. Referential integrity is not enforced, therefore it is possible to have non-matching values in a key column and still create a relationship. If this happens, you should be aware that blank values or non-matching values might affect the results of formulas. - -- When you link tables in your model by using relationships, you enlarge the scope, or *context*, in which your formulas are evaluated. Changes in context resulting from the addition of new tables, new relationships, or from changes in the active relationship can cause your results to change in ways that you might not anticipate. To learn more, see [Context](#context) in this article. - +Tabular data models support multiple relationships among tables. To avoid confusion or incorrect results, only one relationship at a time is designated as the active relationship, but you can change the active relationship as necessary to traverse different connections in the data in calculations. [USERELATIONSHIP](userelationship-function-dax.md) function can be used to specify one or more relationships to be used in a specific calculation. + +It's important to observe these formula design rules when using relationships: + +- When tables are connected by a relationship, you must ensure the two columns used as keys have values that match. Referential integrity is not enforced, therefore it is possible to have non-matching values in a key column and still create a relationship. If this happens, you should be aware that blank values or non-matching values might affect the results of formulas. + +- When you link tables in your model by using relationships, you enlarge the scope, or *context*, in which your formulas are evaluated. Changes in context resulting from the addition of new tables, new relationships, or from changes in the active relationship can cause your results to change in ways that you might not anticipate. To learn more, see [Context](#context) in this article. + ## Process and refresh -*Process* and *recalculation* are two separate but related operations. You should thoroughly understand these concepts when designing a model that contains complex formulas, large amounts of data, or data that is obtained from external data sources. - -*Process (refresh)* is updating the data in a model with new data from an external data source. - -*Recalculation* is the process of updating the results of formulas to reflect any changes to the formulas themselves and to reflect changes in the underlying data. Recalculation can affect performance in the following ways: - -- The values in a calculated column are computed and stored in the model. To update the values in the calculated column, you must process the model using one of three processing commands – Process Full, Process Data, or Process Recalc. The result of the formula must always be recalculated for the entire column, whenever you change the formula. - -- The values calculated by measures are dynamically evaluated whenever a user adds the measure to a PivotTable or open a report; as the user modifies the context, values returned by the measure change. The results of the measure always reflect the latest in the in-memory cache. - -Processing and recalculation have no effect on row-level security formulas unless the result of a recalculation returns a different value, thus making the row queryable or not queryable by role members. +*Process* and *recalculation* are two separate but related operations. You should thoroughly understand these concepts when designing a model that contains complex formulas, large amounts of data, or data that is obtained from external data sources. + +*Process (refresh)* is updating the data in a model with new data from an external data source. + +*Recalculation* is the process of updating the results of formulas to reflect any changes to the formulas themselves and to reflect changes in the underlying data. Recalculation can affect performance in the following ways: + +- The values in a calculated column are computed and stored in the model. To update the values in the calculated column, you must process the model using one of three processing commands – Process Full, Process Data, or Process Recalc. The result of the formula must always be recalculated for the entire column, whenever you change the formula. + +- The values calculated by measures are dynamically evaluated whenever a user adds the measure to a PivotTable or open a report; as the user modifies the context, values returned by the measure change. The results of the measure always reflect the latest in the in-memory cache. + +Processing and recalculation have no effect on row-level security formulas unless the result of a recalculation returns a different value, thus making the row queryable or not queryable by role members. ## Updates @@ -426,55 +423,55 @@ Not all functions are supported in earlier versions of SQL Server Analysis Servi ## Troubleshooting -If you get an error when defining a formula, the formula might contain either a *syntactic error*, *semantic error*, or *calculation error*. - +If you get an error when defining a formula, the formula might contain either a *syntactic error*, *semantic error*, or *calculation error*. + Syntactic errors are the easiest to resolve. They typically involve a missing parenthesis or comma. - -The other type of error occurs when the syntax is correct, but the value or a column referenced does not make sense in the context of the formula. Such semantic and calculation errors might be caused by any of the following problems: - -- The formula refers to a non-existing column, table, or function. -- The formula appears to be correct, but when the data engine fetches the data, it finds a type mismatch and raises an error. -- The formula passes an incorrect number or type of arguments to a function. -- The formula refers to a different column that has an error, and therefore its values are invalid. -- The formula refers to a column that has not been processed, meaning it has metadata but no actual data to use for calculations. - -In the first four cases, DAX flags the entire column that contains the invalid formula. In the last case, DAX grays out the column to indicate that the column is in an unprocessed state. + +The other type of error occurs when the syntax is correct, but the value or a column referenced does not make sense in the context of the formula. Such semantic and calculation errors might be caused by any of the following problems: + +- The formula refers to a non-existing column, table, or function. +- The formula appears to be correct, but when the data engine fetches the data, it finds a type mismatch and raises an error. +- The formula passes an incorrect number or type of arguments to a function. +- The formula refers to a different column that has an error, and therefore its values are invalid. +- The formula refers to a column that has not been processed, meaning it has metadata but no actual data to use for calculations. + +In the first four cases, DAX flags the entire column that contains the invalid formula. In the last case, DAX grays out the column to indicate that the column is in an unprocessed state. ## Apps and tools ### Power BI Desktop -![Power BI Desktop](media/dax-overview-pbid.png) +![Power BI Desktop](media/dax-overview/dax-overview-pbid.png) [Power BI Desktop](https://powerbi.microsoft.com/desktop/) is a free data modeling and reporting application. The model designer includes a DAX editor for creating DAX calculation formulas. ### Power Pivot in Excel -![Power Pivot in Excel](media/dax-overview-excel.png) +![Power Pivot in Excel](media/dax-overview/dax-overview-excel.png) The [Power Pivot in Excel](https://support.office.com/article/power-pivot-powerful-data-analysis-and-data-modeling-in-excel-a9c2c6e2-cc49-4976-a7d7-40896795d045) models designer includes a DAX editor for creating DAX calculation formulas. ### Visual Studio -![Visual Studio](media/dax-overview-vs.png) +![Visual Studio](media/dax-overview/dax-overview-vs.png) Visual Studio with [Analysis Services projects](https://marketplace.visualstudio.com/items?itemName=ProBITools.MicrosoftAnalysisServicesModelingProjects) extension (VSIX) is used to create Analysis Services model projects. Tabular model designer, installed with the projects extension includes a DAX editor. ### SQL Server Management Studio -![SQL Server Management Studio](media/dax-overview-ssms.png) +![SQL Server Management Studio](media/dax-overview/dax-overview-ssms.png) [SQL Server Management Studio](/sql/ssms/download-sql-server-management-studio-ssms) (SSMS) is an essential tool for working with Analysis Services. SSMS includes a DAX query editor for querying both tabular and multidimensional models. ### DAX Studio -![DAX Studio icon](media/dax-overview-studio.png) +![DAX Studio icon](media/dax-overview/dax-overview-studio.png) [DAX Studio](http://daxstudio.org/) is an open-source client tool for creating and running DAX queries against Analysis Services, Power BI Desktop, and Power Pivot in Excel models. ### Tabular Editor -![Tabular Editor icon](media/dax-overview-te.png) +![Tabular Editor icon](media/dax-overview/dax-overview-te.png) [Tabular Editor](https://tabulareditor.com/) is an open-source tool that provides an intuitive, hierarchical view of every object in tabular model metadata. Tabular Editor includes a DAX Editor with syntax highlighting, which provides an easy way to edit measures, calculated column, and calculated table expressions. @@ -484,11 +481,11 @@ When learning DAX, it's best to use the application you'll be using to create yo [Videos](dax-learn-videos.md) -[Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) path in Microsoft Learn. +[Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) learning path. The [Definitive Guide to DAX](https://www.sqlbi.com/books/the-definitive-guide-to-dax-2nd-edition/) by Alberto Ferrari and Marco Russo (Microsoft Press). Now in its second edition, this extensive guide provides basics to innovative high-performance techniques for beginning data modelers and BI professionals. -![The Definitive Guide to DAX book image](media/dax-overview-book.png) +![The Definitive Guide to DAX book image](media/dax-overview/dax-overview-book.png) ## Community diff --git a/query-languages/dax/dax-parameter-naming-conventions.md b/query-languages/dax/dax-parameter-naming-conventions.md index a8a49a70c..c89efc6eb 100644 --- a/query-languages/dax/dax-parameter-naming-conventions.md +++ b/query-languages/dax/dax-parameter-naming-conventions.md @@ -1,36 +1,29 @@ --- description: "Learn more about: DAX parameter-naming conventions" -title: "DAX parameter-naming conventions | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 11/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "DAX parameter-naming conventions" +ms.topic: conceptual --- # DAX parameter-naming conventions -Parameter names are standardized in DAX reference to facilitate the usage and understanding of the functions. - -## Parameter names - -|Term|Definition| -|--------|--------------| -|expression|Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context).| -|value|Any DAX expression that returns a single scalar value where the expression is to be evaluated exactly once before all other operations.| -|table|Any DAX expression that returns a table of data.| -|tableName|The name of an existing table using standard DAX syntax. It cannot be an expression.| -|columnName|The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression.| -|name|A string constant that will be used to provide the name of a new object.| -|order|An enumeration used to determine the sort order.| -|ties|An enumeration used to determine the handling of tie values.| -|type|An enumeration used to determine the data type for PathItem and PathItemReverse.| - -### Prefixing parameter names or using the prefix only - -|Term|Definition| -|--------|--------------| -|prefixing|Parameter names may be further qualified with a prefix that is descriptive of how the argument is used and to avoid ambiguous reading of the parameters. For example:

Result_ColumnName - Refers to an existing column used to get the result values in the LOOKUPVALUE() function.

Search_ColumnName - Refers to an existing column used to search for a value in the LOOKUPVALUE() function.| -|omitting|Parameter names will be omitted if the prefix is clear enough to describe the parameter.

For example, instead of having the following syntax DATE (Year_Value, Month_Value, Day_Value) it is clearer for the user to read DATE (Year, Month, Day); repeating three times the suffix value does not add anything to a better comprehension of the function and it clutters the reading unnecessarily.

However, if the prefixed parameter is Year_columnName then the parameter name and the prefix will stay to make sure the user understands that the parameter requires a reference to an existing column of Years.| - +Parameter names are standardized in DAX reference to facilitate the usage and understanding of the functions. + +## Parameter names + +|Term|Definition| +|--------|--------------| +|`expression`|Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context).| +|`value`|Any DAX expression that returns a single scalar value where the expression is to be evaluated exactly once before all other operations.| +|`table`|Any DAX expression that returns a table of data.| +|`tableName`|The name of an existing table using standard DAX syntax. It cannot be an expression.| +|`columnName`|The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression.| +|`name`|A string constant that will be used to provide the name of a new object.| +|`order`|An enumeration used to determine the sort order.| +|`ties`|An enumeration used to determine the handling of tie values.| +|`type`|An enumeration used to determine the data type for PathItem and PathItemReverse.| + +### Prefixing parameter names or using the prefix only + +|Term|Definition| +|--------|--------------| +|`prefixing`|Parameter names may be further qualified with a prefix that is descriptive of how the argument is used and to avoid ambiguous reading of the parameters. For example:

Result_ColumnName - Refers to an existing column used to get the result values in the LOOKUPVALUE() function.

Search_ColumnName - Refers to an existing column used to search for a value in the LOOKUPVALUE() function.| +|`omitting`|Parameter names will be omitted if the prefix is clear enough to describe the parameter.

For example, instead of having the following syntax DATE (Year_Value, Month_Value, Day_Value) it is clearer for the user to read DATE (Year, Month, Day); repeating three times the suffix value does not add anything to a better comprehension of the function and it clutters the reading unnecessarily.

However, if the prefixed parameter is Year_columnName then the parameter name and the prefix will stay to make sure the user understands that the parameter requires a reference to an existing column of Years.| + diff --git a/query-languages/dax/dax-queries.md b/query-languages/dax/dax-queries.md index c416584b0..c059a392d 100644 --- a/query-languages/dax/dax-queries.md +++ b/query-languages/dax/dax-queries.md @@ -1,188 +1,272 @@ --- -title: "DAX Queries | Microsoft Docs" +title: "DAX Queries" description: Describes Data Analysis Expressions (DAX) language queries. -ms.service: powerbi -ms.subservice: dax -ms.date: 06/14/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +ms.topic: conceptual --- # DAX queries -With DAX queries, you can query and return data defined by a table expression. Reporting clients construct DAX queries whenever a field is placed on a report surface, or a whenever a filter or calculation is applied. DAX queries can also be created and run in [SQL Server Management Studio](/sql/ssms/download-sql-server-management-studio-ssms) (SSMS) and open-source tools like [DAX Studio](https://daxstudio.org). DAX queries run in SSMS and DAX Studio return results as a table. +Reporting clients like Power BI and Excel execute DAX queries whenever visuals display in a report, or a field added to a table, and these DAX queries adjust when a filter is applied. The [performance analyzer](/power-bi/create-reports/desktop-performance-analyzer) in Power BI Desktop can show you these DAX queries and even run them in DAX query view of Power BI Desktop. -Before learning about queries, it's important you have a solid understanding of DAX basics. If you haven't already, be sure to checkout [DAX overview](dax-overview.md). +By using [DAX query view](/power-bi/transform-model/dax-query-view) in Power BI Desktop or [Write DAX queries](/power-bi/transform-model/dax-query-view#dax-query-view-in-web) in Power BI service, you can create and run your own DAX queries. With [Microsoft Fabric](/fabric/get-started/microsoft-fabric-overview), you can further increase your productivity with [Copilot to write DAX queries](/dax/dax-copilot) in DAX query view of Desktop or web. In addition to Power BI tools, DAX queries can be run in [Fabric notebooks](/fabric/data-engineering/how-to-use-notebook) using [semantic link](/fabric/data-science/read-write-power-bi-python) to read data from semantic models with python, and with the [Execute Queries REST API](/rest/api/power-bi/datasets/execute-queries), also available in [Power Automate](https://powerbi.microsoft.com/blog/unlocking-new-self-service-bi-scenarios-with-executequeries-support-in-power-automate/). Other tools such as [SQL Server Management Studio](/sql/ssms/download-sql-server-management-studio-ssms) (SSMS), [Power BI Report Builder](/power-bi/paginated-reports/report-builder-power-bi), and open-source tools like [DAX Studio](https://daxstudio.org), also allow you to create and run DAX queries. -## Syntax +DAX queries return results as a table right within the tool, allowing you to quickly create and test the performance of your DAX formulas in measures or simply view the data in your semantic model. INFO and INFO.VIEW DAX functions can also get information about your semantic model, such as a listing of tables, columns, measures, and much more. -```dax -[DEFINE { MEASURE [] = } - { VAR = }] -EVALUATE
-[ORDER BY { [{ASC | DESC}]}[, …] -[START AT {|} [, …]]] -``` +Before learning about queries, it is important you have a solid understanding of DAX basics. If you haven't already, be sure to check out [DAX overview](dax-overview.md). ## Keywords +DAX queries have a simple syntax comprised of just one required keyword, EVALUATE. EVALUATE is followed by a table expression, such as a DAX function or table name, that when run outputs a result table. +Table expressions that output a result table include: + +1. Common DAX functions that output a table, such as [SUMMARIZE](summarize-function-dax.md), [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md), [SELECTCOLUMNS](selectcolumns-function-dax.md), [FILTER](filter-function-dax.md), [UNION](union-function-dax.md), [TOPN](topn-function-dax.md), [ADDCOLUMNS](addcolumns-function-dax.md), [DATATABLE](datatable-function-dax.md), and many others, work with EVALUATE to output a result table. +2. Tables in the model when referenced by name work with EVALUATE to output a result table showing the data in the table. For example, **EVALUATE ‘Table name’** can be ran as a DAX query. +3. Measures in the model or any DAX formula, which return a scalar value, work with EVALUATE to show the value as a result table when enclosed in curly braces. For example, **EVALUATE {[Total Sales]}** or **EVALUATE {COUNTROWS(‘Sales’)}** can be ran as a DAX query. These are called [table constructors](table-constructor.md). + +There are several optional keywords specific to DAX queries: ORDER BY, START AT, DEFINE, MEASURE, VAR, TABLE, and COLUMN. + ### EVALUATE (Required) -At the most basic level, a DAX query is an **EVALUATE** statement containing a table expression. However, a query can contain multiple EVALUATE statements. +At the most basic level, a DAX query is an `EVALUATE` statement containing a table expression. At least one EVALUATE statement is required, however, a query can contain any number of EVALUATE statements. + +#### EVALUATE Syntax -#### Syntax - ```dax -EVALUATE
+EVALUATE
``` -#### Arguments +#### EVALUATE Parameters |Term |Definition | |---------|---------| -| table | A table expression. | +| `table` | A table expression. | -#### Example +#### EVALUATE Example ```dax -EVALUATE( - 'Internet Sales' - ) +EVALUATE + 'Sales Order' ``` -Returns all rows and columns from the Internet Sales table, as a table. +Returns all rows and columns from the Sales Order table, as a result table. This can be limited with the use of [TOPN](topn-function-dax.md) or [FILTER](filter-function-dax.md), and sorted with ORDER BY. -![DAX Evaluate statement](media/dax-queries/dax-evaluate.png) +:::image type="content" source="media/dax-queries/dax-evaluate.png" alt-text="Screenshot showing how to use EVALUATE for a DAX query in DAX query view of Power BI Desktop." lightbox="media/dax-queries/dax-evaluate.png"::: ### ORDER BY (Optional) -The optional **ORDER BY** keyword defines one or more expressions used to sort query results. Any expression that can be evaluated for each row of the result is valid. +The optional `ORDER BY` keyword defines one or more columns in the query or expressions used to sort query results. Any expression that can be evaluated for each row of the result is valid. Any column in the query itself is also valid. + +Sort by column property in semantic models do not apply to DAX query results. If a column should be sorted by a different column in the model, such as in the case of Month Name, the sort by column should also be included in the DAX query to be used in the ORDER BY. -#### Syntax +#### ORDER BY Syntax ```dax -EVALUATE
-[ORDER BY { [{ASC | DESC}]}[, …] +EVALUATE
+[ORDER BY { [{ASC | DESC}]}[, …]] ``` -#### Arguments +#### ORDER BY Parameters |Term |Definition | |---------|---------| -| expression | Any DAX expression that returns a single scalar value. | -| ASC | (default) Ascending sort order. | -| DESC | Descending sort order. | +| `expression` | Any DAX expression that returns a single scalar value, or column included in the DAX query. | +| `ASC` | (default) Ascending sort order. | +| `DESC` | Descending sort order. | + +#### ORDER BY Example + +```dax +EVALUATE + SUMMARIZECOLUMNS( + // Group by columns + 'Date'[Month Name], + 'Date'[Month of Year], + 'Product'[Category], + + // Optional filters + FILTER( + VALUES('Product'[Category]), + [Category] = "Clothing" + ), + + // Measures or explicit DAX formulas to aggregate and analyze the data by row + "Orders", [Orders], + "Avg Profit per Order", DIVIDE( + [Total Sales Profit], + [Orders] + ) + ) + + // DAX queries do not use sort order defined in Power BI, + // sort by columns must be included in the DAX query to be used in order by + ORDER BY 'Date'[Month of Year] ASC +``` + +Returns clothing orders and average profit per order by month, in ascending order by month, as a result table. -#### Example +:::image type="content" source="media/dax-queries/dax-evaluate-orderby.png" alt-text="Screenshot showing how to use ORDER BY for a DAX query in DAX query view of Power BI Desktop." lightbox="media/dax-queries/dax-evaluate-orderby.png"::: + +TOPN does not choose the specified number of rows to return based on the sort order specified in ORDER BY. Instead, TOPN has its own syntax to optionally specify a sort before the top 100 rows are return. ORDER BY only sorts the result table returned by TOPN. ```dax -EVALUATE( - 'Internet Sales' - ) -ORDER BY - 'Internet Sales'[Order Date] +EVALUATE + TOPN( + 100, + 'Sales Order', + // The way the data is sorted before the top 100 rows are selected + 'Sales Order'[SalesOrderLineKey], ASC + ) + // The way the data is sorted for the results + ORDER BY + 'Sales Order'[Sales Order] ASC, + 'Sales Order'[Sales Order Line] ASC ``` -Returns all rows and columns from the Internet Sales table, ordered by Order Date, as a table. +Returns the top 100 sales orders sorted by SalesOrderLienKey ascending, then sorts the results first by sales order, then by sales order line. -![DAX Evaluate order by statement](media/dax-queries/dax-evaluate-orderby.png) +:::image type="content" source="media/dax-queries/dax-evaluate-topn.png" alt-text="Screenshot showing how to use TOPN and ORDER BY for a DAX query in DAX query view of Power BI Desktop." lightbox="media/dax-queries/dax-evaluate-topn.png"::: ### START AT (Optional) -The optional **START AT** keyword is used inside an **ORDER BY** clause. It defines the value at which the query results begin. +The optional `START AT` keyword is used inside an `ORDER BY` clause. It defines the value at which the query results begin. -#### Syntax +#### START AT Syntax ```dax -EVALUATE
-[ORDER BY { [{ASC | DESC}]}[, …] -[START AT {|} [, …]]] +EVALUATE
+[ORDER BY { [{ASC | DESC}]}[, …] +[START AT {|} [, …]]] ``` -#### Arguments +#### START AT Parameters |Term |Definition | |---------|---------| -| value | A constant value. Cannot be an expression. | -| parameter | The name of a parameter in an XMLA statement prefixed with an `@` character. | - -START AT arguments have a one-to-one correspondence with the columns in the ORDER BY clause. There can be as many arguments in the START AT clause as there are in the ORDER BY clause, but not more. The first argument in the START AT defines the starting value in column 1 of the ORDER BY columns. The second argument in the START AT defines the starting value in column 2 of the ORDER BY columns within the rows that meet the first value for column 1. +| `value` | A constant value. Cannot be an expression. | +| `parameter` | The name of a parameter in an XMLA statement prefixed with an `@` character. | + +#### START AT Remarks -#### Example +START AT arguments have a one-to-one correspondence with the columns in the ORDER BY clause. There can be as many arguments in the START AT clause as there are in the ORDER BY clause, but not more. The first argument in the START AT defines the starting value in column 1 of the ORDER BY columns. The second argument in the START AT defines the starting value in column 2 of the ORDER BY columns within the rows that meet the first value for column 1. + +#### START AT Example ```dax -EVALUATE( - 'Internet Sales' - ) -ORDER BY - 'Internet Sales'[Sales Order Number] -START AT "SO7000" +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" ``` -Returns all rows and columns from the Internet Sales table, ordered by Sales Order Number, beginning at SO7000. - -![DAX Evaluate order by Sales order number statement](media/dax-queries/dax-evaluate-startat.png) +Returns all columns from the Sales Order table, in ascending order by Sales Order, beginning at SO43661. Rows before this sales order are not included in the result table. -Multiple **EVALUATE**/**ORDER BY**/**START AT** clauses can be specified in a single query. +:::image type="content" source="media/dax-queries/dax-evaluate-startat.png" alt-text="Screenshot showing how to use ORDER BY and START AT for a DAX query in DAX query view of Power BI Desktop." lightbox="media/dax-queries/dax-evaluate-startat.png"::: ### DEFINE (Optional) -The optional **DEFINE** keyword defines entities that exist only for the duration of the query. Definitions are valid for all EVALUATE statements. Entities can be variables, measures, tables, and columns. Definitions can reference other definitions that appear before or after the current definition. Definitions typically precede the EVALUATE statement. +The optional `DEFINE` keyword introduces one or more calculated entity definitions that exist only for the duration of the query. Unlike `EVALUATE`, there can only be one `DEFINE` block with one or more definitions in a DAX query. `DEFINE` must precede the first `EVALUATE` statement and are valid for all EVALUATE statements in the query. Definitions can be variables, measures, tables[1](#not-rec), and columns[1](#not-rec). Definitions can reference other definitions that appear before or after the current definition. At least one definition is required if the `DEFINE` keyword is included in a query. + +`DEFINE MEASURE` is a common scenario to build new measures or edit existing measures in a semantic model. When the measure already exists in the model, the DAX query will use the measure DAX formula defined in the query. This is helpful for testing measures with a DAX query before updating the model. + +`DEFINE MEASURE` is also helpful to build additional analysis with DAX formulas for a specific DAX query where you may not have permission to add a model measure or it is not necessary to have it in the model. + +#### DEFINE Syntax -#### Syntax - ```dax -[DEFINE { MEASURE [] = } - { VAR = }] -EVALUATE
+[DEFINE + ( + (MEASURE
[] = ) | + (VAR =
) | + (TABLE
= ) | + (COLUMN
[] = ) | + ) + +] + +(EVALUATE
) + ``` -#### Arguments +#### DEFINE Parameters -|Term |Definition | -|---------|---------| -| tableName | The name of an existing table using standard DAX syntax. It cannot be an expression. | -| name | The name of a new measure. It cannot be an expression. | -| expression | Any DAX expression that returns a single scalar value. The expression can use any of the defined measures. The expression must return a table. If a scalar value is required, wrap the scalar inside a ROW() function to produce a table. | -| VAR | An optional expression as a named variable. A [VAR](var-dax.md) can be passed as an argument to other expressions. | +|Term|Definition| +|--------|--------------| +|`Entity`|MEASURE, VAR, TABLE[1](#not-rec), or COLUMN[1](#not-rec). | +|`name`|The name of a measure, var, table, or column definition. It cannot be an expression. The name does not have to be unique. The name exists only for the duration of the query.| +|`expression`|Any DAX expression that returns a table or scalar value. The expression can use any of the defined entities. If there is a need to convert a scalar expression into a table expression, wrap the expression inside a table constructor with curly braces `{}`, or use the `ROW()` function to return a single row table.| + +[1] **Caution:** Query scoped TABLE and COLUMN definitions are meant for internal use only. While you can define TABLE and COLUMN expressions for a query without syntax error, they may produce runtime errors and are not recommended. + +#### DEFINE Remarks + +- A DAX query can have multiple EVALUATE statements, but can have only one DEFINE statement. Definitions in the DEFINE statement can apply to any EVALUATE statements in the query. + +- At least one definition is required in a DEFINE statement. + +- Measure definitions for a query override model measures of the same name but are only used within the query. They will not affect the model measure. + +- VAR names have unique restrictions. To learn more, see [VAR - Parameters](var-dax.md#parameters). + +#### DEFINE Example + +```dax +DEFINE + VAR _firstyear = MIN('Date'[Fiscal Year]) + VAR _lastyear = MAX('Date'[Fiscal Year]) + TABLE 'Unbought products' = FILTER('Product', [Orders] + 0 = 0) + COLUMN 'Unbought products'[Year Range] = _firstyear & " - " & _lastyear + MEASURE 'Unbought products'[Unbought products] = COUNTROWS('Unbought products') + +EVALUATE + 'Unbought products' + +EVALUATE + {[Unbought products]} +``` + +Returns the table defined in the DAX query to show unbought products with an additional defined column referencing defined variables. A measure is also defined and evaluated to count the rows of unbought products. -#### Example +:::image type="content" source="media/dax-queries/dax-evaluate-define.png" alt-text="Screenshot showing how to use DEFINE for a DAX query in DAX query view of Power BI Desktop." lightbox="media/dax-queries/dax-evaluate-define.png"::: ```dax DEFINE -MEASURE 'Internet Sales'[Internet Total Sales] = SUM('Internet Sales'[Sales Amount]) + MEASURE 'Pick a sales measure'[Orders] = DISTINCTCOUNT('Sales Order'[Sales Order]) + MEASURE 'Pick a sales measure'[Customers] = CALCULATE( + COUNTROWS(Customer), + FILTER( + 'Sales', + [Orders] > 0 + ) + ) + MEASURE 'Pick a sales measure'[Orders per Customer] = DIVIDE( + [Orders], + [Customers], + 0 + ) + EVALUATE -SUMMARIZECOLUMNS -( - 'Date'[Calendar Year], - TREATAS({2013, 2014}, 'Date'[Calendar Year]), - "Total Sales", [Internet Total Sales], - "Combined Years Total Sales", CALCULATE([Internet Total Sales], ALLSELECTED('Date'[Calendar Year])) -) -ORDER BY [Calendar Year] + SUMMARIZECOLUMNS( + 'Date'[Fiscal Year], + "Orders", [Orders], + "Customers", [Customers], + "Orders per Customer", [Orders per Customer] + ) ``` +Returns a table evaluating three defined measures to show the results by fiscal year. All measures also exist in the model, and Orders per Customer is modified in the DAX query. + +:::image type="content" source="media/dax-queries/dax-evaluate-define-measures.png" alt-text="Screenshot showing how to use DEFINE MEASURE for a DAX query in DAX query view of Power BI Desktop." lightbox="media/dax-queries/dax-evaluate-define-measures.png"::: + +## Parameters in DAX queries -Returns the calculated total sales for years 2013 and 2014, and combined calculated total sales for years 2013 and 2014, as a table. The measure in the DEFINE statement, Internet Total Sales, is used in both Total Sales and Combined Years Total Sales expressions. +A well-defined DAX query statement can be parameterized and then used over and over with just changes in the parameter values. -![DAX Evaluate with measure defnition](media/dax-queries/dax-evaluate-define.png) +The [Execute Method (XMLA)](/analysis-services/xmla/xml-elements-methods-execute) method has a [Parameters Element (XMLA)](/analysis-services/xmla/xml-elements-properties/parameters-element-xmla) collection element that allows parameters to be defined and assigned a value. Within the collection, each [Parameter Element (XMLA)](/analysis-services/xmla/xml-elements-properties/parameter-element-xmla) element defines the name of the parameter and a value to it. -## Parameters in DAX queries +Reference XMLA parameters by prefixing the name of the parameter with an `@` character. Any place in the syntax where a value is allowed, the value can be replaced with a parameter call. All XMLA parameters are typed as text. -A well-defined DAX query statement can be parameterized and then used over and over with just changes in the parameter values. - -The [Execute Method (XMLA)](/analysis-services/xmla/xml-elements-methods-execute) method has a [Parameters Element (XMLA)](/analysis-services/xmla/xml-elements-properties/parameters-element-xmla) collection element that allows parameters to be defined and assigned a value. Within the collection, each [Parameter Element (XMLA)](/analysis-services/xmla/xml-elements-properties/parameter-element-xmla) element defines the name of the parameter and a value to it. - -Reference XMLA parameters by prefixing the name of the parameter with an `@` character. Any place in the syntax where a value is allowed, the value can be replaced with a parameter call. All XMLA parameters are typed as text. - > [!IMPORTANT] -> Parameters defined in the parameters section and not used in the **<STATEMENT>** element generate an error response in XMLA. -> Parameters used and not defined in the **<Parameters>** element generate an error response in XMLA. - -## See also - -[FILTER](filter-function-dax.md) -[SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) -[TREATAS](treatas-function.md) -[VAR](var-dax.md) +> Parameters defined in the parameters section and not used in the `` element generate an error response in XMLA. +> Parameters used and not defined in the `` element generate an error response in XMLA. + +## Related content + +[DAX statements](statements-dax.md) +[SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) diff --git a/query-languages/dax/dax-sample-model.md b/query-languages/dax/dax-sample-model.md index 0020b877b..1d9cf87c8 100644 --- a/query-languages/dax/dax-sample-model.md +++ b/query-languages/dax/dax-sample-model.md @@ -2,13 +2,7 @@ title: "DAX sample model" description: DAX sample model to support reference articles. author: peter-myers -ms.author: owend -ms.reviewer: owend -ms.service: powerbi -ms.subservice: dax ms.topic: conceptual -ms.date: 08/25/2021 -recommendations: false --- # DAX sample model @@ -27,7 +21,7 @@ The Adventure Works company represents a bicycle manufacturer that sells bicycle The model has seven tables: -|Table|Description| +|**Table**|**Description**| |-----|-------| |**Customer**|Describes customers and their geographic location. Customers purchase products online (Internet sales).| |**Date**|There are three relationships between the **Date** and **Sales** tables, for order date, ship date, and due date. The order date relationship is active. The company's reports sales using a fiscal year that commences on July 1 of each year. The table is marked as a date table using the **Date** column.| @@ -37,14 +31,12 @@ The model has seven tables: |**Sales Order**|Describes sales order and order line numbers, and also the sales channel, which is either **Reseller** or **Internet**. This table has a one-to-one relationship with the **Sales** table.| |**Sales Territory**|Sales territories are organized into groups (North America, Europe, and Pacific), countries, and regions. Only the United States sells products at the region level.| - - ## Download sample Download the Power BI Desktop sample model file [here](https://aka.ms/dax-docs-sample-file). -## See also +## Related content -- Learning path: [Use DAX in Power BI Desktop](/learn/paths/dax-power-bi/) +- Learning path: [Use DAX in Power BI Desktop](/training/paths/dax-power-bi/) - Questions? [Try asking the Power BI Community](https://community.powerbi.com/) -- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) \ No newline at end of file +- Suggestions? [Contribute ideas to improve Power BI](https://ideas.powerbi.com) diff --git a/query-languages/dax/dax-syntax-reference.md b/query-languages/dax/dax-syntax-reference.md index 1c5456e33..1171282c9 100644 --- a/query-languages/dax/dax-syntax-reference.md +++ b/query-languages/dax/dax-syntax-reference.md @@ -1,165 +1,158 @@ --- description: "Learn more about: DAX syntax" -title: "DAX syntax | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "DAX syntax" +ms.topic: conceptual --- # DAX syntax -This article describes syntax and requirements for the DAX formula expression language. - -## Syntax requirements - -A DAX formula always starts with an equal sign (=). After the equals sign, you can provide any expression that evaluates to a scalar, or an expression that can be converted to a scalar. These include the following: - -- A scalar constant, or expression that uses a scalar operator (+,-,*,/,>=,...,&&, ...) - -- References to columns or tables. The DAX language always uses tables and columns as inputs to functions, never an array or arbitrary set of values. - -- Operators, constants, and values provided as part of an expression. - -- The result of a function and its required arguments. Some DAX functions return a table instead of a scalar, and must be wrapped in a function that evaluates the table and returns a scalar; unless the table is a single column, single row table, then it is treated as a scalar value. - - Most DAX functions require one or more arguments, which can include tables, columns, expressions, and values. However, some functions, such as PI, do not require any arguments, but always require parentheses to indicate the null argument. For example, you must always type PI(), not PI. You can also nest functions within other functions. - -- Expressions. An expression can contain any or all of the following: operators, constants, or references to columns. - -For example, the following are all valid formulas. - -|Formula|Result| -|-----------|----------| -|= 3|3| -|= "**Sales**"|**Sales**| -|= 'Sales'[Amount]|If you use this formula within the Sales table, you will get the value of the column Amount in the Sales table for the current row.| -|= (0.03 *[Amount])

=0.03 \* [Amount]|Three percent of the value in the Amount column of the current table.

Although this formula can be used to calculate a percentage, the result is not shown as a percentage unless you apply formatting in the table.| -|= PI()|The value of the constant pi.| - -Formulas can behave differently depending on how they are used. You must always be aware of the context and how the data that you use in the formula is related to other data that might be used in the calculation. - -## Naming requirements - -A data model often contains multiple tables. Together the tables and their columns comprise a database stored in the in-memory analytics engine (VertiPaq). Within that database, all tables must have unique names. The names of columns must also be unique within each table. All object names are *case-insensitive*; for example, the names **SALES** and **Sales** would represent the same table. - -Each column and measure you add to an existing data model must belong to a specific table. You specify the table that contains the column either implicitly, when you create a calculated column within a table, or explicitly, when you create a measure and specify the name of the table where the measure definition should be stored. - -When you use a table or column as an input to a function, you must generally *qualify* the column name. The *fully qualified* name of a column is the table name, followed by the column name in square brackets: for examples, 'U.S. Sales'[Products]. A fully qualified name is always required when you reference a column in the following contexts: - -- As an argument to the function, VALUES - -- As an argument to the functions, ALL or ALLEXCEPT - -- In a filter argument for the functions, CALCULATE or CALCULATETABLE - -- As an argument to the function, RELATEDTABLE - -- As an argument to any time intelligence function - -An *unqualified* column name is just the name of the column, enclosed in brackets: for example, [Sales Amount]. For example, when you are referencing a scalar value from the same row of the current table, you can use the unqualified column name. - -If the name of a table contains spaces, reserved keywords, or disallowed characters, you must enclose the table name in single quotation marks. You must also enclose table names in quotation marks if the name contains any characters outside the ANSI alphanumeric character range, regardless of whether your locale supports the character set or not. For example, if you open a workbook that contains table names written in Cyrillic characters, such as 'Таблица', the table name must be enclosed in quotation marks, even though it does not contain spaces. - -> [!NOTE] -> To make it easier to enter the fully qualified names of columns, use the AutoComplete feature in the formula editor. - -#### Tables - -- Table names are required whenever the column is from a different table than the current table. Table names must be unique within the database. - -- Table names must be enclosed in single quotation marks if they contain spaces, other special characters or any non-English alphanumeric characters. - -#### Measures - -- Measure names must always be in brackets. - -- Measure names can contain spaces. - -- Each measure name must be unique within a model. Therefore, the table name is optional in front of a measure name when referencing an existing measure. However, when you create a measure you must always specify a table where the measure definition will be stored. - -#### Columns - -Column names must be unique in the context of a table; however, multiple tables can have columns with the same names (disambiguation comes with the table name). - -In general, columns can be referenced without referencing the base table that they belong to, except when there might be a name conflict to resolve or with certain functions that require column names to be fully qualified. - -#### Reserved keywords - -If the name that you use for a table is the same as an Analysis Services reserved keyword, an error is raised, and you must rename the table. However, you can use keywords in object names if the object name is enclosed in brackets (for columns) or quotation marks (for tables). - -> [!NOTE] -> Quotation marks can be represented by several different characters, depending on the application. If you paste formulas from an external document or Web page, make sure to check the ASCII code of the character that is used for opening and closing quotes, to ensure that they are the same. Otherwise DAX may be unable to recognize the symbols as quotation marks, making the reference invalid. - -#### Special characters - -The following characters and character types are not valid in the names of tables, columns, or measures: - -- Leading or trailing spaces; unless the spaces are enclosed by name delimiters, brackets, or single apostrophes. - -- Control characters - -- The following characters that are not valid in the names of objects: - - .,;':/\\*|?&%$!+=()[]{}<> - -#### Examples of object names - -The following table shows examples of some object names: - -|Object Types|Examples|Comment| +This article describes syntax and requirements for the DAX formula expression language. + +## Syntax requirements + +A DAX formula always starts with an equal sign (`=`). After the equals sign, you can provide any expression that evaluates to a scalar, or an expression that can be converted to a scalar. These include the following: + +- A scalar constant, or expression that uses a scalar operator (`+,-,*,/,>=,...,&&, ...`) + +- References to columns or tables. The DAX language always uses tables and columns as inputs to functions, never an array or arbitrary set of values. + +- Operators, constants, and values provided as part of an expression. + +- The result of a function and its required arguments. Some DAX functions return a table instead of a scalar, and must be wrapped in a function that evaluates the table and returns a scalar; unless the table is a single column, single row table, then it is treated as a scalar value. + + Most DAX functions require one or more arguments, which can include tables, columns, expressions, and values. However, some functions, such as PI, do not require any arguments, but always require parentheses to indicate the null argument. For example, you must always type PI(), not PI. You can also nest functions within other functions. + +- Expressions. An expression can contain any or all of the following: operators, constants, or references to columns. + +For example, the following are all valid formulas. + +|Formula|Result| +|-----------|----------| +|`= 3`|3| +|`= "Sales"`|**Sales**| +|`= 'Sales'[Amount]`|If you use this formula within the Sales table, you will get the value of the column Amount in the Sales table for the current row.| +|`= (0.03 *[Amount])`

`=0.03 * [Amount]`|Three percent of the value in the Amount column of the current table.

Although this formula can be used to calculate a percentage, the result is not shown as a percentage unless you apply formatting in the table.| +|`= PI()`|The value of the constant pi.| + +Formulas can behave differently depending on how they are used. You must always be aware of the context and how the data that you use in the formula is related to other data that might be used in the calculation. + +## Naming requirements + +A data model often contains multiple tables. Together the tables and their columns comprise a database stored in the in-memory analytics engine (VertiPaq). Within that database, all tables must have unique names. The names of columns must also be unique within each table. All object names are *case-insensitive*; for example, the names **SALES** and **Sales** would represent the same table. + +Each column and measure you add to an existing data model must belong to a specific table. You specify the table that contains the column either implicitly, when you create a calculated column within a table, or explicitly, when you create a measure and specify the name of the table where the measure definition should be stored. + +When you use a table or column as an input to a function, you must generally *qualify* the column name. The *fully qualified* name of a column is the table name, followed by the column name in square brackets: for examples, 'U.S. Sales'[Products]. A fully qualified name is always required when you reference a column in the following contexts: + +- As an argument to the function, `VALUES` + +- As an argument to the functions, `ALL` or `ALLEXCEPT` + +- In a filter argument for the functions, `CALCULATE` or `CALCULATETABLE` + +- As an argument to the function, `RELATEDTABLE` + +- As an argument to any time intelligence function + +An *unqualified* column name is just the name of the column, enclosed in brackets: for example, [Sales Amount]. For example, when you are referencing a scalar value from the same row of the current table, you can use the unqualified column name. + +If the name of a table contains spaces, reserved keywords, or disallowed characters, you must enclose the table name in single quotation marks. You must also enclose table names in quotation marks if the name contains any characters outside the ANSI alphanumeric character range, regardless of whether your locale supports the character set or not. For example, if you open a workbook that contains table names written in Cyrillic characters, such as 'Таблица', the table name must be enclosed in quotation marks, even though it does not contain spaces. + +> [!NOTE] +> To make it easier to enter the fully qualified names of columns, use the AutoComplete feature in the formula editor. + +#### Tables + +- Table names are required whenever the column is from a different table than the current table. Table names must be unique within the database. + +- Table names must be enclosed in single quotation marks if they contain spaces, other special characters or any non-English alphanumeric characters. + +#### Measures + +- Measure names must always be in brackets. + +- Measure names can contain spaces. + +- Each measure name must be unique within a model. Therefore, the table name is optional in front of a measure name when referencing an existing measure. However, when you create a measure you must always specify a table where the measure definition will be stored. + +#### Columns + +Column names must be unique in the context of a table; however, multiple tables can have columns with the same names (disambiguation comes with the table name). + +In general, columns can be referenced without referencing the base table that they belong to, except when there might be a name conflict to resolve or with certain functions that require column names to be fully qualified. + +#### Reserved keywords + +If the name that you use for a table is the same as an Analysis Services reserved keyword, an error is raised, and you must rename the table. However, you can use keywords in object names if the object name is enclosed in brackets (for columns) or quotation marks (for tables). + +> [!NOTE] +> Quotation marks can be represented by several different characters, depending on the application. If you paste formulas from an external document or Web page, make sure to check the ASCII code of the character that is used for opening and closing quotes, to ensure that they are the same. Otherwise DAX may be unable to recognize the symbols as quotation marks, making the reference invalid. + +#### Special characters + +The following characters and character types are not valid in the names of tables, columns, or measures: + +- Leading or trailing spaces; unless the spaces are enclosed by name delimiters, brackets, or single apostrophes. + +- Control characters + +- The following characters that are not valid in the names of objects: + + `.,;':/\\*|?&%$!+=()[]{}<>` + +#### Examples of object names + +The following table shows examples of some object names: + +|Object Types|Examples|Comment| |-----|-----|----| -|Table name|**Sales**|If the table name does not contain spaces or other special characters, the name does not need to be enclosed in quotation marks.| -|Table name|**'Canada Sales'**|If the name contains spaces, tabs or other special characters, enclose the name in single quotation marks.| -|Fully qualified column name|**Sales[Amount]**|The table name precedes the column name, and the column name is enclosed in brackets.| -|Fully qualified measure name|**Sales[Profit]**|The table name precedes the measure name, and the measure name is enclosed in brackets. In certain contexts, a fully qualified name is always required.| -|Unqualified column name|**[Amount]**|The unqualified name is just the column name, in brackets. Contexts where you can use the unqualified name include formulas in a calculated column within the same table, or in an aggregation function that is scanning over the same table.| -|Fully qualified column in table with spaces|**'Canada Sales'[Qty]**|The table name contains spaces, so it must be surrounded by single quotes.| - - -### Other restrictions - -The syntax required for each function, and the type of operation it can perform, varies greatly depending on the function. In general, however, the following rules apply to all formulas and expressions: - -- DAX formulas and expressions cannot modify or insert individual values in tables. - -- You cannot create calculated rows by using DAX. You can create only calculated columns and measures. - -- When defining calculated columns, you can nest functions to any level. - -- DAX has several functions that return a table. Typically, you use the values returned by these functions as input to other functions, which require a table as input. - - -## DAX operators and constants - -The following table lists the operators that are supported by DAX. For more information about the syntax of individual operators, see [DAX operators](dax-operator-reference.md). - -|Operator type|Symbol and use| -|-----------------|------------------| -|Parenthesis operator|() precedence order and grouping of arguments| -|Arithmetic operators|+ (addition)

- (subtraction/

sign)

* (multiplication)

/ (division)

^ (exponentiation)| -|Comparison operators|= (equal to)

> (greater than)

< (less than)

>= (greater than or equal to)

<= (less than or equal to)

<> (not equal to)| -|Text concatenation operator|& (concatenation)| -|Logic operators|&& (and)

|| (or)| - -## Data types - -You do not need to cast, convert, or otherwise specify the data type of a column or value that you use in a DAX formula. When you use data in a DAX formula, DAX automatically identifies the data types in referenced columns and of the values that you type in, and performs implicit conversions where necessary to complete the specified operation. - -For example, if you try to add a number to a date value, the engine will interpret the operation in the context of the function, and convert the numbers to a common data type, and then present the result in the intended format, a date. - -However, there are some limitations on the values that can be successfully converted. If a value or a column has a data type that is incompatible with the current operation, DAX returns an error. Also, DAX does not provide functions that let you explicitly change, convert, or cast the data type of existing data that you have imported into a data model. - -> [!IMPORTANT] -> DAX does not support use of the variant data type. Therefore, when you load or import data into a data model, it's expected the data in each column is generally of a consistent data type. - -Some functions return scalar values, including strings, whereas other functions work with numbers, both integers and real numbers, or dates and times. The data type required for each function is described in the section, [DAX functions](dax-function-reference.md). - -You can use tables containing multiple columns and multiple rows of data as the argument to a function. Some functions also return tables, which are stored in memory and can be used as arguments to other functions. - +|Table name|**Sales**|If the table name does not contain spaces or other special characters, the name does not need to be enclosed in quotation marks.| +|Table name|**'Canada Sales'**|If the name contains spaces, tabs or other special characters, enclose the name in single quotation marks.| +|Fully qualified column name|**Sales[Amount]**|The table name precedes the column name, and the column name is enclosed in brackets.| +|Fully qualified measure name|**Sales[Profit]**|The table name precedes the measure name, and the measure name is enclosed in brackets. In certain contexts, a fully qualified name is always required.| +|Unqualified column name|**[Amount]**|The unqualified name is just the column name, in brackets. Contexts where you can use the unqualified name include formulas in a calculated column within the same table, or in an aggregation function that is scanning over the same table.| +|Fully qualified column in table with spaces|**'Canada Sales'[Qty]**|The table name contains spaces, so it must be surrounded by single quotes.| + + +### Other restrictions + +The syntax required for each function, and the type of operation it can perform, varies greatly depending on the function. In general, however, the following rules apply to all formulas and expressions: + +- DAX formulas and expressions cannot modify or insert individual values in tables. + +- You cannot create calculated rows by using DAX. You can create only calculated columns and measures. + +- When defining calculated columns, you can nest functions to any level. + +- DAX has several functions that return a table. Typically, you use the values returned by these functions as input to other functions, which require a table as input. + + +## DAX operators and constants + +The following table lists the operators that are supported by DAX. For more information about the syntax of individual operators, see [DAX operators](dax-operator-reference.md). + +|Operator type|Symbol and use| +|-----------------|------------------| +|Parenthesis operator|`()` precedence order and grouping of arguments| +|Arithmetic operators|`+` (addition)

`-` (subtraction)

`*` (multiplication)

`/` (division)

`^` (exponentiation)| +|Comparison operators|`=` (equal to)

`>` (greater than)

`<` (less than)

`>=` (greater than or equal to)

`<=` (less than or equal to)

`<>` (not equal to)| +|Text concatenation operator|`&` (concatenation)| +|Logic operators|`&&` (and)

`||` (or)| + +## Data types + +You do not need to cast, convert, or otherwise specify the data type of a column or value that you use in a DAX formula. When you use data in a DAX formula, DAX automatically identifies the data types in referenced columns and of the values that you type in, and performs implicit conversions where necessary to complete the specified operation. + +For example, if you try to add a number to a date value, the engine will interpret the operation in the context of the function, and convert the numbers to a common data type, and then present the result in the intended format, a date. + +However, there are some limitations on the values that can be successfully converted. If a value or a column has a data type that is incompatible with the current operation, DAX returns an error. Also, DAX does not provide functions that let you explicitly change, convert, or cast the data type of existing data that you have imported into a data model. + +> [!IMPORTANT] +> DAX does not support use of the variant data type. Therefore, when you load or import data into a data model, it's expected the data in each column is generally of a consistent data type. + +Some functions return scalar values, including strings, whereas other functions work with numbers, both integers and real numbers, or dates and times. The data type required for each function is described in the section, [DAX functions](dax-function-reference.md). + +You can use tables containing multiple columns and multiple rows of data as the argument to a function. Some functions also return tables, which are stored in memory and can be used as arguments to other functions. + ## Date and time DAX stores date and time values using the datetime data type used by Microsoft SQL Server. Datetime format uses a floating-point number where Date values correspond to the integer portion representing the number of days since December 30, 1899. Time values correspond to the decimal portion of a date value where Hours, minutes, and seconds are represented by decimal fractions of a day. DAX date and time functions implicitly convert arguments to datetime data type. diff --git a/query-languages/dax/day-function-dax.md b/query-languages/dax/day-function-dax.md index 6c5dad94a..04ec42260 100644 --- a/query-languages/dax/day-function-dax.md +++ b/query-languages/dax/day-function-dax.md @@ -1,71 +1,64 @@ --- description: "Learn more about: DAY" -title: "DAY function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/05/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DAY function (DAX)" --- # DAY -Returns the day of the month, a number from 1 to 31. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the day of the month, a number from 1 to 31. + +## Syntax + ```dax -DAY() +DAY() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|date|A date in **datetime** format, or a text representation of a date.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`date`|A date in `datetime` format, or a text representation of a date.| + ## Return value -An integer number indicating the day of the month. - +An integer number indicating the day of the month. + ## Remarks -- The DAY function takes as an argument the date of the day you are trying to find. Dates can be provided to the function by using another date function, by using an expression that returns a date, or by typing a date in a **datetime** format. You can also type a date in one of the accepted string formats for dates. - -- Values returned by the YEAR, MONTH and DAY functions will be Gregorian values regardless of the display format for the supplied date value. For example, if the display format of the supplied date is Hijri, the returned values for the YEAR, MONTH and DAY functions will be values associated with the equivalent Gregorian date. - -- When the date argument is a text representation of the date, the day function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. If the current date/time settings represent dates in the format of Month/Day/Year, then the string, "1/8/2009", is interpreted as a **datetime** value equivalent to January 8th of 2009, and the function returns 8. However, if the current date/time settings represent dates in the format of Day/Month/Year, the same string would be interpreted as a **datetime** value equivalent to August 1st of 2009, and the function returns 1. - -## Example: Getting the day from a date column +- The DAY function takes as an argument the date of the day you are trying to find. Dates can be provided to the function by using another date function, by using an expression that returns a date, or by typing a date in a `datetime` format. You can also type a date in one of the accepted string formats for dates. + +- Values returned by the YEAR, MONTH and DAY functions will be Gregorian values regardless of the display format for the supplied date value. For example, if the display format of the supplied date is Hijri, the returned values for the YEAR, MONTH and DAY functions will be values associated with the equivalent Gregorian date. + +- When the date argument is a text representation of the date, the day function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. If the current date/time settings represent dates in the format of Month/Day/Year, then the string, "1/8/2009", is interpreted as a `datetime` value equivalent to January 8th of 2009, and the function returns 8. However, if the current date/time settings represent dates in the format of Day/Month/Year, the same string would be interpreted as a `datetime` value equivalent to August 1st of 2009, and the function returns 1. + +## Example: Getting the day from a date column + +The following formula returns the day from the date in the column, [Birthdate]. -The following formula returns the day from the date in the column, [Birthdate]. - ```dax -= DAY([Birthdate]) += DAY([Birthdate]) ``` - -## Example - Getting the day from a string date -The following formulas return the day, 4, using dates that have been supplied as strings in an accepted text format. - +## Example - Getting the day from a string date + +The following formulas return the day, 4, using dates that have been supplied as strings in an accepted text format. + ```dax -= DAY("3-4-1007") -= DAY("March 4 2007") += DAY("3-4-1007") += DAY("March 4 2007") ``` - -## Example - Using a day value as a condition -The following expression returns the day that each sales order was placed, and flags the row as a promotional sale item if the order was placed on the 10th of the month. - +## Example - Using a day value as a condition + +The following expression returns the day that each sales order was placed, and flags the row as a promotional sale item if the order was placed on the 10th of the month. + ```dax -= IF( DAY([SalesDate])=10,"promotion","") += IF( DAY([SalesDate])=10,"promotion","") ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[TODAY function](today-function-dax.md) -[DATE function](date-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[TODAY function](today-function-dax.md) +[DATE function](date-function-dax.md) diff --git a/query-languages/dax/db-function-dax.md b/query-languages/dax/db-function-dax.md index 5e885b282..ff617b9e1 100644 --- a/query-languages/dax/db-function-dax.md +++ b/query-languages/dax/db-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: DB" -title: "DB function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/06/2021 -ms.reviewer: owend -ms.topic: reference +title: "DB function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # DB +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the depreciation of an asset for a specified period using the fixed-declining balance method. ## Syntax @@ -24,13 +18,13 @@ DB(, , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|cost|The initial cost of the asset.| -|salvage|The value at the end of the depreciation (sometimes called the salvage value of the asset). This value can be 0.| -|life|The number of periods over which the asset is being depreciated (sometimes called the useful life of the asset).| -|period|The period for which you want to calculate the depreciation. Period must use the same units as life. Must be between 1 and life (inclusive).| -|month|(Optional) The number of months in the first year. If month is omitted, it is assumed to be 12.| +|Term|Definition| +|--------|--------------| +|`cost`|The initial cost of the asset.| +|`salvage`|The value at the end of the depreciation (sometimes called the salvage value of the asset). This value can be 0.| +|`life`|The number of periods over which the asset is being depreciated (sometimes called the useful life of the asset).| +|`period`|The period for which you want to calculate the depreciation. Period must use the same units as life. Must be between 1 and life (inclusive).| +|`month`|(Optional) The number of months in the first year. If month is omitted, it is assumed to be 12.| ## Return Value diff --git a/query-languages/dax/ddb-function-dax.md b/query-languages/dax/ddb-function-dax.md index 627c57a72..4e005ba78 100644 --- a/query-languages/dax/ddb-function-dax.md +++ b/query-languages/dax/ddb-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: DDB" -title: "DDB function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "DDB function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # DDB +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the depreciation of an asset for a specified period using the double-declining balance method or some other method you specify. ## Syntax @@ -24,13 +18,13 @@ DDB(, , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|cost|The initial cost of the asset.| -|salvage|The value at the end of the depreciation (sometimes called the salvage value of the asset). This value can be 0.| -|life|The number of periods over which the asset is being depreciated (sometimes called the useful life of the asset).| -|period|The period for which you want to calculate the depreciation. Period must use the same units as life. Must be between 1 and life (inclusive).| -|factor|(Optional) The rate at which the balance declines. If factor is omitted, it is assumed to be 2 (the double-declining balance method).| +|Term|Definition| +|--------|--------------| +|`cost`|The initial cost of the asset.| +|`salvage`|The value at the end of the depreciation (sometimes called the salvage value of the asset). This value can be 0.| +|`life`|The number of periods over which the asset is being depreciated (sometimes called the useful life of the asset).| +|`period`|The period for which you want to calculate the depreciation. Period must use the same units as life. Must be between 1 and life (inclusive).| +|`factor`|(Optional) The rate at which the balance declines. If factor is omitted, it is assumed to be 2 (the double-declining balance method).| ## Return Value diff --git a/query-languages/dax/define-statement-dax.md b/query-languages/dax/define-statement-dax.md index 1370fc21f..2173120da 100644 --- a/query-languages/dax/define-statement-dax.md +++ b/query-languages/dax/define-statement-dax.md @@ -1,46 +1,57 @@ --- description: "Learn more about: DEFINE" -title: "DEFINE keyword (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DEFINE keyword (DAX)" --- # DEFINE - -A keyword that defines entities that can be applied to one or more EVALUATE statements of a [DAX query](dax-queries.md). -## Syntax - +Introduces a statement with one or more entity definitions that can be applied to one or more EVALUATE statements of a [DAX query](dax-queries.md). + +## Syntax + ```dax -DEFINE { [] = } +[DEFINE + ( + (MEASURE
[] = ) | + (VAR =
) | + (TABLE
= ) | + (COLUMN
[] = ) | + ) + +] + +(EVALUATE
) + ``` - -### Arguments - -|Term|Definition| -|--------|--------------| -|entity|MEASURE, VAR, TABLE, or COLUMN.| -|name|The name of an entity. It cannot be an expression.| -|expression|Any DAX expression that returns a single scalar value. The expression can use any of the defined entities. The expression must return a table. If a scalar value is required, wrap the scalar inside a ROW() function to produce a table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Entity`|MEASURE, VAR, TABLE[1](#not-rec), or COLUMN[1](#not-rec). | +|`name`|The name of a measure, var, table, or column definition. It cannot be an expression. The name does not have to be unique. The name exists only for the duration of the query.| +|`expression`|Any DAX expression that returns a table or scalar value. The expression can use any of the defined entities. If there is a need to convert a scalar expression into a table expression, wrap the expression inside a table constructor with curly braces `{}`, or use the `ROW()` function to return a single row table.| + +[1] **Caution:** Query scoped TABLE and COLUMN definitions are meant for internal use only. While you can define TABLE and COLUMN expressions for a query without syntax error, they may produce runtime errors and are not recommended. + ## Remarks -- Entities can be variables, measures, tables, and columns. +- A DAX query can have multiple EVALUATE statements, but can have only one DEFINE statement. Definitions in the DEFINE statement can apply to any EVALUATE statements in the query. + +- At least one definition is required in a DEFINE statement. + +- Measure definitions for a query override model measures of the same name. + +- VAR names have unique restrictions. To learn more, see [VAR - Parameters](var-dax.md#parameters). -- Definitions typically precede the EVALUATE statement and are valid for all EVALUATE statements. +- To learn more about how a DEFINE statement is used, see [DAX queries](dax-queries.md). -- Definitions can reference other definitions that appear before or after the current definition. +- To learn more about virtual column, see [Virtual Column](virtual-column-statement-dax.md) -- Definitions exist only for the duration of the query. +- To learn more about virtual table, see [Virtual Table](virtual-table-statement-dax.md) -## See also +## Related content -[DAX queries](dax-queries.md) -[ORDER BY](orderby-statement-dax.md) +[EVALUATE](evaluate-statement-dax.md) [VAR](var-dax.md) +[MEASURE](measure-statement-dax.md) +[Virtual Column](virtual-column-statement-dax.md) +[Virtual Table](virtual-table-statement-dax.md) +[DAX queries](dax-queries.md) diff --git a/query-languages/dax/degrees-function-dax.md b/query-languages/dax/degrees-function-dax.md index 7a25a730f..eab1f59cb 100644 --- a/query-languages/dax/degrees-function-dax.md +++ b/query-languages/dax/degrees-function-dax.md @@ -1,34 +1,27 @@ --- description: "Learn more about: DEGREES" -title: "DEGREES function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DEGREES function (DAX)" --- # DEGREES -Converts radians into degrees. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Converts radians into degrees. + +## Syntax + ```dax -DEGREES(angle) +DEGREES(angle) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|angle|Required. The angle in radians that you want to convert.| - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= DEGREES(PI())|Degrees of pi radians|180| + +### Parameters + +|Term|Definition| +|--------|--------------| +|`angle`|Required. The angle in radians that you want to convert.| + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= DEGREES(PI())`|Degrees of pi radians|180| diff --git a/query-languages/dax/dependon-function-dax.md b/query-languages/dax/dependon-function-dax.md new file mode 100644 index 000000000..3e734a884 --- /dev/null +++ b/query-languages/dax/dependon-function-dax.md @@ -0,0 +1,49 @@ +--- +description: "Learn more about: DEPENDON" +title: "DEPENDON function (DAX) | Microsoft Docs" +--- +# DEPENDON + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Change the table expression to be dependent on outer columns, based on the table data. + +## Syntax + +```dax +DEPENDON(
[, [, [,…]]]) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|table expression|Any table expression.| +|column|Column in the table expression.| + +## Return value + +The first few columns will be remapped to be dependent on specified outer columns. + +### Example + +```dax +DEFINE TABLE VTable = SELECTCOLUMNS({"USA", "Canada", "Mexico"}, "Country", [Value]) +EVALUATE SUMMARIZECOLUMNS( + VTable[Country], + "Measure", SUMX(DEPENDON({("USA", 10), ("USA", 11), ("Canada", 12)}, VTable[Country]), [Value2]) +) +``` + +This DEPENDON makes the first column depend on outer VTable[Country]. So the result table now returns table {10,11} if VTable[Country] == "USA" and returns {12} if VTable[Country] == "Canada". So the result should look like: + +|VTable[Country]|Measure| +|--------------|| +|USA|21| +|Canada|12| + +## Related content + +[Filter functions](filter-functions-dax.md) +[GROUPCROSSAPPLY function](groupcrossapply-function-dax.md) +[GROUPCROSSAPPLYTABLE function](groupcrossapplytable-function-dax.md) diff --git a/query-languages/dax/detailrows-function-dax.md b/query-languages/dax/detailrows-function-dax.md index 8dfae16d5..8d3ef5a2f 100644 --- a/query-languages/dax/detailrows-function-dax.md +++ b/query-languages/dax/detailrows-function-dax.md @@ -1,32 +1,25 @@ --- description: "Learn more about: DETAILROWS" -title: "DETAILROWS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/26/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DETAILROWS function (DAX)" --- # DETAILROWS +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Evaluates a Detail Rows Expression defined for a measure and returns the data. -## Syntax - +## Syntax + ```dax -DETAILROWS([Measure]) +DETAILROWS([Measure]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Measure|Name of a measure.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Measure`|Name of a measure.| + ## Return value A table with the data returned by the Detail Rows Expression. If no Detail Rows Expression is defined, the data for the table containing the measure is returned. diff --git a/query-languages/dax/disc-function-dax.md b/query-languages/dax/disc-function-dax.md index a2b2969a8..cef768395 100644 --- a/query-languages/dax/disc-function-dax.md +++ b/query-languages/dax/disc-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: DISC" -title: "DISC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "DISC function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # DISC +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the discount rate for a security. ## Syntax @@ -24,17 +18,17 @@ DISC(, , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|pr|The security's price per \\$100 face value.| -|redemption|The security's redemption value per \\$100 face value.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`pr`|The security's price per \\$100 face value.| +|`redemption`|The security's redemption value per \\$100 face value.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/distinct-function-dax.md b/query-languages/dax/distinct-function-dax.md index b6e8a4602..0418a6f13 100644 --- a/query-languages/dax/distinct-function-dax.md +++ b/query-languages/dax/distinct-function-dax.md @@ -1,42 +1,35 @@ --- description: "Learn more about: DISTINCT (column)" -title: "DISTINCT (column) function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DISTINCT (column) function (DAX)" --- # DISTINCT (column) -Returns a one-column table that contains the distinct values from the specified column. In other words, duplicate values are removed and only unique values are returned. - -> [!NOTE] -> This function cannot be used to Return values into a cell or column on a worksheet; rather, you nest the DISTINCT function within a formula, to get a list of distinct values that can be passed to another function and then counted, summed, or used for other operations. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a one-column table that contains the distinct values from the specified column. In other words, duplicate values are removed and only unique values are returned. + +> [!NOTE] +> This function cannot be used to Return values into a cell or column on a worksheet; rather, you nest the DISTINCT function within a formula, to get a list of distinct values that can be passed to another function and then counted, summed, or used for other operations. + +## Syntax + ```dax -DISTINCT() +DISTINCT() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column from which unique values are to be returned. Or, an expression that returns a column.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column from which unique values are to be returned. Or, an expression that returns a column.| + ## Return value -A column of unique values. - +A column of unique values. + ## Remarks -- The results of DISTINCT are affected by the current filter context. For example, if you use the formula in the following example to create a measure, the results would change whenever the table was filtered to show only a particular region or a time period. +- The results of DISTINCT are affected by the current filter context. For example, if you use the formula in the following example to create a measure, the results would change whenever the table was filtered to show only a particular region or a time period. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] @@ -44,31 +37,31 @@ A column of unique values. There is another version of the DISTINCT function, [DISTINCT (table)](distinct-table-function-dax.md), that returns a table by removing duplicate rows from another table or expression.. -The VALUES function is similar to DISTINCT; it can also be used to return a list of unique values, and generally will return exactly the same results as DISTINCT. However, in some context VALUES will return one additional special value. For more information, see [VALUES function](values-function-dax.md). - +The VALUES function is similar to DISTINCT; it can also be used to return a list of unique values, and generally will return exactly the same results as DISTINCT. However, in some context VALUES will return one additional special value. For more information, see [VALUES function](values-function-dax.md). + ## Example -The following formula counts the number of unique customers who have generated orders over the internet channel. The table that follows illustrates the possible results when the formula is added to a report. - +The following formula counts the number of unique customers who have generated orders over the internet channel. The table that follows illustrates the possible results when the formula is added to a report. + ```dax -= COUNTROWS(DISTINCT(InternetSales_USD[CustomerKey])) += COUNTROWS(DISTINCT(InternetSales_USD[CustomerKey])) ``` -You cannot paste the list of values that DISTINCT returns directly into a column. Instead, you pass the results of the DISTINCT function to another function that counts, filters, or aggregates values by using the list. To make the example as simple as possible, here the table of distinct values has been passed to the COUNTROWS function. - -|Row Labels|Accessories|Bikes|Clothing|Grand Total| -|-----------------------------|-----------------|----|----|----| -|2005||1013||1013| -|2006||2677||2677| -|2007|6792|4875|2867|9309| -|2008|9435|5451|4196|11377| -|Grand Total|15114|9132|6852|18484| - -Also, note that the results are not additive. That is to say, the total number of unique customers in *2007* is not the sum of unique customers of *Accessories*, *Bikes* and *Clothing* for that year. The reason is that a customer can be counted in multiple groups. - -## See also - -[Filter functions](filter-functions-dax.md) -[FILTER function](filter-function-dax.md) -[RELATED function](related-function-dax.md) -[VALUES function](values-function-dax.md) +You cannot paste the list of values that DISTINCT returns directly into a column. Instead, you pass the results of the DISTINCT function to another function that counts, filters, or aggregates values by using the list. To make the example as simple as possible, here the table of distinct values has been passed to the COUNTROWS function. + +|Row Labels|Accessories|Bikes|Clothing|Grand Total| +|-----------------------------|-----------------|----|----|----| +|2005||1013||1013| +|2006||2677||2677| +|2007|6792|4875|2867|9309| +|2008|9435|5451|4196|11377| +|Grand Total|15114|9132|6852|18484| + +Also, note that the results are not additive. That is to say, the total number of unique customers in *2007* is not the sum of unique customers of *Accessories*, *Bikes* and *Clothing* for that year. The reason is that a customer can be counted in multiple groups. + +## Related content + +[Filter functions](filter-functions-dax.md) +[FILTER function](filter-function-dax.md) +[RELATED function](related-function-dax.md) +[VALUES function](values-function-dax.md) diff --git a/query-languages/dax/distinct-table-function-dax.md b/query-languages/dax/distinct-table-function-dax.md index a15b58d1a..710a10aa0 100644 --- a/query-languages/dax/distinct-table-function-dax.md +++ b/query-languages/dax/distinct-table-function-dax.md @@ -1,41 +1,34 @@ --- description: "Learn more about: DISTINCT (table)" -title: "DISTINCT (table) function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DISTINCT (table) function (DAX)" --- # DISTINCT (table) +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns a table by removing duplicate rows from another table or expression. - -## Syntax - + +## Syntax + ```dax -DISTINCT(
) +DISTINCT(
) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table from which unique rows are to be returned. The table can also be an expression that results in a table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table from which unique rows are to be returned. The table can also be an expression that results in a table.| + ## Return value -A table containing only distinct rows. - +A table containing only distinct rows. + ## Related functions There is another version of the DISTINCT function, [DISTINCT (column)](distinct-function-dax.md), that takes a column name as input parameter. - -## Example + +## Example The following query: @@ -50,10 +43,10 @@ Returns table: |1 | A | |2 | B | -## See also +## Related content -[Filter functions](filter-functions-dax.md) -[DISTINCT (column)](distinct-function-dax.md) -[FILTER function](filter-function-dax.md) -[RELATED function](related-function-dax.md) -[VALUES function](values-function-dax.md) +[Filter functions](filter-functions-dax.md) +[DISTINCT (column)](distinct-function-dax.md) +[FILTER function](filter-function-dax.md) +[RELATED function](related-function-dax.md) +[VALUES function](values-function-dax.md) diff --git a/query-languages/dax/distinctcount-function-dax.md b/query-languages/dax/distinctcount-function-dax.md index 4f8e3a153..61c754ace 100644 --- a/query-languages/dax/distinctcount-function-dax.md +++ b/query-languages/dax/distinctcount-function-dax.md @@ -1,39 +1,32 @@ --- description: "Learn more about: DISTINCTCOUNT" -title: "DISTINCTCOUNT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/21/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DISTINCTCOUNT function (DAX)" --- # DISTINCTCOUNT -Counts the number of distinct values in a column. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Counts the number of distinct values in a column. + +## Syntax + ```dax -DISTINCTCOUNT() +DISTINCTCOUNT() ``` - -### Parameters -|Term |Description| +### Parameters + +|Term |Description| |---------|---------| -|column | The column that contains the values to be counted | +|`column`| The column that contains the values to be counted | ## Return value -The number of distinct values in *column*. - +The number of distinct values in `column`. + ## Remarks -- The only argument allowed to this function is a column. You can use columns containing any type of data. When the function finds no rows to count, it returns a BLANK, otherwise it returns the count of distinct values. +- The only argument allowed to this function is a column. You can use columns containing any type of data. When the function finds no rows to count, it returns a BLANK, otherwise it returns the count of distinct values. - DISTINCTCOUNT function counts the BLANK value. To skip the BLANK value, use the [DISTINCTCOUNTNOBLANK](distinctcountnoblank-function-dax.md) function. @@ -41,29 +34,29 @@ The number of distinct values in *column*. ## Example -The following example shows how to count the number of distinct sales orders in the column ResellerSales_USD[SalesOrderNumber]. - +The following example shows how to count the number of distinct sales orders in the column ResellerSales_USD[SalesOrderNumber]. + ```dax -= DISTINCTCOUNT(ResellerSales_USD[SalesOrderNumber]) += DISTINCTCOUNT(ResellerSales_USD[SalesOrderNumber]) ``` -Using the above measure in a table with calendar year in the side and product category on top returns the following results: - +Using the above measure in a table with calendar year in the side and product category on top returns the following results: + |Row Labels|Accessories|Bikes|Clothing|Components|-|Grand Total| -|-----|-----|-----|-----|-----|-----|-----| -|2005|135|345|242|205||366| -|2006|356|850|644|702||1015| -|2007|531|1234|963|1138||1521| -|2008|293|724|561|601||894| -||||||1|1| -|**Grand Total**|**1315**|**3153**|**2410**|**2646**|**1**|**3797**| - -In the above example, note that the rows Grand Total numbers do not add up, this happens because the same order might contain line items, in the same order, from different product categories. - -## See also - -[COUNT function](count-function-dax.md) -[COUNTA function](counta-function-dax.md) -[COUNTAX function](countax-function-dax.md) -[COUNTX function](countx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +|-----|-----|-----|-----|-----|-----|-----| +|2005|135|345|242|205||366| +|2006|356|850|644|702||1015| +|2007|531|1234|963|1138||1521| +|2008|293|724|561|601||894| +||||||1|1| +|**Grand Total**|**1315**|**3153**|**2410**|**2646**|**1**|**3797**| + +In the above example, note that the rows Grand Total numbers do not add up, this happens because the same order might contain line items, in the same order, from different product categories. + +## Related content + +[COUNT function](count-function-dax.md) +[COUNTA function](counta-function-dax.md) +[COUNTAX function](countax-function-dax.md) +[COUNTX function](countx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/distinctcountnoblank-function-dax.md b/query-languages/dax/distinctcountnoblank-function-dax.md index fd4edbd2c..509f1146a 100644 --- a/query-languages/dax/distinctcountnoblank-function-dax.md +++ b/query-languages/dax/distinctcountnoblank-function-dax.md @@ -1,48 +1,41 @@ --- description: "Learn more about: DISTINCTCOUNTNOBLANK" -title: "DISTINCTCOUNTNOBLANK function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/21/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DISTINCTCOUNTNOBLANK function (DAX)" --- # DISTINCTCOUNTNOBLANK +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Counts the number of distinct values in a column. - -## Syntax - + +## Syntax + ```dax -DISTINCTCOUNTNOBLANK () +DISTINCTCOUNTNOBLANK() ``` - -### Parameters -|Term |Description| +### Parameters + +|Term |Description| |---------|---------| -|column | The column that contains the values to be counted | +|`column`| The column that contains the values to be counted | ## Return value -The number of distinct values in *column*. - -## Remarks +The number of distinct values in `column`. + +## Remarks - Unlike [DISTINCTCOUNT](distinctcount-function-dax.md) function, DISTINCTCOUNTNOBLANK does not count the BLANK value. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows how to count the number of distinct sales orders in the column ResellerSales_USD[SalesOrderNumber]. - +The following example shows how to count the number of distinct sales orders in the column ResellerSales_USD[SalesOrderNumber]. + ```dax -= DISTINCTCOUNT(ResellerSales_USD[SalesOrderNumber]) += DISTINCTCOUNT(ResellerSales_USD[SalesOrderNumber]) ``` DAX query @@ -59,6 +52,6 @@ EVALUATE |---------|---------| |2 | 3 | -## See also +## Related content [DISTINCTCOUNT](distinctcount-function-dax.md) diff --git a/query-languages/dax/divide-function-dax.md b/query-languages/dax/divide-function-dax.md index ad2141b33..c197b14c7 100644 --- a/query-languages/dax/divide-function-dax.md +++ b/query-languages/dax/divide-function-dax.md @@ -1,69 +1,62 @@ --- description: "Learn more about: DIVIDE" -title: "DIVIDE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/13/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "DIVIDE function (DAX)" --- # DIVIDE -Performs division and returns alternate result or BLANK() on division by 0. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Performs division and returns alternate result or BLANK() on division by 0. + +## Syntax + ```dax -DIVIDE(, [,]) +DIVIDE(, [,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|numerator|The dividend or number to divide.| -|denominator|The divisor or number to divide by.| -|alternateresult|(Optional) The value returned when division by zero results in an error. When not provided, the default value is BLANK().| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`numerator`|The dividend or number to divide.| +|`denominator`|The divisor or number to divide by.| +|`alternateresult`|(Optional) The value returned when division by zero results in an error. When not provided, the default value is BLANK().| + ## Return value -- A decimal number. - +- A decimal number. + ## Remarks -- Alternate result on divide by 0 must be a constant. +- Alternate result on divide by 0 must be a constant. - For best practices when using DIVIDE, see [DIVIDE function vs. divide operator (/) in DAX](best-practices/dax-divide-function-operator.md). - + ## Example -The following example returns 2.5. - +The following example returns 2.5. + ```dax -= DIVIDE(5,2) += DIVIDE(5,2) ``` - + ## Example 1 -The following example returns BLANK. - +The following example returns BLANK. + ```dax -= DIVIDE(5,0) += DIVIDE(5,0) ``` - + ## Example 2 -The following example returns 1. - +The following example returns 1. + ```dax -= DIVIDE(5,0,1) += DIVIDE(5,0,1) ``` - -## See also -[QUOTIENT function](quotient-function-dax.md) -[Math and Trig functions](math-and-trig-functions-dax.md) +## Related content + +[QUOTIENT function](quotient-function-dax.md) +[Math and Trig functions](math-and-trig-functions-dax.md) diff --git a/query-languages/dax/docfx.json b/query-languages/dax/docfx.json index 617aac45d..a88a314e3 100644 --- a/query-languages/dax/docfx.json +++ b/query-languages/dax/docfx.json @@ -36,10 +36,410 @@ "overwrite": [], "externalReference": [], "globalMetadata": { + "feedback_system": "Standard", "breadcrumb_path": "/dax/breadcrumb/toc.json", - "extendBreadcrumb": true, + "uhfHeaderId": "MSDocsHeader-DAX", "titleSuffix": "DAX", - "show_latex": true + "ms.service": "powerbi", + "ms.subservice": "dax", + "ms.topic": "reference", + "ms.author": "jterh", + "author": "jeroenterheerdt", + "recommendations": "false", + "searchScope": ["Power BI", "Analysis Services", "DAX formula language"], + "ms.date": "10/20/2023", + "show_latex": true, + "contributors_to_exclude": [ "mikekinsman" ], + "no-loc": [ + "ABS", + "ACCRINT", + "ACCRINTM", + "ACOS", + "ACOSH", + "ACOT", + "ACOTH", + "ADDCOLUMNS", + "ADDMISSINGITEMS", + "ALL", + "ALLCROSSFILTERED", + "ALLEXCEPT", + "ALLNOBLANKROW", + "ALLSELECTED", + "ALPHABETICAL", + "AMORDEGRC", + "AMORLINC", + "AND", + "APPROXIMATEDISTINCTCOUNT", + "ASC", + "ASIN", + "ASINH", + "ATAN", + "ATANH", + "AVERAGE", + "AVERAGEA", + "AVERAGEX", + "BETA.DIST", + "BETA.INV", + "BITAND", + "BITLSHIFT", + "BITOR", + "BITRSHIFT", + "BITXOR", + "BLANK", + "CALCULATE", + "CALCULATETABLE", + "CALENDAR", + "CALENDARAUTO", + "CEILING", + "CHISQ.DIST", + "CHISQ.DIST.RT", + "CHISQ.INV", + "CHISQ.INV.RT", + "CLOSINGBALANCEMONTH", + "CLOSINGBALANCEQUARTER", + "CLOSINGBALANCEYEAR", + "COALESCE", + "COLLAPSE", + "COLLAPSEALL", + "COLUMNSTATISTICS", + "COMBIN", + "COMBINA", + "COMBINEVALUES", + "CONCATENATE", + "CONCATENATEX", + "CONFIDENCE.NORM", + "CONFIDENCE.T", + "CONTAINS", + "CONTAINSSTRING", + "CONTAINSSTRINGEXACT", + "CONVERT", + "COS", + "COSH", + "COT", + "COTH", + "COUNT", + "COUNTA", + "COUNTAX", + "COUNTBLANK", + "COUNTROWS", + "COUNTX", + "COUPDAYBS", + "COUPDAYS", + "COUPDAYSNC", + "COUPNCD", + "COUPNUM", + "COUPPCD", + "CROSSFILTER", + "CROSSJOIN", + "CUMIPMT", + "CUMPRINC", + "CURRENCY", + "CURRENTGROUP", + "CUSTOMDATA", + "DATATABLE", + "DATE", + "DATEADD", + "DATEDIFF", + "DATESBETWEEN", + "DATESINPERIOD", + "DATESMTD", + "DATESQTD", + "DATESYTD", + "DATEVALUE", + "Videos", + "DAX", + "DAY", + "DB", + "DDB", + "DEFINE", + "DEGREES", + "DESC", + "DETAILROWS", + "DISC", + "DISTINCT (column)", + "DISTINCT (table)", + "DISTINCTCOUNT", + "DISTINCTCOUNTNOBLANK", + "DIVIDE", + "DOLLARDE", + "DOLLARFR", + "DURATION", + "EARLIER", + "EARLIEST", + "EDATE", + "EFFECT", + "ENDOFMONTH", + "ENDOFQUARTER", + "ENDOFYEAR", + "EOMONTH", + "ERROR", + "EVALUATE", + "EVALUATEANDLOG", + "EVEN", + "EXACT", + "EXCEPT", + "EXP", + "EXPAND", + "EXPANDALL", + "EXPON.DIST", + "FACT", + "FALSE", + "FILTER", + "FILTERS", + "FIND", + "FIRST", + "FIRSTDATE", + "FIRSTNONBLANK", + "FIRSTNONBLANKVALUE", + "FIXED", + "FLOOR", + "FORMAT", + "FV", + "GCD", + "GENERATE", + "GENERATEALL", + "GENERATESERIES", + "GEOMEAN", + "GEOMEANX", + "GROUPBY", + "HASONEFILTER", + "HASONEVALUE", + "HIGHESTPARENT", + "HOUR", + "IF.EAGER", + "IF", + "IFERROR", + "IGNORE", + "INDEX", + "INT", + "INTERSECT", + "INTRATE", + "IPMT", + "ISAFTER", + "ISATLEVEL", + "ISBLANK", + "ISCROSSFILTERED", + "ISEMPTY", + "ISERROR", + "ISEVEN", + "ISFILTERED", + "ISINSCOPE", + "ISLOGICAL", + "ISNONTEXT", + "ISNUMBER", + "ISO.CEILING", + "ISODD", + "ISONORAFTER", + "ISPMT", + "ISSELECTEDMEASURE", + "ISSUBTOTAL", + "ISTEXT", + "KEEPFILTERS", + "LAST", + "LASTDATE", + "LASTNONBLANK", + "LASTNONBLANKVALUE", + "LOWESTPARENT", + "LCM", + "LEFT", + "LEN", + "LINEST", + "LINESTX", + "LN", + "LOG", + "LOG10", + "LOOKUPVALUE", + "LOWER", + "MATCHBY", + "MAX", + "MAXA", + "MAXX", + "MDURATION", + "MEASURE", + "MEDIAN", + "MEDIANX", + "MID", + "MIN", + "MINA", + "MINUTE", + "MINX", + "MOD", + "MONTH", + "MOVINGAVERAGE", + "MROUND", + "NATURALINNERJOIN", + "NATURALLEFTOUTERJOIN", + "NETWORKDAYS", + "NEXT", + "NEXTDAY", + "NEXTMONTH", + "NEXTQUARTER", + "NEXTYEAR", + "NOMINAL", + "NONE", + "NONVISUAL", + "NORM.DIST", + "NORM.INV", + "NORM.S.DIST", + "NORM.S.INV", + "NOT", + "NOW", + "NPER", + "ODD", + "ODDFPRICE", + "ODDFYIELD", + "ODDLPRICE", + "ODDLYIELD", + "OFFSET", + "OPENINGBALANCEMONTH", + "OPENINGBALANCEQUARTER", + "OPENINGBALANCEYEAR", + "OR", + "ORDERBY", + "ORDER BY", + "PARALLELPERIOD", + "PARTITIONBY", + "PATH", + "PATHCONTAINS", + "PATHITEM", + "PATHITEMREVERSE", + "PATHLENGTH", + "PDURATION", + "PERCENTILE.EXC", + "PERCENTILE.INC", + "PERCENTILEX.EXC", + "PERCENTILEX.INC", + "PERMUT", + "PI", + "PMT", + "POISSON.DIST", + "POWER", + "PPMT", + "PREVIOUS", + "PREVIOUSDAY", + "PREVIOUSMONTH", + "PREVIOUSQUARTER", + "PREVIOUSYEAR", + "PRICE", + "PRICEDISC", + "PRICEMAT", + "PRODUCT", + "PRODUCTX", + "PV", + "QUARTER", + "QUOTIENT", + "RADIANS", + "RAND", + "RANDBETWEEN", + "RANGE", + "RANK.EQ", + "RANK", + "RANKX", + "RATE", + "RECEIVED", + "RELATED", + "RELATEDTABLE", + "REMOVEFILTERS", + "REPLACE", + "REPT", + "RIGHT", + "ROLLUP", + "ROLLUPADDISSUBTOTAL", + "ROLLUPGROUP", + "ROLLUPISSUBTOTAL", + "ROUND", + "ROUNDDOWN", + "ROUNDUP", + "ROWNUMBER", + "RRI", + "RUNNINGSUM", + "SAMEPERIODLASTYEAR", + "SAMPLE", + "SAMPLEAXISWITHLOCALMINMAX", + "SEARCH", + "SECOND", + "SELECTCOLUMNS", + "SELECTEDMEASURE", + "SELECTEDMEASUREFORMATSTRING", + "SELECTEDMEASURENAME", + "SELECTEDVALUE", + "SIGN", + "SIN", + "SINH", + "SLN", + "SQRT", + "SQRTPI", + "START AT", + "STARTOFMONTH", + "STARTOFQUARTER", + "STARTOFYEAR", + "Statements", + "STDEV.P", + "STDEV.S", + "STDEVX.P", + "STDEVX.S", + "SUBSTITUTE", + "SUBSTITUTEWITHINDEX", + "SUM", + "SUMMARIZE", + "SUMMARIZECOLUMNS", + "SUMX", + "SWITCH", + "SYD", + "T.DIST.2T", + "T.DIST", + "T.DIST.RT", + "T.INV.2T", + "T.INV", + "TAN", + "TANH", + "TBILLEQ", + "TBILLPRICE", + "TBILLYIELD", + "TIME", + "TIMEVALUE", + "TOCSV", + "TODAY", + "TOJSON", + "TOPN", + "TOTALMTD", + "TOTALQTD", + "TOTALYTD", + "TREATAS", + "TRIM", + "TRUE", + "TRUNC", + "UNICHAR", + "UNICODE", + "UNION", + "UPPER", + "USERCULTURE", + "USERELATIONSHIP", + "USERNAME", + "USEROBJECTID", + "USERPRINCIPALNAME", + "UTCNOW", + "UTCTODAY", + "VALUE", + "VALUES", + "VAR", + "VAR.P", + "VAR.S", + "VARX.P", + "VARX.S", + "VDB", + "WEEKDAY", + "WEEKNUM", + "WINDOW", + "XIRR", + "XNPV", + "YEAR", + "YEARFRAC", + "YIELD", + "YIELDDISC", + "YIELDMAT" + ] + }, "fileMetadata": {}, "template": [], diff --git a/query-languages/dax/dollarde-function-dax.md b/query-languages/dax/dollarde-function-dax.md index 8417a6a62..5730906fc 100644 --- a/query-languages/dax/dollarde-function-dax.md +++ b/query-languages/dax/dollarde-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: DOLLARDE" -title: "DOLLARDE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "DOLLARDE function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # DOLLARDE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Converts a dollar price expressed as an integer part and a fraction part, such as 1.02, into a dollar price expressed as a decimal number. Fractional dollar numbers are sometimes used for security prices. ## Syntax @@ -24,14 +18,14 @@ DOLLARDE(, ) ### Parameters -|Term|Definition| -|--------|--------------| -|fractional_dollar|A number expressed as an integer part and a fraction part, separated by a decimal symbol.| -|fraction|The integer to use in the denominator of the fraction.| +|Term|Definition| +|--------|--------------| +|`fractional_dollar`|A number expressed as an integer part and a fraction part, separated by a decimal symbol.| +|`fraction`|The integer to use in the denominator of the fraction.| ## Return Value -The decimal value of *fractional_dollar*. +The decimal value of `fractional_dollar`. ## Remarks diff --git a/query-languages/dax/dollarfr-function-dax.md b/query-languages/dax/dollarfr-function-dax.md index eddf0b141..d475f2d58 100644 --- a/query-languages/dax/dollarfr-function-dax.md +++ b/query-languages/dax/dollarfr-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: DOLLARFR" -title: "DOLLARFR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "DOLLARFR function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # DOLLARFR +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Converts a dollar price expressed as a decimal number into a dollar price expressed as an integer part and a fraction part, such as 1.02. Fractional dollar numbers are sometimes used for security prices. ## Syntax @@ -24,14 +18,14 @@ DOLLARFR(, ) ### Parameters -|Term|Definition| -|--------|--------------| -|decimal_dollar|A decimal number.| -|fraction|The integer to use in the denominator of the fraction.| +|Term|Definition| +|--------|--------------| +|`decimal_dollar`|A decimal number.| +|`fraction`|The integer to use in the denominator of the fraction.| ## Return Value -The fractional value of *decimal_dollar*, expressed as an integer part and a fraction part. +The fractional value of `decimal_dollar`, expressed as an integer part and a fraction part. ## Remarks diff --git a/query-languages/dax/duration-function-dax.md b/query-languages/dax/duration-function-dax.md index 614342ced..ec68b6a58 100644 --- a/query-languages/dax/duration-function-dax.md +++ b/query-languages/dax/duration-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: DURATION" -title: "DURATION function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "DURATION function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # DURATION +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the Macauley duration for an assumed par value of \\$100. Duration is defined as the weighted average of the present value of cash flows, and is used as a measure of a bond price's response to changes in yield. ## Syntax @@ -24,18 +18,18 @@ DURATION(, , , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|coupon|The security's annual coupon rate.| -|yld|The security's annual yield.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`coupon`|The security's annual coupon rate.| +|`yld`|The security's annual yield.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/earlier-function-dax.md b/query-languages/dax/earlier-function-dax.md index 8faf7f37f..4ec485021 100644 --- a/query-languages/dax/earlier-function-dax.md +++ b/query-languages/dax/earlier-function-dax.md @@ -1,129 +1,122 @@ --- description: "Learn more about: EARLIER" -title: "EARLIER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "EARLIER function (DAX)" --- # EARLIER -Returns the current value of the specified column in an outer evaluation pass of the mentioned column. - -EARLIER is useful for nested calculations where you want to use a certain value as an input and produce calculations based on that input. In Microsoft Excel, you can do such calculations only within the context of the current row; however, in DAX you can store the value of the input and then make calculation using data from the entire table. - -EARLIER is mostly used in the context of calculated columns. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Returns the current value of the specified column in an outer evaluation pass of the mentioned column. + +EARLIER is useful for nested calculations where you want to use a certain value as an input and produce calculations based on that input. In Microsoft Excel, you can do such calculations only within the context of the current row; however, in DAX you can store the value of the input and then make calculation using data from the entire table. + +EARLIER is mostly used in the context of calculated columns. + +## Syntax + ```dax -EARLIER(, ) +EARLIER(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|A column or expression that resolves to a column.| -|num|(Optional) A positive number to the outer evaluation pass.

The next evaluation level out is represented by 1; two levels out is represented by 2 and so on.

When omitted default value is 1.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A column or expression that resolves to a column.| +|`num`|(Optional) A positive number to the outer evaluation pass.

The next evaluation level out is represented by 1; two levels out is represented by 2 and so on.

When omitted default value is 1.| + ## Return value -The current value of row, from **column**, at **number** of outer evaluation passes. - +The current value of row, from `column`, at `number` of outer evaluation passes. + ## Exceptions -Description of errors - +Description of errors + ## Remarks -- **EARLIER** succeeds if there is a row context prior to the beginning of the table scan. Otherwise it returns an error. - -- The performance of **EARLIER** might be slow because it theoretically, it might have to perform a number of operations that is close to the total number of rows (in the column) times the same number (depending on the syntax of the expression). For example if you have 10 rows in the column, approximately a 100 operations could be required; if you have 100 rows then close to 10,000 operations might be performed. +- `EARLIER` succeeds if there is a row context prior to the beginning of the table scan. Otherwise it returns an error. + +- The performance of `EARLIER` might be slow because theoretically, it might have to perform a number of operations that is close to the total number of rows (in the column) times the same number (depending on the syntax of the expression). For example if you have 10 rows in the column, approximately a 100 operations could be required; if you have 100 rows then close to 10,000 operations might be performed. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -> [!NOTE] -> In practice, the VertiPaq in-memory analytics engine performs optimizations to reduce the actual number of calculations, but you should be cautious when creating formulas that involve recursion. - +> [!NOTE] +> In practice, the VertiPaq in-memory analytics engine performs optimizations to reduce the actual number of calculations, but you should be cautious when creating formulas that involve recursion. + ## Example -To illustrate the use of EARLIER, it is necessary to build a scenario that calculates a rank value and then uses that rank value in other calculations. - -The following example is based on this simple table, **ProductSubcategory**, which shows the total sales for each ProductSubcategory. - -The final table, including the ranking column is shown here. - -|ProductSubcategoryKey|EnglishProductSubcategoryName|TotalSubcategorySales|SubcategoryRanking| -|-------------------------|---------------------------------|-------------------------|----------------------| -|18|Bib-Shorts|$156,167.88|18| -|26|Bike Racks|$220,720.70|14| -|27|Bike Stands|$35,628.69|30| -|28|Bottles and Cages|$59,342.43|24| -|5|Bottom Brackets|$48,643.47|27| -|6|Brakes|$62,113.16|23| -|19|Caps|$47,934.54|28| -|7|Chains|$8,847.08|35| -|29|Cleaners|$16,882.62|32| -|8|Cranksets|$191,522.09|15| -|9|Derailleurs|$64,965.33|22| -|30|Fenders|$41,974.10|29| -|10|Forks|$74,727.66|21| -|20|Gloves|$228,353.58|12| -|4|Handlebars|$163,257.06|17| -|11|Headsets|$57,659.99|25| -|31|Helmets|$451,192.31|9| -|32|Hydration Packs|$96,893.78|20| -|21|Jerseys|$699,429.78|7| -|33|Lights||36| -|34|Locks|$15,059.47|33| -|1|Mountain Bikes|$34,305,864.29|2| -|12|Mountain Frames|$4,511,170.68|4| -|35|Panniers||36| -|13|Pedals|$140,422.20|19| -|36|Pumps|$12,695.18|34| -|2|Road Bikes|$40,551,696.34|1| -|14|Road Frames|$3,636,398.71|5| -|15|Saddles|$52,526.47|26| -|22|Shorts|$385,707.80|10| -|23|Socks|$28,337.85|31| -|24|Tights|$189,179.37|16| -|37|Tires and Tubes|$224,832.81|13| -|3|Touring Bikes|$13,334,864.18|3| -|16|Touring Frames|$1,545,344.02|6| -|25|Vests|$240,990.04|11| -|17|Wheels|$648,240.04|8| - +To illustrate the use of EARLIER, it is necessary to build a scenario that calculates a rank value and then uses that rank value in other calculations. + +The following example is based on this simple table, `ProductSubcategory`, which shows the total sales for each ProductSubcategory. + +The final table, including the ranking column is shown here. + +|ProductSubcategoryKey|EnglishProductSubcategoryName|TotalSubcategorySales|SubcategoryRanking| +|-------------------------|---------------------------------|-------------------------|----------------------| +|18|Bib-Shorts|$156,167.88|18| +|26|Bike Racks|$220,720.70|14| +|27|Bike Stands|$35,628.69|30| +|28|Bottles and Cages|$59,342.43|24| +|5|Bottom Brackets|$48,643.47|27| +|6|Brakes|$62,113.16|23| +|19|Caps|$47,934.54|28| +|7|Chains|$8,847.08|35| +|29|Cleaners|$16,882.62|32| +|8|Cranksets|$191,522.09|15| +|9|Derailleurs|$64,965.33|22| +|30|Fenders|$41,974.10|29| +|10|Forks|$74,727.66|21| +|20|Gloves|$228,353.58|12| +|4|Handlebars|$163,257.06|17| +|11|Headsets|$57,659.99|25| +|31|Helmets|$451,192.31|9| +|32|Hydration Packs|$96,893.78|20| +|21|Jerseys|$699,429.78|7| +|33|Lights||36| +|34|Locks|$15,059.47|33| +|1|Mountain Bikes|$34,305,864.29|2| +|12|Mountain Frames|$4,511,170.68|4| +|35|Panniers||36| +|13|Pedals|$140,422.20|19| +|36|Pumps|$12,695.18|34| +|2|Road Bikes|$40,551,696.34|1| +|14|Road Frames|$3,636,398.71|5| +|15|Saddles|$52,526.47|26| +|22|Shorts|$385,707.80|10| +|23|Socks|$28,337.85|31| +|24|Tights|$189,179.37|16| +|37|Tires and Tubes|$224,832.81|13| +|3|Touring Bikes|$13,334,864.18|3| +|16|Touring Frames|$1,545,344.02|6| +|25|Vests|$240,990.04|11| +|17|Wheels|$648,240.04|8| + ## Creating a Rank Value -One way to obtain a rank value for a given value in a row is to count the number of rows, in the same table, that have a value larger (or smaller) than the one that is being compared. This technique returns a blank or zero value for the highest value in the table, whereas equal values will have the same rank value and next value (after the equal values) will have a non consecutive rank value. See the sample below. - -A new calculated column, **SubCategorySalesRanking**, is created by using the following formula. - +One way to obtain a rank value for a given value in a row is to count the number of rows, in the same table, that have a value larger (or smaller) than the one that is being compared. This technique returns a blank or zero value for the highest value in the table, whereas equal values will have the same rank value and next value (after the equal values) will have a non consecutive rank value. See the sample below. + +A new calculated column, **SubCategorySalesRanking**, is created by using the following formula. + ```dax -= COUNTROWS(FILTER(ProductSubcategory, EARLIER(ProductSubcategory[TotalSubcategorySales])) +EARLIEST() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|A reference to a column.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A reference to a column.| + ## Return value -A column with filters removed. - +A column with filters removed. + ## Remarks -- The EARLIEST function is similar to EARLIER, but lets you specify one additional level of recursion. +- The EARLIEST function is similar to EARLIER, but lets you specify one additional level of recursion. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The current sample data does not support this scenario. - +The current sample data does not support this scenario. + ```dax -= EARLIEST() += EARLIEST() ``` - -## See also -[EARLIER function](earlier-function-dax.md) -[Filter functions](filter-functions-dax.md) +## Related content + +[EARLIER function](earlier-function-dax.md) +[Filter functions](filter-functions-dax.md) diff --git a/query-languages/dax/edate-function-dax.md b/query-languages/dax/edate-function-dax.md index c95e6ec43..62dfaafa6 100644 --- a/query-languages/dax/edate-function-dax.md +++ b/query-languages/dax/edate-function-dax.md @@ -1,60 +1,53 @@ --- description: "Learn more about: EDATE" -title: "EDATE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "EDATE function (DAX)" --- # EDATE -Returns the date that is the indicated number of months before or after the start date. Use EDATE to calculate maturity dates or due dates that fall on the same day of the month as the date of issue. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the date that is the indicated number of months before or after the start date. Use EDATE to calculate maturity dates or due dates that fall on the same day of the month as the date of issue. + +## Syntax + ```dax -EDATE(, ) +EDATE(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|start_date|A date in **datetime** or **text** format that represents the start date.| -|months|An integer that represents the number of months before or after **start_date**.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`start_date`|A date in `datetime` or `text` format that represents the start date.| +|`months`|An integer that represents the number of months before or after `start_date`.| + ## Return value -A date (**datetime**). - +A date (`datetime`). + ## Remarks -- In contrast to Microsoft Excel, which stores dates as sequential serial numbers, DAX works with dates in a **datetime** format. Dates stored in other formats are converted implicitly. - -- If **start_date** is not a valid date, EDATE returns an error. Make sure that the column reference or date that you supply as the first argument is a date. - -- If **months** is not an integer, it is truncated. - -- When the date argument is a text representation of the date, the EDATE function uses the locale and date time settings of the client computer to understand the text value in order to perform the conversion. If the current date time settings represent a date in the format of Month/Day/Year, then the following string "1/8/2009" is interpreted as a datetime value equivalent to January 8th of 2009. However, if the current date time settings represent a date in the format of Day/Month/Year, the same string would be interpreted as a datetime value equivalent to August 1st of 2009. - -- If the requested date is past the last day of the corresponding month, then the last day of the month is returned. For example, the following functions: EDATE("2009-01-29", 1), EDATE("2009-01-30", 1), EDATE("2009-01-31", 1) return February 28th of 2009; that corresponds to one month after the start date. - +- In contrast to Microsoft Excel, which stores dates as sequential serial numbers, DAX works with dates in a `datetime` format. Dates stored in other formats are converted implicitly. + +- If `start_date` is not a valid date, EDATE returns an error. Make sure that the column reference or date that you supply as the first argument is a date. + +- If `months` is not an integer, it is truncated. + +- When the date argument is a text representation of the date, the EDATE function uses the locale and date time settings of the client computer to understand the text value in order to perform the conversion. If the current date time settings represent a date in the format of Month/Day/Year, then the following string "1/8/2009" is interpreted as a datetime value equivalent to January 8th of 2009. However, if the current date time settings represent a date in the format of Day/Month/Year, the same string would be interpreted as a datetime value equivalent to August 1st of 2009. + +- If the requested date is past the last day of the corresponding month, then the last day of the month is returned. For example, the following functions: EDATE("2009-01-29", 1), EDATE("2009-01-30", 1), EDATE("2009-01-31", 1) return February 28th of 2009; that corresponds to one month after the start date. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example returns the date three months after the order date, which is stored in the column [TransactionDate]. - +The following example returns the date three months after the order date, which is stored in the column [TransactionDate]. + ```dax -= EDATE([TransactionDate],3) += EDATE([TransactionDate],3) ``` - -## See also -[EOMONTH function](eomonth-function-dax.md) -[Date and time functions](date-and-time-functions-dax.md) +## Related content + +[EOMONTH function](eomonth-function-dax.md) +[Date and time functions](date-and-time-functions-dax.md) diff --git a/query-languages/dax/effect-function-dax.md b/query-languages/dax/effect-function-dax.md index 0f3d93c65..5223ed9eb 100644 --- a/query-languages/dax/effect-function-dax.md +++ b/query-languages/dax/effect-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: EFFECT" -title: "EFFECT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "EFFECT function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # EFFECT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the effective annual interest rate, given the nominal annual interest rate and the number of compounding periods per year. ## Syntax @@ -24,10 +18,10 @@ EFFECT(, ) ### Parameters -|Term|Definition| -|--------|--------------| -|nominal_rate|The nominal interest rate.| -|npery|The number of compounding periods per year.| +|Term|Definition| +|--------|--------------| +|`nominal_rate`|The nominal interest rate.| +|`npery`|The number of compounding periods per year.| ## Return Value diff --git a/query-languages/dax/endofmonth-function-dax.md b/query-languages/dax/endofmonth-function-dax.md index 83b6b0796..26d84e35b 100644 --- a/query-languages/dax/endofmonth-function-dax.md +++ b/query-languages/dax/endofmonth-function-dax.md @@ -1,59 +1,52 @@ --- description: "Learn more about: ENDOFMONTH" -title: "ENDOFMONTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ENDOFMONTH function (DAX)" --- # ENDOFMONTH -Returns the last date of the month in the current context for the specified column of dates. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns the last date of the month in the current context for the specified column of dates. + +## Syntax + ```dax -ENDOFMONTH() +ENDOFMONTH() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| + ## Return value -A table containing a single column and single row with a date value. - +A table containing a single column and single row with a date value. + ## 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](calculate-function-dax.md). - +- 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](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that returns the end of the month, for the current context. +The following sample formula creates a measure that returns the end of the month, for the current context. ```dax -= ENDOFMONTH(DateTime[DateKey]) += ENDOFMONTH(DateTime[DateKey]) ``` - -## See also - -[Date and time functions](date-and-time-functions-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[ENDOFYEAR function](endofyear-function-dax.md) -[ENDOFQUARTER function](endofquarter-function-dax.md) - + +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[ENDOFYEAR function](endofyear-function-dax.md) +[ENDOFQUARTER function](endofquarter-function-dax.md) + diff --git a/query-languages/dax/endofquarter-function-dax.md b/query-languages/dax/endofquarter-function-dax.md index 66833cfc4..18899d913 100644 --- a/query-languages/dax/endofquarter-function-dax.md +++ b/query-languages/dax/endofquarter-function-dax.md @@ -1,58 +1,51 @@ --- description: "Learn more about: ENDOFQUARTER" -title: "ENDOFQUARTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ENDOFQUARTER function (DAX)" --- # ENDOFQUARTER -Returns the last date of the quarter in the current context for the specified column of dates. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns the last date of the quarter in the current context for the specified column of dates. + +## Syntax + ```dax -ENDOFQUARTER() +ENDOFQUARTER() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| + ## Return value -A table containing a single column and single row with a date value. - +A table containing a single column and single row with a date value. + ## 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](calculate-function-dax.md). - +- 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](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that returns the end of the quarter, for the current context. - +The following sample formula creates a measure that returns the end of the quarter, for the current context. + ```dax -= ENDOFQUARTER(DateTime[DateKey]) += ENDOFQUARTER(DateTime[DateKey]) ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[ENDOFYEAR function](endofyear-function-dax.md) -[ENDOFMONTH function](endofmonth-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[ENDOFYEAR function](endofyear-function-dax.md) +[ENDOFMONTH function](endofmonth-function-dax.md) diff --git a/query-languages/dax/endofyear-function-dax.md b/query-languages/dax/endofyear-function-dax.md index 4bdb9ca14..b568c1107 100644 --- a/query-languages/dax/endofyear-function-dax.md +++ b/query-languages/dax/endofyear-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: ENDOFYEAR" -title: "ENDOFYEAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ENDOFYEAR function (DAX)" --- # ENDOFYEAR -Returns the last date of the year in the current context for the specified column of dates. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns the last date of the year in the current context for the specified column of dates. + +## Syntax + ```dax -ENDOFYEAR( [,]) +ENDOFYEAR( [,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| -|year_end_date|(optional) A literal string with a date that defines the year-end date. The default is December 31.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| +|`year_end_date`|(optional) A literal string with a date that defines the year-end date. The default is December 31.| + ## Return value -A table containing a single column and single row with a date value. - +A table containing a single column and single row with a date value. + ## 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](calculate-function-dax.md). - -- The **year_end_date** parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. - +- 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](calculate-function-dax.md). + +- The `year_end_date` parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that returns the end of the fiscal year that ends on June 30, for the current context. +The following sample formula creates a measure that returns the end of the fiscal year that ends on June 30, for the current context. ```dax -= ENDOFYEAR(DateTime[DateKey],"06/30/2004") += ENDOFYEAR(DateTime[DateKey],"06/30/2004") ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[ENDOFMONTH function](endofmonth-function-dax.md) -[ENDOFQUARTER function](endofquarter-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[ENDOFMONTH function](endofmonth-function-dax.md) +[ENDOFQUARTER function](endofquarter-function-dax.md) diff --git a/query-languages/dax/eomonth-function-dax.md b/query-languages/dax/eomonth-function-dax.md index 8c4ab24e4..c6674b0eb 100644 --- a/query-languages/dax/eomonth-function-dax.md +++ b/query-languages/dax/eomonth-function-dax.md @@ -1,60 +1,53 @@ --- description: "Learn more about: EOMONTH" -title: "EOMONTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "EOMONTH function (DAX)" --- # EOMONTH -Returns the date in **datetime** format of the last day of the month, before or after a specified number of months. Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the date in `datetime` format of the last day of the month, before or after a specified number of months. Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. + +## Syntax + ```dax -EOMONTH(, ) +EOMONTH(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|start_date|The start date in **datetime** format, or in an accepted text representation of a date.| -|months|A number representing the number of months before or after the **start_date**. **Note:** If you enter a number that is not an integer, the number is rounded up or down to the nearest integer.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`start_date`|The start date in `datetime` format, or in an accepted text representation of a date.| +|`months`|A number representing the number of months before or after the `start_date`. **Note:** If you enter a number that is not an integer, the number is rounded up or down to the nearest integer.| + ## Return value -A date (**datetime**). - +A date (`datetime`). + ## Remarks -- In contrast to Microsoft Excel, which stores dates as sequential serial numbers, DAX works with dates in a **datetime** format. The EOMONTH function can accept dates in other formats, with the following restrictions: - -- If **start_date** is not a valid date, EOMONTH returns an error. - -- If **start_date** is a numeric value that is not in a **datetime** format, EOMONTH will convert the number to a date. To avoid unexpected results, convert the number to a **datetime** format before using the EOMONTH function. - -- If **start_date** plus months yields an invalid date, EOMONTH returns an error. Dates before March 1st of 1900 and after December 31st of 9999 are invalid. - -- When the date argument is a text representation of the date, the EDATE function uses the locale and date time settings, of the client computer, to understand the text value in order to perform the conversion. If current date time settings represent a date in the format of Month/Day/Year, then the following string "1/8/2009" is interpreted as a datetime value equivalent to January 8th of 2009. However, if the current date time settings represent a date in the format of Day/Month/Year, the same string would be interpreted as a datetime value equivalent to August 1st of 2009. - +- In contrast to Microsoft Excel, which stores dates as sequential serial numbers, DAX works with dates in a `datetime` format. The EOMONTH function can accept dates in other formats, with the following restrictions: + +- If `start_date` is not a valid date, EOMONTH returns an error. + +- If `start_date` is a numeric value that is not in a `datetime` format, EOMONTH will convert the number to a date. To avoid unexpected results, convert the number to a `datetime` format before using the EOMONTH function. + +- If `start_date` plus months yields an invalid date, EOMONTH returns an error. Dates before March 1st of 1900 and after December 31st of 9999 are invalid. + +- When the date argument is a text representation of the date, the EDATE function uses the locale and date time settings, of the client computer, to understand the text value in order to perform the conversion. If current date time settings represent a date in the format of Month/Day/Year, then the following string "1/8/2009" is interpreted as a datetime value equivalent to January 8th of 2009. However, if the current date time settings represent a date in the format of Day/Month/Year, the same string would be interpreted as a datetime value equivalent to August 1st of 2009. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following expression returns May 31, 2008, because the **months** argument is rounded to 2. - +The following expression returns May 31, 2008, because the `months` argument is rounded to 2. + ```dax -= EOMONTH("March 3, 2008",1.5) += EOMONTH("March 3, 2008",1.5) ``` - -## See also -[EDATE function](edate-function-dax.md) -[Date and time functions](date-and-time-functions-dax.md) +## Related content + +[EDATE function](edate-function-dax.md) +[Date and time functions](date-and-time-functions-dax.md) diff --git a/query-languages/dax/error-function.md b/query-languages/dax/error-function-dax.md similarity index 75% rename from query-languages/dax/error-function.md rename to query-languages/dax/error-function-dax.md index 252298d9d..a2d337ab7 100644 --- a/query-languages/dax/error-function.md +++ b/query-languages/dax/error-function-dax.md @@ -1,36 +1,29 @@ --- description: "Learn more about: ERROR" -title: "ERROR function | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/05/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ERROR function" --- # ERROR -Raises an error with an error message. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Raises an error with an error message. + +## Syntax + ```dax -ERROR() +ERROR() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|A text string containing an error message.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|A text string containing an error message.| + ## Return value None - + ## Remarks - The ERROR function can be placed in a DAX expression anywhere a scalar value is expected. @@ -76,14 +69,14 @@ Returns the following table: DimProduct[Color] |[Measure] ---------|--------- Black | Black -Blue | Blue +Blue | Blue Grey | Grey Multi | Multi NA | NA Red | Red Silver | Silver Silver\Black | Silver\Black -White | White +White | White Yellow | Yellow Because Magenta is not one of the product colors, the ERROR function is not executed. diff --git a/query-languages/dax/evaluate-statement-dax.md b/query-languages/dax/evaluate-statement-dax.md index b2d39c80b..136c516ab 100644 --- a/query-languages/dax/evaluate-statement-dax.md +++ b/query-languages/dax/evaluate-statement-dax.md @@ -1,52 +1,46 @@ --- description: "Learn more about: EVALUATE" -title: "EVALUATE keyword (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "EVALUATE keyword (DAX)" --- # EVALUATE - -A statement containing a table expression required in a [DAX query](dax-queries.md). -## Syntax - +Introduces a statement containing a table expression required in a [DAX query](dax-queries.md). + +## Syntax + ```dax -EVALUATE
+EVALUATE
``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|A table expression| - + +## Parameters + +|Term|Definition| +|--------|--------------| +|`table`|A table expression| + ## Return value The result of a table expression. ## Remarks -A query can contain multiple EVALUATE statements. +- A DAX query can contain multiple EVALUATE statements. + +- To learn more about how EVALUATE statements are used, see [DAX queries](dax-queries.md). ## Example ```dax -EVALUATE( +EVALUATE 'Internet Sales' - ) ``` Returns all rows and columns from the Internet Sales table, as a table. - -## See also -[DAX queries](dax-queries.md) -[DEFINE](define-statement-dax.md) +## Related content + [ORDER BY](orderby-statement-dax.md) +[START AT](startat-statement-dax.md) +[DEFINE](define-statement-dax.md) +[VAR](var-dax.md) +[DAX queries](dax-queries.md) diff --git a/query-languages/dax/evaluateandlog-function-dax.md b/query-languages/dax/evaluateandlog-function-dax.md new file mode 100644 index 000000000..99cbae94a --- /dev/null +++ b/query-languages/dax/evaluateandlog-function-dax.md @@ -0,0 +1,146 @@ +--- +description: "Learn more about: EVALUATEANDLOG" +title: "EVALUATEANDLOG function (DAX)" +--- +# EVALUATEANDLOG + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the value of the first argument and logs it in a DAX Evaluation Log profiler event. This function is fully functional in Power BI Desktop only. It acts as a simple passthrough function in other environments. + +## Syntax + +```dax +EVALUATEANDLOG(, [Label], [MaxRows]) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Value`|Any scalar expression or table expression to be evaluated and logged.| +|`Label`|(Optional) A constant string included in both the json text and the Label column of the DAX Evaluation Log event that can be used to easily identify an instance of the function call.| +|`MaxRows`|(Optional) The maximum number of rows in the json text of the DAX Evaluation Log event when the first argument is a table expression. Default is 10.| + +## Return value + +The value of the first argument. + +The JSON structure logged in a DAX Evaluation Log profiler event includes: + +- `expression` is the text version of the first argument. +- `label` is the Label parameter when specified in the expression. +- `inputs` is a list of columns in the evaluation context that affects the values of the first argument. +- `outputs` is a list of a single column [Value] when the first argument is a scalar expression and a list of output columns when the first argument is a table expression. +- `data` is a list of input values and output values when the first argument is a scalar expression, and a list of input values and corresponding output rows when the first argument is a table expression. +- `rowCount` is the number of rows when the first argument is a table expression. Even though the number of rows in the json output is truncated by the MaxRows parameter, rowCount is the real number of rows without truncation. + +## Remarks + +- Trace events can be captured by using [SQL Server Profiler](/analysis-services/instances/use-sql-server-profiler-to-monitor-analysis-services) and the open-source [DAX Debug Output](https://github.com/pbidax/DAXDebugOutput/releases/) tool. +- This function can be used with almost any sub-expression in a DAX expression, and the entire expression will still be valid. + +- When the first argument is evaluated multiple times in a single query, the function generates a single DAX Evaluation Log event that contains both the input values and the corresponding output values. + +- When the label parameter is specified, its value is returned in both the json output and the Label column of the DAX Evaluation Log event. + +- If the first argument is a table expression, only the top MaxRows rows are shown in the DAX Evaluation Log event. + +- In some cases, this function is not executed due to optimizations. + +- If the DAX Evaluation Log event is greater than one million characters, it's truncated to preserve correct json structure. + +## Example 1 + +The following DAX query: + +```dax +evaluate +SUMMARIZE( + EVALUATEANDLOG(FILTER(Sales, [ProductKey] = 528)), + Sales[SalesTerritoryKey], + "sum", + sum(Sales[Sales Amount]) +) +``` + +Returns the following DAX Evaluation Log event: + +```json +{ + "expression": "FILTER(Sales, [ProductKey] = 528)", + "inputs": [], + "outputs": ["'Sales'[SalesOrderLineKey]", "'Sales'[ResellerKey]", "'Sales'[CustomerKey]", "'Sales'[ProductKey]", "'Sales'[OrderDateKey]", "'Sales'[DueDateKey]", "'Sales'[ShipDateKey]", "'Sales'[SalesTerritoryKey]", "'Sales'[Order Quantity]", "'Sales'[Unit Price]", "'Sales'[Extended Amount]", "'Sales'[Product Standard Cost]", "'Sales'[Total Product Cost]", "'Sales'[Sales Amount]", "'Sales'[Unit Price Discount Pct]"], + "data": [ + { + "input": [], + "rowCount": 3095, + "output": [ + [52174001, -1, 23785, 528, 20190707, 20190717, 20190714, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0], + [52173001, -1, 26278, 528, 20190707, 20190717, 20190714, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0], + [52082001, -1, 23831, 528, 20190705, 20190715, 20190712, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0], + [52054002, -1, 11207, 528, 20190704, 20190714, 20190711, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0], + [52036001, -1, 25337, 528, 20190704, 20190714, 20190711, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0], + [51939002, -1, 23670, 528, 20190702, 20190712, 20190709, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0], + [51911002, -1, 11746, 528, 20190701, 20190711, 20190708, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0], + [51379003, -1, 13745, 528, 20190612, 20190622, 20190619, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0], + [51264002, -1, 11282, 528, 20190605, 20190615, 20190612, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0], + [51184003, -1, 11263, 528, 20190531, 20190610, 20190607, 1, 1, 4.99, 4.99, 1.8663, 1.8663, 4.99, 0.0] + ] + } + ] +} +``` + +## Example 2 + +The following DAX query with a scalar argument and varying attributes: + +```dax +evaluate +SELECTCOLUMNS( + TOPN(5, Customer), + [Customer], + "Customer", + EVALUATEANDLOG([Customer] & ", " & [Country-Region], "customerLog") +) + +``` + +Returns the following DAX Evaluation Log event: + +```json +{ + "expression": "[Customer] & \", \" & [Country-Region]", + "label": "customerLog", + "inputs": ["'Customer'[Customer]", "'Customer'[Country-Region]"], + "data": [ + { + "input": ["Russell Xie", "United States"], + "output": "Russell Xie, United States" + }, + { + "input": ["Savannah Baker", "United States"], + "output": "Savannah Baker, United States" + }, + { + "input": ["Maurice Tang", "United States"], + "output": "Maurice Tang, United States" + }, + { + "input": ["Emily Wood", "United States"], + "output": "Emily Wood, United States" + }, + { + "input": ["Meghan Hernandez", "United States"], + "output": "Meghan Hernandez, United States" + } + ] +} + +``` + +## Related content + +[TOCSV](tocsv-function-dax.md) +[TOJSON](tojson-function-dax.md) diff --git a/query-languages/dax/even-function-dax.md b/query-languages/dax/even-function-dax.md index 485a7c909..65de028b5 100644 --- a/query-languages/dax/even-function-dax.md +++ b/query-languages/dax/even-function-dax.md @@ -1,50 +1,42 @@ --- description: "Learn more about: EVEN" -title: "EVEN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "EVEN function (DAX)" --- # EVEN -Returns number rounded up to the nearest even integer. You can use this function for processing items that come in twos. For example, a packing crate accepts rows of one or two items. The crate is full when the number of items, rounded up to the nearest two, matches the crate's capacity. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns number rounded up to the nearest even integer. You can use this function for processing items that come in twos. For example, a packing crate accepts rows of one or two items. The crate is full when the number of items, rounded up to the nearest two, matches the crate's capacity. + +## Syntax + ```dax -EVEN(number) +EVEN(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The value to round.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The value to round.| + ## Return value -Returns number rounded up to the nearest even integer. - +Returns number rounded up to the nearest even integer. + ## Remarks -- If number is nonnumeric, EVEN returns the #VALUE! error value. - -- Regardless of the sign of number, a value is rounded up when adjusted away from zero. If number is an even integer, no rounding occurs. +- If `number` is nonnumeric, EVEN returns the `#VALUE!` error value. + +- Regardless of the sign of number, a value is rounded up when adjusted away from zero. If number is an even integer, no rounding occurs. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= EVEN(1.5)|Rounds 1.5 to the nearest even integer|2| -|= EVEN(3)|Rounds 3 to the nearest even integer|4| -|= EVEN(2)|Rounds 2 to the nearest even integer|2| -|= EVEN(-1)|Rounds -1 to the nearest even integer|-2| - +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= EVEN(1.5)`|Rounds 1.5 to the nearest even integer|2| +|`= EVEN(3)`|Rounds 3 to the nearest even integer|4| +|`= EVEN(2)`|Rounds 2 to the nearest even integer|2| +|`= EVEN(-1)`|Rounds -1 to the nearest even integer|-2| diff --git a/query-languages/dax/exact-function-dax.md b/query-languages/dax/exact-function-dax.md index ebb963ac6..9d7a1a5a2 100644 --- a/query-languages/dax/exact-function-dax.md +++ b/query-languages/dax/exact-function-dax.md @@ -1,47 +1,40 @@ --- description: "Learn more about: EXACT" -title: "EXACT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 03/16/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "EXACT function (DAX)" --- # EXACT -Compares two text strings and returns TRUE if they are exactly the same, otherwise returns FALSE. EXACT is case-sensitive but ignores formatting differences. EXACT is case-sensitive - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Compares two text strings and returns `TRUE` if they are exactly the same, otherwise returns `FALSE`. EXACT is case-sensitive but ignores formatting differences. EXACT is case-sensitive + +## Syntax + ```dax -EXACT(,) +EXACT(,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text1|The first text string or column that contains text.| -|text2|The second text string or column that contains text.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text1`|The first text string or column that contains text.| +|`text2`|The second text string or column that contains text.| + ## Return value -True or False. (Boolean) - +True or False. (Boolean) + ## Example -The following formula used in a calculated column in the Product table checks the value of Product for the current row against the value of Model for the current row, and returns True if they are the same, and returns False if they are different. +The following formula used in a calculated column in the Product table checks the value of Product for the current row against the value of Model for the current row, and returns True if they are the same, and returns False if they are different. [!INCLUDE [power-bi-dax-sample-model](includes/power-bi-dax-sample-model.md)] ```dax -= EXACT([Product], [Model]) += EXACT([Product], [Model]) ``` - -## See also -[Text functions](text-functions-dax.md) +## Related content + +[Text functions](text-functions-dax.md) diff --git a/query-languages/dax/except-function-dax.md b/query-languages/dax/except-function-dax.md index e56dec9d2..9cc836188 100644 --- a/query-languages/dax/except-function-dax.md +++ b/query-languages/dax/except-function-dax.md @@ -1,91 +1,84 @@ --- description: "Learn more about: EXCEPT" -title: "EXCEPT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "EXCEPT function (DAX)" --- # EXCEPT -Returns the rows of one table which do not appear in another table. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the rows of the first table in the expression which do not appear in the second table. + +## Syntax + ```dax -EXCEPT(, +EXCEPT(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Table_expression|Any DAX expression that returns a table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Table_expression`|Any DAX expression that returns a table.| + ## Return value -A table that contains the rows of one table minus all the rows of another table. - +A table that contains the rows of one table minus all the rows of another table. + ## Remarks -- If a row appears at all in both tables, it and its duplicates are not present in the result set. If a row appears in only table_expression1, it and its duplicates will appear in the result set. - -- The column names will match the column names in table_expression1. - -- The returned table has lineage based on the columns in table_expression1 , regardless of the lineage of the columns in the second table. For example, if the first column of first table_expression has lineage to the base column C1 in the model, the Except will reduce the rows based on the availability of values in the first column of second table_expression and keep the lineage on base column C1 intact. - -- The two tables must have the same number of columns. - -- Columns are compared based on positioning, and data comparison with no type coercion. - -- The set of rows returned depends on the order of the two expressions. - -- The returned table does not include columns from tables related to table_expression1. +- If a row appears at all in both tables, it and its duplicates are not present in the result set. If a row appears in only table_expression1, it and its duplicates will appear in the result set. + +- The column names will match the column names in table_expression1. + +- The returned table has lineage based on the columns in table_expression1 , regardless of the lineage of the columns in the second table. For example, if the first column of first table_expression has lineage to the base column C1 in the model, the Except will reduce the rows based on the availability of values in the first column of second table_expression and keep the lineage on base column C1 intact. + +- The two tables must have the same number of columns. + +- Columns are compared based on positioning, and data comparison with no type coercion. + +- The set of rows returned depends on the order of the two expressions. + +- The returned table does not include columns from tables related to table_expression1. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -States1 - -|State| -|---------| -|A| -|B| -|B| -|B| -|C| -|D| -|D| - -States2 - -|State| -|---------| -|B| -|C| -|D| -|D| -|D| -|E| -|E| -|E| - -Except(States1, States2) - -|State| -|---------| -|A| - -Except(States2, States1) - -|State| -|---------| -|E| -|E| -|E| +States1 + +|State| +|---------| +|A| +|B| +|B| +|B| +|C| +|D| +|D| + +States2 + +|State| +|---------| +|B| +|C| +|D| +|D| +|D| +|E| +|E| +|E| + +Except(States1, States2) + +|State| +|---------| +|A| + +Except(States2, States1) + +|State| +|---------| +|E| +|E| +|E| diff --git a/query-languages/dax/exp-function-dax.md b/query-languages/dax/exp-function-dax.md index dd9171c4d..4696ab31e 100644 --- a/query-languages/dax/exp-function-dax.md +++ b/query-languages/dax/exp-function-dax.md @@ -1,56 +1,49 @@ --- description: "Learn more about: EXP" -title: "EXP function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "EXP function (DAX)" --- # EXP -Returns e raised to the power of a given number. The constant e equals 2.71828182845904, the base of the natural logarithm. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns e raised to the power of a given number. The constant e equals 2.71828182845904, the base of the natural logarithm. + +## Syntax + ```dax -EXP() +EXP() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The exponent applied to the base e. The constant e equals 2.71828182845904, the base of the natural logarithm.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The exponent applied to the base e. The constant e equals 2.71828182845904, the base of the natural logarithm.| + ## Return value -A decimal number. - -## Exceptions - +A decimal number. + +## Exceptions + ## Remarks -- EXP is the inverse of LN, which is the natural logarithm of the given number. - +- EXP is the inverse of LN, which is the natural logarithm of the given number. + - To calculate powers of bases other than e, use the exponentiation operator (^). For more information, see [DAX Operator Reference](dax-operator-reference.md). ## Example -The following formula calculates e raised to the power of the number contained in the column, `[Power]`. - +The following formula calculates e raised to the power of the number contained in the column, `[Power]`. + ```dax -= EXP([Power]) += EXP([Power]) ``` - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[LN function](ln-function-dax.md) -[EXP function](exp-function-dax.md) -[LOG function](log-function-dax.md) -[LOG function](log-function-dax.md) + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[LN function](ln-function-dax.md) +[EXP function](exp-function-dax.md) +[LOG function](log-function-dax.md) +[LOG function](log-function-dax.md) diff --git a/query-languages/dax/expand-function-dax.md b/query-languages/dax/expand-function-dax.md new file mode 100644 index 000000000..859730c0b --- /dev/null +++ b/query-languages/dax/expand-function-dax.md @@ -0,0 +1,78 @@ +--- +description: "Learn more about: EXPAND" +title: "EXPAND function (DAX)" +ms.service: powerbi +ms.subservice: dax +ms.date: 02/20/2024 +ms.topic: reference +author: jewang-msft +ms.author: jewang +recommendations: false + +--- + +# EXPAND + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Retrieves a context with added levels of detail compared to the current context. If an expression is provided, returns its value in the new context, allowing for navigation in hierarchies and calculation at a more detailed level. + +## Syntax + +The syntaxes that perform both navigation and calculation. +```dax +EXPAND ( , [, N] ) +EXPAND ( , [, ] ... ) +``` + +The syntaxes that perform navigation only. +```dax +EXPAND ( [, N] ) +EXPAND ( [, ] ... ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression`|The expression to be evaluated in the new context.| +|`axis`|An axis reference.| +|`column`|A column in the data grid.| +|`N`|(Optional) The number of levels to expand. If omitted, the default value is 1.| + +## Return value + +For versions that perform both navigation and calculation, the function returns the value of the expression in the new context after navigating to a new level. +For versions that perform navigation only, the function modifies the evaluation context by navigating to a new level. + +## Remarks + +* This function can be used only in visual calculations. +* The navigation-only versions of the function can be used inside the CALCULATE function. +* The levels of the hierarchy are determined by all columns in each axis referenced by the axis reference. +* When columns are specified, the axes are determined by including each column's axis the first time it is encountered. +* When N is specified, the function navigates down the hierarchy N levels from the current level or the bottom level, whichever comes first. +* When multiple columns are specified, the function navigates down the hierarchy until it reaches the first level at which all the specified columns are present. +* Navigation begins at the current cell in the data matrix, descending down the hierarchy. If a specified column is at a level higher than the current cell, it will be disregarded. +* Often, there are multiple descendent cells at a lower level; therefore, some form of aggregation is required for the expression argument. + +## Example + +Given a table that summarizes the total sales for a hierarchy with levels for total, year, quarter and month, the following DAX calculations calculate the maximum value of [SalesAmount] at the child level, the grandchildren level, and the month level, respectively. + +```dax +MaxOfChildren = EXPAND(MAX([SalesAmount]), ROWS) +MaxOfGrandChildren = EXPAND(MAX([SalesAmount]), ROWS, 2) +MaxOfMonthChildren = EXPAND(MAX([SalesAmount]), [Month]) +``` + +The screenshot below shows the matrix with the three visual calculations. + +![DAX visual calculation](media/dax-queries/dax-visualcalc-expand.png) + +## See also + +[EXPANDALL](expandall-function-dax.md) +[COLLAPSE](collapse-function-dax.md) +[COLLAPSEALL](collapseall-function-dax.md) + diff --git a/query-languages/dax/expandall-function-dax.md b/query-languages/dax/expandall-function-dax.md new file mode 100644 index 000000000..d0da2168f --- /dev/null +++ b/query-languages/dax/expandall-function-dax.md @@ -0,0 +1,68 @@ +--- +description: "Learn more about: EXPANDALL" +title: "EXPANDALL function (DAX)" +ms.service: powerbi +ms.subservice: dax +ms.date: 02/21/2024 +ms.topic: reference +author: jewang-msft +ms.author: jewang +recommendations: false + +--- + +# EXPANDALL + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Retrieves a context at the most detailed level. If an expression is provided, returns its value in the new context, allowing for navigation in hierarchies and calculation at the most detailed level. + +## Syntax + +The syntax that performs both navigation and calculation. +```dax +EXPANDALL ( , ) +``` + +The syntax that performs navigation only. +```dax +EXPANDALL ( ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression`|The expression to be evaluated in the new context.| +|`axis`|An axis reference.| + +## Return value + +For the version that performs both navigation and calculation, the function returns the value of the expression in the new context after navigating to the lowest level of the hierarchy. +For the version that performs navigation only, the function modifies the evaluation context by navigating to the lowest level of the hierarchy. + +## Remarks + +* This function can be used only in visual calculations. +* The navigation-only version of the function can be used inside the CALCULATE function. +* The levels of the hierarchy are determined by all columns in each axis referenced by the axis reference. +* Often, there are multiple descendent cells at a lower level; therefore, some form of aggregation is required for the expression argument. + +## Example + +Given a table that summarizes the total sales for a hierarchy with levels for total, year, quarter and month, the following DAX calculation calculates the maximum value of [SalesAmount] at the lowest level, [Month]. + +```dax +MaxOfLeafLevel = EXPANDALL(MAX([SalesAmount]), ROWS) +``` + +The screenshot below shows the matrix with the visual calculation. + +![DAX visual calculation](media/dax-queries/dax-visualcalc-expandall.png) + +## See also + +[EXPAND](expand-function-dax.md) +[COLLAPSE](collapse-function-dax.md) +[COLLAPSEALL](collapseall-function-dax.md) + diff --git a/query-languages/dax/expon-dist-function-dax.md b/query-languages/dax/expon-dist-function-dax.md index 457861903..b8cf1e95b 100644 --- a/query-languages/dax/expon-dist-function-dax.md +++ b/query-languages/dax/expon-dist-function-dax.md @@ -1,53 +1,46 @@ --- description: "Learn more about: EXPON.DIST" -title: "EXPON.DIST function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "EXPON.DIST function (DAX)" --- # EXPON.DIST -Returns the exponential distribution. Use EXPON.DIST to model the time between events, such as how long an automated bank teller takes to deliver cash. For example, you can use EXPON.DIST to determine the probability that the process takes at most 1 minute. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the exponential distribution. Use EXPON.DIST to model the time between events, such as how long an automated bank teller takes to deliver cash. For example, you can use EXPON.DIST to determine the probability that the process takes at most 1 minute. + +## Syntax + ```dax -EXPON.DIST(x,lambda,cumulative) +EXPON.DIST(x,lambda,cumulative) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|x|Required. The value of the function.| -|lambda|Required. The parameter value.| -|cumulative|Required. A logical value that indicates which form of the exponential function to provide. If cumulative is TRUE, EXPON.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`x`|Required. The value of the function.| +|`lambda`|Required. The parameter value.| +|`cumulative`|Required. A logical value that indicates which form of the exponential function to provide. If cumulative is `TRUE`, EXPON.DIST returns the cumulative distribution function; if `FALSE`, it returns the probability density function.| + ## Return value -Returns the exponential distribution. - +Returns the exponential distribution. + ## Remarks -- If x or lambda is nonnumeric, EXPON.DIST returns the #VALUE! error value. +- If `x` or `lambda` is nonnumeric, EXPON.DIST returns the `#VALUE!` error value. -- If x or lambda is not an integer, it is rounded. +- If `x` or `lambda` is not an integer, it is rounded. -- If x < 0, EXPON.DIST returns the #NUM! error value. +- If `x` < 0, EXPON.DIST returns the `#NUM!` error value. -- If lambda ≤ 0, EXPON.DIST returns the #NUM! error value. +- If `lambda` ≤ 0, EXPON.DIST returns the `#NUM!` error value. -- The equation for the probability density function is: +- The equation for the probability density function is: $$f(x; \lambda) = \lambda e^{-\lambda x}$$ -- The equation for the cumulative distribution function is: +- The equation for the cumulative distribution function is: $$F(x; \lambda) = 1 - e^{-\lambda x}$$ diff --git a/query-languages/dax/fact-function-dax.md b/query-languages/dax/fact-function-dax.md index f23890e0a..b3aa69d6e 100644 --- a/query-languages/dax/fact-function-dax.md +++ b/query-languages/dax/fact-function-dax.md @@ -1,63 +1,56 @@ --- description: "Learn more about: FACT" -title: "FACT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FACT function (DAX)" --- # FACT -Returns the factorial of a number, equal to the series 1*2\*3\*...\* , ending in the given number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the factorial of a number, equal to the series 1*2\*3\*...\* , ending in the given number. + +## Syntax + ```dax -FACT() +FACT() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The non-negative number for which you want to calculate the factorial.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The non-negative number for which you want to calculate the factorial.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- If the number is not an integer, it is truncated and an error is returned. If the result is too large, an error is returned. +- If the number is not an integer, it is truncated and an error is returned. If the result is too large, an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following formula returns the factorial for the series of integers in the column, `[Values]`. - +The following formula returns the factorial for the series of integers in the column, `[Values]`. + ```dax -= FACT([Values]) += FACT([Values]) ``` -The following table shows the expected results: - -|Values|Results| -|----------|-----------| -|0|1| -|1|1| -|2|2| -|3|6| -|4|24| -|5|120| -|170|7.257415615308E+306| - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[TRUNC function](trunc-function-dax.md) +The following table shows the expected results: + +|Values|Results| +|----------|-----------| +|0|1| +|1|1| +|2|2| +|3|6| +|4|24| +|5|120| +|170|7.257415615308E+306| + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[TRUNC function](trunc-function-dax.md) diff --git a/query-languages/dax/false-function-dax.md b/query-languages/dax/false-function-dax.md index 2237e1b55..608355e4c 100644 --- a/query-languages/dax/false-function-dax.md +++ b/query-languages/dax/false-function-dax.md @@ -1,55 +1,48 @@ --- description: "Learn more about: FALSE" -title: "FALSE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FALSE function (DAX)" --- # FALSE -Returns the logical value FALSE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the logical value `FALSE`. + +## Syntax + ```dax -FALSE() +FALSE() ``` - + ## Return value -Always FALSE. - +Always `FALSE`. + ## Remarks -The word FALSE is also interpreted as the logical value FALSE. - +The word `FALSE` is also interpreted as the logical value `FALSE`. + ## Example -The formula returns the logical value FALSE when the value in the column, 'InternetSales_USD'[SalesAmount_USD], is less than or equal to 200000. - +The formula returns the logical value `FALSE` when the value in the column, 'InternetSales_USD'[SalesAmount_USD], is less than or equal to 200000. + ```dax -= IF(SUM('InternetSales_USD'[SalesAmount_USD]) >200000, TRUE(), false()) += IF(SUM('InternetSales_USD'[SalesAmount_USD]) >200000, TRUE(), false()) ``` -The following table shows the results when the example formula is used with 'ProductCategory'[ProductCategoryName] in Row Labels and 'DateTime'[CalendarYear] in Column Labels. - +The following table shows the results when the example formula is used with 'ProductCategory'[ProductCategoryName] in Row Labels and 'DateTime'[CalendarYear] in Column Labels. + |Row Labels|2005|2006|2007|2008|-|Grand Total| -|---------------|-----------------|----|----|----|----|----| -|Accessories|FALSE|FALSE|TRUE|TRUE|FALSE|TRUE| -|Bikes|TRUE|TRUE|TRUE|TRUE|FALSE|TRUE| -|Clothing|FALSE|FALSE|FALSE|FALSE|FALSE|TRUE| -|Components|FALSE|FALSE|FALSE|FALSE|FALSE|FALSE| -||FALSE|FALSE|FALSE|FALSE|FALSE|FALSE| -|Grand Total|TRUE|TRUE|TRUE|TRUE|FALSE|TRUE| - -## See also - -[TRUE function](true-function-dax.md) -[NOT function](not-function-dax.md) -[IF function](if-function-dax.md) +|---------------|-----------------|----|----|----|----|----| +|Accessories|``FALSE``|``FALSE``|``TRUE``|``TRUE``|``FALSE``|``TRUE``| +|Bikes|``TRUE``|``TRUE``|``TRUE``|``TRUE``|``FALSE``|``TRUE``| +|Clothing|``FALSE``|``FALSE``|``FALSE``|``FALSE``|``FALSE``|``TRUE``| +|Components|``FALSE``|``FALSE``|``FALSE``|``FALSE``|``FALSE``|``FALSE``| +||``FALSE``|``FALSE``|``FALSE``|``FALSE``|``FALSE``|``FALSE``| +|Grand Total|``TRUE``|``TRUE``|``TRUE``|``TRUE``|``FALSE``|``TRUE``| + +## Related content + +[TRUE function](true-function-dax.md) +[NOT function](not-function-dax.md) +[IF function](if-function-dax.md) diff --git a/query-languages/dax/filter-function-dax.md b/query-languages/dax/filter-function-dax.md index e813dea5f..fd0f645b3 100644 --- a/query-languages/dax/filter-function-dax.md +++ b/query-languages/dax/filter-function-dax.md @@ -1,37 +1,30 @@ --- description: "Learn more about: FILTER" -title: "FILTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/13/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FILTER function (DAX)" --- # FILTER -Returns a table that represents a subset of another table or expression. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table that represents a subset of another table or expression. + +## Syntax + ```dax -FILTER(
,) +FILTER(
,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table to be filtered. The table can also be an expression that results in a table.| -|filter|A Boolean expression that is to be evaluated for each row of the table. For example, `[Amount] > 0` or `[Region] = "France"`| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table to be filtered. The table can also be an expression that results in a table.| +|`filter`|A Boolean expression that is to be evaluated for each row of the table. For example, `[Amount] > 0` or `[Region] = "France"`| + ## Return value -A table containing only the filtered rows. - +A table containing only the filtered rows. + ## Remarks - You can use FILTER to reduce the number of rows in the table that you are working with, and use only specific data in calculations. FILTER is not used independently, but as a function that is embedded in other functions that require a table as an argument. @@ -41,54 +34,54 @@ A table containing only the filtered rows. Use COUNTROWS instead of COUNT in DAX - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example creates a report of Internet sales outside the United States by using a measure that filters out sales in the United States, and then slicing by calendar year and product categories. To create this measure, you filter the table, Internet Sales USD, by using Sales Territory, and then use the filtered table in a SUMX function. - +The following example creates a report of Internet sales outside the United States by using a measure that filters out sales in the United States, and then slicing by calendar year and product categories. To create this measure, you filter the table, Internet Sales USD, by using Sales Territory, and then use the filtered table in a SUMX function. + In this example, the expression: ```dax FILTER('InternetSales_USD', RELATED('SalesTerritory'[SalesTerritoryCountry])<>"United States") ``` -Returns a table that is a subset of Internet Sales minus all rows that belong to the United States sales territory. The RELATED function is what links the Territory key in the Internet Sales table to SalesTerritoryCountry in the SalesTerritory table. - -The following table demonstrates the proof of concept for the measure, NON USA Internet Sales, the formula for which is provided in the code section below. The table compares all Internet sales with non- USA Internet sales, to show that the filter expression works, by excluding United States sales from the computation. - -To re-create this table, add the field, SalesTerritoryCountry, to the **Row Labels** area of a report or PivotTable. - -### Table 1. Comparing total sales for U.S. vs. all other regions - +Returns a table that is a subset of Internet Sales minus all rows that belong to the United States sales territory. The RELATED function is what links the Territory key in the Internet Sales table to SalesTerritoryCountry in the SalesTerritory table. + +The following table demonstrates the proof of concept for the measure, NON USA Internet Sales, the formula for which is provided in the code section below. The table compares all Internet sales with non- USA Internet sales, to show that the filter expression works, by excluding United States sales from the computation. + +To re-create this table, add the field, SalesTerritoryCountry, to the **Row Labels** area of a report or PivotTable. + +### Table 1. Comparing total sales for U.S. vs. all other regions + |Row Labels|Internet Sales|Non USA Internet Sales| -|--------------|------------------|--------------------------| -|Australia|$4,999,021.84|$4,999,021.84| -|Canada|$1,343,109.10|$1,343,109.10| -|France|$2,490,944.57|$2,490,944.57| -|Germany|$2,775,195.60|$2,775,195.60| -|United Kingdom|$5,057,076.55|$5,057,076.55| -|United States|$9,389,479.79|| -|Grand Total|$26,054,827.45|$16,665,347.67| - -The final report table shows the results when you create a PivotTable by using the measure, NON USA Internet Sales. Add the field, CalendarYear, to the **Row Labels** area of the PivotTable and add the field, ProductCategoryName, to the **Column Labels** area. - -### Table 2. Comparing non- U.S. sales by product categories - +|--------------|------------------|--------------------------| +|Australia|$4,999,021.84|$4,999,021.84| +|Canada|$1,343,109.10|$1,343,109.10| +|France|$2,490,944.57|$2,490,944.57| +|Germany|$2,775,195.60|$2,775,195.60| +|United Kingdom|$5,057,076.55|$5,057,076.55| +|United States|$9,389,479.79|| +|Grand Total|$26,054,827.45|$16,665,347.67| + +The final report table shows the results when you create a PivotTable by using the measure, NON USA Internet Sales. Add the field, CalendarYear, to the **Row Labels** area of the PivotTable and add the field, ProductCategoryName, to the **Column Labels** area. + +### Table 2. Comparing non- U.S. sales by product categories + |Row Labels|Accessories|Bikes|Clothing|Grand Total| -|--------------------------|-----------------|----|----|----| -|2005||$1,526,481.95||$1,526,481.95| -|2006||$3,554,744.04||$3,554,744.04| -|2007|$156,480.18|$5,640,106.05|$70,142.77|$5,866,729.00| -|2008|$228,159.45|$5,386,558.19|$102,675.04|$5,717,392.68| -|Grand Total|$384,639.63|$16,107,890.23|$172,817.81|$16,665,347.67| - +|--------------------------|-----------------|----|----|----| +|2005||$1,526,481.95||$1,526,481.95| +|2006||$3,554,744.04||$3,554,744.04| +|2007|$156,480.18|$5,640,106.05|$70,142.77|$5,866,729.00| +|2008|$228,159.45|$5,386,558.19|$102,675.04|$5,717,392.68| +|Grand Total|$384,639.63|$16,107,890.23|$172,817.81|$16,665,347.67| + ```dax -SUMX(FILTER('InternetSales_USD', RELATED('SalesTerritory'[SalesTerritoryCountry])<>"United States") - ,'InternetSales_USD'[SalesAmount_USD]) +SUMX(FILTER('InternetSales_USD', RELATED('SalesTerritory'[SalesTerritoryCountry])<>"United States") + ,'InternetSales_USD'[SalesAmount_USD]) ``` - -## See also -[Filter functions](filter-functions-dax.md) -[ALL function](all-function-dax.md) -[ALLEXCEPT function](allexcept-function-dax.md) +## Related content + +[Filter functions](filter-functions-dax.md) +[ALL function](all-function-dax.md) +[ALLEXCEPT function](allexcept-function-dax.md) diff --git a/query-languages/dax/filter-functions-dax.md b/query-languages/dax/filter-functions-dax.md index 77541bf70..276e29a22 100644 --- a/query-languages/dax/filter-functions-dax.md +++ b/query-languages/dax/filter-functions-dax.md @@ -1,19 +1,11 @@ --- description: "Learn more about: Filter functions" -title: "Filter functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/17/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Filter functions (DAX)" --- # Filter functions -The filter and value functions in DAX are some of the most complex and powerful, and differ greatly from Excel functions. The lookup functions work by using tables and relationships, like a database. The filtering functions let you manipulate data context to create dynamic calculations. - +The filter and value functions in DAX are some of the most complex and powerful, and differ greatly from Excel functions. The lookup functions work by using tables and relationships, like a database. The filtering functions let you manipulate data context to create dynamic calculations. + ## In this category |Function |Description | @@ -28,7 +20,24 @@ The filter and value functions in DAX are some of the most complex and powerful, |[EARLIER](earlier-function-dax.md) | Returns the current value of the specified column in an outer evaluation pass of the mentioned column. | |[EARLIEST](earliest-function-dax.md) | Returns the current value of the specified column in an outer evaluation pass of the specified column. | |[FILTER](filter-function-dax.md) | Returns a table that represents a subset of another table or expression. | +|[FIRST](first-function-dax.md) | Used in visual calculations only. Retrieves a value in the visual matrix from the first row of an axis. | +|[INDEX](index-function-dax.md)|Returns a row at an absolute position, specified by the position parameter, within the specified partition, sorted by the specified order or on the specified axis.| |[KEEPFILTERS](keepfilters-function-dax.md) | Modifies how filters are applied while evaluating a CALCULATE or CALCULATETABLE function. | +|[LAST](last-function-dax.md) | Used in visual calculations only. Retrieves a value in the visual matrix from the last row of an axis. | +|[LOOKUP](lookup-function-dax.md) | In visual calculation mode only. Look up the value when filters applied.| +|[LOOKUPWITHTOTALS](lookupwithtotals-function-dax.md) | In visual calculation mode only. Look up the value when filters applied. Filters not specified will not be inferred.| |[LOOKUPVALUE](lookupvalue-function-dax.md) | Returns the value for the row that meets all criteria specified by search conditions. The function can apply one or more search conditions. | +|[MATCHBY](matchby-function-dax.md) | In window functions, defines the columns that are used to determine how to match data and identify the *current row*. | +|[MOVINGAVERAGE](movingaverage-function-dax.md)|Returns a moving average calculated along the given axis of the visual matrix.| +|[NEXT](next-function-dax.md) | Used in visual calculations only. Retrieves a value in the next row of an axis in the visual matrix. | +|[OFFSET](offset-function-dax.md)|Returns a single row that is positioned either before or after the *current row* within the same table, by a given offset. | +|[ORDERBY](orderby-function-dax.md)|Defines the columns that determine the sort order within each of a window function’s partitions.| +|[PARTITIONBY](partitionby-function-dax.md)|Defines the columns that are used to partition a window function’s `relation` parameter.| +|[PREVIOUS](previous-function-dax.md)| Used in visual calculations only. Retrieves a value in the previous row of an axis in the visual matrix. | +|[RANGE](range-function-dax.md)|Returns an interval of rows within the given axis, relative to the current row. A shortcut for WINDOW.| +|[RANK](rank-function-dax.md)| Returns the ranking of a row within the given interval. | |[REMOVEFILTERS](removefilters-function-dax.md)|Clears filters from the specified tables or columns.| -|[SELECTEDVALUE](selectedvalue-function.md) | Returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult. | +|[ROWNUMBER](rownumber-function-dax.md)| Returns the unique ranking of a row within the given interval. | +|[RUNNINGSUM](runningsum-function-dax.md)|Returns a running sum calculated along the given axis of the visual matrix.| +|[SELECTEDVALUE](selectedvalue-function-dax.md) | Returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult. | +|[WINDOW](window-function-dax.md)| Returns multiple rows which are positioned within the given interval. | diff --git a/query-languages/dax/filtercluster-function-dax.md b/query-languages/dax/filtercluster-function-dax.md new file mode 100644 index 000000000..b12117fee --- /dev/null +++ b/query-languages/dax/filtercluster-function-dax.md @@ -0,0 +1,40 @@ +--- +description: "Learn more about: FILTERCLUSTER" +title: "FILTERCLUSTER function (DAX) | Microsoft Docs" +--- +# FILTERCLUSTER + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Returns a correlated join table over a set of groups. + +## Syntax + +```dax +FILTERCLUSTER( [, < groupBy_columnName >]…, []… [, , …] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|groupBy_columnName|A fully qualified column reference (Table[Column]) to a base table for which the distinct values are included in the returned table. Each groupBy_columnName column is cross-joined (different tables) or auto-existed (same table) with the subsequent specified columns.| +|filterTable|A table expression participating in the join.| +|separator|A string literal which serves no purpose other than separating filterTable parameter with tableScan parameter| +|tableScan|A table scan that joins with filterTable parameters, applying autoexist semantics, and returns columns specified in groupBy_columnName| + +## Return value + +A table which includes combinations of values from the supplied columns based on the grouping specified. The column only includes column specified by groupBy_columnName parameter. + +## Remarks + +- FILTERCLUSTER function can only be used inside GROUPCROSSAPPLY and GROUPCROSSAPPLYTABLE functions. + +- FILTERCLUSTER is semantically equivalent to a natural join across all filterTable and tableScan parameters, and then group by columns specified by groupBy_columnName parameters. Group by columns must come from tableScan parameters. + +- tableScan parameters are evaluated in the context of filterTable + +[SUMMARIZE](summarize-function-dax.md) +[GROUPCROSSAPPLY function](groupcrossapply-function-dax.md) +[GROUPCROSSAPPLYTABLE function](groupcrossapplytable-function-dax.md) diff --git a/query-languages/dax/filters-function-dax.md b/query-languages/dax/filters-function-dax.md index 695366e74..66bc73afb 100644 --- a/query-languages/dax/filters-function-dax.md +++ b/query-languages/dax/filters-function-dax.md @@ -1,46 +1,39 @@ --- description: "Learn more about: FILTERS" -title: "FILTERS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FILTERS function (DAX)" --- # FILTERS -Returns the values that are directly applied as filters to *columnName*. - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the values that are directly applied as filters to `columnName`. + ## Syntax - + ```dax -FILTERS() +FILTERS() ``` - + ### Parameters -|Term |Description| +|Term |Description| |---------|---------| -|columnName | The name of an existing column, using standard DAX syntax. It cannot be an expression. | +|`columnName`| The name of an existing column, using standard DAX syntax. It cannot be an expression. | ## Return value -The values that are directly applied as filters to *columnName*. - +The values that are directly applied as filters to `columnName`. + ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows how to determine the number of direct filters a column has. - +The following example shows how to determine the number of direct filters a column has. + ```dax -= COUNTROWS(FILTERS(ResellerSales_USD[ProductKey])) += COUNTROWS(FILTERS(ResellerSales_USD[ProductKey])) ``` -This example lets you know how many direct filters on ResellerSales_USD[ProductKey] have been applied to the context where the expression is being evaluated. +This example lets you know how many direct filters on ResellerSales_USD[ProductKey] have been applied to the context where the expression is being evaluated. diff --git a/query-languages/dax/financial-functions-dax.md b/query-languages/dax/financial-functions-dax.md index b9b852e33..e23444cae 100644 --- a/query-languages/dax/financial-functions-dax.md +++ b/query-languages/dax/financial-functions-dax.md @@ -1,19 +1,11 @@ --- description: "Learn more about: Financial functions" -title: "Financial functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Financial functions (DAX)" --- # Financial functions Financial functions in DAX are used in formulas that perform financial calculations, such as net present value and rate of return. These functions are similar to financial functions used in Microsoft Excel. - + ## In this category |Function |Description | diff --git a/query-languages/dax/find-function-dax.md b/query-languages/dax/find-function-dax.md index 09a39a53c..8aa45c93b 100644 --- a/query-languages/dax/find-function-dax.md +++ b/query-languages/dax/find-function-dax.md @@ -1,55 +1,48 @@ --- description: "Learn more about: FIND" -title: "FIND function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 02/28/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FIND function (DAX)" --- # FIND -Returns the starting position of one text string within another text string. FIND is case-sensitive. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the starting position of one text string within another text string. FIND is case-sensitive. + +## Syntax + ```dax -FIND(, [, [][, ]]) +FIND(, [, [][, ]]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|find_text|The text you want to find. Use double quotes (empty text) to match the first character in **within_text**. | -|within_text|The text containing the text you want to find.| -|start_num|(optional) The character at which to start the search; if omitted, **start_num** = 1. The first character in **within_text** is character number 1.| -|NotFoundValue|(optional, but strongly recommended) The value that should be returned when the operation does not find a matching substring, typically 0, -1, or BLANK(). If not specified, an error is returned.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`find_text`|The text you want to find. Use double quotes (empty text) to match the first character in `within_text`. | +|`within_text`|The text containing the text you want to find.| +|`start_num`|(optional) The character at which to start the search; if omitted, `start_num` = 1. The first character in `within_text` is character number 1.| +|`NotFoundValue`|(optional, but strongly recommended) The value that should be returned when the operation does not find a matching substring, typically 0, -1, or BLANK(). If not specified, an error is returned.| + ## Return value -Number that shows the starting point of the text string you want to find. - +Number that shows the starting point of the text string you want to find. + ## Remarks -- Whereas Microsoft Excel has multiple versions of the FIND function to accommodate single-byte character set (SBCS) and double-byte character set (DBCS) languages, DAX uses Unicode and counts each character the same way; therefore, you do not need to use a different version depending on the character type. - +- Whereas Microsoft Excel has multiple versions of the FIND function to accommodate single-byte character set (SBCS) and double-byte character set (DBCS) languages, DAX uses Unicode and counts each character the same way; therefore, you do not need to use a different version depending on the character type. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - FIND does not support wildcards. To use wildcards, use [SEARCH](search-function-dax.md). - + ## Example The following DAX query finds the position of the first letter of "Bike", in the string that contains the reseller name. If not found, Blank is returned. -Keep in mind, FIND is case-sensitive. In this example, if "bike" were used in the \ argument, no results would be returned. Use [SEARCH](search-function-dax.md) for case-insensitive. +Keep in mind, FIND is case-sensitive. In this example, if "bike" were used in the `find_text` argument, no results would be returned. Use [SEARCH](search-function-dax.md) for case-insensitive. [!INCLUDE [power-bi-dax-sample-model](includes/power-bi-dax-sample-model.md)] - + ```dax EVALUATE CALCULATETABLE ( @@ -61,7 +54,7 @@ CALCULATETABLE ( ) ``` -Returns, +Returns, |Reseller |Business Type | Position of Bike | |---------|---------|---------| @@ -76,7 +69,7 @@ Returns, |Helmets and Cycles |Value Added Reseller| | |Jumbo Bikes |Specialty Bike Shop| 7 | -## See also +## Related content -[SEARCH](search-function-dax.md) -[Text functions](text-functions-dax.md) +[SEARCH](search-function-dax.md) +[Text functions](text-functions-dax.md) diff --git a/query-languages/dax/first-function-dax.md b/query-languages/dax/first-function-dax.md new file mode 100644 index 000000000..a69aeec07 --- /dev/null +++ b/query-languages/dax/first-function-dax.md @@ -0,0 +1,54 @@ +--- +description: "Learn more about: FIRST" +title: "FIRST function (DAX)" +--- + +# FIRST + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Used in visual calculations only. Retrieves a value in the visual matrix from the first element of an axis. + +## Syntax + +```dax +FIRST ( [, ][, ][, ][, reset] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column to be retrieved.| +|`axis`|(Optional) An axis reference. If omitted, the first axis of the Visual Shape definition is used.| +|`orderBy`|(Optional) An ORDERBY() clause with expressions that determine how to sort each partition along the `axis`. If `orderBy` is not provided, the data is sorted by the grouping columns on the default `axis` in ascending order by default.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.
| +|`reset`|(Optional) Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +The value of `column` from the first element of the axis. + +## Remarks + +This function can only be used in a visual calculation. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example + +The following visual calculation returns the sales amount of the first row on ROWS axis, that resets on the lowest parent. + +```dax +FirstInternetSalesAmount = FIRST ( [Sum of SalesAmount], ROWS, LowestParent ) +``` + +The screenshot below shows the visual matrix and the visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-first.png) + +## Related content + +[LAST](last-function-dax.md) +[PREVIOUS](previous-function-dax.md) +[NEXT](next-function-dax.md) diff --git a/query-languages/dax/firstdate-function-dax.md b/query-languages/dax/firstdate-function-dax.md index 04d6eea56..3d6ab1e17 100644 --- a/query-languages/dax/firstdate-function-dax.md +++ b/query-languages/dax/firstdate-function-dax.md @@ -1,62 +1,55 @@ --- description: "Learn more about: FIRSTDATE" -title: "FIRSTDATE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FIRSTDATE function (DAX)" --- # FIRSTDATE -Returns the first date in the current context for the specified column of dates. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns the first date in the current context for the specified column of dates. + +## Syntax + ```dax -FIRSTDATE() +FIRSTDATE() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| + ## Return value -A table containing a single column and single row with a date value. - +A table containing a single column and single row with a date value. + ## 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](calculate-function-dax.md). - -- When the current context is a single date, the date returned by the FIRSTDATE and LASTDATE functions will be equal. - -- The Return value is a table that contains a single column and single value. Therefore, this function can be used as an argument to any function that requires a table in its arguments. Also, the returned value can be used whenever a date value is required. - +- 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](calculate-function-dax.md). + +- When the current context is a single date, the date returned by the FIRSTDATE and LASTDATE functions will be equal. + +- The Return value is a table that contains a single column and single value. Therefore, this function can be used as an argument to any function that requires a table in its arguments. Also, the returned value can be used whenever a date value is required. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that obtains the first date when a sale was made in the Internet sales channel for the current context. - +The following sample formula creates a measure that obtains the first date when a sale was made in the Internet sales channel for the current context. + ```dax -= FIRSTDATE('InternetSales_USD'[SaleDateKey]) += FIRSTDATE('InternetSales_USD'[SaleDateKey]) ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[LASTDATE function](lastdate-function-dax.md) -[FIRSTNONBLANK function](firstnonblank-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[LASTDATE function](lastdate-function-dax.md) +[FIRSTNONBLANK function](firstnonblank-function-dax.md) diff --git a/query-languages/dax/firstnonblank-function-dax.md b/query-languages/dax/firstnonblank-function-dax.md index 09006c5e1..5d4e8c338 100644 --- a/query-languages/dax/firstnonblank-function-dax.md +++ b/query-languages/dax/firstnonblank-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: FIRSTNONBLANK" -title: "FIRSTNONBLANK function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FIRSTNONBLANK function (DAX)" --- # FIRSTNONBLANK -Returns the first value in the column, **column**, filtered by the current context, where the expression is not blank. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns the first value in the column, ``, filtered by the current context, where the expression is not blank. + +## Syntax + ```dax -FIRSTNONBLANK(,) +FIRSTNONBLANK(,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|A column expression.| -|expression|An expression evaluated for blanks for each value of **column**.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A column expression.| +|`expression`|An expression evaluated for blanks for each value of `column`.| + ## Return value -A table containing a single column and single row with the computed first value. - +A table containing a single column and single row with the computed first value. + ## Remarks -- The **column** argument can be any of the following: - - A reference to any column. - - A table with a single column. - -- A Boolean expression that defines a single-column table . - -- Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). - -- This function is typically used to return the first value of a column for which the expression is not blank. For example, you could get the last value for which there were sales of a product. - +- The `column` argument can be any of the following: + - A reference to any column. + - A table with a single column. + +- A Boolean expression that defines a single-column table . + +- Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). + +- This function is typically used to return the first value of a column for which the expression is not blank. For example, you could get the last value for which there were sales of a product. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## See also -[LASTNONBLANK function](lastnonblank-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[LASTNONBLANK function](lastnonblank-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/firstnonblankvalue-function-dax.md b/query-languages/dax/firstnonblankvalue-function-dax.md index b88b5ade9..62ebf433d 100644 --- a/query-languages/dax/firstnonblankvalue-function-dax.md +++ b/query-languages/dax/firstnonblankvalue-function-dax.md @@ -1,47 +1,41 @@ --- description: "Learn more about: FIRSTNONBLANKVALUE" -title: "FIRSTNONBLANKVALUE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "FIRSTNONBLANKVALUE function (DAX)" --- # FIRSTNONBLANKVALUE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + Evaluates an expression filtered by the sorted values of a column and returns the first value of the expression that is not blank. - -## Syntax - + +## Syntax + ```dax FIRSTNONBLANKVALUE(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|A column or an expression that returns a single-column table.| -|expression|An expression evaluated for each value of \.| - -## Return value - -The first non-blank value of \ corresponding to the sorted values of \. - -## Remarks + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A column or an expression that returns a single-column table.| +|`expression`|An expression evaluated for each value of `column`.| + +## Return value + +The first non-blank value of `expression` corresponding to the sorted values of `column`. + +## Remarks - The column argument can be any of the following: - A reference to any column. - A table with a single column. -- This function is different from FIRSTNONBLANK in that the \ is added to the filter context for the evaluation of \. +- This function is different from FIRSTNONBLANK in that the `column` is added to the filter context for the evaluation of `expression`. -- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] +- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example The following DAX query, @@ -60,7 +54,7 @@ SUMMARIZECOLUMNS( Returns, |DimProduct[Class]|[FNBV]| -|-----------|---------------|----------| +|-----------|---------------|----------| |L|699.0982| |H|13778.24| |M|1000.4375| diff --git a/query-languages/dax/fixed-function-dax.md b/query-languages/dax/fixed-function-dax.md index 7ad87381a..94de79fe4 100644 --- a/query-languages/dax/fixed-function-dax.md +++ b/query-languages/dax/fixed-function-dax.md @@ -1,66 +1,59 @@ --- description: "Learn more about: FIXED" -title: "FIXED function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 03/16/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FIXED function (DAX)" --- # FIXED -Rounds a number to the specified number of decimals and returns the result as text. You can specify that the result be returned with or without commas. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Rounds a number to the specified number of decimals and returns the result as text. You can specify that the result be returned with or without commas. + +## Syntax + ```dax -FIXED(, , ) +FIXED(, , ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number you want to round and convert to text, or a column containing a number.| -|decimals|(optional) The number of digits to the right of the decimal point; if omitted, 2.| -|no_commas|(optional) A logical value: if 1, do not display commas in the returned text; if 0 or omitted, display commas in the returned text.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number you want to round and convert to text, or a column containing a number.| +|`decimals`|(optional) The number of digits to the right of the decimal point; if omitted, 2.| +|`no_commas`|(optional) A logical value: if 1, do not display commas in the returned text; if 0 or omitted, display commas in the returned text.| + ## Return value -A number represented as text. - +A number represented as text. + ## Remarks -- If the value used for the **decimals** parameter is negative, **number** is rounded to the left of the decimal point. - -- If you omit **decimals**, it is assumed to be 2. - -- If **no_commas** is 0 or is omitted, then the returned text includes commas as usual. - -- The major difference between formatting a cell containing a number by using a command and formatting a number directly with the FIXED function is that FIXED converts its result to text. A number formatted with a command from the formatting menu is still a number. - +- If the value used for the `decimals` parameter is negative, `number` is rounded to the left of the decimal point. + +- If you omit `decimals`, it is assumed to be 2. + +- If `no_commas` is 0 or is omitted, then the returned text includes commas as usual. + +- The major difference between formatting a cell containing a number by using a command and formatting a number directly with the FIXED function is that FIXED converts its result to text. A number formatted with a command from the formatting menu is still a number. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following formula used in a calculated column gets the numeric value for the current row in Product[List Price] and returns it as text with 2 decimal places and no commas. +The following formula used in a calculated column gets the numeric value for the current row in Product[List Price] and returns it as text with 2 decimal places and no commas. [!INCLUDE [power-bi-dax-sample-model](includes/power-bi-dax-sample-model.md)] - + ```dax -= FIXED([List Price],2,1) += FIXED([List Price],2,1) ``` -## See also +## Related content -[CEILING](ceiling-function-dax.md) -[FLOOR](floor-function-dax.md) -[ISO.CEILING](iso-ceiling-function-dax.md) -[MROUND](mround-function-dax.md) -[ROUND](round-function-dax.md) -[ROUNDDOWN](rounddown-function-dax.md) -[ROUNDUP](roundup-function-dax.md) +[CEILING](ceiling-function-dax.md) +[FLOOR](floor-function-dax.md) +[ISO.CEILING](iso-ceiling-function-dax.md) +[MROUND](mround-function-dax.md) +[ROUND](round-function-dax.md) +[ROUNDDOWN](rounddown-function-dax.md) +[ROUNDUP](roundup-function-dax.md) diff --git a/query-languages/dax/floor-function-dax.md b/query-languages/dax/floor-function-dax.md index 4679bd300..7fce7bfc9 100644 --- a/query-languages/dax/floor-function-dax.md +++ b/query-languages/dax/floor-function-dax.md @@ -1,63 +1,56 @@ --- description: "Learn more about: FLOOR" -title: "FLOOR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/21/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FLOOR function (DAX)" --- # FLOOR -Rounds a number down, toward zero, to the nearest multiple of significance. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Rounds a number down, toward zero, to the nearest multiple of significance. + +## Syntax + ```dax -FLOOR(, ) +FLOOR(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The numeric value you want to round.| -|significance|The multiple to which you want to round. The arguments**number** and **significance** must either both be positive, or both be negative.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The numeric value you want to round.| +|`significance`|The multiple to which you want to round. The arguments`number` and `significance` must either both be positive, or both be negative.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- If either argument is nonnumeric, FLOOR returns **#VALUE!**error value. - -- If number and significance have different signs, FLOOR returns the **#NUM!**error value. - -- Regardless of the sign of the number, a value is rounded down when adjusted away from zero. If the number is an exact multiple of significance, no rounding occurs. +- If either argument is nonnumeric, FLOOR returns `#VALUE!` error value. + +- If number and significance have different signs, FLOOR returns the `#NUM!` error value. + +- Regardless of the sign of the number, a value is rounded down when adjusted away from zero. If the number is an exact multiple of significance, no rounding occurs. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following formula takes the values in the [Total Product Cost] column from the table, InternetSales, and rounds down to the nearest multiple of .1. - +The following formula takes the values in the [Total Product Cost] column from the table, InternetSales, and rounds down to the nearest multiple of .1. + ```dax -= FLOOR(InternetSales[Total Product Cost],.1) += FLOOR(InternetSales[Total Product Cost],.1) ``` -The following table shows the expected results for some sample values: - -|Values|Expected Result| -|----------|-------------------| -|10.8423|10.8| -|8.0373|8| -|2.9733|2.9| - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) +The following table shows the expected results for some sample values: + +|Values|Expected Result| +|----------|-------------------| +|10.8423|10.8| +|8.0373|8| +|2.9733|2.9| + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) diff --git a/query-languages/dax/format-function-dax.md b/query-languages/dax/format-function-dax.md index 402b12be1..f6218bb9c 100644 --- a/query-languages/dax/format-function-dax.md +++ b/query-languages/dax/format-function-dax.md @@ -1,18 +1,11 @@ --- description: "Learn more about: FORMAT" -title: "FORMAT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/18/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "FORMAT function (DAX)" --- # FORMAT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Converts a value to text according to the specified format. ## Syntax @@ -25,18 +18,18 @@ FORMAT(, [, ]) |Term|Definition| |--------|--------------| -|value|A value or expression that evaluates to a single value.| -|format_string|A string with the formatting template.| -|locale_name|(Optional) Name of the locale to be used by the function. Possible values are strings accepted by the Windows API function [LocaleNameToLCID()](/windows/win32/api/winnls/nf-winnls-localenametolcid).| +|`value`|A value or expression that evaluates to a single value.| +|`format_string`|A string with the formatting template.| +|`locale_name`|(Optional) Name of the locale to be used by the function. Possible values are strings accepted by the Windows API function [LocaleNameToLCID()](/windows/win32/api/winnls/nf-winnls-localenametolcid).| ## Return value -A string containing **value** formatted as defined by **format_string**. +A string containing `value` formatted as defined by `format_string`. > [!NOTE] -> If **value** is BLANK, the function returns an empty string. +> If `value` is BLANK, the function returns an empty string. > -> If **format_string** is BLANK, the value is formatted with a "General Number" or "General Date" format (according to **value** data type). +> If `format_string` is BLANK, the value is formatted with a "General Number" or "General Date" format (according to `value` data type). ## Remarks @@ -44,7 +37,9 @@ A string containing **value** formatted as defined by **format_string**. - The format strings supported as an argument to the DAX FORMAT function are based on the format strings used by Visual Basic (OLE Automation), not on the format strings used by the .NET Framework. Therefore, you might get unexpected results or an error if the argument doesn't match any defined format strings. For example, "p" as an abbreviation for "Percent" isn't supported. Strings that you provide as an argument to the FORMAT function that aren't included in the list of predefined format strings are handled as part of a custom format string, or as a string literal. -- To learn more specifying a locale with FORMAT, check out this [video](https://www.microsoft.com/videoplayer/embed/RWLjrD). +- To learn more specifying a locale with FORMAT, check out this [video](https://learn-video.azurefd.net/vod/player?id=95820b42-974a-4adb-a4d5-418e923dcd2a). + +- Using FORMAT changes a measure result to a text data type. If the measure result is originally of numeric data type, then with FORMAT, the measure can't be used on visuals where the values section requires a numeric data type, like with charts. In Power BI, you can alternatively use **Dynamic format strings for measures** specify a conditional format string that maintains the numeric data type of the measure. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] @@ -53,26 +48,26 @@ A string containing **value** formatted as defined by **format_string**. #### Format strings ```dax -= FORMAT( 12345.67, "General Number") -= FORMAT( 12345.67, "Currency") -= FORMAT( 12345.67, "Fixed") -= FORMAT( 12345.67, "Standard") -= FORMAT( 12345.67, "Percent") += FORMAT( 12345.67, "General Number") += FORMAT( 12345.67, "Currency") += FORMAT( 12345.67, "Fixed") += FORMAT( 12345.67, "Standard") += FORMAT( 12345.67, "Percent") = FORMAT( 12345.67, "Scientific") ``` -Returns: - -**12345.67** "General Number" displays the number with no formatting. - -**$12,345.67** "Currency" displays the number with your currency locale formatting. The sample here shows the default United States currency formatting. - -**12345.67** "Fixed" displays at least one digit to the left of the decimal separator and two digits to the right of the decimal separator. - -**12,345.67** "Standard" displays at least one digit to the left of the decimal separator and two digits to the right of the decimal separator, and includes thousand separators. The sample here shows the default United States number formatting. - -**1,234,567.00 %** "Percent" displays the number as a percentage (multiplied by 100) with formatting and the percent sign at the right of the number separated by a single space. - +Returns: + +**12345.67** "General Number" displays the number with no formatting. + +**$12,345.67** "Currency" displays the number with your currency locale formatting. The sample here shows the default United States currency formatting. + +**12345.67** "Fixed" displays at least one digit to the left of the decimal separator and two digits to the right of the decimal separator. + +**12,345.67** "Standard" displays at least one digit to the left of the decimal separator and two digits to the right of the decimal separator, and includes thousand separators. The sample here shows the default United States number formatting. + +**1,234,567.00 %** "Percent" displays the number as a percentage (multiplied by 100) with formatting and the percent sign at the right of the number separated by a single space. + **1.23E+04** "Scientific" displays the number in scientific notation with two decimal digits. #### Datetime with optional locale_name @@ -89,23 +84,23 @@ Returns: **15/12/2020 12:30:59** Where day precedes month and time is 24-hour format. -**12/15/2020 12:30:59** Where month precedes day and time is 24-hour format. Because a non-locale dependent format string is specified, the locale is not applied and the non-locale format is returned. +**12/15/2020 12:30:59** Where month precedes day and time is 24-hour format. Because a non-locale dependent format string is specified, the locale is not applied and the non-locale format is returned. ## Predefined numeric formats -The following predefined numeric formats can be specified in the **format_string** argument: - -|Format|Description| -|------------------------|---------------| -|`"General Number"`|Displays number with no thousand separators.| -|`"Currency"`|Displays number with thousand separators, if appropriate; displays two digits to the right of the decimal separator. Output is based on system locale settings.| -|`"Fixed"`|Displays at least one digit to the left and two digits to the right of the decimal separator.| -|`"Standard"`|Displays number with thousand separators, at least one digit to the left and two digits to the right of the decimal separator.| -|`"Percent"`|Displays number multiplied by 100 with a percent sign (%) appended immediately to the right; always displays two digits to the right of the decimal separator.| -|`"Scientific"`|Uses standard scientific notation, providing two significant digits.| -|`"Yes/No"`|Displays No if number is 0; otherwise, displays Yes.| -|`"True/False"`|Displays False if number is 0; otherwise, displays True.| -|`"On/Off"`|Displays Off if number is 0; otherwise, displays On.| +The following predefined numeric formats can be specified in the `format_string` argument: + +|`Format`|Description| +|------------------------|---------------| +|`"General Number"`|Displays number with no thousand separators.| +|`"Currency"`|Displays number with thousand separators, if appropriate; displays two digits to the right of the decimal separator. Output is based on system locale settings.| +|`"Fixed"`|Displays at least one digit to the left and two digits to the right of the decimal separator.| +|`"Standard"`|Displays number with thousand separators, at least one digit to the left and two digits to the right of the decimal separator.| +|`"Percent"`|Displays number multiplied by 100 with a percent sign (%) appended immediately to the right; always displays two digits to the right of the decimal separator.| +|`"Scientific"`|Uses standard scientific notation, providing two significant digits.| +|`"Yes/No"`|Displays No if number is 0; otherwise, displays Yes.| +|`"True/False"`|Displays False if number is 0; otherwise, displays True.| +|`"On/Off"`|Displays Off if number is 0; otherwise, displays On.| ## Custom numeric formats @@ -131,75 +126,75 @@ If you include semicolons with nothing between them, the missing section is show ### Custom numeric format characters -The following custom numeric format characters can be specified in the **format_string** argument: +The following custom numeric format characters can be specified in the `format_string` argument: |Character|Description| |:-----|:-----| |None|Display the number with no formatting.| -|(**0**)|Digit placeholder. Display a digit or a zero. If the expression has a digit in the position where the 0 appears in the format string, display it; otherwise, display a zero in that position.If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, display leading or trailing zeros. If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, round the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, display the extra digits without modification.| -|(**#**)|Digit placeholder. Display a digit or nothing. If the expression has a digit in the position where the # appears in the format string, display it; otherwise, display nothing in that position. This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has the same or fewer digits than there are # characters on either side of the decimal separator in the format expression.| -|(**.**)|Decimal placeholder. In some locales, a comma is used as the decimal separator. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only number signs to the left of this symbol, numbers smaller than 1 begin with a decimal separator. To display a leading zero displayed with fractional numbers, use 0 as the first digit placeholder to the left of the decimal separator. The actual character used as a decimal placeholder in the formatted output depends on the Number Format recognized by your system.| -|(**%)**|Percentage placeholder. The expression is multiplied by 100. The percent character (**%**) is inserted in the position where it appears in the format string.| -|(**,**)|Thousand separator. In some locales, a period is used as a thousand separator. The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a thousand separator surrounded by digit placeholders (**0** or **#**). Two adjacent thousand separators or a thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) means "scale the number by dividing it by 1000, rounding as needed." For example, you can use the format string "##0,," to represent 100 million as 100. Numbers smaller than 1 million are displayed as 0. Two adjacent thousand separators in any position other than immediately to the left of the decimal separator are treated simply as specifying the use of a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system.| -|(**:**)|Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.| -|(**/**)|Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.| -|(**E- E+ e- e+**)|Scientific format. If the format expression contains at least one digit placeholder (**0** or **#**) to the right of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the right determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents.| -|**- + $** ( )|Display a literal character. To display a character other than one of those listed, precede it with a backslash (`\`) or enclose it in double quotation marks (" ").| -|(**\\**)|Display the next character in the format string. To display a character that has special meaning as a literal character, precede it with a backslash (`\`). The backslash itself isn't displayed. Using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (`\\`). Examples of characters that can't be displayed as literal characters are the date-formatting and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, and :), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !).| +|(`0`)|Digit placeholder. Display a digit or a zero. If the expression has a digit in the position where the 0 appears in the format string, display it; otherwise, display a zero in that position.If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, display leading or trailing zeros. If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, round the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, display the extra digits without modification.| +|(`#`)|Digit placeholder. Display a digit or nothing. If the expression has a digit in the position where the # appears in the format string, display it; otherwise, display nothing in that position. This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has the same or fewer digits than there are # characters on either side of the decimal separator in the format expression.| +|(`.`)|Decimal placeholder. In some locales, a comma is used as the decimal separator. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only number signs to the left of this symbol, numbers smaller than 1 begin with a decimal separator. To display a leading zero displayed with fractional numbers, use 0 as the first digit placeholder to the left of the decimal separator. The actual character used as a decimal placeholder in the formatted output depends on the Number Format recognized by your system.| +|(`%`)|Percentage placeholder. The expression is multiplied by 100. The percent character (`%`) is inserted in the position where it appears in the format string.| +|(`,`)|Thousand separator. In some locales, a period is used as a thousand separator. The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a thousand separator surrounded by digit placeholders (`0` or `#`). Two adjacent thousand separators or a thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) means "scale the number by dividing it by 1000, rounding as needed." For example, you can use the format string "##0,," to represent 100 million as 100. Numbers smaller than 1 million are displayed as 0. Two adjacent thousand separators in any position other than immediately to the left of the decimal separator are treated simply as specifying the use of a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system.| +|(`:`)|Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.| +|(`/`)|Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.| +|(`E- E+ e- e+`)|Scientific format. If the format expression contains at least one digit placeholder (`0` or `#`) to the right of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the right determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents.| +|`- + $` ( )|Display a literal character. To display a character other than one of those listed, precede it with a backslash (`\`) or enclose it in double quotation marks (" ").| +|(`\\`)|Display the next character in the format string. To display a character that has special meaning as a literal character, precede it with a backslash (`\`). The backslash itself isn't displayed. Using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (`\\`). Examples of characters that can't be displayed as literal characters are the date-formatting and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, and :), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !).| |("ABC")|Display the string inside the double quotation marks (" ").| ## Predefined date/time formats -The following predefined date/time formats can be specified in the **format_string** argument. When using formats other than these, they are interpreted as a custom date/time format: +The following predefined date/time formats can be specified in the `format_string` argument. When using formats other than these, they are interpreted as a custom date/time format: |Format|Description| |------------------------|---------------| |`"General Date"`|Displays a date and/or time. For example, 3/12/2008 11:07:31 AM. Date display is determined by your application's current culture value.| |`"Long Date"` or `"Medium Date"`|Displays a date according to your current culture's long date format. For example, Wednesday, March 12, 2008.| -|`"Short Date"`|Displays a date using your current culture's short date format. For example, 3/12/2008.| +|`"Short Date"`|Displays a date using your current culture's short date format. For example, 3/12/2008.| |`"Long Time"` or|Displays a time using your current culture's long time format; typically includes hours, minutes, seconds. For example, 11:07:31 AM.| |`"Medium Time"`|Displays a time in 12 hour format. For example, 11:07 AM.| |`"Short Time"`|Displays a time in 24 hour format. For example, 11:07.| ## Custom date/time formats -The following format characters can be specified in the **format_string** to create custom date/time formats: +The following format characters can be specified in the `format_string` to create custom date/time formats: |Character|Description| |:-----|:-----| -|(**:**)|Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.| -|(**/**)|Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.| -|(**\**)|Backslash. Displays the next character as a literal character. So, it's not interpreted as a formatting character.| -|(**"**)|Double quote. Text enclosed within double quotes is displayed. So, it's not interpreted as formatting characters.| -|c|Display the date as `ddddd` and display the time as `ttttt`, in that order. Display only date information if there is no fractional part to the date serial number; display only time information if there is no integer portion.| -|d|Display the day as a number without a leading zero (1-31).| -|dd|Display the day as a number with a leading zero (01-31).| -|ddd|Display the day as an abbreviation (Sun-Sat). Localized.| -|dddd|Display the day as a full name (Sunday-Saturday). Localized.| -|ddddd|Display the date as a complete date (including day, month, and year), formatted according to your system's short date format setting. The default short date format is `mm/dd/yyyy`.| -|dddddd|Display a date serial number as a complete date (including day, month, and year) formatted according to the long date setting recognized by your system. The default long date format is `dddd, mmmm d, yyyy`.| -|w|Display the day of the week as a number (1 for Sunday through 7 for Saturday).| -|ww|Display the week of the year as a number (1-54).| -|m|Display the month as a number without a leading zero (1-12). If `m` immediately follows `h` or `hh`, minute rather than the month is displayed.| -|mm|Display the month as a number with a leading zero (01-12). If `mm` immediately follows `h` or `hh`, minute rather than the month is displayed. | -|mmm|Display the month as an abbreviation (Jan-Dec). Localized.| -|mmmm|Display the month as a full month name (January-December). Localized.| -|q|Display the quarter of the year as a number (1-4).| -|y|Display the day of the year as a number (1-366).| -|yy|Display the year as a 2-digit number (00-99).| -|yyyy|Display the year as a 4-digit number (100-9999).| -|h|Display the hour as a number without a leading zero (0-23).| -|hh|Display the hour as a number with a leading zero (00-23).| -|n|Display the minute as a number without a leading zero (0-59).| -|nn|Display the minute as a number with a leading zero (00-59).| -|s|Display the second as a number without a leading zero (0-59).| -|ss|Display the second as a number with a leading zero (00-59).| -|ttttt|Display a time as a complete time (including hour, minute, and second), formatted using the time separator defined by the time format recognized by your system. A leading zero is displayed if the leading zero option is selected and the time is before 10:00 A.M. or P.M. The default time format is `h:mm:ss`.| -|AM/PM|Use the 12-hour clock and display an uppercase AM with any hour before noon; display an uppercase PM with any hour between noon and 11:59 P.M.| -|am/pm|Use the 12-hour clock and display a lowercase AM with any hour before noon; display a lowercase PM with any hour between noon and 11:59 P.M.| -|A/P|Use the 12-hour clock and display an uppercase A with any hour before noon; display an uppercase P with any hour between noon and 11:59 P.M.| -|a/p|Use the 12-hour clock and display a lowercase A with any hour before noon; display a lowercase P with any hour between noon and 11:59 P.M.| -|AMPM|Use the 12-hour clock and display the AM string literal as defined by your system with any hour before noon; display the PM string literal as defined by your system with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. The default format is AM/PM. If your system is set to 24-hour clock, the string is typical set to an empty string.| +|(`:`)|Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.| +|(`/`)|Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.| +|(`\`)|Backslash. Displays the next character as a literal character. So, it's not interpreted as a formatting character.| +|(`"`)|Double quote. Text enclosed within double quotes is displayed. So, it's not interpreted as formatting characters.| +|`c`|Display the date as `ddddd` and display the time as `ttttt`, in that order. Display only date information if there is no fractional part to the date serial number; display only time information if there is no integer portion.| +|`d`|Display the day as a number without a leading zero (1-31).| +|`dd`|Display the day as a number with a leading zero (01-31).| +|`ddd`|Display the day as an abbreviation (Sun-Sat). Localized.| +|`dddd`|Display the day as a full name (Sunday-Saturday). Localized.| +|`ddddd`|Display the date as a complete date (including day, month, and year), formatted according to your system's short date format setting. The default short date format is `mm/dd/yyyy`.| +|`dddddd`|Display a date serial number as a complete date (including day, month, and year) formatted according to the long date setting recognized by your system. The default long date format is `dddd, mmmm d, yyyy`.| +|`w`|Display the day of the week as a number (1 for Sunday through 7 for Saturday).| +|`ww`|Display the week of the year as a number (1-54).| +|`m`|Display the month as a number without a leading zero (1-12). If `m` immediately follows `h` or `hh`, minute rather than the month is displayed.| +|`mm`|Display the month as a number with a leading zero (01-12). If `mm` immediately follows `h` or `hh`, minute rather than the month is displayed. | +|`mmm`|Display the month as an abbreviation (Jan-Dec). Localized.| +|`mmmm`|Display the month as a full month name (January-December). Localized.| +|`q`|Display the quarter of the year as a number (1-4).| +|`y`|Display the day of the year as a number (1-366).| +|`yy`|Display the year as a 2-digit number (00-99).| +|`yyyy`|Display the year as a 4-digit number (100-9999).| +|`h`|Display the hour as a number without a leading zero (0-23).| +|`hh`|Display the hour as a number with a leading zero (00-23).| +|`n`|Display the minute as a number without a leading zero (0-59).| +|`nn`|Display the minute as a number with a leading zero (00-59).| +|`s`|Display the second as a number without a leading zero (0-59).| +|`ss`|Display the second as a number with a leading zero (00-59).| +|`ttttt`|Display a time as a complete time (including hour, minute, and second), formatted using the time separator defined by the time format recognized by your system. A leading zero is displayed if the leading zero option is selected and the time is before 10:00 A.M. or P.M. The default time format is `h:mm:ss`.| +|`AM/PM`|Use the 12-hour clock and display an uppercase AM with any hour before noon; display an uppercase PM with any hour between noon and 11:59 P.M.| +|`am/pm`|Use the 12-hour clock and display a lowercase AM with any hour before noon; display a lowercase PM with any hour between noon and 11:59 P.M.| +|`A/P`|Use the 12-hour clock and display an uppercase A with any hour before noon; display an uppercase P with any hour between noon and 11:59 P.M.| +|`a/p`|Use the 12-hour clock and display a lowercase A with any hour before noon; display a lowercase P with any hour between noon and 11:59 P.M.| +|`AMPM`|Use the 12-hour clock and display the AM string literal as defined by your system with any hour before noon; display the PM string literal as defined by your system with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. The default format is AM/PM. If your system is set to 24-hour clock, the string is typical set to an empty string.| Date/time formatting uses the current user locale to format the string. For example, consider the date June 25, 2020. When it's formatted using format string "m/d/yyyy" it will be: @@ -241,4 +236,3 @@ The following examples use the date/time Thursday, June 25, 2020, at 1:23:45 PM. |`"ttttt AMPM"`|13:23:45 PM|13:23:45| |`"mm/dd/yyyy hh:nn:ss AMPM"`|06/25/2020 01:23:45 PM|6.25.2020 01:23:45| - diff --git a/query-languages/dax/fv-function-dax.md b/query-languages/dax/fv-function-dax.md index 15bcc13b5..e315a71d0 100644 --- a/query-languages/dax/fv-function-dax.md +++ b/query-languages/dax/fv-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: FV" -title: "FV function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "FV function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # FV +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Calculates the future value of an investment based on a constant interest rate. You can use FV with either periodic, constant payments, and/or a single lump sum payment. ## Syntax @@ -24,15 +18,15 @@ FV(, , [, [, ]]) ### Parameters -|Term|Definition| -|--------|--------------| -|rate|The interest rate per period.| -|nper|The total number of payment periods in an annuity.| -|pmt|The payment made each period; it cannot change over the life of the annuity. Typically, pmt contains principal and interest but no other fees or taxes.| -|pv|(Optional) The present value, or the lump-sum amount that a series of future payments is worth right now. If pv 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. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`rate`|The interest rate per period.| +|`nper`|The total number of payment periods in an annuity.| +|`pmt`|The payment made each period; it cannot change over the life of the annuity. Typically, pmt contains principal and interest but no other fees or taxes.| +|`pv`|(Optional) The present value, or the lump-sum amount that a series of future payments is worth right now. If pv 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. The accepted values are listed below this table.| -The **type** parameter accepts the following values: +The `type` parameter accepts the following values: | **Set type equal to** | **If payments are due** | | --------------------- | ------------------------------ | diff --git a/query-languages/dax/gcd-function-dax.md b/query-languages/dax/gcd-function-dax.md index 8aa081d43..eeceab031 100644 --- a/query-languages/dax/gcd-function-dax.md +++ b/query-languages/dax/gcd-function-dax.md @@ -1,54 +1,47 @@ --- description: "Learn more about: GCD" -title: "GCD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "GCD function (DAX)" --- # GCD -Returns the greatest common divisor of two or more integers. The greatest common divisor is the largest integer that divides both number1 and number2 without a remainder. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the greatest common divisor of two or more integers. The greatest common divisor is the largest integer that divides both number1 and number2 without a remainder. + +## Syntax + ```dax -GCD(number1, [number2], ...) +GCD(number1, [number2], ...) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number1, number2, ...|Number1 is required, subsequent numbers are optional. 1 to 255 values. If any value is not an integer, it is truncated.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number1, number2, ...`|Number1 is required, subsequent numbers are optional. 1 to 255 values. If any value is not an integer, it is truncated.| + ## Return value -The greatest common divisor of two or more integers. - +The greatest common divisor of two or more integers. + ## Remarks -- If any argument is nonnumeric, GCD returns the #VALUE! error value. - -- If any argument is less than zero, GCD returns the #NUM! error value. - -- One divides any value evenly. - -- A prime number has only itself and one as even divisors. - -- If a parameter to GCD is >=2^53, GCD returns the #NUM! error value. +- If any argument is nonnumeric, GCD returns the `#VALUE!` error value. + +- If any argument is less than zero, GCD returns the `#NUM!` error value. + +- One divides any value evenly. + +- A prime number has only itself and one as even divisors. + +- If a parameter to GCD is >=2^53, GCD returns the `#NUM!` error value. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= GCD(5, 2)|Greatest common divisor of 5 and 2.|1| -|= GCD(24, 36)|Greatest common divisor of 24 and 36.|12| -|= GCD(7, 1)|Greatest common divisor of 7 and 1.|1| +## Example + +|DAX expression|Description|Result| +|-----------|---------------|----------| +|`= GCD(5, 2)`|Greatest common divisor of 5 and 2.|1| +|`= GCD(24, 36)`|Greatest common divisor of 24 and 36.|12| +|`= GCD(7, 1)`|Greatest common divisor of 7 and 1.|1| diff --git a/query-languages/dax/generate-function-dax.md b/query-languages/dax/generate-function-dax.md index a5bb4343f..e75a19909 100644 --- a/query-languages/dax/generate-function-dax.md +++ b/query-languages/dax/generate-function-dax.md @@ -1,92 +1,85 @@ --- description: "Learn more about: GENERATE" -title: "GENERATE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "GENERATE function (DAX)" --- # GENERATE -Returns a table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1*. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1*. + +## Syntax + ```dax -GENERATE(, ) +GENERATE(, ) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -|table1|Any DAX expression that returns a table. | -|table2|Any DAX expression that returns a table. | +### Parameters + +|Term|Definition| +|--------|--------------| +|`table1`|Any DAX expression that returns a table. | +|`table2`|Any DAX expression that returns a table. | ## Return value -A table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1* - -## Remarks - -- If the evaluation of *table2* for the current row in *table1* returns an empty table, then the result table will not contain the current row from *table1*. This is different than GENERATEALL() where the current row from *table1* will be included in the results and columns corresponding to *table2* will have null values for that row. - -- All column names from *table1* and *table2* must be different or an error is returned. +A table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1* + +## Remarks + +- If the evaluation of *table2* for the current row in *table1* returns an empty table, then the result table will not contain the current row from *table1*. This is different than GENERATEALL() where the current row from *table1* will be included in the results and columns corresponding to *table2* will have null values for that row. + +- All column names from *table1* and *table2* must be different or an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -In the following example the user wants a summary table of the sales by Region and Product Category for the Resellers channel, like the following table: - -|SalesTerritory[SalesTerritoryGroup]|ProductCategory[ProductCategoryName]|[Reseller Sales]| -|-----|-----|-----| -|Europe|Accessories|$ 142,227.27| -|Europe|Bikes|$ 9,970,200.44| -|Europe|Clothing|$ 365,847.63| -|Europe|Components|$ 2,214,440.19| -|North America|Accessories|$ 379,305.15| -|North America|Bikes|$ 52,403,796.85| -|North America|Clothing|$ 1,281,193.26| -|North America|Components|$ 8,882,848.05| -|Pacific|Accessories|$ 12,769.57| -|Pacific|Bikes|$ 710,677.75| -|Pacific|Clothing|$ 22,902.38| -|Pacific|Components|$ 108,549.71| - -The following formula produces the above table: - +In the following example the user wants a summary table of the sales by Region and Product Category for the Resellers channel, like the following table: + +|SalesTerritory[SalesTerritoryGroup]|ProductCategory[ProductCategoryName]|[Reseller Sales]| +|-----|-----|-----| +|Europe|Accessories|$ 142,227.27| +|Europe|Bikes|$ 9,970,200.44| +|Europe|Clothing|$ 365,847.63| +|Europe|Components|$ 2,214,440.19| +|North America|Accessories|$ 379,305.15| +|North America|Bikes|$ 52,403,796.85| +|North America|Clothing|$ 1,281,193.26| +|North America|Components|$ 8,882,848.05| +|Pacific|Accessories|$ 12,769.57| +|Pacific|Bikes|$ 710,677.75| +|Pacific|Clothing|$ 22,902.38| +|Pacific|Components|$ 108,549.71| + +The following formula produces the above table: + ```dax -GENERATE( -SUMMARIZE(SalesTerritory, SalesTerritory[SalesTerritoryGroup]) -,SUMMARIZE(ProductCategory -, [ProductCategoryName] -, "Reseller Sales", SUMX(RELATEDTABLE(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD]) -) -) +GENERATE( +SUMMARIZE(SalesTerritory, SalesTerritory[SalesTerritoryGroup]) +,SUMMARIZE(ProductCategory +, [ProductCategoryName] +, "Reseller Sales", SUMX(RELATEDTABLE(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD]) +) +) ``` - -1. The first SUMMARIZE statement, `SUMMARIZE(SalesTerritory, SalesTerritory[SalesTerritoryGroup])`, produces a table of territory groups, where each row is a territory group, as shown below: - - |SalesTerritory[SalesTerritoryGroup]| - |----------------------------------------| - |North America| - |Europe| - |Pacific| - |NA| - -2. The second SUMMARIZE statement, `SUMMARIZE(ProductCategory, [ProductCategoryName], "Reseller Sales", SUMX(RELATEDTABLE(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD]))`, produces a table of Product Category groups with the Reseller sales for each group, as shown below: - - |ProductCategory[ProductCategoryName]|[Reseller Sales]| - |-----------------------------------------|---------------------| - |Bikes|$ 63,084,675.04| - |Components|$ 11,205,837.96| - |Clothing|$ 1,669,943.27| - |Accessories|$ 534,301.99| - -3. However, when you take the above table and evaluate it under the context of each row from the territory groups table, you obtain different results for each territory. + +1. The first SUMMARIZE statement, `SUMMARIZE(SalesTerritory, SalesTerritory[SalesTerritoryGroup])`, produces a table of territory groups, where each row is a territory group, as shown below: + + |SalesTerritory[SalesTerritoryGroup]| + |----------------------------------------| + |North America| + |Europe| + |Pacific| + |NA| + +2. The second SUMMARIZE statement, `SUMMARIZE(ProductCategory, [ProductCategoryName], "Reseller Sales", SUMX(RELATEDTABLE(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD]))`, produces a table of Product Category groups with the Reseller sales for each group, as shown below: + + |ProductCategory[ProductCategoryName]|[Reseller Sales]| + |-----------------------------------------|---------------------| + |Bikes|$ 63,084,675.04| + |Components|$ 11,205,837.96| + |Clothing|$ 1,669,943.27| + |Accessories|$ 534,301.99| + +3. However, when you take the above table and evaluate it under the context of each row from the territory groups table, you obtain different results for each territory. diff --git a/query-languages/dax/generateall-function-dax.md b/query-languages/dax/generateall-function-dax.md index 3e57354bc..bfcf3c283 100644 --- a/query-languages/dax/generateall-function-dax.md +++ b/query-languages/dax/generateall-function-dax.md @@ -1,96 +1,89 @@ --- description: "Learn more about: GENERATEALL" -title: "GENERATEALL function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "GENERATEALL function (DAX)" --- # GENERATEALL -Returns a table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1*. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1*. + +## Syntax + ```dax -GENERATEALL(, ) +GENERATEALL(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table1|Any DAX expression that returns a table. | -|table2|Any DAX expression that returns a table. | - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table1`|Any DAX expression that returns a table. | +|`table2`|Any DAX expression that returns a table. | + ## Return value -A table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1* - -## Remarks - -- If the evaluation of *table2* for the current row in *table1* returns an empty table, then the current row from *table1* will be included in the results and columns corresponding to *table2* will have null values for that row. This is different than GENERATE() where the current row from *table1* will **not** be included in the results. - -- All column names from *table1* and *table2* must be different or an error is returned. +A table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1* + +## Remarks + +- If the evaluation of *table2* for the current row in *table1* returns an empty table, then the current row from *table1* will be included in the results and columns corresponding to *table2* will have null values for that row. This is different than GENERATE() where the current row from *table1* will **not** be included in the results. + +- All column names from *table1* and *table2* must be different or an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -In the following example, the user wants a summary table of the sales by Region and Product Category for the Resellers channel, like the following table: - -|SalesTerritory[SalesTerritoryGroup]|ProductCategory[ProductCategoryName]|[Reseller Sales]| -|----------------------------------------|-----------------------------------------|---------------------| -|Europe|Accessories|$ 142,227.27| -|Europe|Bikes|$ 9,970,200.44| -|Europe|Clothing|$ 365,847.63| -|Europe|Components|$ 2,214,440.19| -|NA|Accessories|| -|NA|Bikes|| -|NA|Clothing|| -|NA|Components|| -|North America|Accessories|$ 379,305.15| -|North America|Bikes|$ 52,403,796.85| -|North America|Clothing|$ 1,281,193.26| -|North America|Components|$ 8,882,848.05| -|Pacific|Accessories|$ 12,769.57| -|Pacific|Bikes|$ 710,677.75| -|Pacific|Clothing|$ 22,902.38| -|Pacific|Components|$ 108,549.71| - -The following formula produces the above table: - +In the following example, the user wants a summary table of the sales by Region and Product Category for the Resellers channel, like the following table: + +|SalesTerritory[SalesTerritoryGroup]|ProductCategory[ProductCategoryName]|[Reseller Sales]| +|----------------------------------------|-----------------------------------------|---------------------| +|Europe|Accessories|$ 142,227.27| +|Europe|Bikes|$ 9,970,200.44| +|Europe|Clothing|$ 365,847.63| +|Europe|Components|$ 2,214,440.19| +|NA|Accessories|| +|NA|Bikes|| +|NA|Clothing|| +|NA|Components|| +|North America|Accessories|$ 379,305.15| +|North America|Bikes|$ 52,403,796.85| +|North America|Clothing|$ 1,281,193.26| +|North America|Components|$ 8,882,848.05| +|Pacific|Accessories|$ 12,769.57| +|Pacific|Bikes|$ 710,677.75| +|Pacific|Clothing|$ 22,902.38| +|Pacific|Components|$ 108,549.71| + +The following formula produces the above table: + ```dax -GENERATEALL( -SUMMARIZE(SalesTerritory, SalesTerritory[SalesTerritoryGroup]) +GENERATEALL( +SUMMARIZE(SalesTerritory, SalesTerritory[SalesTerritoryGroup]) ,SUMMARIZE(ProductCategory -, [ProductCategoryName] -, "Reseller Sales", SUMX(RELATEDTABLE(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD]) -) -) +, [ProductCategoryName] +, "Reseller Sales", SUMX(RELATEDTABLE(ResellerSales_USD), ResellerSales_USD[SalesAmount_USD]) +) +) ``` - -1. The first SUMMARIZE produces a table of territory groups, where each row is a territory group, like those listed below: - - |SalesTerritory[SalesTerritoryGroup]| - |----------------------------------------| - |North America| - |Europe| - |Pacific| - |NA| - -2. The second SUMMARIZE produces a table of Product Category groups with the Reseller sales for each group, as shown below: - - |ProductCategory[ProductCategoryName]|[Reseller Sales]| - |-----------------------------------------|---------------------| - |Bikes|$ 63,084,675.04| - |Components|$ 11,205,837.96| - |Clothing|$ 1,669,943.27| - |Accessories|$ 534,301.99| - -3. However, when you take the above table and evaluate the table under the context of each row from the territory groups table, you obtain different results for each territory. + +1. The first SUMMARIZE produces a table of territory groups, where each row is a territory group, like those listed below: + + |SalesTerritory[SalesTerritoryGroup]| + |----------------------------------------| + |North America| + |Europe| + |Pacific| + |NA| + +2. The second SUMMARIZE produces a table of Product Category groups with the Reseller sales for each group, as shown below: + + |ProductCategory[ProductCategoryName]|[Reseller Sales]| + |-----------------------------------------|---------------------| + |Bikes|$ 63,084,675.04| + |Components|$ 11,205,837.96| + |Clothing|$ 1,669,943.27| + |Accessories|$ 534,301.99| + +3. However, when you take the above table and evaluate the table under the context of each row from the territory groups table, you obtain different results for each territory. diff --git a/query-languages/dax/generateseries-function.md b/query-languages/dax/generateseries-function-dax.md similarity index 68% rename from query-languages/dax/generateseries-function.md rename to query-languages/dax/generateseries-function-dax.md index 4e0148fb7..0faebb8f8 100644 --- a/query-languages/dax/generateseries-function.md +++ b/query-languages/dax/generateseries-function-dax.md @@ -1,41 +1,34 @@ --- description: "Learn more about: GENERATESERIES" -title: "GENERATESERIES function | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "GENERATESERIES function" --- # GENERATESERIES -Returns a single column table containing the values of an arithmetic series, that is, a sequence of values in which each differs from the preceding by a constant quantity. The name of the column returned is Value. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a single column table containing the values of an arithmetic series, that is, a sequence of values in which each differs from the preceding by a constant quantity. The name of the column returned is Value. + +## Syntax + ```dax GENERATESERIES(, [, ]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|startValue|The initial value used to generate the sequence.| -|endValue|The end value used to generate the sequence.| -|incrementValue|(Optional) The increment value of the sequence. When not provided, the default value is 1.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`startValue`|The initial value used to generate the sequence.| +|`endValue`|The end value used to generate the sequence.| +|`incrementValue`|(Optional) The increment value of the sequence. When not provided, the default value is 1.| + ## Return value A single column table containing the values of an arithmetic series. The name of the column is Value. - + ## Remarks -- When startValue is less than endValue, an empty table is returned. +- When endValue is less than startValue, an empty table is returned. - incrementValue must be a positive value. diff --git a/query-languages/dax/geomean-function-dax.md b/query-languages/dax/geomean-function-dax.md index d8d11d63e..1489c5844 100644 --- a/query-languages/dax/geomean-function-dax.md +++ b/query-languages/dax/geomean-function-dax.md @@ -1,54 +1,47 @@ --- description: "Learn more about: GEOMEAN" -title: "GEOMEAN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "GEOMEAN function (DAX)" --- # GEOMEAN - -Returns the geometric mean of the numbers in a column. - -To return the geometric mean of an expression evaluated for each row in a table, use [GEOMEANX function](geomeanx-function-dax.md). - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the geometric mean of the numbers in a column. + +To return the geometric mean of an expression evaluated for each row in a table, use [GEOMEANX function](geomeanx-function-dax.md). + +## Syntax + ```dax -GEOMEAN() +GEOMEAN() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column that contains the numbers for which the geometric mean is to be computed.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that contains the numbers for which the geometric mean is to be computed.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- Only the numbers in the column are counted. Blanks, logical values, and text are ignored. - -- GEOMEAN( Table[Column] ) is equivalent to GEOMEANX( Table, Table[Column] ) +- Only the numbers in the column are counted. Blanks, logical values, and text are ignored. + +- GEOMEAN( Table[Column] ) is equivalent to GEOMEANX( Table, Table[Column] ) - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following computes the geometric mean of the Return column in the Investment table: - +The following computes the geometric mean of the Return column in the Investment table: + ```dax -= GEOMEAN( Investment[Return] ) += GEOMEAN( Investment[Return] ) ``` - -## See also -[GEOMEANX function](geomeanx-function-dax.md) +## Related content + +[GEOMEANX function](geomeanx-function-dax.md) diff --git a/query-languages/dax/geomeanx-function-dax.md b/query-languages/dax/geomeanx-function-dax.md index 5fbe7be6d..8b987b658 100644 --- a/query-languages/dax/geomeanx-function-dax.md +++ b/query-languages/dax/geomeanx-function-dax.md @@ -1,55 +1,48 @@ --- description: "Learn more about: GEOMEANX" -title: "GEOMEANX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "GEOMEANX function (DAX)" --- # GEOMEANX - -Returns the geometric mean of an expression evaluated for each row in a table. - -To return the geometric mean of the numbers in a column, use [GEOMEAN function](geomean-function-dax.md). - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the geometric mean of an expression evaluated for each row in a table. + +To return the geometric mean of the numbers in a column, use [GEOMEAN function](geomean-function-dax.md). + +## Syntax + ```dax -GEOMEANX(
, ) +GEOMEANX(
, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of the table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of the table.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- The GEOMEANX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers for which you want to compute the geometric mean, or an expression that evaluates to a column. - -- Only the numbers in the column are counted. Blanks, logical values, and text are ignored. +- The GEOMEANX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers for which you want to compute the geometric mean, or an expression that evaluates to a column. + +- Only the numbers in the column are counted. Blanks, logical values, and text are ignored. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following computes the geometric mean of the ReturnPct column in the Investments table: - +The following computes the geometric mean of the ReturnPct column in the Investments table: + ```dax -= GEOMEANX( Investments, Investments[ReturnPct] + 1 ) += GEOMEANX( Investments, Investments[ReturnPct] + 1 ) ``` - -## See also -[GEOMEAN function](geomean-function-dax.md) +## Related content + +[GEOMEAN function](geomean-function-dax.md) diff --git a/query-languages/dax/groupby-function-dax.md b/query-languages/dax/groupby-function-dax.md index 369e7e7da..a55ad806d 100644 --- a/query-languages/dax/groupby-function-dax.md +++ b/query-languages/dax/groupby-function-dax.md @@ -1,58 +1,51 @@ --- description: "Learn more about: GROUPBY" -title: "GROUPBY function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/14/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "GROUPBY function (DAX)" --- # GROUPBY - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + The GROUPBY function is similar to the [SUMMARIZE](summarize-function-dax.md) function. However, GROUPBY does not do an implicit [CALCULATE](calculate-function-dax.md) for any extension columns that it adds. GROUPBY permits a new function, [CURRENTGROUP](currentgroup-function-dax.md), to be used inside aggregation functions in the extension columns that it adds. GROUPBY is used to perform multiple aggregations in a single table scan. - -## Syntax - + +## Syntax + ```dax GROUPBY (
[, [, [, …]]] [, , [, , [, …]]]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|Any DAX expression that returns a table of data.| -|groupBy_columnName|The name of an existing column in the table (or in a related table,) by which the data is to be grouped. This parameter cannot be an expression.| -|name|The name given to a new column that is being added to the list of GroupBy columns, enclosed in double quotes.| -|expression|One of the X aggregation functions with the first argument being CURRENTGROUP(). See With CURRENTGROUP section below for the full list of supported X aggregation functions.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|Any DAX expression that returns a table of data.| +|`groupBy_columnName`|The name of an existing column in the table (or in a related table,) by which the data is to be grouped. This parameter cannot be an expression.| +|`name`|The name given to a new column that is being added to the list of GroupBy columns, enclosed in double quotes.| +|`expression`|One of the X aggregation functions with the first argument being CURRENTGROUP(). See With CURRENTGROUP section below for the full list of supported X aggregation functions.| + ## Return value -A table with the selected columns for the groupBy_columnName arguments and the extension columns designated by the name arguments. - +A table with the selected columns for the groupBy_columnName arguments and the extension columns designated by the name arguments. + ## Remarks -- The GROUPBY function does the following: - - 1. Start with the specified table (and all related tables in the "to-one" direction). - - 2. Create a grouping using all of the GroupBy columns (which are required to exist in the table from step #1.). - - 3. Each group is one row in the result, but represents a set of rows in the original table. - - 4. For each group, evaluate the extension columns being added. Unlike the SUMMARIZE function, an implied CALCULATE is not performed, and the group isn't placed into the filter context. - -- Each column for which you define a name must have a corresponding expression; otherwise, an error is returned. The first argument, name, defines the name of the column in the results. The second argument, expression, defines the calculation performed to obtain the value for each row in that column. - -- groupBy_columnName must be either in table or in a related table. - -- Each name must be enclosed in double quotation marks. - -- The function groups a selected set of rows into a set of summary rows by the values of one or more groupBy_columnName columns. One row is returned for each group. +- The GROUPBY function does the following: + + 1. Start with the specified table (and all related tables in the "to-one" direction). + + 2. Create a grouping using all of the GroupBy columns (which are required to exist in the table from step #1.). + + 3. Each group is one row in the result, but represents a set of rows in the original table. + + 4. For each group, evaluate the extension columns being added. Unlike the SUMMARIZE function, an implied CALCULATE is not performed, and the group isn't placed into the filter context. + +- Each column for which you define a name must have a corresponding expression; otherwise, an error is returned. The first argument, name, defines the name of the column in the results. The second argument, expression, defines the calculation performed to obtain the value for each row in that column. + +- `groupBy_columnName` must be either in table or in a related table. + +- Each name must be enclosed in double quotation marks. + +- The function groups a selected set of rows into a set of summary rows by the values of one or more groupBy_columnName columns. One row is returned for each group. - GROUPBY is primarily used to perform aggregations over intermediate results from DAX table expressions. For efficient aggregations over physical tables in the model, consider using [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) or [SUMMARIZE](summarize-function-dax.md) function. @@ -60,30 +53,30 @@ A table with the selected columns for the groupBy_columnName arguments and the e ## With CURRENTGROUP -[CURRENTGROUP](currentgroup-function-dax.md) can only be used in an expression that defines an extension column within the GROUPBY function. In-effect, [CURRENTGROUP](currentgroup-function-dax.md) returns a set of rows from the table argument of GROUPBY that belong to the current row of the GROUPBY result. The [CURRENTGROUP](currentgroup-function-dax.md) function takes no arguments and is only supported as the first argument to one of the following aggregation functions: [AVERAGEX](averagex-function-dax.md), [COUNTAX](countax-function-dax.md), [COUNTX](countx-function-dax.md), [GEOMEANX](geomeanx-function-dax.md), [MAXX](maxx-function-dax.md), [MINX](minx-function-dax.md), [PRODUCTX](productx-function-dax.md), [STDEVX.S](stdevx-s-function-dax.md), [STDEVX.P](stdevx-s-function-dax.md), [SUMX](sumx-function-dax.md), [VARX.S](varx-s-function-dax.md), [VARX.P](varx-p-function-dax.md). - +[CURRENTGROUP](currentgroup-function-dax.md) can only be used in an expression that defines an extension column within the GROUPBY function. In-effect, [CURRENTGROUP](currentgroup-function-dax.md) returns a set of rows from the table argument of GROUPBY that belong to the current row of the GROUPBY result. The [CURRENTGROUP](currentgroup-function-dax.md) function takes no arguments and is only supported as the first argument to one of the following aggregation functions: [AVERAGEX](averagex-function-dax.md), [COUNTAX](countax-function-dax.md), [COUNTX](countx-function-dax.md), [GEOMEANX](geomeanx-function-dax.md), [MAXX](maxx-function-dax.md), [MINX](minx-function-dax.md), [PRODUCTX](productx-function-dax.md), [STDEVX.S](stdevx-s-function-dax.md), [STDEVX.P](stdevx-s-function-dax.md), [SUMX](sumx-function-dax.md), [VARX.S](varx-s-function-dax.md), [VARX.P](varx-p-function-dax.md). + ### Example The following example first calculates the total sales grouped by country and product category over physical tables by using the [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) function. It then uses the GROUPBY function to scan the intermediate result from the first step to find the maximum sales in each country across the product categories. - + ```dax -DEFINE -VAR SalesByCountryAndCategory = -SUMMARIZECOLUMNS( +DEFINE +VAR SalesByCountryAndCategory = +SUMMARIZECOLUMNS( Geography[Country], Product[Category], -"Total Sales", SUMX(Sales, Sales[Price] * Sales[Qty]) -) - +"Total Sales", SUMX(Sales, Sales[Price] * Sales[Qty]) +) + EVALUATE -GROUPBY( +GROUPBY( SalesByCountryAndCategory, Geography[Country], -"Max Sales", MAXX(CURRENTGROUP(), [Total Sales]) -) +"Max Sales", MAXX(CURRENTGROUP(), [Total Sales]) +) ``` - -## See also -[SUMMARIZE function](summarize-function-dax.md) -[SUMMARIZECOLUMNS function](summarizecolumns-function-dax.md) +## Related content + +[SUMMARIZE function](summarize-function-dax.md) +[SUMMARIZECOLUMNS function](summarizecolumns-function-dax.md) diff --git a/query-languages/dax/groupcrossapply-function-dax.md b/query-languages/dax/groupcrossapply-function-dax.md new file mode 100644 index 000000000..735c7d0f3 --- /dev/null +++ b/query-languages/dax/groupcrossapply-function-dax.md @@ -0,0 +1,57 @@ +--- +description: "Learn more about: GROUPCROSSAPPLY" +title: "GROUPCROSSAPPLY function (DAX) | Microsoft Docs" +--- +# GROUPCROSSAPPLY + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Returns a summary table over a set of groups. + +## Syntax + +```dax +GROUPCROSSAPPLY( [, < groupBy_columnName >]…, []…[, , ]…) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|groupBy_columnName|A fully qualified column reference (Table[Column]) to a base table for which the distinct values are included in the returned table.| +|filterTable|A table expression which is added to the filter context of all columns specified as groupBy_columnName arguments.| +|name|A string representing the column name to use for the subsequent expression specified.| +|expression|Any DAX expression that returns a single value (not a table).| + +## Return value + +A table which includes combinations of values from the supplied columns based on the grouping specified. Only rows for which at least one of the supplied expressions return a non-blank value are included in the table returned. If all expressions evaluate to BLANK/NULL for a row, that row is not included in the table returned. + +## Remarks + +- GROUPCROSSAPPLY is similar to SUMMARIZECOLUMNS function, but it does not apply implicit autoexist. All filterTable parameters are cross-join. FILTERCLUSTER function can be used to perform natural joins of filter tables or group by columns if needed. + +- You can modify filtering behavior of filterTable by using the following functions: + + - ALLSELECTEDAPPLY + + - ALLSELECTEDREMOVE + + - ALWAYSAPPLY + + - KEEPFILTERS + + - SHADOWCLUSTER + + - NONFILTER + +## Related content + +[ALLSELECTEDAPPLY function](allselectedapply-function-dax.md) +[ALLSELECTEDREMOVE function](allselectedremove-function-dax.md) +[ALWAYSAPPLY function](alwaysapply-function-dax.md) +[KEEPFILTERS function](keepfilters-function-dax.md) +[SHADOWCLUSTER function](shadowcluster-function-dax.md) +[NONFILTER function](nonfilter-function-dax.md) +[FILTERCLUSTER function](filtercluster-function-dax.md) +[GROUPCROSSAPPLYTABLE function](groupcrossapplytable-function-dax.md) diff --git a/query-languages/dax/groupcrossapplytable-function-dax.md b/query-languages/dax/groupcrossapplytable-function-dax.md new file mode 100644 index 000000000..32fc8b071 --- /dev/null +++ b/query-languages/dax/groupcrossapplytable-function-dax.md @@ -0,0 +1,59 @@ +--- +description: "Learn more about: GROUPCROSSAPPLYTABLE" +title: "GROUPCROSSAPPLYTABLE function (DAX) | Microsoft Docs" +--- +# GROUPCROSSAPPLYTABLE + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Returns a summary table over a set of groups. + +## Syntax + +```dax +GROUPCROSSAPPLYTABLE( [, < groupBy_columnName >]…, []… [, ,
] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|groupBy_columnName|A fully qualified column reference (Table[Column]) to a base table for which the distinct values are included in the returned table.| +|filterTable|A table expression which is added to the filter context of all columns specified as groupBy_columnName arguments. The values present in the filter table are used to filter before cross-join/auto-exist is performed.| +|separator|A string literal which serves no purpose other than separating filterTable parameter with table expression parameter| +|table expression|A table expression that is evaluated under filter context of filterTable parameters and returned as a part of the join in the return value| + +## Return value + +A table which includes combinations of values from the supplied columns based on the grouping specified. + +## Remarks + +- GROUPCROSSAPPLYTABLE is similar to GROUPCROSSJOIN function. All filterTable parameters are cross-join. FILTERCLUSTER function can be used to perform natural joins of filter tables or group by columns if needed. + +- The table expression parameter is evaluated in the filter context containing all filterTable parameters. + +- You can modify filtering behavior of filterTable by using the following functions: + + - ALLSELECTEDAPPLY + + - ALLSELECTEDREMOVE + + - ALWAYSAPPLY + + - KEEPFILTERS + + - SHADOWCLUSTER + + - NONFILTER + +## Related content + +[ALLSELECTEDAPPLY function](allselectedapply-function-dax.md) +[ALLSELECTEDREMOVE function](allselectedremove-function-dax.md) +[ALWAYSAPPLY function](alwaysapply-function-dax.md) +[KEEPFILTERS function](keepfilters-function-dax.md) +[SHADOWCLUSTER function](shadowcluster-function-dax.md) +[NONFILTER function](nonfilter-function-dax.md) +[FILTERCLUSTER function](filtercluster-function-dax.md) +[GROUPCROSSAPPLY function](groupcrossapply-function-dax.md) diff --git a/query-languages/dax/hasonefilter-function-dax.md b/query-languages/dax/hasonefilter-function-dax.md index ee21a80a0..22615f5c6 100644 --- a/query-languages/dax/hasonefilter-function-dax.md +++ b/query-languages/dax/hasonefilter-function-dax.md @@ -1,46 +1,39 @@ --- description: "Learn more about: HASONEFILTER" -title: "HASONEFILTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "HASONEFILTER function (DAX)" --- # HASONEFILTER -Returns **TRUE** when the number of directly filtered values on *columnName* is one; otherwise returns **FALSE**. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` when the number of directly filtered values on `columnName` is one; otherwise returns `FALSE`. + +## Syntax + ```dax -HASONEFILTER() +HASONEFILTER() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| columnName | The name of an existing column, using standard DAX syntax. It cannot be an expression. | - +### Parameters + +|Term|Definition| +|--------|--------------| +|`columnName`| The name of an existing column, using standard DAX syntax. It cannot be an expression. | + ## Return value -**TRUE** when the number of directly filtered values on *columnName* is one; otherwise returns **FALSE**. - -## Remarks - -- This function is similar to HASONEVALUE() with the difference that HASONEVALUE() works based on cross-filters while HASONEFILTER() works by a direct filter. +`TRUE` when the number of directly filtered values on `columnName` is one; otherwise returns `FALSE`. + +## Remarks + +- This function is similar to HASONEVALUE() with the difference that HASONEVALUE() works based on cross-filters while HASONEFILTER() works by a direct filter. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example shows how to use HASONEFILTER() to return the filter for ResellerSales_USD[ProductKey]) if there is one filter, or to return BLANK if there are no filters or more than one filter on ResellerSales_USD[ProductKey]). - +The following example shows how to use HASONEFILTER() to return the filter for ResellerSales_USD[ProductKey]) if there is one filter, or to return BLANK if there are no filters or more than one filter on ResellerSales_USD[ProductKey]). + ```dax -= IF(HASONEFILTER(ResellerSales_USD[ProductKey]),FILTERS(ResellerSales_USD[ProductKey]),BLANK()) += IF(HASONEFILTER(ResellerSales_USD[ProductKey]),FILTERS(ResellerSales_USD[ProductKey]),BLANK()) ``` diff --git a/query-languages/dax/hasonevalue-function-dax.md b/query-languages/dax/hasonevalue-function-dax.md index 4cf884421..caa520ff1 100644 --- a/query-languages/dax/hasonevalue-function-dax.md +++ b/query-languages/dax/hasonevalue-function-dax.md @@ -1,46 +1,39 @@ --- description: "Learn more about: HASONEVALUE" -title: "HASONEVALUE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "HASONEVALUE function (DAX)" --- # HASONEVALUE -Returns **TRUE** when the context for *columnName* has been filtered down to one distinct value only. Otherwise is **FALSE**. - -## Syntax - -```html -HASONEVALUE() +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` when the context for `columnName` has been filtered down to one distinct value only. Otherwise is `FALSE`. + +## Syntax + +```html +HASONEVALUE() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| columnName | The name of an existing column, using standard DAX syntax. It cannot be an expression. | +### Parameters + +|Term|Definition| +|--------|--------------| +| columnName | The name of an existing column, using standard DAX syntax. It cannot be an expression. | ## Return value -**TRUE** when the context for *columnName* has been filtered down to one distinct value only. Otherwise is **FALSE**. - -## Remarks - -- An equivalent expression for HASONEVALUE() is `COUNTROWS(VALUES()) = 1`. +`TRUE` when the context for `columnName` has been filtered down to one distinct value only. Otherwise is `FALSE`. + +## Remarks + +- An equivalent expression for HASONEVALUE() is `COUNTROWS(VALUES()) = 1`. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example The following measure formula verifies if the context is being sliced by one value in order to estimate a percentage against a predefined scenario; in this case you want to compare Reseller Sales against sales in 2007, then you need to know if the context is filtered by single years. Also, if the comparison is meaningless you want to return BLANK. - + ```dax -= IF(HASONEVALUE(DateTime[CalendarYear]),SUM(ResellerSales_USD[SalesAmount_USD])/CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]),DateTime[CalendarYear]=2007),BLANK()) += IF(HASONEVALUE(DateTime[CalendarYear]),SUM(ResellerSales_USD[SalesAmount_USD])/CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]),DateTime[CalendarYear]=2007),BLANK()) ``` diff --git a/query-languages/dax/hour-function-dax.md b/query-languages/dax/hour-function-dax.md index d2640adaa..b3c287334 100644 --- a/query-languages/dax/hour-function-dax.md +++ b/query-languages/dax/hour-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: HOUR" -title: "HOUR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "HOUR function (DAX)" --- # HOUR -Returns the hour as a number from 0 (12:00 A.M.) to 23 (11:00 P.M.). - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the hour as a number from 0 (12:00 A.M.) to 23 (11:00 P.M.). + +## Syntax + ```dax -HOUR() +HOUR() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|datetime|A **datetime** value, such as 16:48:00 or 4:48 PM.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`datetime`|A `datetime` value, such as 16:48:00 or 4:48 PM.| + ## Return value -An integer number from 0 to 23. +An integer number from 0 to 23. ## Remarks -- The HOUR function takes as argument the time that contains the hour you want to find. You can supply the time by using a date/time function, an expression that returns a **datetime**, or by typing the value directly in one of the accepted time formats. Times can also be entered as any accepted text representation of a time. - -- When the **datetime** argument is a text representation of the date and time, the function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. Most locales use the colon (:) as the time separator and any input text using colons as time separators will parse correctly. Review your locale settings to understand your results. - +- The HOUR function takes as argument the time that contains the hour you want to find. You can supply the time by using a date/time function, an expression that returns a `datetime`, or by typing the value directly in one of the accepted time formats. Times can also be entered as any accepted text representation of a time. + +- When the `datetime` argument is a text representation of the date and time, the function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. Most locales use the colon (:) as the time separator and any input text using colons as time separators will parse correctly. Review your locale settings to understand your results. + ## Example 1 -The following example returns the hour from the **TransactionTime** column of a table named **Orders**. - +The following example returns the hour from the **TransactionTime** column of a table named **Orders**. + ```dax -= HOUR('Orders'[TransactionTime]) += HOUR('Orders'[TransactionTime]) ``` - + ## Example 2 -The following example returns 15, meaning the hour corresponding to 3 PM in a 24-hour clock. The text value is automatically parsed and converted to a date/time value. - +The following example returns 15, meaning the hour corresponding to 3 PM in a 24-hour clock. The text value is automatically parsed and converted to a date/time value. + ```dax -= HOUR("March 3, 2008 3:00 PM") += HOUR("March 3, 2008 3:00 PM") ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[MINUTE function](minute-function-dax.md) -[YEAR function](year-function-dax.md) -[SECOND function](second-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[MINUTE function](minute-function-dax.md) +[YEAR function](year-function-dax.md) +[SECOND function](second-function-dax.md) diff --git a/query-languages/dax/if-eager-function-dax.md b/query-languages/dax/if-eager-function-dax.md index 7da95b4c8..8d0e09d9c 100644 --- a/query-languages/dax/if-eager-function-dax.md +++ b/query-languages/dax/if-eager-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: IF.EAGER" -title: "IF.EAGER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 02/22/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "IF.EAGER function (DAX)" --- # IF.EAGER -Checks a condition, and returns one value when TRUE, otherwise it returns a second value. It uses an *eager* execution plan which always executes the branch expressions regardless of the condition expression. +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks a condition, and returns one value when `TRUE`, otherwise it returns a second value. It uses an *eager* execution plan which always executes the branch expressions regardless of the condition expression. ## Syntax @@ -25,24 +18,24 @@ IF.EAGER(, [, ]) |Term|Definition| |--------|--------------| -|logical_test|Any value or expression that can be evaluated to TRUE or FALSE.| -|value_if_true|The value that's returned if the logical test is TRUE.| -|value_if_false|(Optional) The value that's returned if the logical test is FALSE. If omitted, BLANK is returned.| +|`logical_test`|Any value or expression that can be evaluated to `TRUE` or `FALSE`.| +|`value_if_true`|The value that's returned if the logical test is `TRUE`.| +|`value_if_false`|(Optional) The value that's returned if the logical test is `FALSE`. If omitted, `BLANK` is returned.| ## Return value -Either **value_if_true**, **value_if_false**, or BLANK. +Either `value_if_true`, `value_if_false`, or `BLANK`. ## Remarks -- The IF.EAGER function can return a variant data type if value_if_true and value_if_false are of different data types, but the function attempts to return a single data type if both **value_if_true** and **value_if_false** are of numeric data types. In the latter case, the IF.EAGER function will implicitly convert data types to accommodate both values. +- The IF.EAGER function can return a variant data type if value_if_true and value_if_false are of different data types, but the function attempts to return a single data type if both `value_if_true` and `value_if_false` are of numeric data types. In the latter case, the IF.EAGER function will implicitly convert data types to accommodate both values. - For example, the formula `IF.EAGER(, TRUE(), 0)` returns TRUE or 0, but the formula `IF.EAGER(, 1.0, 0)` returns only decimal values even though **value_if_false** is of the whole number data type. To learn more about implicit data type conversion, see [Data types](dax-overview.md#data-types). + For example, the formula `IF.EAGER(, TRUE(), 0)` returns `TRUE` or 0, but the formula `IF.EAGER(, 1.0, 0)` returns only decimal values even though `value_if_false` is of the whole number data type. To learn more about implicit data type conversion, see [Data types](dax-overview.md#data-types). - IF.EAGER has the same functional behavior as the IF function, but performance may differ due to differences in execution plans. `IF.EAGER(, , )` has the same execution plan as the following DAX expression: ```dax - + VAR _value_if_true = VAR _value_if_false = RETURN @@ -55,7 +48,7 @@ Either **value_if_true**, **value_if_false**, or BLANK. See [IF Examples](if-function-dax.md#examples). -## See also +## Related content -[IF function](if-function-dax.md) -[Logical functions](logical-functions-dax.md) +[IF function](if-function-dax.md) +[Logical functions](logical-functions-dax.md) diff --git a/query-languages/dax/if-function-dax.md b/query-languages/dax/if-function-dax.md index a0b9823ac..984ba18a9 100644 --- a/query-languages/dax/if-function-dax.md +++ b/query-languages/dax/if-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: IF" -title: "IF function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 02/22/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "IF function (DAX)" --- # IF -Checks a condition, and returns one value when it's TRUE, otherwise it returns a second value. +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks a condition, and returns one value when it's `TRUE`, otherwise it returns a second value. ## Syntax @@ -25,19 +18,19 @@ IF(, [, ]) |Term|Definition| |--------|--------------| -|logical_test|Any value or expression that can be evaluated to TRUE or FALSE.| -|value_if_true|The value that's returned if the logical test is TRUE.| -|value_if_false|(Optional) The value that's returned if the logical test is FALSE. If omitted, BLANK is returned.| +|`logical_test`|Any value or expression that can be evaluated to `TRUE` or `FALSE`.| +|`value_if_true`|The value that's returned if the logical test is `TRUE`.| +|`value_if_false`|(Optional) The value that's returned if the logical test is `FALSE`. If omitted, BLANK is returned.| ## Return value -Either **value_if_true**, **value_if_false**, or BLANK. +Either `value_if_true`, `value_if_false`, or `BLANK`. ## Remarks -- The IF function can return a variant data type if **value_if_true** and **value_if_false** are of different data types, but the function attempts to return a single data type if both **value_if_true** and **value_if_false** are of numeric data types. In the latter case, the IF function will implicitly convert data types to accommodate both values. +- The IF function can return a variant data type if `value_if_true` and `value_if_false` are of different data types, but the function attempts to return a single data type if both `value_if_true` and `value_if_false` are of numeric data types. In the latter case, the IF function will implicitly convert data types to accommodate both values. - For example, the formula `IF(, TRUE(), 0)` returns TRUE or 0, but the formula `IF(, 1.0, 0)` returns only decimal values even though **value_if_false** is of the whole number data type. To learn more about implicit data type conversion, see [Data types](dax-overview.md#data-types). + For example, the formula `IF(, TRUE(), 0)` returns `TRUE` or 0, but the formula `IF(, 1.0, 0)` returns only decimal values even though `value_if_false` is of the whole number data type. To learn more about implicit data type conversion, see [Data types](dax-overview.md#data-types). - To execute the branch expressions regardless of the condition expression, use [IF.EAGER](if-eager-function-dax.md) instead. @@ -45,7 +38,7 @@ Either **value_if_true**, **value_if_false**, or BLANK. The following **Product** table calculated column definitions use the IF function in different ways to classify each product based on its list price. -The first example tests whether the **List Price** column value is less than 500. When this condition is true, the value **Low** is returned. Because there's no **value_if_false** value, BLANK is returned. +The first example tests whether the **List Price** column value is less than 500. When this condition is true, the value **Low** is returned. Because there's no `value_if_false` value, BLANK is returned. [!INCLUDE [power-bi-dax-sample-model](includes/power-bi-dax-sample-model.md)] @@ -57,7 +50,7 @@ IF( ) ``` -The second example uses the same test, but this time includes a **value_if_false** value. So, the formula classifies each product as either **Low** or **High**. +The second example uses the same test, but this time includes a `value_if_false` value. So, the formula classifies each product as either `Low` or `High`. ```dax Price Group = @@ -68,7 +61,7 @@ IF( ) ``` -The third example uses the same test, but this time nests an IF function to perform an additional test. So, the formula classifies each product as either **Low**, **Medium**, or **High**. +The third example uses the same test, but this time nests an IF function to perform an additional test. So, the formula classifies each product as either `Low`, `Medium`, or `High`. ```dax Price Group = @@ -86,8 +79,8 @@ IF( > [!TIP] > When you need to nest multiple IF functions, the [SWITCH](switch-function-dax.md) function might be a better option. This function provides a more elegant way to write an expression that returns more than two possible values. -## See also +## Related content -[IF.EAGER function](if-eager-function-dax.md) -[SWITCH function (DAX)](switch-function-dax.md) -[Logical functions](logical-functions-dax.md) +[IF.EAGER function](if-eager-function-dax.md) +[SWITCH function (DAX)](switch-function-dax.md) +[Logical functions](logical-functions-dax.md) diff --git a/query-languages/dax/iferror-function-dax.md b/query-languages/dax/iferror-function-dax.md index 4569502b0..b3c358a29 100644 --- a/query-languages/dax/iferror-function-dax.md +++ b/query-languages/dax/iferror-function-dax.md @@ -1,48 +1,41 @@ --- description: "Learn more about: IFERROR" -title: "IFERROR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/13/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "IFERROR function (DAX)" --- # IFERROR -Evaluates an expression and returns a specified value if the expression returns an error; otherwise returns the value of the expression itself. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Evaluates an expression and returns a specified value if the expression returns an error; otherwise returns the value of the expression itself. + +## Syntax + ```dax -IFERROR(value, value_if_error) +IFERROR(value, value_if_error) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|value|Any value or expression.| -|value_if_error|Any value or expression.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`value`|Any value or expression.| +|`value_if_error`|Any value or expression.| + ## Return value -A scalar of the same type as **value** - +A scalar of the same type as `value` + ## Remarks -- You can use the IFERROR function to trap and handle errors in an expression. - -- If **value** or **value_if_error** is an empty cell, IFERROR treats it as an empty string value (""). - -- The IFERROR function is based on the IF function, and uses the same error messages, but has fewer arguments. The relationship between the IFERROR function and the IF function as follows: - - `IFERROR(A,B) := IF(ISERROR(A), B, A)` - - Values that are returned for A and B must be of the same data type; therefore, the column or expression used for **value** and the value returned for **value_if_error** must be the same data type. +- You can use the IFERROR function to trap and handle errors in an expression. + +- If `value` or `value_if_error` is an empty cell, IFERROR treats it as an empty string value (""). + +- The IFERROR function is based on the IF function, and uses the same error messages, but has fewer arguments. The relationship between the IFERROR function and the IF function as follows: + + `IFERROR(A,B) := IF(ISERROR(A), B, A)` + + Values that are returned for A and B must be of the same data type; therefore, the column or expression used for `value` and the value returned for `value_if_error` must be the same data type. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] @@ -50,12 +43,12 @@ A scalar of the same type as **value** ## Example -The following example returns 9999 if the expression 25/0 evaluates to an error. If the expression returns a value other than error, that value is passed to the invoking expression. - +The following example returns 9999 if the expression 25/0 evaluates to an error. If the expression returns a value other than error, that value is passed to the invoking expression. + ```dax -= IFERROR(25/0,9999) += IFERROR(25/0,9999) ``` - -## See also -[Logical functions](logical-functions-dax.md) +## Related content + +[Logical functions](logical-functions-dax.md) diff --git a/query-languages/dax/ignore-function-dax.md b/query-languages/dax/ignore-function-dax.md index 1d973487a..b31f2149c 100644 --- a/query-languages/dax/ignore-function-dax.md +++ b/query-languages/dax/ignore-function-dax.md @@ -1,45 +1,38 @@ --- description: "Learn more about: IGNORE" -title: "IGNORE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/01/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "IGNORE function (DAX)" --- # IGNORE +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Modifies the behavior of the [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) function by omitting specific expressions from the BLANK/NULL evaluation. Rows for which all expressions not using IGNORE return BLANK/NULL will be excluded independent of whether the expressions which do use IGNORE evaluate to BLANK/NULL or not. This function can only be used within a [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) expression. - -## Syntax - + +## Syntax + ```dax IGNORE() ``` With SUMMARIZECOLUMNS, - + ```dax SUMMARIZECOLUMNS([, < groupBy_columnName >]…, []…[, , IGNORE(…)]…) -``` - -### Parameters +``` -|Term|Definition| -|--------|--------------| -|expression|Any DAX expression that returns a single value (not a table).| +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression`|Any DAX expression that returns a single value (not a table).| ## Return value The function does not return a value. - -## Remarks -IGNORE can only be used as an expression argument to [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md). +## Remarks + +IGNORE can only be used as an expression argument to [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md). ## Example diff --git a/query-languages/dax/includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md b/query-languages/dax/includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md new file mode 100644 index 000000000..112c4b6db --- /dev/null +++ b/query-languages/dax/includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md @@ -0,0 +1,4 @@ +**Applies to:** :::image type="icon" source="../media/icons/yes.png":::[Calculated column](/power-bi/transform-model/desktop-calculations-options#calculated-column-dax) :::image type="icon" source="../media/icons/yes.png":::[Calculated table](/power-bi/transform-model/desktop-calculations-options#calculated-table) :::image type="icon" source="../media/icons/yes.png":::[Measure](/power-bi/transform-model/desktop-calculations-options#measures) :::image type="icon" source="../media/icons/discouraged.png":::[Visual calculation](/power-bi/transform-model/desktop-calculations-options#visual-calculation) + +> [!NOTE] +> This function is discouraged for use in [visual calculations](/power-bi/transform-model/desktop-visual-calculations-overview) as it likely returns meaningless results. \ No newline at end of file diff --git a/query-languages/dax/includes/applies-to-measures-columns-tables-visual-calculations.md b/query-languages/dax/includes/applies-to-measures-columns-tables-visual-calculations.md new file mode 100644 index 000000000..3a89b6c87 --- /dev/null +++ b/query-languages/dax/includes/applies-to-measures-columns-tables-visual-calculations.md @@ -0,0 +1 @@ +**Applies to:** :::image type="icon" source="../media/icons/yes.png":::[Calculated column](/power-bi/transform-model/desktop-calculations-options#calculated-column-dax) :::image type="icon" source="../media/icons/yes.png":::[Calculated table](/power-bi/transform-model/desktop-calculations-options#calculated-table) :::image type="icon" source="../media/icons/yes.png":::[Measure](/power-bi/transform-model/desktop-calculations-options#measures) :::image type="icon" source="../media/icons/yes.png":::[Visual calculation](/power-bi/transform-model/desktop-calculations-options#visual-calculation) \ No newline at end of file diff --git a/query-languages/dax/includes/applies-to-measures-columns-tables.md b/query-languages/dax/includes/applies-to-measures-columns-tables.md new file mode 100644 index 000000000..772c3c6da --- /dev/null +++ b/query-languages/dax/includes/applies-to-measures-columns-tables.md @@ -0,0 +1 @@ +**Applies to:** :::image type="icon" source="../media/icons/yes.png":::[Calculated column](/power-bi/transform-model/desktop-calculations-options#calculated-column-dax) :::image type="icon" source="../media/icons/yes.png":::[Calculated table](/power-bi/transform-model/desktop-calculations-options#calculated-table) :::image type="icon" source="../media/icons/yes.png":::[Measure](/power-bi/transform-model/desktop-calculations-options#measures) :::image type="icon" source="../media/icons/no.png":::[Visual calculation](/power-bi/transform-model/desktop-calculations-options#visual-calculation) \ No newline at end of file diff --git a/query-languages/dax/includes/applies-to-query-only.md b/query-languages/dax/includes/applies-to-query-only.md new file mode 100644 index 000000000..ce91b606c --- /dev/null +++ b/query-languages/dax/includes/applies-to-query-only.md @@ -0,0 +1,9 @@ +--- +author: DataZoeMS +ms.author: zoedouglas +ms.date: 03/17/2025 +ms.topic: include +ms.service: powerbi +ms.subservice: dax +--- +Applies to: :::image type="icon" source="../media/icons/no.png":::Calculated column :::image type="icon" source="../media/icons/no.png":::Calculated table :::image type="icon" source="../media/icons/no.png":::Measure :::image type="icon" source="../media/icons/no.png":::Visual calculation :::image type="icon" source="../media/icons/yes.png":::DAX query diff --git a/query-languages/dax/includes/applies-to-visual-calculations.md b/query-languages/dax/includes/applies-to-visual-calculations.md new file mode 100644 index 000000000..81f92b244 --- /dev/null +++ b/query-languages/dax/includes/applies-to-visual-calculations.md @@ -0,0 +1 @@ +**Applies to:** :::image type="icon" source="../media/icons/no.png":::[Calculated column](/power-bi/transform-model/desktop-calculations-options#calculated-column-dax) :::image type="icon" source="../media/icons/no.png":::[Calculated table](/power-bi/transform-model/desktop-calculations-options#calculated-table) :::image type="icon" source="../media/icons/no.png":::[Measure](/power-bi/transform-model/desktop-calculations-options#measures) :::image type="icon" source="../media/icons/yes.png":::[Visual calculation](/power-bi/transform-model/desktop-calculations-options#visual-calculation) \ No newline at end of file diff --git a/query-languages/dax/includes/enum-objecttype.md b/query-languages/dax/includes/enum-objecttype.md new file mode 100644 index 000000000..9898f535d --- /dev/null +++ b/query-languages/dax/includes/enum-objecttype.md @@ -0,0 +1,102 @@ +--- +author: DataZoeMS +ms.author: zoedouglas +ms.date: 03/17/2025 +ms.topic: include +ms.service: powerbi +ms.subservice: dax +--- +### ObjectType + +| Number | Value | +|-------------|------------------------| +| 0 | Null | +| 1 | Model | +| 2 | DataSource | +| 3 | Table | +| 4 | Column | +| 5 | AttributeHierarchy | +| 6 | Partition | +| 7 | Relationship | +| 8 | Measure | +| 9 | Hierarchy | +| 10 | Level | +| 11 | Annotation | +| 12 | KPI | +| 13 | Culture | +| 14 | ObjectTranslation | +| 15 | LinguisticMetadata | +| 29 | Perspective | +| 30 | PerspectiveTable | +| 31 | PerspectiveColumn | +| 32 | PerspectiveHierarchy | +| 33 | PerspectiveMeasure | +| 34 | Role | +| 35 | RoleMembership | +| 36 | TablePermission | +| 37 | Variation | +| 38 | Set | +| 39 | PerspectiveSet | +| 40 | ExtendedProperty | +| 41 | Expression | +| 42 | ColumnPermission | +| 43 | DetailRowsDefinition | +| 44 | RelatedColumnDetails | +| 45 | GroupByColumn | +| 46 | CalculationGroup | +| 47 | CalculationItem | +| 48 | AlternateOf | +| 49 | RefreshPolicy | +| 50 | FormatStringDefinition | + +This table is based on the [official documentation](/dotnet/api/microsoft.analysisservices.tabular.objecttype). + +To join with INFO functions use this DAX query. + +```dax +EVALUATE + DATATABLE( + "ObjectType",INTEGER, + "Object",STRING, + { + {0,"Null"}, + {1,"Model"}, + {2,"DataSource"}, + {3,"Table"}, + {4,"Column"}, + {5,"AttributeHierarchy"}, + {6,"Partition"}, + {7,"Relationship"}, + {8,"Measure"}, + {9,"Hierarchy"}, + {10,"Level"}, + {11,"Annotation"}, + {12,"KPI"}, + {13,"Culture"}, + {14,"ObjectTranslation"}, + {15,"LinguisticMetadata"}, + {29,"Perspective"}, + {30,"PerspectiveTable"}, + {31,"PerspectiveColumn"}, + {32,"PerspectiveHierarchy"}, + {33,"PerspectiveMeasure"}, + {34,"Role"}, + {35,"RoleMembership"}, + {36,"TablePermission"}, + {37,"Variation"}, + {38,"Set"}, + {39,"PerspectiveSet"}, + {40,"ExtendedProperty"}, + {41,"Expression"}, + {42,"ColumnPermission"}, + {43,"DetailRowsDefinition"}, + {44,"RelatedColumnDetails"}, + {45,"GroupByColumn"}, + {46,"CalculationGroup"}, + {47,"CalculationItem"}, + {48,"AlternateOf"}, + {49,"RefreshPolicy"}, + {50,"FormatStringDefinition"} + } + ) +``` diff --git a/query-languages/dax/includes/enum-title-for-info-dax-functions.md b/query-languages/dax/includes/enum-title-for-info-dax-functions.md new file mode 100644 index 000000000..d1841804c --- /dev/null +++ b/query-languages/dax/includes/enum-title-for-info-dax-functions.md @@ -0,0 +1,11 @@ +--- +author: DataZoeMS +ms.author: zoedouglas +ms.date: 03/17/2025 +ms.topic: include +ms.service: powerbi +ms.subservice: dax +--- +## Enumerations + +Columns returned in this INFO function give the ID of an enumeration, or lookup table. Here are the values for each enumeration in this DAX function. diff --git a/query-languages/dax/includes/parameters-for-info-dax-functions.md b/query-languages/dax/includes/parameters-for-info-dax-functions.md new file mode 100644 index 000000000..e4250d0a0 --- /dev/null +++ b/query-languages/dax/includes/parameters-for-info-dax-functions.md @@ -0,0 +1,20 @@ +--- +author: DataZoeMS +ms.author: zoedouglas +ms.date: 03/17/2025 +ms.topic: include +ms.service: powerbi +ms.subservice: dax +--- +## Parameters + +Parameters are optional for this DAX function. When parameters are used, both must be given. More than one pair of parameters is allowed. The restriction name and value are text and entered in double-quotes. + +| Term | Definition | +|---|---| +| Restriction name | Name of the restriction used to filter the results. | +| Restriction value | Value used to filter the results of the restriction. | + +## Restrictions + +Typically, all columns of the DAX function results can be used as a restriction. Additional restrictions may also be allowed. diff --git a/query-languages/dax/index-function-dax.md b/query-languages/dax/index-function-dax.md new file mode 100644 index 000000000..17afe13b5 --- /dev/null +++ b/query-languages/dax/index-function-dax.md @@ -0,0 +1,155 @@ +--- +description: "Learn more about: INDEX" +title: "INDEX function (DAX)" +--- + +# INDEX + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a row at an absolute position, specified by the position parameter, within the specified partition, sorted by the specified order. If the current partition can't be deduced to a single partition, multiple rows may be returned. + +## Syntax + +```dax +INDEX([, or ][, ][, ][, ][, ][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`position`|The absolute position (1-based) from which to obtain the data:
- `position` is positive: 1 is the first row, 2 is the second row, etc.
- `position` is negative: -1 is the last row, -2 is the second last row, etc.
When `position` is out of the boundary, or zero, or BLANK(), INDEX will return an empty table. It can be any DAX expression that returns a scalar value.| +|`relation`|(Optional) A table expression from which the output is returned. If used in visual calculations, this parameter accepts an axis in the visual shape.
If specified, all columns in `partitionBy` must come from it or a related table.
If omitted:
- `orderBy` must be explicitly specified.
- All `orderBy` and `partitionBy` expressions must be fully qualified column names and come from a single table.
- Defaults to `ALLSELECTED()` of all columns in `orderBy` and `partitionBy`. +|`orderBy`|(Optional) An ORDERBY() clause containing the expressions that define how each partition is sorted.
If omitted:
- `relation` must be explicitly specified.
- Defaults to ordering by every column in `relation` that is not already specified in `partitionBy`.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `relation` or `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.

Note, when the `blanks` parameter and blanks in the [ORDERBY()](orderby-function-dax.md) function on individual expressions are both specified, `blanks` on individual orderBy expression takes priority for the relevant orderBy expression, and orderBy expressions without `blanks` being specified will honor the `blanks` parameter on the parent function.| +|`partitionBy`|(Optional) A [PARTITIONBY()](partitionby-function-dax.md) clause containing the columns that define how `relation` is partitioned. If omitted, `relation` is treated as a single partition.| +|`matchBy`|(Optional) A [MATCHBY()](matchby-function-dax.md) clause containing the columns that define how to match data and identify the current row.| +|`reset`|(Optional) Available in visual calculations only. Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +A row at an absolute position. + +## Remarks + +Each `partitionBy` and `matchBy` column must have a corresponding outer value to help define the "current partition" on which to operate, with the following behavior: + +- If there is exactly one corresponding outer column, its value is used. +- If there is no corresponding outer column: + - INDEX will first determine all `partitionBy` and `matchBy` columns that have no corresponding outer column. + - For every combination of existing values for these columns in INDEX’s parent context, INDEX is evaluated and a row is returned. + - INDEX’s final output is a union of these rows. +- If there is more than one corresponding outer column, an error is returned. + +If `matchBy` is present, INDEX will try to use `matchBy` and `partitionBy` columns to identify the row. +If `matchBy` is not present and the columns specified within `orderBy` and `partitionBy` cannot uniquely identify every row in `relation`: + +- INDEX will try to find the least number of additional columns required to uniquely identify every row. +- If such columns can be found, INDEX will automatically append these new columns to `orderBy`, and each partition is sorted using this new set of OrderBy columns. +- If such columns cannot be found, an error is returned. + +An empty table is returned if: + +- The corresponding outer value of a PartitionBy column does not exist within `relation`. +- The `position` value refers to a position that does not exist within the partition. + +If INDEX is used within a calculated column defined on the same table as `relation` and `orderBy` is omitted, an error is returned. + +`reset` can be used in visual calculations only, and cannot be used in combination with `orderBy` or `partitionBy`. If `reset` is present, `axis` can be specified but `relation` cannot. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example 1 - calculated column + +The following DAX query: + +```dax +EVALUATE INDEX(1, ALL(DimDate[CalendarYear])) +``` + +Returns the following table: + +|DimDate[CalendarYear] | +|---------| +| 2005 | + +## Example 2 - calculated column + +The following DAX query: + +```dax +EVALUATE +SUMMARIZECOLUMNS ( + FactInternetSales[ProductKey], + DimDate[MonthNumberOfYear], + FILTER ( + VALUES(FactInternetSales[ProductKey]), + [ProductKey] < 222 + ), + "CurrentSales", SUM(FactInternetSales[SalesAmount]), + "LastMonthSales", + CALCULATE ( + SUM(FactInternetSales[SalesAmount]), + INDEX(-1, ORDERBY(DimDate[MonthNumberOfYear])) + ) +) +ORDER BY [ProductKey], [MonthNumberOfYear] +``` + +Returns the following table: + +|FactInternetSales[ProductKey] |DimDate[MonthNumberOfYear] |[CurrentSales] |[LastMonthSales] | +|---------|---------|---------|---------| +|214 | 1 | 5423.45 | 8047.7 | +|214 | 2 | 4968.58 | 8047.7 | +|214 | 3 | 5598.4 | 8047.7 | +|214 | 4 | 5073.55 | 8047.7 | +|214 | 5 | 5248.5 | 8047.7 | +|214 | 6 | 7487.86 | 8047.7 | +|214 | 7 | 7382.89 | 8047.7 | +|214 | 8 | 6543.13 | 8047.7 | +|214 | 9 | 6788.06 | 8047.7 | +|214 | 10 | 6858.04 | 8047.7 | +|214 | 11 | 8607.54 | 8047.7 | +|214 | 12 | 8047.7 | 8047.7 | +|217 | 1 | 5353.47 | 7767.78 | +|217 | 2 | 4268.78 | 7767.78 | +|217 | 3 | 5773.35 | 7767.78 | +|217 | 4 | 5738.36 | 7767.78 | +|217 | 5 | 6158.24 | 7767.78 | +|217 | 6 | 6998 | 7767.78 | +|217 | 7 | 5563.41 | 7767.78 | +|217 | 8 | 5913.31 | 7767.78 | +|217 | 9 | 5913.31 | 7767.78 | +|217 | 10 | 6823.05 | 7767.78 | +|217 | 11 | 6683.09 | 7767.78 | +|217 | 12 | 7767.78 | 7767.78 | + +## Example 3 - visual calculation + +The following visual calculation DAX queries: + +```dax +SalesComparedToBeginningOfYear = [SalesAmount] - CALCULATE(SUM([SalesAmount]), INDEX(1, ROWS, HIGHESTPARENT)) + +SalesComparedToBeginningOfQuarter = [SalesAmount] - CALCULATE(SUM([SalesAmount]), INDEX(1, , -1)) +``` + +Enhance a table so it contains, for each month: +
- the total sales amount; +
- the difference to the first month of the respective year; +
- and the difference to the first month of the respective quarter. + +The screenshot below shows the visual matrix and the first visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-index.png) + +## Related content + +[OFFSET](offset-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[WINDOW](window-function-dax.md) +[RANK](rank-function-dax.md) +[ROWNUMBER](rownumber-function-dax.md) diff --git a/query-languages/dax/index.yml b/query-languages/dax/index.yml index 257e396c6..a35b2e4cd 100644 --- a/query-languages/dax/index.yml +++ b/query-languages/dax/index.yml @@ -9,8 +9,8 @@ metadata: ms.service: powerbi ms.topic: landing-page ms.collection: - author: minewiskan - ms.author: owend + author: kfollis + ms.author: kfollis ms.date: 07/27/2020 # linkListType: architecture | concept | deploy | download | get-started | how-to-guide | learn | overview | quickstart | reference | tutorial | whats-new @@ -31,7 +31,7 @@ landingContent: links: - text: New DAX functions url: new-dax-functions.md - + # Card - title: Learn about DAX linkLists: @@ -46,8 +46,8 @@ landingContent: - linkListType: learn links: - text: Use DAX in Power BI Desktop - url: https://docs.microsoft.com/learn/paths/dax-power-bi/ - + url: /training/paths/dax-power-bi/ + # Card - title: Understand @@ -61,4 +61,4 @@ landingContent: - text: DAX queries url: dax-queries.md - text: DAX syntax - url: dax-syntax-reference.md \ No newline at end of file + url: dax-syntax-reference.md diff --git a/query-languages/dax/info-annotations-function-dax.md b/query-languages/dax/info-annotations-function-dax.md new file mode 100644 index 000000000..2d6279b8e --- /dev/null +++ b/query-languages/dax/info-annotations-function-dax.md @@ -0,0 +1,159 @@ +--- +description: "Learn more about: INFO.ANNOTATIONS" +title: "INFO.ANNOTATIONS function (DAX)" +author: DataZoeMS +--- +# INFO.ANNOTATIONS + +[!INCLUDE[applies-to-query-only](includes/applies-to-query-only.md)] + +Returns a table with information about each annotation in the semantic model. This information helps you understand the model. + +## Syntax + +```dax +INFO.ANNOTATIONS([, ], ...) +``` + +[!INCLUDE[parameters-for-info-dax-functions](includes/parameters-for-info-dax-functions.md)] + +## Return value + +A table with the following columns: + +| Column | Description | +|---|---| +| [ID] | A reference to the object. IDs are usually autogenerated and should not be changed after the model is created. Data type is unsigned long (4 bytes). | +| [ObjectID] | A reference to the object that owns this Annotation. | +| [ObjectType] | A reference to the type of object that owns this Annotation. | +| [Name] | The name of the object, used in code, script, and queries. | +| [Value] | The value of the annotation. | +| [ModifiedTime] | The time that the object was last modified. | + +## Remarks + +Can only be ran by users with write permission on the semantic model and not when live connected to the semantic model in Power BI Desktop. This function can be used in [DAX queries](/dax/dax-queries), and can't be used in calculations. + +## Example 1 - DAX query + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + INFO.ANNOTATIONS() +``` + +This DAX query returns a table with all of the columns of this DAX function. + +## Example 2 - DAX query with joins + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + VAR _ObjectTypeEnum = + DATATABLE( + "ObjectType",INTEGER, + "Object",STRING, + { + {0,"Null"}, + {1,"Model"}, + {2,"DataSource"}, + {3,"Table"}, + {4,"Column"}, + {5,"AttributeHierarchy"}, + {6,"Partition"}, + {7,"Relationship"}, + {8,"Measure"}, + {9,"Hierarchy"}, + {10,"Level"}, + {11,"Annotation"}, + {12,"KPI"}, + {13,"Culture"}, + {14,"ObjectTranslation"}, + {15,"LinguisticMetadata"}, + {29,"Perspective"}, + {30,"PerspectiveTable"}, + {31,"PerspectiveColumn"}, + {32,"PerspectiveHierarchy"}, + {33,"PerspectiveMeasure"}, + {34,"Role"}, + {35,"RoleMembership"}, + {36,"TablePermission"}, + {37,"Variation"}, + {38,"Set"}, + {39,"PerspectiveSet"}, + {40,"ExtendedProperty"}, + {41,"Expression"}, + {42,"ColumnPermission"}, + {43,"DetailRowsDefinition"}, + {44,"RelatedColumnDetails"}, + {45,"GroupByColumn"}, + {46,"CalculationGroup"}, + {47,"CalculationItem"}, + {48,"AlternateOf"}, + {49,"RefreshPolicy"}, + {50,"FormatStringDefinition"} + } + ) + + VAR _INFO = + INFO.ANNOTATIONS() + + VAR _CombinedTable = + NATURALLEFTOUTERJOIN( + _INFO, + _ObjectTypeEnum + ) + + VAR _ModelObjects = + UNION( + SELECTCOLUMNS( + INFO.MEASURES(), + "ObjectID", [ID], + "Object Name", [Name] + ), + SELECTCOLUMNS( + INFO.TABLES(), + "ObjectID", [ID], + "Object Name", [Name] + ), + SELECTCOLUMNS( + INFO.COLUMNS(), + "ObjectID", [ID], + "Object Name", [ExplicitName] + ), + SELECTCOLUMNS( + INFO.EXPRESSIONS(), + "ObjectID", [ID], + "Object Name", [Name] + ), + SELECTCOLUMNS( + INFO.MODEL(), + "ObjectID", [ID], + "Object Name", [Name] + ) + ) + + VAR _CombinedTable2 = + NATURALLEFTOUTERJOIN( + _CombinedTable, + _ModelObjects + ) + + RETURN + SELECTCOLUMNS( + _CombinedTable2, + "Object type", [Object], + "Object", [Object Name], + "Annotation name", [Name], + "Annotation value", [Value] + ) + ORDER BY [Annotation name] +``` + +This DAX query returns a table with only the specified columns and joining to other INFO DAX functions and the enumeration table. + +[!INCLUDE[enum-title-for-info-dax-functions](includes/enum-title-for-info-dax-functions.md)] + +[!INCLUDE[enum-objecttype](includes/enum-objecttype.md)] diff --git a/query-languages/dax/info-calcdependency-function-dax.md b/query-languages/dax/info-calcdependency-function-dax.md new file mode 100644 index 000000000..fc17ce2b5 --- /dev/null +++ b/query-languages/dax/info-calcdependency-function-dax.md @@ -0,0 +1,80 @@ +--- +description: "Learn more about: INFO.CALCDEPENDENCY" +title: "INFO.CALCDEPENDENCY function (DAX)" +author: DataZoeMS +--- +# INFO.CALCDEPENDENCY + +[!INCLUDE[applies-to-query-only](includes/applies-to-query-only.md)] + +Returns a table with information about each calculation dependency in the semantic model. This information helps you understand the model. + +## Syntax + +```dax +INFO.CALCDEPENDENCY([, ], ...) +``` + +[!INCLUDE[parameters-for-info-dax-functions](includes/parameters-for-info-dax-functions.md)] + +## Return value + +A table with the following columns: + +| Column | Description | +|---|---| +| [DATABASE_NAME] | The name of the semantic model. | +| [OBJECT_TYPE] | The type of object. | +| [TABLE] | The object's table name. | +| [OBJECT] | The name of the object. | +| [EXPRESSION] | The DAX formula of the object. | +| [REFERENCED_OBJECT_TYPE] | The type of object this object references. The "Object" is dependent on this object. | +| [REFERENCED_TABLE] | The referenced object's table name. | +| [REFERENCED_OBJECT] | The referenced object's name. | +| [REFERENCED_EXPRESSION] | The referenced object's DAX formula. | +| [QUERY] | The query, if specified as a restriction. | + +## Remarks + +Can only be ran by users with write permission on the semantic model and not when live connected to the semantic model in Power BI Desktop. This function can be used in [DAX queries](/dax/dax-queries), and can't be used in calculations. + +You can also call this DAX function with INFO.DEPENDENCIES. + +## Example 1 - DAX query + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + INFO.CALCDEPENDENCY() +``` + +This DAX query returns a table with all of the columns of this DAX function. + +## Example 2 - DAX query with restriction + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + INFO.CALCDEPENDENCY("Query", "EVALUATE { [Orders] }") +``` + +This DAX query returns a table showing the objects in the semantic model needed to run this specified DAX query. The restriction name of "query" is used with the value of a DAX query. This DAX query is getting the output of the measure named Orders. + +If a query has double-quotes they can be escaped with another double-quote and you can optionally use a VAR to hold the value. + +```dax +EVALUATE + VAR _query = + "EVALUATE + SELECTCOLUMNS( + 'Date', + ""Date"", [Date] + )" + RETURN + INFO.CALCDEPENDENCY( + "Query", + _query + ) +``` diff --git a/query-languages/dax/info-functions-dax.md b/query-languages/dax/info-functions-dax.md new file mode 100644 index 000000000..71cab3e41 --- /dev/null +++ b/query-languages/dax/info-functions-dax.md @@ -0,0 +1,161 @@ +--- +title: "INFO functions (DAX)" +description: "Learn more about: INFO DAX functions" +author: DataZoeMS +ms.author: zoedouglas +ms.date: 03/13/2025 +ms.topic: overview +ms.service: powerbi +ms.subservice: dax +--- +# INFO functions + +Data Analysis Expressions (DAX) includes a set of INFO functions based on the library of [Dynamic Management Views (DMVs) in Analysis Services](/analysis-services/instances/use-dynamic-management-views-dmvs-to-monitor-analysis-services), which have been modified to work as DAX functions. INFO DAX functions output as a table data type. As tables they can be used with other DAX functions such as FILTER, SELECTCOLUMNS, ADDCOLUMNS, and others. This section describes INFO functions available in the DAX language. + +For Power BI semantic models, just like DMVs, the INFO DAX functions require semantic model admin permissions. Some also require workspace admin permissions. + +As DAX functions these INFO functions go beyond the capability of the DMVs, which use a SQL-like syntax and return a row set. As these new functions are DAX functions, they can be used like any table in a DAX query – further combined and structured in the DAX query. + +```dax +EVALUATE + ADDCOLUMNS( + SELECTCOLUMNS( + INFO.VIEW.MEASURES(), + "Measure", [Name], + [Description], + "DAX Formula", [Expression], + "State", [State] + ), + "Model name", "My semantic model", + "As of date", NOW() + ) +``` + +INFO functions are supported on Power BI semantic models, SQL Server Analysis Services models, Azure Analysis Services models, and PowerPivot models. Errors may happen if the INFO function is for a feature not supported or available. INFO.VIEW DAX functions can be run in calculated tables, columns, measures, and DAX queries, but other INFO DAX functions can only be run in DAX queries. + +## INFO.VIEW DAX functions + +Four of the INFO DAX functions also have INFO.VIEW DAX functions counterparts. Friendly names, such as table name instead of table ID, are used and new columns added to make it easier to use without the need to join other INFO DAX function tables. INFO.VIEW DAX functions can be used in calculations inside a semantic model. When included in a [calculated table](/power-bi/transform-model/desktop-calculated-tables) they can self-document a model for other people using it to build reports or DAX queries. + +### INFO.VIEW.TABLES +INFO.VIEW.TABLES contains information about the tables in the model, such as the table name, description, storage mode, and whether it is hidden or not. + +```dax +// Remove EVALUATE when using this DAX function in a calculated table +EVALUATE INFO.VIEW.TABLES() +``` + +The following screenshot is an example of using this DAX function in [DAX query view](/power-bi/transform-model/dax-query-view) with the **Regional Sales Sample** available from **Learn** in the Power BI service. + +:::image type="content" source="media/info-functions-dax/info-view-tables-dax-query.png" alt-text="Screenshot showing the output of INFO.VIEW.TABLES() DAX function in DAX query view." lightbox="media/info-functions-dax/info-view-tables-dax-query.png"::: + +### INFO.VIEW.COLUMNS +INFO.VIEW.COLUMNS contains information about the columns in a model, such as the column name, data type, and whether it is hidden or not. + +```dax +// Remove EVALUATE when using this DAX function in a calculated table +EVALUATE INFO.VIEW.COLUMNS() +``` + +The following screenshot is an example of using this DAX function in [DAX query view](/power-bi/transform-model/dax-query-view) with the **Regional Sales Sample** available from **Learn** in the Power BI service. + +:::image type="content" source="media/info-functions-dax/info-view-columns-dax-query.png" alt-text="Screenshot showing the output of INFO.VIEW.COLUMNS() DAX function in DAX query view." lightbox="media/info-functions-dax/info-view-columns-dax-query.png"::: + +### INFO.VIEW.MEASURES +INFO.VIEW.MEASURES contains information about the measures in the model, such as the measure name, expression, and format string. + +```dax +// Remove EVALUATE when using this DAX function in a calculated table +EVALUATE INFO.VIEW.MEASURES() +``` + +The following screenshot is an example of using this DAX function in [DAX query view](/power-bi/transform-model/dax-query-view) with the **Regional Sales Sample** available from **Learn** in the Power BI service. + +:::image type="content" source="media/info-functions-dax/info-view-measures-dax-query.png" alt-text="Screenshot showing the output of INFO.VIEW.MEASURES() DAX function in DAX query view." lightbox="media/info-functions-dax/info-view-measures-dax-query.png"::: + +### INFO.VIEW.RELATIONSHIPS +INFO.VIEW.RELATIONSHIPS contains information about the relationships in the model, such as the to and from table and columns, cardinality, and cross filter direction. + +```dax +// Remove EVALUATE when using this DAX function in a calculated table +EVALUATE INFO.VIEW.RELATIONSHIPS() +``` + +The following screenshot is an example of using this DAX function in [DAX query view](/power-bi/transform-model/dax-query-view) with the **Regional Sales Sample** available from **Learn** in the Power BI service. + +:::image type="content" source="media/info-functions-dax/info-view-relationships-dax-query.png" alt-text="Screenshot showing the output of INFO.VIEW.RELATIONSHIPS() DAX function in DAX query view." lightbox="media/info-functions-dax/info-view-relationships-dax-query.png"::: + +## INFO DAX functions + +Here is the list of INFO functions. Some work only on specific compat levels and for certain storage modes or other semantic model properties. + +| [Function] | [Description] | +|-----------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------| +| INFO.VIEW.COLUMNS | Returns a list of all columns in the current model. Can use in calculations, including calculated tables. | +| INFO.VIEW.MEASURES | Returns a list of all measures in the current model. Can use in calculations, including calculated tables. | +| INFO.VIEW.RELATIONSHIPS | Returns a list of all relationships in the current model. Can use in calculations, including calculated tables. | +| INFO.VIEW.TABLES | Returns a list of all tables in the current model. Can use in calculations, including calculated tables. | +| INFO.ALTERNATEOFDEFINITIONS | | +| INFO.ANNOTATIONS | Returns a list of all annotations in the current model with columns matching the schema rowset for annotation objects. | +| INFO.ATTRIBUTEHIERARCHIES | Represents the TMSCHEMA_ATTRIBUTE_HIERARCHIES DMV query function. | +| INFO.ATTRIBUTEHIERARCHYSTORAGES | | +| INFO.CALCDEPENDENCY | Returns information about the calculation dependency for a DAX query. | +| INFO.CALCULATIONGROUPS | | +| INFO.CALCULATIONITEMS | | +| INFO.CATALOGS | Represents the DBSCHEMA_CATALOGS DMV query function. | +| INFO.CHANGEDPROPERTIES | Represents the TMSCHEMA_CHANGED_PROPERTIES DMV query function. | +| INFO.COLUMNPARTITIONSTORAGES | | +| INFO.COLUMNPERMISSIONS | Returns a list of all column permissions in the current model with columns matching the schema rowset for column permissions objects. | +| INFO.COLUMNS | Returns a list of all columns in the current model with columns matching the schema rowset for column objects. | +| INFO.COLUMNSTORAGES | Returns a list of all column storages in the current model with columns matching the schema rowset for column storage objects. | +| INFO.CSDLMETADATA | Returns information about database metadata in XML format. | +| INFO.CULTURES | Returns a list of all cultures in the current model with columns matching the schema rowset for culture objects. | +| INFO.DATACOVERAGEDEFINITIONS | | +| INFO.DATASOURCES | Represents the TMSCHEMA_DATASOURCES DMV query function. | +| INFO.DELTATABLEMETADATASTORAGES | | +| INFO.DEPENDENCIES | Returns information about the calculation dependency for a DAX query. | +| INFO.DETAILROWSDEFINITIONS | Returns a list of all detail rows definitions in the current model with columns matching the schema rowset for detail rows definitions objects. | +| INFO.DICTIONARYSTORAGES | | +| INFO.EXCLUDEDARTIFACTS | Represents the TMSCHEMA_EXCLUDED_ARTIFACTS DMV query function. | +| INFO.EXPRESSIONS | Returns a list of all expressions in the current model with columns matching the schema rowset for expressions objects. | +| INFO.EXTENDEDPROPERTIES | Returns a list of all extended properties in the current model with columns matching the schema rowset for extended properties objects. | +| INFO.FORMATSTRINGDEFINITIONS | | +| INFO.FUNCTIONS | Returns information about the functions that are currently available for use in the DAX programming language. Represents the MDSCHEMA_FUNCTIONS DMV query function, but returns only DAX (and not MDX) functions by default. If the ORIGIN restriction is not specified, it defaults to 3 or 4. | +| INFO.GENERALSEGMENTMAPSEGMENTMETADATASTORAGES | | +| INFO.GROUPBYCOLUMNS | | +| INFO.HIERARCHIES | Represents the TMSCHEMA_HIERARCHIES DMV query function. | +| INFO.HIERARCHYSTORAGES | | +| INFO.KPIS | Returns a list of all KPIS in the current model with columns matching the schema rowset for KPI objects. | +| INFO.LEVELS | Returns a list of all levels in the current model with columns matching the schema rowset for level objects. | +| INFO.LINGUISTICMETADATA | Represents the TMSCHEMA_LINGUISTIC_METADATA DMV query function. | +| INFO.MEASURES | Returns a list of all measures in the current model with columns matching the schema rowset for measure objects. | +| INFO.MODEL | Represents the TMSCHEMA_MODEL DMV query function. | +| INFO.OBJECTTRANSLATIONS | Returns a list of all object translations in the current model with columns matching the schema rowset for object translation objects. | +| INFO.PARQUETFILESTORAGES | | +| INFO.PARTITIONS | Represents the TMSCHEMA_PARTITIONS DMV query function. | +| INFO.PARTITIONSTORAGES | Returns a list of all partition storages in the current model with columns matching the schema rowset for partition storage objects. | +| INFO.PERSPECTIVECOLUMNS | Returns a list of all perspective columns in the current model with columns matching the schema rowset for perspective columns objects. | +| INFO.PERSPECTIVEHIERARCHIES | Returns a list of all perspective hierarchies in the current model with columns matching the schema rowset for perspective hierarchies objects. | +| INFO.PERSPECTIVEMEASURES | Returns a list of all perspective measures in the current model with columns matching the schema rowset for perspective measures objects. | +| INFO.PERSPECTIVES | Returns a list of all perspectives in the current model with columns matching the schema rowset for perspectives objects. | +| INFO.PERSPECTIVETABLES | Returns a list of all perspective tables in the current model with columns matching the schema rowset for perspective tables objects. | +| INFO.PROPERTIES | Represents the DISCOVER_PROPERTIES DMV query function. | +| INFO.QUERYGROUPS | | +| INFO.REFRESHPOLICIES | | +| INFO.RELATEDCOLUMNDETAILS | | +| INFO.RELATIONSHIPINDEXSTORAGES | | +| INFO.RELATIONSHIPS | Represents the TMSCHEMA_RELATIONSHIPS DMV query function. | +| INFO.RELATIONSHIPSTORAGES | | +| INFO.ROLEMEMBERSHIPS | Returns a list of all role memberships in the current model with columns matching the schema rowset for role memberships objects. | +| INFO.ROLES | Returns a list of all roles in the current model with columns matching the schema rowset for roles objects. | +| INFO.SEGMENTMAPSTORAGES | Returns a list of all segment map storages in the current model with columns matching the schema rowset for segment map storage objects. | +| INFO.SEGMENTSTORAGES | | +| INFO.STORAGEFILES | Returns a list of all storage files in the current model with columns matching the schema rowset for storage file objects. | +| INFO.STORAGEFOLDERS | Returns a list of all storage folders in the current model with columns matching the schema rowset for storage folder objects. | +| INFO.STORAGETABLECOLUMNS | Returns statistics about the columns of in-memory tables. | +| INFO.STORAGETABLECOLUMNSEGMENTS | Returns information about the column segments used for storing data for in-memory tables. | +| INFO.STORAGETABLES | Returns statistics about in-memory tables. | +| INFO.TABLEPERMISSIONS | Returns a list of all table permissions in the current model with columns matching the schema rowset for table permissions objects. | +| INFO.TABLES | Returns a list of all tables in the current model with columns matching the schema rowset for table objects. | +| INFO.TABLESTORAGES | Returns a list of all table storages in the current model with columns matching the schema rowset for table storage objects. | +| INFO.VARIATIONS | Returns a list of all variations in the current model with columns matching the schema rowset for variations objects. | diff --git a/query-languages/dax/info-view-columns-function-dax.md b/query-languages/dax/info-view-columns-function-dax.md new file mode 100644 index 000000000..07aad5eb7 --- /dev/null +++ b/query-languages/dax/info-view-columns-function-dax.md @@ -0,0 +1,158 @@ +--- +description: "Learn more about: INFO.VIEW.COLUMNS" +title: "INFO.VIEW.COLUMNS function (DAX)" +author: DataZoeMS +--- +# INFO.VIEW.COLUMNS + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table with information about each column in the semantic model, such as name, description, and format string. This information helps you understand the model and to self-document the model when used in calculated tables. + +## Syntax + +```dax +INFO.VIEW.COLUMNS() +``` + +## Return value + +A table with the following columns: + +| Column | Description | +|---|---| +| [ID] | The unique ID for each column in this semantic model as an integer. | +| [Name] | The name of each column in this semantic model as a string. | +| [Table] | The table of each column in this semantic model as a string. | +| [DataType] | The data type of each column in this semantic model as a string. | +| [DataCategory] | The data category of each column in this semantic model as a string. | +| [Description] | The description of each column in this semantic model as a string. | +| [IsHidden] | The hidden state of each column in this semantic model as True or False. | +| [IsUnique] | The is unique of each column in this semantic model as True of False. | +| [IsKey] | The is key of each column in this semantic model as True or False. | +| [IsNullable] | The is nullable of each column in this semantic model as True or False. | +| [Alignment] | The alignment of each column in this semantic model as a string. | +| [SummarizeBy] | The summarize by of each column in this semantic model as a string. | +| [ColumnStorage] | The column storage of each column in this semantic model as a string combination of name and ID. | +| [Type] | The type of each column in this semantic model as a string. | +| [SourceColumn] | The source column of each column in this semantic model as a string. | +| [Expression] | The DAX formula of calculated columns. | +| [FormatString] | The format string of each column in this semantic model as a string. | +| [IsAvailableInMDX] | The is available in MDX of each column in this semantic model as True or False. Analyze in Excel pivot tables will only show columns set to True. | +| [SortByColumn] | The sort by column of each column in this semantic model as a string. Shows as blank when sorting by itself. | +| [GroupingBehavior] | The grouping behavior of each column in this semantic model as a string. | +| [SourceProviderType] | The source provider type of each column in this semantic model as a string. | +| [DisplayFolder] | The display folder of each column in this semantic model as a string. Nested folders shown with / and multiple folders separated by ;. | +| [AlternateOf] | The alternate of property of each column in this semantic model as a string. | +| [LineageTag] | The lineage tag of each column in this semantic model as a string. | + + +## Remarks + +Can only be ran by users with write permission on the semantic model and not when live connected to the semantic model in Power BI Desktop. This function can be used in calculated tables, columns, and measures of a semantic model and will update when the model is refreshed. + +## Example 1 - DAX query + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + INFO.VIEW.COLUMNS() +``` + +This DAX query returns a table with all of the columns of this DAX function. + +## Example 2 - DAX query with SELECTCOLUMNS and FILTER + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + // Select specific columns from the filtered result + SELECTCOLUMNS( + // Filter columns from the INFO.VIEW.COLUMNS() table + FILTER( + INFO.VIEW.COLUMNS(), + // Exclude rows where DataCategory is "RowNumber" and Table is "xTables" + [DataCategory] <> "RowNumber" && [Table] <> "xTables" + ), + // Show only these selected columns with new names where specified + [Table], + "Column", [Name], + [Description], + "DAX formula", [Expression], + [DataCategory], + [DataType], + [IsHidden] + ) + // Order the result by Table and then by Column + ORDER BY + [Table], [Column] +``` + +This DAX query returns a table with only the specified columns and rows meeting the filter condition with a DAX formula. + +:::image type="content" source="media/info-view-columns-function-dax/dax-query-example-2.png" alt-text="Screenshot showing the output of INFO.VIEW.COLUMNS() with selected columns in DAX query view." lightbox="media/info-view-columns-function-dax/dax-query-example-2.png"::: + +## Example 3 - calculated table with SELECTCOLUMNS and FILTER + +Either of the above examples work in a calculated table when the EVALUATE and ORDER BY keywords are removed and a table name added. Here is example 2 in a calculated table: + +```dax +Columns in this semantic model = +// Select specific columns from the filtered result + SELECTCOLUMNS( + // Filter columns from the INFO.VIEW.COLUMNS() table + FILTER( + INFO.VIEW.COLUMNS(), + // Exclude rows where DataCategory is "RowNumber" and Table is "xTables" + [DataCategory] <> "RowNumber" && [Table] <> "xTables" + ), + // Show only these selected columns with new names where specified + [Table], + "Column", [Name], + [Description], + "DAX formula", [Expression], + [DataCategory], + [DataType], + [IsHidden] + ) +``` +This calculated table shows the same information as the DAX query in example 2 in a table in the model itself. + +## Example 4 - measure + +The following measure can be added to count the number of text columns in a semantic model: + +```dax +Number of text columns = +COUNTROWS( + FILTER( + INFO.VIEW.COLUMNS(), + [DataType] = "Text" + ) +) +``` +This will show a scalar value with the number of text columns in my model. + +This can be shown in a visual: + +:::image type="content" source="media/info-view-columns-function-dax/measure-example-4-visuals.png" alt-text="Screenshot showing the output of INFO.VIEW.COLUMNS() with a measure then used in report visuals." lightbox="media/info-view-columns-function-dax/measure-example-4-visuals.png"::: + +Or a DAX query in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +DEFINE + MEASURE 'Columns in this semantic model'[Number of text columns] = + COUNTROWS( + FILTER( + INFO.VIEW.COLUMNS(), + [DataType] = "Text" + ) + ) + +EVALUATE + SUMMARIZECOLUMNS( + "Number of text columns", [Number of text columns] + ) +``` diff --git a/query-languages/dax/info-view-measures-function-dax.md b/query-languages/dax/info-view-measures-function-dax.md new file mode 100644 index 000000000..cf576bcab --- /dev/null +++ b/query-languages/dax/info-view-measures-function-dax.md @@ -0,0 +1,121 @@ +--- +description: "Learn more about: INFO.VIEW.MEASURES" +title: "INFO.VIEW.MEASURES function (DAX)" +author: DataZoeMS +--- +# INFO.VIEW.MEASURES + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table with information about each measure in the semantic model, such as name, description, and DAX formula. This information helps you understand the model and to self-document the model when used in calculated tables. + +## Syntax + +```dax +INFO.VIEW.MEASURES() +``` + +## Return value + +A table with the following columns: + +| Column | Description | +|---|---| +| [ID] | The unique ID for each measure in this semantic model as an integer. | +| [Name] | The name of each measure in this semantic model as a string. | +| [Table] | The home table of each measure in this semantic model as a string. | +| [Description] | The description of each measure in this semantic model as a string. | +| [DataType] | The data type of each measure in this semantic model as a string. Measures are usually variant data type. | +| [Expression] | The DAX formula of each measure in this semantic model. | +| [FormatString] | The format string of each measure in this semantic model as a string. | +| [IsHidden] | The hidden state of each measure in this semantic model as True or False. | +| [State] | The state (such as valid or error) of each measure in this semantic model as a string. | +| [KPIID] | The KPI ID of each measure in this semantic model as an integer. | +| [IsSimpleMeasure] | The simple measure flag of each measure in this semantic model as True of False. | +| [DisplayFolder] | The display folder of each measure in this semantic model as a string. Nested folders shown with / and multiple folders separated by ;. | +| [DetailRowsDefinition] | The details rows definition of each measure in this semantic model. | +| [DataCategory] | The data category of each measure in this semantic model as a string. | +| [FormatStringDefinition] | The dynamic format string of each measure in this semantic model. | +| [LineageTag] | The lineage tag of each measure in this semantic model as a string. | + +## Remarks + +Can only be ran by users with write permission on the semantic model and not when live connected to the semantic model in Power BI Desktop. This function can be used in calculated tables, columns, and measures of a semantic model and will update when the model is refreshed. + +## Example 1 - DAX query + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + INFO.VIEW.MEASURES() +``` + +This DAX query returns a table with all of the columns of this DAX function. + +:::image type="content" source="media/info-view-measures-function-dax/dax-query-example-1.png" alt-text="Screenshot showing the output of INFO.VIEW.MEASURES() in DAX query view." lightbox="media/info-view-measures-function-dax/dax-query-example-1.png"::: + +## Example 2 - DAX query with SELECTCOLUMNS + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + SELECTCOLUMNS( + INFO.VIEW.MEASURES(), + "Home table", [Table], + "Measure", [Name], + [Description], + "DAX formula", [Expression], + [State] + ) +``` + +This DAX query returns a table with only the specified columns. + +:::image type="content" source="media/info-view-measures-function-dax/dax-query-example-2.png" alt-text="Screenshot showing the output of INFO.VIEW.MEASURES() with selected columns in DAX query view." lightbox="media/info-view-measures-function-dax/dax-query-example-2.png"::: + +## Example 3 - calculated table with SELECTCOLUMNS + +Either of the above examples work in a calculated table when the EVALUATE keyword is removed and a table name added. Here is example 2 in a calculated table: + +```dax +Measures in this semantic model = +SELECTCOLUMNS( + INFO.VIEW.MEASURES(), + "Home table", [Table], + "Measure", [Name], + [Description], + "DAX formula", [Expression], + [State] + ) +``` +This calculated table shows the same information as the DAX query in example 2 in a table in the model itself. + +## Example 4 - measure + +The following measure can be added to count the number of text columns in a semantic model: + +```dax +Number of measures = +COUNTROWS( INFO.VIEW.MEASURES() ) +``` +This will show a scalar value with the number of measures in my model. + +This can be shown in a visual: + +:::image type="content" source="media/info-view-measures-function-dax/measure-example-4-visuals.png" alt-text="Screenshot showing the output of INFO.VIEW.MEASURES() with a measure then used in report visuals." lightbox="media/info-view-measures-function-dax/measure-example-4-visuals.png"::: + +Or a DAX query in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +DEFINE + MEASURE 'Measures in this semantic model'[Number of measures] = COUNTROWS( INFO.VIEW.MEASURES() ) + +EVALUATE + SUMMARIZECOLUMNS( + "Number of measures", [Number of measures] + ) +``` + +:::image type="content" source="media/info-view-measures-function-dax/measure-example-4-dax-query.png" alt-text="Screenshot showing the output of INFO.VIEW.MEASURES() with a measure then used in a DAX query in DAX query view." lightbox="media/info-view-measures-function-dax/measure-example-4-dax-query.png"::: diff --git a/query-languages/dax/info-view-relationships-function-dax.md b/query-languages/dax/info-view-relationships-function-dax.md new file mode 100644 index 000000000..413226785 --- /dev/null +++ b/query-languages/dax/info-view-relationships-function-dax.md @@ -0,0 +1,115 @@ +--- +description: "Learn more about: INFO.VIEW.RELATIONSHIPS" +title: "INFO.VIEW.RELATIONSHIPS function (DAX)" +author: DataZoeMS +--- +# INFO.VIEW.RELATIONSHIPS + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table with information about each [relationship](/power-bi/transform-model/desktop-create-and-manage-relationships) in the semantic model, such as name, cardinality, and cross-filtering behavior. This information helps you understand the model and to self-document the model when used in calculated tables. + +## Syntax + +```dax +INFO.VIEW.RELATIONSHIPS() +``` + +## Return value + +A table with the following columns: + +| Column | Description | +|---|---| +| [ID] | The unique ID for each relationship in this semantic model as an integer. | +| [Name] | The name of each relationship in this semantic model as a string. Might be a GUID. | +| [Relationship] | The descriptive relationship name of each relationship in this semantic model as a string. Includes from table and column, to table and column, with cardinality and cross filter direction. | +| [Model] | The relationship's semantic model ID, usually a GUID. | +| [IsActive] | The is active property of each relationship in this semantic model as True or False. | +| [CrossFilteringBehavior] | The cross-filter behavior or direction of each relationship in this semantic model as a string. | +| [RelyOnReferentialIntegrity] | The rely on referential integrity property of each relationship in this semantic model as a string. Also called [assume referential integrity](/power-bi/connect-data/desktop-assume-referential-integrity) in the relationship editor, as it assumes all rows in the column in the many table have a match to a row in the one side table. | +| [FromTable] | The from table name of each relationship in this semantic model as a string. | +| [FromColumn] | The from column name of each relationship in this semantic model as a string. | +| [FromCardinality] | The from column cardinality of each relationship in this semantic model as a string. | +| [ToTable] | The to table name of each relationship in this semantic model as a string. | +| [ToColumn] | The to column name of each relationship in this semantic model as a string. | +| [ToCardinality] | The to column cardinality of each relationship in this semantic model as a string. | +| [State] | The state of each relationship in this semantic model as a string. | +| [SecurityFilteringBehavior] | The security filtering behavior of each relationship in this semantic model as a string. Important for row-level security roles. | + + +## Remarks + +Can only be ran by users with write permission on the semantic model and not when live connected to the semantic model in Power BI Desktop. This function can be used in calculated tables, columns, and measures of a semantic model and will update when the model is refreshed. + +## Example 1 - DAX query + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + INFO.VIEW.RELATIONSHIPS() +``` + +This DAX query returns a table with all of the columns of this DAX function. + +:::image type="content" source="media/info-view-relationships-function-dax/dax-query-example-1.png" alt-text="Screenshot showing the output of INFO.VIEW.RELATIONSHIPS() in DAX query view." lightbox="media/info-view-relationships-function-dax/dax-query-example-1.png"::: + +## Example 2 - DAX query with SELECTCOLUMNS + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + SELECTCOLUMNS( + INFO.VIEW.RELATIONSHIPS(), + [Relationship], + [IsActive] + ) +``` + +This DAX query returns a table with only the specified columns. + +:::image type="content" source="media/info-view-relationships-function-dax/dax-query-example-2.png" alt-text="Screenshot showing the output of INFO.VIEW.RELATIONSHIPS() with selected columns in DAX query view." lightbox="media/info-view-relationships-function-dax/dax-query-example-2.png"::: + +## Example 3 - calculated table with SELECTCOLUMNS + +Either of the above examples work in a calculated table when the EVALUATE and ORDER BY keywords are removed and a table name added. Here is example 2 in a calculated table: + +```dax +Relationships in this semantic model = +SELECTCOLUMNS( + INFO.VIEW.RELATIONSHIPS(), + [Relationship], + [IsActive] +) +``` +This calculated table shows the same information as the DAX query in example 2 in a table in the model itself. + +## Example 4 - measure + +The following measure can be added to count the number of relationships in a semantic model: + +```dax +Number of relationships = +COUNTROWS( INFO.VIEW.RELATIONSHIPS() ) +``` +This will show a scalar value with the number of relationships in my model. + +This can be shown in a visual: + +:::image type="content" source="media/info-view-relationships-function-dax/measure-example-4-visuals.png" alt-text="Screenshot showing the output of INFO.VIEW.RELATIONSHIPS() with a measure then used in report visuals." lightbox="media/info-view-relationships-function-dax/measure-example-4-visuals.png"::: + +Or a DAX query in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +DEFINE + MEASURE 'Measures in this semantic model'[Number of measures] = COUNTROWS( INFO.VIEW.MEASURES() ) + +EVALUATE + SUMMARIZECOLUMNS( + "Number of measures", [Number of measures] + ) +``` + +:::image type="content" source="media/info-view-relationships-function-dax/measure-example-4-dax-query.png" alt-text="Screenshot showing the output of INFO.VIEW.RELATIONSHIPS() with a measure then used in a DAX query in DAX query view." lightbox="media/info-view-relationships-function-dax/measure-example-4-dax-query.png"::: diff --git a/query-languages/dax/info-view-tables-function-dax.md b/query-languages/dax/info-view-tables-function-dax.md new file mode 100644 index 000000000..250227809 --- /dev/null +++ b/query-languages/dax/info-view-tables-function-dax.md @@ -0,0 +1,151 @@ +--- +description: "Learn more about: INFO.VIEW.TABLES" +title: "INFO.VIEW.TABLES function (DAX)" +author: DataZoeMS +--- +# INFO.VIEW.TABLES + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table with information about each table in the semantic model, such as table name, description, and storage mode. This information helps you understand the model and to self-document the model when used in calculated tables. + +## Syntax + +```dax +INFO.VIEW.TABLES() +``` + +## Return value + +A table with the following columns: + +| Column | Description | +|---|---| +| [ID] | The unique ID for each table in this semantic model as an integer. | +| [Name] | The name of each table in this semantic model as a string. | +| [Model] | The ID of the table's semantic model as a GUID. | +| [DataCategory] | The data category of each table in this semantic model as a string. | +| [Description] | The description of each table in this semantic model as a string. | +| [IsHidden] | The hidden state of each table in this semantic model as TRUE or FALSE. | +| [StorageMode] | The storage mode of each table in this semantic model as a string. | +| [TableStorage] | The name and unique ID of each table in this semantic model as a string. | +| [Expression] | The DAX formula of each table in this semantic model as a string. Only applies to calculated tables. | +| [ShowAsVariationOnly] | The show as variation only state of each table in this semantic model as TRUE or FALSE. | +| [IsPrivate] | The private state of each table in this semantic model as TRUE or FALSE. | +| [CalculationGroupPrecedence] | The calculation group precedence of each table in this semantic model as an integer. Only applies to calculation groups. | +| [LineageTag] | The lineage tag of each table in this semantic model as a string. | + +## Remarks + +Can only be ran by users with write permission on the semantic model and not when live connected to the semantic model in Power BI Desktop. This function can be used in calculated tables, columns, and measures of a semantic model and will update when the model is refreshed. + +## Example 1 - DAX query + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + INFO.VIEW.TABLES() +``` + +This DAX query returns a table with all of the columns of this DAX function. + +:::image type="content" source="media/info-view-tables-function-dax/dax-query-example-1.png" alt-text="Screenshot showing the output of INFO.VIEW.TABLES() DAX function in DAX query view." lightbox="media/info-view-tables-function-dax/dax-query-example-1.png"::: + +## Example 2 - DAX query with SELECTCOLUMNS and ADDCOLUMNS + +The following DAX query can be run in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +EVALUATE + ADDCOLUMNS( + SELECTCOLUMNS( + INFO.VIEW.TABLES(), + "Table", [Name], + [Description], + "Storage mode", [StorageMode], + "Calc table DAX formula", [Expression], + "Calc group precedence", [CalculationGroupPrecedence], + [DataCategory] + ), + "Table type", SWITCH( + TRUE(), + NOT (ISBLANK([Calc group precedence])), "Calculation group", + NOT (ISBLANK([Calc table DAX formula])), "Calculated (DAX) table", + [DataCategory] = "Time", "Date table", + [DataCategory] + ) + ) +``` + +This DAX query returns a table with only the specified columns and a new column to categorize the tables with a DAX formula. + +:::image type="content" source="media/info-view-tables-function-dax/dax-query-example-2.png" alt-text="Screenshot showing the output of INFO.VIEW.TABLES() with selected columns in DAX query view." lightbox="media/info-view-tables-function-dax/dax-query-example-2.png"::: + +## Example 3 - calculated table with SELECTCOLUMNS and ADDCOLUMNS + +Either of the above examples work in a calculated table when the EVALUATE keyword is removed and a table name added. Here is example 2 in a calculated table: + +```dax +xTables2 = + ADDCOLUMNS( + SELECTCOLUMNS( + INFO.VIEW.TABLES(), + "Table", [Name], + [Description], + "Storage mode", [StorageMode], + "Calc table DAX formula", [Expression], + "Calc group precedence", [CalculationGroupPrecedence], + [DataCategory] + ), + "Table type", SWITCH( + TRUE(), + NOT (ISBLANK([Calc group precedence])), "Calculation group", + NOT (ISBLANK([Calc table DAX formula])), "Calculated (DAX) table", + [DataCategory] = "Time", "Date table", + [DataCategory] + ) + ) +``` +This calculated table shows the same information as the DAX query in example 2 in a table in the model itself. + +:::image type="content" source="media/info-view-tables-function-dax/calculated-table-example-3.png" alt-text="Screenshot showing the output of INFO.VIEW.TABLES() with selected columns in a calculated table." lightbox="media/info-view-tables-function-dax/calculated-table-example-3.png"::: + +## Example 4 - measure + +The following measure can be added to count the number of calculated columns in a semantic model: + +```dax +Number of calculated tables = +COUNTROWS( + FILTER( + INFO.VIEW.TABLES(), + NOT ( ISBLANK( [Expression] ) ) + ) +) +``` +This will show a scalar value with the number of calculated tables in my model. + +This can be shown in a visual: + +:::image type="content" source="media/info-view-tables-function-dax/measure-example-4-visuals.png" alt-text="Screenshot showing the output of INFO.VIEW.TABLES() with a measure then used in report visuals." lightbox="media/info-view-tables-function-dax/measure-example-4-visuals.png"::: + +Or a DAX query in [DAX query view](/power-bi/transform-model/dax-query-view): + +```dax +DEFINE + MEASURE 'xTables'[Number of calculated tables] = + COUNTROWS( + FILTER( + INFO.VIEW.TABLES(), + NOT ( ISBLANK( [Expression] ) ) + ) + ) + +EVALUATE + SUMMARIZECOLUMNS( + "Number of calculated tables", [Number of calculated tables] + ) +``` + +:::image type="content" source="media/info-view-tables-function-dax/measure-example-4-dax-query.png" alt-text="Screenshot showing the output of INFO.VIEW.TABLES() with a measure then used in a DAX query in DAX query view." lightbox="media/info-view-tables-function-dax/measure-example-4-dax-query.png"::: diff --git a/query-languages/dax/information-functions-dax.md b/query-languages/dax/information-functions-dax.md index 38a1a22d0..fd5236382 100644 --- a/query-languages/dax/information-functions-dax.md +++ b/query-languages/dax/information-functions-dax.md @@ -1,50 +1,44 @@ --- description: "Learn more about: Information functions" -title: "Information functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/01/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Information functions (DAX)" --- # Information functions -DAX information functions look at the cell or row that is provided as an argument and tells you whether the value matches the expected type. For example, the ISERROR function returns TRUE if the value that you reference contains an error. - -## In this category +DAX information functions look at the cell or row that is provided as an argument and tells you whether the value matches the expected type. For example, the ISERROR function returns `TRUE` if the value that you reference contains an error. + +## In this category |Function |Description | |---------|---------| +|[COLUMNSTATISTICS](columnstatistics-function-dax.md) | Returns a table of statistics regarding every column in every table in the model. | |[CONTAINS](contains-function-dax.md) | Returns true if values for all referred columns exist, or are contained, in those columns; otherwise, the function returns false. | -|[CONTAINSROW](containsrow-function-dax.md) | Returns TRUE if a row of values exists or contained in a table, otherwise returns FALSE. | -|[CONTAINSSTRING](containsstring-function-dax.md) | Returns TRUE or FALSE indicating whether one string contains another string. | -|[CONTAINSSTRINGEXACT](containsstringexact-function-dax.md) | Returns TRUE or FALSE indicating whether one string contains another string. | +|[CONTAINSROW](containsrow-function-dax.md) | Returns `TRUE` if a row of values exists or contained in a table, otherwise returns `FALSE`. | +|[CONTAINSSTRING](containsstring-function-dax.md) | Returns `TRUE` or `FALSE` indicating whether one string contains another string. | +|[CONTAINSSTRINGEXACT](containsstringexact-function-dax.md) | Returns `TRUE` or `FALSE` indicating whether one string contains another string. | |[CUSTOMDATA](customdata-function-dax.md) | Returns the content of the CustomData property in the connection string. | -|[HASONEFILTER](hasonefilter-function-dax.md) | Returns TRUE when the number of directly filtered values on *columnName* is one; otherwise returns FALSE. | -|[HASONEVALUE](hasonevalue-function-dax.md) | Returns TRUE when the context for *columnName* has been filtered down to one distinct value only. Otherwise is FALSE. | +|[HASONEFILTER](hasonefilter-function-dax.md) | Returns TRUE when the number of directly filtered values on `columnName` is one; otherwise returns `FALSE`. | +|[HASONEVALUE](hasonevalue-function-dax.md) | Returns `TRUE` when the context for `columnName` has been filtered down to one distinct value only. Otherwise is `FALSE`. | |[ISAFTER](isafter-function-dax.md) | A boolean function that emulates the behavior of a Start At clause and returns true for a row that meets all of the condition parameters. | -|[ISBLANK](isblank-function-dax.md) | Checks whether a value is blank, and returns TRUE or FALSE. | -|[ISCROSSFILTERED](iscrossfiltered-function-dax.md) | Returns TRUE when *columnName* or another column in the same or related table is being filtered. | +|[ISBLANK](isblank-function-dax.md) | Checks whether a value is blank, and returns `TRUE` or `FALSE`. | +|[ISCROSSFILTERED](iscrossfiltered-function-dax.md) | Returns `TRUE` when `columnName` or another column in the same or related table is being filtered. | |[ISEMPTY](isempty-function-dax.md) | Checks if a table is empty. | -|[ISERROR](iserror-function-dax.md) | Checks whether a value is an error, and returns TRUE or FALSE. | -|[ISEVEN](iseven-function-dax.md) | Returns TRUE if number is even, or FALSE if number is odd. | -|[ISFILTERED](isfiltered-function-dax.md) | Returns TRUE when *columnName* is being filtered directly. | +|[ISERROR](iserror-function-dax.md) | Checks whether a value is an error, and returns `TRUE` or `FALSE`. | +|[ISEVEN](iseven-function-dax.md) | Returns `TRUE` if number is even, or `FALSE` if number is odd. | +|[ISFILTERED](isfiltered-function-dax.md) | Returns `TRUE` when `columnName` is being filtered directly. | |[ISINSCOPE](isinscope-function-dax.md) | Returns true when the specified column is the level in a hierarchy of levels. | -|[ISLOGICAL](islogical-function-dax.md) | Checks whether a value is a logical value, (TRUE or FALSE), and returns TRUE or FALSE. | -|[ISNONTEXT](isnontext-function-dax.md) | Checks if a value is not text (blank cells are not text), and returns TRUE or FALSE. | -|[ISNUMBER](isnumber-function-dax.md) | Checks whether a value is a number, and returns TRUE or FALSE. | -|[ISODD](isodd-function-dax.md) | Returns TRUE if number is odd, or FALSE if number is even. | +|[ISLOGICAL](islogical-function-dax.md) | Checks whether a value is a logical value, (`TRUE` or `FALSE`), and returns `TRUE` or `FALSE`. | +|[ISNONTEXT](isnontext-function-dax.md) | Checks if a value is not text (blank cells are not text), and returns `TRUE` or `FALSE`. | +|[ISNUMBER](isnumber-function-dax.md) | Checks whether a value is a number, and returns `TRUE` or `FALSE`. | +|[ISODD](isodd-function-dax.md) | Returns `TRUE` if number is odd, or `FALSE` if number is even. | |[ISONORAFTER](isonorafter-function-dax.md) | A boolean function that emulates the behavior of a Start At clause and returns true for a row that meets all of the condition parameters. | |[ISSELECTEDMEASURE](isselectedmeasure-function-dax.md)| Used by expressions for calculation items to determine the measure that is in context is one of those specified in a list of measures. | |[ISSUBTOTAL](issubtotal-function-dax.md) | Creates another column in a SUMMARIZE expression that returns True if the row contains subtotal values for the column given as argument, otherwise returns False. | -|[ISTEXT](istext-function-dax.md) | Checks if a value is text, and returns TRUE or FALSE. | +|[ISTEXT](istext-function-dax.md) | Checks if a value is text, and returns `TRUE` or `FALSE`. | |[NONVISUAL](nonvisual-function-dax.md) | Marks a value filter in a SUMMARIZECOLUMNS expression as non-visual. | |[SELECTEDMEASURE](selectedmeasure-function-dax.md) | Used by expressions for calculation items to reference the measure that is in context. | |[SELECTEDMEASUREFORMATSTRING](selectedmeasureformatstring-function-dax.md) | Used by expressions for calculation items to retrieve the format string of the measure that is in context. | |[SELECTEDMEASURENAME](selectedmeasurename-function-dax.md) | Used by expressions for calculation items to determine the measure that is in context by name. | +|[USERCULTURE](userculture-function-dax.md) |Returns the locale for the current user. | |[USERNAME](username-function-dax.md) | Returns the domain name and username from the credentials given to the system at connection time. | |[USEROBJECTID](userobjectid-function-dax.md) | Returns the current user's Object ID or SID. | |[USERPRINCIPALNAME](userprincipalname-function-dax.md) | Returns the user principal name. | diff --git a/query-languages/dax/int-function-dax.md b/query-languages/dax/int-function-dax.md index 90de63f7a..42ea54aa6 100644 --- a/query-languages/dax/int-function-dax.md +++ b/query-languages/dax/int-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: INT" -title: "INT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "INT function (DAX)" --- # INT -Rounds a number down to the nearest integer. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Rounds a number down to the nearest integer. + +## Syntax + ```dax -INT() +INT() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number you want to round down to an integer| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number you want to round down to an integer| + ## Return value -A whole number. - +A whole number. + ## Remarks -TRUNC and INT are similar in that both return integers. TRUNC removes the fractional part of the number. INT rounds numbers down to the nearest integer based on the value of the fractional part of the number. INT and TRUNC are different only when using negative numbers: `TRUNC(-4.3)` returns -4, but `INT(-4.3)` returns -5 because -5 is the lower number. - +TRUNC and INT are similar in that both return integers. TRUNC removes the fractional part of the number. INT rounds numbers down to the nearest integer based on the value of the fractional part of the number. INT and TRUNC are different only when using negative numbers: `TRUNC(-4.3)` returns -4, but `INT(-4.3)` returns -5 because -5 is the lower number. + ## Example -The following expression rounds the value to 1. If you use the ROUND function, the result would be 2. - +The following expression rounds the value to 1. If you use the ROUND function, the result would be 2. + ```dax -= INT(1.5) += INT(1.5) ``` - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[ROUND function](round-function-dax.md) -[ROUNDUP function](roundup-function-dax.md) -[ROUNDDOWN function](rounddown-function-dax.md) -[MROUND function](mround-function-dax.md) + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[ROUND function](round-function-dax.md) +[ROUNDUP function](roundup-function-dax.md) +[ROUNDDOWN function](rounddown-function-dax.md) +[MROUND function](mround-function-dax.md) diff --git a/query-languages/dax/intersect-function-dax.md b/query-languages/dax/intersect-function-dax.md index fbd29b8ac..86e049cd5 100644 --- a/query-languages/dax/intersect-function-dax.md +++ b/query-languages/dax/intersect-function-dax.md @@ -1,97 +1,90 @@ --- description: "Learn more about: INTERSECT" -title: "INTERSECT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "INTERSECT function (DAX)" --- # INTERSECT -Returns the row intersection of two tables, retaining duplicates. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the row intersection of two tables, retaining duplicates. + +## Syntax + ```dax -INTERSECT(, ) +INTERSECT(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Table_expression|Any DAX expression that returns a table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Table_expression`|Any DAX expression that returns a table.| + ## Return value -A table that contains all the rows in table_expression1 that are also in table_expression2 - -## Exceptions - +A table that contains all the rows in table_expression1 that are also in table_expression2 + +## Exceptions + ## Remarks -- Intersect is not commutative. In general, Intersect(T1, T2) will have a different result set than Intersect(T2, T1). - -- Duplicate rows are retained. If a row appears in table_expression1 and table_expression2, it and all duplicates in table_expression_1 are included in the result set. - -- The column names will match the column names in table_expression1. - -- The returned table has lineage based on the columns in table_expression1 , regardless of the lineage of the columns in the second table. For example, if the first column of first table_expression has lineage to the base column C1 in the model, the intersect will reduce the rows based on the intersect on first column of second table_expression and keep the lineage on base column C1 intact. - -- Columns are compared based on positioning, and data comparison with no type coercion. - -- The returned table does not include columns from tables related to table_expression1. +- Intersect is not commutative. In general, Intersect(T1, T2) will have a different result set than Intersect(T2, T1). + +- Duplicate rows are retained. If a row appears in table_expression1 and table_expression2, it and all duplicates in table_expression_1 are included in the result set. + +- The column names will match the column names in table_expression1. + +- The returned table has lineage based on the columns in table_expression1 , regardless of the lineage of the columns in the second table. For example, if the first column of first table_expression has lineage to the base column C1 in the model, the intersect will reduce the rows based on the intersect on first column of second table_expression and keep the lineage on base column C1 intact. + +- Columns are compared based on positioning, and data comparison with no type coercion. + +- The returned table does not include columns from tables related to table_expression1. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -States1 - -|State| -|---------| -|A| -|A| -|B| -|B| -|B| -|C| -|D| -|D| - -States2 - -|State| -|---------| -|B| -|C| -|D| -|D| -|D| -|E| - -Intersect(States1, States2) - -|State| -|---------| -|B| -|B| -|B| -|C| -|D| -|D| - -Intersect(States2, States1) - -|State| -|---------| -|B| -|C| -|D| -|D| -|D| +States1 + +|State| +|---------| +|A| +|A| +|B| +|B| +|B| +|C| +|D| +|D| + +States2 + +|State| +|---------| +|B| +|C| +|D| +|D| +|D| +|E| + +Intersect(States1, States2) + +|State| +|---------| +|B| +|B| +|B| +|C| +|D| +|D| + +Intersect(States2, States1) + +|State| +|---------| +|B| +|C| +|D| +|D| +|D| diff --git a/query-languages/dax/intrate-function-dax.md b/query-languages/dax/intrate-function-dax.md index 8825594bd..4f3e54fc5 100644 --- a/query-languages/dax/intrate-function-dax.md +++ b/query-languages/dax/intrate-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: INTRATE" -title: "INTRATE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference -author: jajin7 -ms.author: owend -recommendations: false - +title: "INTRATE function (DAX)" --- # INTRATE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the interest rate for a fully invested security. ## Syntax @@ -24,17 +17,17 @@ INTRATE(, , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|investment|The amount invested in the security.| -|redemption|The amount to be received at maturity.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`investment`|The amount invested in the security.| +|`redemption`|The amount to be received at maturity.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/ipmt-function-dax.md b/query-languages/dax/ipmt-function-dax.md index 1fcbf3e6f..c31bdfcd8 100644 --- a/query-languages/dax/ipmt-function-dax.md +++ b/query-languages/dax/ipmt-function-dax.md @@ -1,19 +1,12 @@ --- description: "Learn more about: IPMT" -title: "IPMT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference -author: jajin7 -ms.author: owend -recommendations: false - +title: "IPMT function (DAX)" --- # IPMT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate. ## Syntax @@ -24,18 +17,18 @@ IPMT(, , , [, [, ]]) ### Parameters -|Term|Definition| -|--------|--------------| -|rate|The interest rate per period.| -|per|The period for which you want to find the interest. Must be between 1 and nper (inclusive).| -|nper|The total number of payment periods in an annuity.| -|pv|The present value, or the lump-sum amount that a series of future payments is worth right now.| -|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. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`rate`|The interest rate per period.| +|`per`|The period for which you want to find the interest. Must be between 1 and nper (inclusive).| +|`nper`|The total number of payment periods in an annuity.| +|`pv`|The present value, or the lump-sum amount that a series of future payments is worth right now.| +|`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. The accepted values are listed below this table.| -The **type** parameter accepts the following values: +The `type` parameter accepts the following values: -| **Set type equal to** | **If payments are due** | +| **Set `type` equal to** | **If payments are due** | | --------------------- | ------------------------------ | | 0 or omitted | At the end of the period | | 1 | At the beginning of the period | diff --git a/query-languages/dax/isafter-function-dax.md b/query-languages/dax/isafter-function-dax.md index 1db4f2ade..e3ea87705 100644 --- a/query-languages/dax/isafter-function-dax.md +++ b/query-languages/dax/isafter-function-dax.md @@ -1,38 +1,31 @@ --- description: "Learn more about: ISAFTER" -title: "ISAFTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/31/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISAFTER function (DAX)" --- # ISAFTER - -A boolean function that emulates the behavior of a 'Start At' clause and returns true for a row that meets all of the condition parameters. - -Based on the sort order, the first parameter is compared with the second parameter. If the sort order is ascending, the comparison to be done is first parameter greater than the second parameter. If the sort order is descending, the comparison to be done is second parameter less than the first parameter. - -## Syntax - -```DAX -ISAFTER(, [, sort_order [, , [, sort_order]]…) + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +A boolean function that emulates the behavior of a 'Start At' clause and returns true for a row that meets all of the condition parameters. + +Based on the sort order, the first parameter is compared with the second parameter. If the sort order is ascending, the comparison to be done is first parameter greater than the second parameter. If the sort order is descending, the comparison to be done is second parameter less than the first parameter. + +## Syntax + +```DAX +ISAFTER(, [, sort_order [, , [, sort_order]]…) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|scalar expression|Any expression that returns a scalar value like a column reference or integer or string value. Typically the first parameter is a column reference and the second parameter is a scalar value.| -|sort order|(optional) The order in which the column is sorted. Can be ascending (ASC) or descending (DEC). By default the sort order is ascending.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`scalar expression`|Any expression that returns a scalar value like a column reference or integer or string value. Typically the first parameter is a column reference and the second parameter is a scalar value.| +|`sort order`|(optional) The order in which the column is sorted. Can be ascending (ASC) or descending (DEC). By default the sort order is ascending.| + ## Return value -True or false. +True or false. ## Remarks @@ -42,15 +35,15 @@ This function is similar to [ISONORAFTER](isonorafter-function-dax.md). The diff ## Example -Table name: 'Info' - -|Country|State|Count|Total| -|-----------|---------|---------|---------| -|IND|JK|20|800| -|IND|MH|25|1000| -|IND|WB|10|900| -|USA|CA|5|500| -|USA|WA|10|900| +Table name: 'Info' + +|Country/Region|State|Count|Total| +|-----------|---------|---------|---------| +|IND|JK|20|800| +|IND|MH|25|1000| +|IND|WB|10|900| +|USA|CA|5|500| +|USA|WA|10|900| The following expression: @@ -65,12 +58,12 @@ FILTER ( Returns: -|Country|State|Count|Total| -|-----------|---------|---------|---------| -|IND|WB|10|900| -|USA|CA|5|500| -|USA|WA|10|900| +|Country|State|Count|Total| +|-----------|---------|---------|---------| +|IND|WB|10|900| +|USA|CA|5|500| +|USA|WA|10|900| -## See also +## Related content [ISONORAFTER](isonorafter-function-dax.md) \ No newline at end of file diff --git a/query-languages/dax/isatlevel-function-dax.md b/query-languages/dax/isatlevel-function-dax.md new file mode 100644 index 000000000..cadabb480 --- /dev/null +++ b/query-languages/dax/isatlevel-function-dax.md @@ -0,0 +1,67 @@ +--- +description: "Learn more about: ISATLEVEL" +title: "ISATLEVEL function (DAX)" +ms.service: powerbi +ms.subservice: dax +ms.date: 02/20/2024 +ms.topic: reference +author: jewang-msft +ms.author: jewang +recommendations: false + +--- + +# ISATLEVEL + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Reports whether the column is present at the current level. + +## Syntax + +```dax +ISATLEVEL ( ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A grouping column in the data grid.| + +## Return value + +`TRUE` or `FALSE` that indicates whether the grouping column is at the current level in the context. + +## Remarks + +* This function can be used only in visual calculations. +* Unlike other functions with similar functionality, such as ISINSCOPE, ISFILTERED, HASONEVALUE, and so on, ISATLEVEL is a function specialized for visual calculations, therefore it is guaranteed to be compatible with functions that navigate the levels of a hierarchy in the data matrix, such as EXPAND and COLLAPSE. +* A hierarchy level can contain more than one column. For example, in a [Year], [Quarter], [Month] hierarchy, the level that contains the [Quarter] column also includes the [Year] column at the same level. + +## Example + +Consider a table that includes a hierarchy with levels for total, year, quarter, and month. The following DAX calculations can be used to determine whether a specific column is at the current level in the original context or at the new level after a navigation operation. + +```dax +IsYearLevel = ISATLEVEL([Fiscal Year]) +IsQuarterLevel = ISATLEVEL([Fiscal Quarter]) +IsMonthLevel = ISATLEVEL([Month]) +IsQuarterLevelAfterExpand = EXPAND(ISATLEVEL([Fiscal Quarter]), ROWS) +IsQuarterLevelAfterCollapse = COLLAPSE(ISATLEVEL([Fiscal Quarter]), ROWS) +``` + +The screenshot below shows the matrix with the five visual calculations. + +![DAX visual calculation](media/dax-queries/dax-visualcalc-isatlevel.png) + +## See also + +[EXPAND](expand-function-dax.md) +[EXPANDALL](expandall-function-dax.md) +[COLLAPSE](collapse-function-dax.md) +[COLLAPSEALL](collapseall-function-dax.md) +[ISINSCOPE](isinscope-function-dax.md) +[ISFILTERED](isfiltered-function-dax.md) +[HASONEVALUE](hasonevalue-function-dax.md) + diff --git a/query-languages/dax/isblank-function-dax.md b/query-languages/dax/isblank-function-dax.md index d53e23c4d..66ab4ebd4 100644 --- a/query-languages/dax/isblank-function-dax.md +++ b/query-languages/dax/isblank-function-dax.md @@ -1,35 +1,28 @@ --- description: "Learn more about: ISBLANK" -title: "ISBLANK function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/13/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISBLANK function (DAX)" --- # ISBLANK -Checks whether a value is blank, and returns TRUE or FALSE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks whether a value is blank, and returns `TRUE` or `FALSE`. + +## Syntax + ```dax -ISBLANK() +ISBLANK() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|value|The value or expression you want to test.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`value`|The value or expression you want to test.| + ## Return value -A Boolean value of TRUE if the value is blank; otherwise FALSE. +A Boolean value of `TRUE` if the value is blank; otherwise `FALSE`. ## Remarks @@ -37,27 +30,27 @@ To learn more about best practices when working with BLANKS, see [Avoid converti ## Example -This formula computes the increase or decrease ratio in sales compared to the previous year. The example uses the IF function to check the value for the previous year's sales in order to avoid a divide by zero error. +This formula computes the increase or decrease ratio in sales compared to the previous year. The example uses the IF function to check the value for the previous year's sales in order to avoid a divide by zero error. ```dax -//Sales to Previous Year Ratio - -= IF( ISBLANK('CalculatedMeasures'[PreviousYearTotalSales]) - , BLANK() - , ( 'CalculatedMeasures'[Total Sales]-'CalculatedMeasures'[PreviousYearTotalSales] ) - /'CalculatedMeasures'[PreviousYearTotalSales]) +//Sales to Previous Year Ratio + += IF( ISBLANK('CalculatedMeasures'[PreviousYearTotalSales]) + , BLANK() + , ( 'CalculatedMeasures'[Total Sales]-'CalculatedMeasures'[PreviousYearTotalSales] ) + /'CalculatedMeasures'[PreviousYearTotalSales]) ``` Result, -|Row Labels|Total Sales|Total Sales Previous Year|Sales to Previous Year Ratio| -|--------------|---------------|-----------------------------|--------------------------------| -|2005|$10,209,985.08||| -|2006|$28,553,348.43|$10,209,985.08|179.66%| -|2007|$39,248,847.52|$28,553,348.43|37.46%| -|2008|$24,542,444.68|$39,248,847.52|-37.47%| -|Grand Total|$102,554,625.71||| - -## See also - -[Information functions](information-functions-dax.md) +|Row Labels|Total Sales|Total Sales Previous Year|Sales to Previous Year Ratio| +|--------------|---------------|-----------------------------|--------------------------------| +|2005|$10,209,985.08||| +|2006|$28,553,348.43|$10,209,985.08|179.66%| +|2007|$39,248,847.52|$28,553,348.43|37.46%| +|2008|$24,542,444.68|$39,248,847.52|-37.47%| +|Grand Total|$102,554,625.71||| + +## Related content + +[Information functions](information-functions-dax.md) diff --git a/query-languages/dax/iscrossfiltered-function-dax.md b/query-languages/dax/iscrossfiltered-function-dax.md index b38392125..f5f0b88fe 100644 --- a/query-languages/dax/iscrossfiltered-function-dax.md +++ b/query-languages/dax/iscrossfiltered-function-dax.md @@ -1,47 +1,40 @@ --- description: "Learn more about: ISCROSSFILTERED" -title: "ISCROSSFILTERED function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/27/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISCROSSFILTERED function (DAX)" --- # ISCROSSFILTERED -Returns TRUE when the specified table or column is cross-filtered. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` when the specified table or column is cross-filtered. + +## Syntax + ```dax -ISCROSSFILTERED() +ISCROSSFILTERED() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -|TableNameOrColumnName|The name of an existing table or column. It cannot be an expression.| - +### Parameters + +|Term|Definition| +|--------|--------------| +|`TableNameOrColumnName`|The name of an existing table or column. It cannot be an expression.| + ## Return value -TRUE when *ColumnName* or a column of *TableName* is being cross-filtered. Otherwise returns FALSE. - -## Remarks - -- A column or table is said to be cross-filtered when a filter is applied to *ColumnName*, any column of *TableName*, or to any column of a related table. +``TRUE`` when `ColumnName` or a column of `TableName` is being cross-filtered. Otherwise returns `FALSE`. + +## Remarks + +- A column or table is said to be cross-filtered when a filter is applied to `ColumnName`, any column of `TableName`, or to any column of a related table. -- A column or table is said to be filtered directly when a filter is applied to *ColumnName* or to any column of *TableName*. Therefore, the [ISFILTERED](isfiltered-function-dax.md) function also returns TRUE when *ColumnName* or any column of *TableName* is filtered. +- A column or table is said to be filtered directly when a filter is applied to `ColumnName` or to any column of `TableName`. Therefore, the [ISFILTERED](isfiltered-function-dax.md) function also returns `TRUE` when `ColumnName` or any column of `TableName` is filtered. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## See also +## Related content -[ISFILTERED function](isfiltered-function-dax.md) -[FILTERS function](filters-function-dax.md) -[HASONEFILTER function](hasonefilter-function-dax.md) -[HASONEVALUE function](hasonevalue-function-dax.md) +[ISFILTERED function](isfiltered-function-dax.md) +[FILTERS function](filters-function-dax.md) +[HASONEFILTER function](hasonefilter-function-dax.md) +[HASONEVALUE function](hasonevalue-function-dax.md) diff --git a/query-languages/dax/isempty-function-dax.md b/query-languages/dax/isempty-function-dax.md index 65206c48f..a9bcef77e 100644 --- a/query-languages/dax/isempty-function-dax.md +++ b/query-languages/dax/isempty-function-dax.md @@ -1,35 +1,28 @@ --- description: "Learn more about: ISEMPTY" -title: "ISEMPTY function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 04/13/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISEMPTY function (DAX)" --- # ISEMPTY - -Checks if a table is empty. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks if a table is empty. + +## Syntax + ```dax -ISEMPTY() +ISEMPTY() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table_expression|A table reference or a DAX expression that returns a table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table_expression`|A table reference or a DAX expression that returns a table.| + ## Return value -True if the table is empty (has no rows), if else, False. +True if the table is empty (has no rows), if else, False. ## Remarks @@ -37,19 +30,19 @@ True if the table is empty (has no rows), if else, False. ## Example -For the below table named 'Info': - -|Country|State|County|Total| -|-----------|---------|----------|---------| -|IND|JK|20|800| -|IND|MH|25|1000| -|IND|WB|10|900| -|USA|CA|5|500| -|USA|WA|10|900| - +For the below table named 'Info': + +|Country/Region|State|County|Total| +|-----------|---------|----------|---------| +|IND|JK|20|800| +|IND|MH|25|1000| +|IND|WB|10|900| +|USA|CA|5|500| +|USA|WA|10|900| + ```dax EVALUATE -ROW("Any countries with count > 25?", NOT(ISEMPTY(FILTER(Info, [County]>25)))) +ROW("Any countries with count > 25?", NOT(ISEMPTY(FILTER(Info, [County]>25)))) ``` -Return value: **FALSE** +Return value: `FALSE`` diff --git a/query-languages/dax/iserror-function-dax.md b/query-languages/dax/iserror-function-dax.md index e2663c53b..0eb42e029 100644 --- a/query-languages/dax/iserror-function-dax.md +++ b/query-languages/dax/iserror-function-dax.md @@ -1,35 +1,28 @@ --- description: "Learn more about: ISERROR" -title: "ISERROR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISERROR function (DAX)" --- # ISERROR -Checks whether a value is an error, and returns TRUE or FALSE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks whether a value is an error, and returns `TRUE` or `FALSE`. + +## Syntax + ```dax -ISERROR() +ISERROR() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|value|The value you want to test.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`value`|The value you want to test.| + ## Return value -A Boolean value of TRUE if the value is an error; otherwise FALSE. +A Boolean value of `TRUE` if the value is an error; otherwise `FALSE`. ## Remarks @@ -39,21 +32,21 @@ A Boolean value of TRUE if the value is an error; otherwise FALSE. ## Example -The following example calculates the ratio of total Internet sales to total reseller sales. The ISERROR function is used to check for errors, such as division by zero. If there is an error a blank is returned, otherwise the ratio is returned. - +The following example calculates the ratio of total Internet sales to total reseller sales. The ISERROR function is used to check for errors, such as division by zero. If there is an error a blank is returned, otherwise the ratio is returned. + ```dax -= IF( ISERROR( - SUM('ResellerSales_USD'[SalesAmount_USD]) - /SUM('InternetSales_USD'[SalesAmount_USD]) - ) - , BLANK() - , SUM('ResellerSales_USD'[SalesAmount_USD]) - /SUM('InternetSales_USD'[SalesAmount_USD]) - ) += IF( ISERROR( + SUM('ResellerSales_USD'[SalesAmount_USD]) + /SUM('InternetSales_USD'[SalesAmount_USD]) + ) + , BLANK() + , SUM('ResellerSales_USD'[SalesAmount_USD]) + /SUM('InternetSales_USD'[SalesAmount_USD]) + ) ``` - -## See also -[Information functions](information-functions-dax.md) -[IFERROR function](iferror-function-dax.md) -[IF function](if-function-dax.md) +## Related content + +[Information functions](information-functions-dax.md) +[IFERROR function](iferror-function-dax.md) +[IF function](if-function-dax.md) diff --git a/query-languages/dax/iseven-function-dax.md b/query-languages/dax/iseven-function-dax.md index dd406d18b..dedde6e00 100644 --- a/query-languages/dax/iseven-function-dax.md +++ b/query-languages/dax/iseven-function-dax.md @@ -1,38 +1,31 @@ --- description: "Learn more about: ISEVEN" -title: "ISEVEN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISEVEN function (DAX)" --- # ISEVEN -Returns TRUE if number is even, or FALSE if number is odd. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` if number is even, or `FALSE` if number is odd. + +## Syntax + ```dax -ISEVEN(number) +ISEVEN(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The value to test. If number is not an integer, it is truncated.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The value to test. If number is not an integer, it is truncated.| + ## Return value -Returns TRUE if number is even, or FALSE if number is odd. - +Returns `TRUE` if number is even, or `FALSE` if number is odd. + ## Remarks -- If number is nonnumeric, ISEVEN returns the #VALUE! error value. +- If number is nonnumeric, ISEVEN returns the `#VALUE!` error value. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/isfiltered-function-dax.md b/query-languages/dax/isfiltered-function-dax.md index 30130be11..05a33b2ec 100644 --- a/query-languages/dax/isfiltered-function-dax.md +++ b/query-languages/dax/isfiltered-function-dax.md @@ -1,47 +1,40 @@ --- description: "Learn more about: ISFILTERED" -title: "ISFILTERED function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/26/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISFILTERED function (DAX)" --- # ISFILTERED -Returns TRUE when the specified table or column is being filtered directly. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` when the specified table or column is being filtered directly. + +## Syntax + ```dax -ISFILTERED() +ISFILTERED() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -|TableNameOrColumnName|The name of an existing table or column. It cannot be an expression.| - +### Parameters + +|Term|Definition| +|--------|--------------| +|`TableNameOrColumnName`|The name of an existing table or column. It cannot be an expression.| + ## Return value -TRUE when *ColumnName* or a column of *TableName* is being filtered directly. Otherwise returns FALSE. - -## Remarks +`TRUE` when `ColumnName` or a column of `TableName` is being filtered directly. Otherwise returns `FALSE`. + +## Remarks + +- A column or table is said to be filtered directly when a filter is applied to `ColumnName` or any column of `TableName`. -- A column or table is said to be filtered directly when a filter is applied to *ColumnName* or any column of *TableName*. - -- A column or table is said to be cross-filtered when a filter is applied to *ColumnName*, any column of *TableName*, or to any column of a related table. Therefore, the [ISCROSSFILTERED](iscrossfiltered-function-dax.md) function also returns TRUE when *ColumnName*, any column of *TableName*, or a column of a related table is filtered. +- A column or table is said to be cross-filtered when a filter is applied to `ColumnName`, any column of `TableName`, or to any column of a related table. Therefore, the [ISCROSSFILTERED](iscrossfiltered-function-dax.md) function also returns `TRUE` when `ColumnName`, any column of `TableName`, or a column of a related table is filtered. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## See also +## Related content -[ISCROSSFILTERED function](iscrossfiltered-function-dax.md) -[FILTERS function](filters-function-dax.md) -[HASONEFILTER function](hasonefilter-function-dax.md) -[HASONEVALUE function](hasonevalue-function-dax.md) +[ISCROSSFILTERED function](iscrossfiltered-function-dax.md) +[FILTERS function](filters-function-dax.md) +[HASONEFILTER function](hasonefilter-function-dax.md) +[HASONEVALUE function](hasonevalue-function-dax.md) diff --git a/query-languages/dax/isinscope-function-dax.md b/query-languages/dax/isinscope-function-dax.md index 794bdac4e..df6af8b31 100644 --- a/query-languages/dax/isinscope-function-dax.md +++ b/query-languages/dax/isinscope-function-dax.md @@ -1,41 +1,34 @@ --- description: "Learn more about: ISINSCOPE" -title: "ISINSCOPE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISINSCOPE function (DAX)" --- # ISINSCOPE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns true when the specified column is the level in a hierarchy of levels. - -## Syntax - + +## Syntax + ```dax ISINSCOPE() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|columnName|The name of an existing column, using standard DAX syntax. It cannot be an expression.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`columnName`|The name of an existing column, using standard DAX syntax. It cannot be an expression.| + ## Return value -TRUE when the specified column is the level in a hierarchy of levels. +`TRUE` when the specified column is the level in a hierarchy of levels. ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example ```dax DEFINE @@ -80,16 +73,16 @@ Returns, |DimProduct\[Category] |DimProduct\[SubCategory] |\[Category Subtotal] |\[Subcategory Subtotal] |\[Sales] |\[% of Parent] |---------|---------|---------|---------|---------|---------| -| | | TRUE | TRUE | 28,397,095.65 | 100.00 | -|Accessories | | FALSE | TRUE | 78,951.00 | 0.28 | -|Accessories | Bike Racks | FALSE | FALSE | 39,360.00 | 49.85 | -|Accessories | Bike Stands | FALSE | FALSE | 39,591.00 | 50.15 | -|Bikes | | FALSE | TRUE | 28,318,144.65 | 99.72 | -|Bikes | Mountain Bikes | FALSE | FALSE | 9,952,759.56 | 35.15 | -|Bikes | Road Bikes | FALSE | FALSE | 14,520,584.04 | 51.28 | -|Bikes | Touring Bikes | FALSE | FALSE | 3,844,801.05 | 13.58 | - -## See also - -[SUMMARIZECOLUMNS function](summarizecolumns-function-dax.md) +| | | `TRUE` | `TRUE` | 28,397,095.65 | 100.00 | +|Accessories | | `FALSE` | `TRUE` | 78,951.00 | 0.28 | +|Accessories | Bike Racks | `FALSE` | `FALSE` | 39,360.00 | 49.85 | +|Accessories | Bike Stands | `FALSE` | `FALSE` | 39,591.00 | 50.15 | +|Bikes | | `FALSE` | `TRUE` | 28,318,144.65 | 99.72 | +|Bikes | Mountain Bikes | `FALSE` | `FALSE` | 9,952,759.56 | 35.15 | +|Bikes | Road Bikes | `FALSE` | `FALSE` | 14,520,584.04 | 51.28 | +|Bikes | Touring Bikes | `FALSE` | `FALSE` | 3,844,801.05 | 13.58 | + +## Related content + +[SUMMARIZECOLUMNS function](summarizecolumns-function-dax.md) [CALCULATE function](calculate-function-dax.md) diff --git a/query-languages/dax/islogical-function-dax.md b/query-languages/dax/islogical-function-dax.md index 60a61ea76..8c5235182 100644 --- a/query-languages/dax/islogical-function-dax.md +++ b/query-languages/dax/islogical-function-dax.md @@ -1,35 +1,28 @@ --- description: "Learn more about: ISLOGICAL" -title: "ISLOGICAL function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISLOGICAL function (DAX)" --- # ISLOGICAL -Checks whether a value is a logical value, (TRUE or FALSE), and returns TRUE or FALSE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks whether a value is a logical value, (`TRUE` or `FALSE`), and returns `TRUE` or `FALSE`. + +## Syntax + ```dax -ISLOGICAL() +ISLOGICAL() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|value|The value that you want to test.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`value`|The value that you want to test.| + ## Return value -TRUE if the value is a logical value; FALSE if any value other than TRUE OR FALSE. +`TRUE` if the value is a logical value; `FALSE` if any value other than `TRUE` OR `FALSE`. ## Remarks @@ -37,19 +30,19 @@ TRUE if the value is a logical value; FALSE if any value other than TRUE OR FALS ## Example -The following three samples show the behavior of ISLOGICAL. - +The following three samples show the behavior of ISLOGICAL. + ```dax -//RETURNS: Is Boolean type or Logical -= IF(ISLOGICAL(true), "Is Boolean type or Logical", "Is different type") - -//RETURNS: Is Boolean type or Logical -= IF(ISLOGICAL(false), "Is Boolean type or Logical", "Is different type") - -//RETURNS: Is different type -= IF(ISLOGICAL(25), "Is Boolean type or Logical", "Is different type") +//RETURNS: Is Boolean type or Logical += IF(ISLOGICAL(true), "Is Boolean type or Logical", "Is different type") + +//RETURNS: Is Boolean type or Logical += IF(ISLOGICAL(false), "Is Boolean type or Logical", "Is different type") + +//RETURNS: Is different type += IF(ISLOGICAL(25), "Is Boolean type or Logical", "Is different type") ``` - -## See also -[Information functions](information-functions-dax.md) +## Related content + +[Information functions](information-functions-dax.md) diff --git a/query-languages/dax/isnontext-function-dax.md b/query-languages/dax/isnontext-function-dax.md index 5857b7168..f68429bb6 100644 --- a/query-languages/dax/isnontext-function-dax.md +++ b/query-languages/dax/isnontext-function-dax.md @@ -1,57 +1,50 @@ --- description: "Learn more about: ISNONTEXT" -title: "ISNONTEXT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISNONTEXT function (DAX)" --- # ISNONTEXT -Checks if a value is not text (blank cells are not text), and returns TRUE or FALSE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks if a value is not text (blank cells are not text), and returns `TRUE` or `FALSE`. + +## Syntax + ```dax -ISNONTEXT() +ISNONTEXT() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|value|The value you want to check.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`value`|The value you want to check.| + ## Return value -TRUE if the value is not text or blank; FALSE if the value is text. - +`TRUE` if the value is not text or blank; `FALSE` if the value is text. + ## Remarks -- An empty string is considered text. +- An empty string is considered text. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following examples show the behavior of the ISNONTEXT function. - +The following examples show the behavior of the ISNONTEXT function. + ```dax -//RETURNS: Is Non-Text -= IF(ISNONTEXT(1), "Is Non-Text", "Is Text") - -//RETURNS: Is Non-Text -= IF(ISNONTEXT(BLANK()), "Is Non-Text", "Is Text") - -//RETURNS: Is Text -= IF(ISNONTEXT(""), "Is Non-Text", "Is Text") +//RETURNS: Is Non-Text += IF(ISNONTEXT(1), "Is Non-Text", "Is Text") + +//RETURNS: Is Non-Text += IF(ISNONTEXT(BLANK()), "Is Non-Text", "Is Text") + +//RETURNS: Is Text += IF(ISNONTEXT(""), "Is Non-Text", "Is Text") ``` - -## See also -[Information functions](information-functions-dax.md) +## Related content + +[Information functions](information-functions-dax.md) diff --git a/query-languages/dax/isnumber-function-dax.md b/query-languages/dax/isnumber-function-dax.md index a9b5508c8..51271c66a 100644 --- a/query-languages/dax/isnumber-function-dax.md +++ b/query-languages/dax/isnumber-function-dax.md @@ -1,35 +1,28 @@ --- description: "Learn more about: ISNUMBER" -title: "ISNUMBER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 12/10/2018 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISNUMBER function (DAX)" --- # ISNUMBER -Checks whether a value is a number, and returns TRUE or FALSE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks whether a value is a number, and returns `TRUE` or `FALSE`. + +## Syntax + ```dax -ISNUMBER() +ISNUMBER() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|value|The value you want to test.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`value`|The value you want to test.| + ## Return value -TRUE if the value is numeric; otherwise FALSE. +`TRUE` if the value is numeric; otherwise `FALSE`. ## Remarks @@ -37,19 +30,19 @@ TRUE if the value is numeric; otherwise FALSE. ## Example -The following three samples show the behavior of ISNUMBER. - +The following three samples show the behavior of ISNUMBER. + ```dax -//RETURNS: Is number -= IF(ISNUMBER(0), "Is number", "Is Not number") - -//RETURNS: Is number -= IF(ISNUMBER(3.1E-1),"Is number", "Is Not number") - -//RETURNS: Is Not number -= IF(ISNUMBER("123"), "Is number", "Is Not number") +//RETURNS: Is number += IF(ISNUMBER(0), "Is number", "Is Not number") + +//RETURNS: Is number += IF(ISNUMBER(3.1E-1),"Is number", "Is Not number") + +//RETURNS: Is Not number += IF(ISNUMBER("123"), "Is number", "Is Not number") ``` - -## See also -[Information functions](information-functions-dax.md) +## Related content + +[Information functions](information-functions-dax.md) diff --git a/query-languages/dax/iso-ceiling-function-dax.md b/query-languages/dax/iso-ceiling-function-dax.md index a3ca07051..503f0585e 100644 --- a/query-languages/dax/iso-ceiling-function-dax.md +++ b/query-languages/dax/iso-ceiling-function-dax.md @@ -1,76 +1,69 @@ --- description: "Learn more about: ISO.CEILING" -title: "ISO.CEILING function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISO.CEILING function (DAX)" --- # ISO.CEILING -Rounds a number up, to the nearest integer or to the nearest multiple of significance. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Rounds a number up, to the nearest integer or to the nearest multiple of significance. + +## Syntax + ```dax -ISO.CEILING([, ]) +ISO.CEILING([, ]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number you want to round, or a reference to a column that contains numbers.| -|significance|(optional) The multiple of significance to which you want to round. For example, to round to the nearest integer, type 1. If the unit of significance is not specified, the number is rounded up to the nearest integer.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number you want to round, or a reference to a column that contains numbers.| +|`significance`|(optional) The multiple of significance to which you want to round. For example, to round to the nearest integer, type 1. If the unit of significance is not specified, the number is rounded up to the nearest integer.| + ## Return value -A number, of the same type as the *number* argument, rounded as specified. - +A number, of the same type as the `number` argument, rounded as specified. + ## Remarks -There are two CEILING functions in DAX, with the following differences: - -- The CEILING function emulates the behavior of the CEILING function in Excel. - -- The ISO.CEILING function follows the ISO-defined behavior for determining the ceiling value. - -The two functions return the same value for positive numbers, but different values for negative numbers. When using a positive multiple of significance, both CEILING and ISO.CEILING round negative numbers upward (toward positive infinity). When using a negative multiple of significance, CEILING rounds negative numbers downward (toward negative infinity), while ISO.CEILING rounds negative numbers upward (toward positive infinity). - -The result type is usually the same type of the significance used as argument with the following exceptions: - -- If the first argument is of currency type then the result will be currency type. - -- If the optional argument is not included the result is of integer type. - -- If the significance argument is of Boolean type then the result is of integer type. - -- If the significance argument is non-numeric type then the result is of real type. - -## Example: Positive Numbers +There are two CEILING functions in DAX, with the following differences: + +- The CEILING function emulates the behavior of the CEILING function in Excel. + +- The ISO.CEILING function follows the ISO-defined behavior for determining the ceiling value. + +The two functions return the same value for positive numbers, but different values for negative numbers. When using a positive multiple of significance, both CEILING and ISO.CEILING round negative numbers upward (toward positive infinity). When using a negative multiple of significance, CEILING rounds negative numbers downward (toward negative infinity), while ISO.CEILING rounds negative numbers upward (toward positive infinity). + +The result type is usually the same type of the significance used as argument with the following exceptions: + +- If the first argument is of currency type then the result will be currency type. + +- If the optional argument is not included the result is of integer type. + +- If the significance argument is of Boolean type then the result is of integer type. + +- If the significance argument is non-numeric type then the result is of real type. + +## Example: Positive Numbers The following formula returns 4.45. This might be useful if you want to avoid using smaller units in your pricing. If an existing product is priced at $4.42, you can use ISO.CEILING to round prices up to the nearest unit of five cents. - + ```dax -= ISO.CEILING(4.42,0.05) += ISO.CEILING(4.42,0.05) ``` - -## Example: Negative Numbers -The following formula returns the ISO ceiling value of -4.40. - +## Example: Negative Numbers + +The following formula returns the ISO ceiling value of -4.40. + ```dax -= ISO.CEILING(-4.42,0.05) += ISO.CEILING(-4.42,0.05) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) -[FLOOR function](floor-function-dax.md) -[CEILING function](ceiling-function-dax.md) -[ROUNDUP function](roundup-function-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[FLOOR function](floor-function-dax.md) +[CEILING function](ceiling-function-dax.md) +[ROUNDUP function](roundup-function-dax.md) diff --git a/query-languages/dax/isodd-function-dax.md b/query-languages/dax/isodd-function-dax.md index 4f3979645..5b12770fd 100644 --- a/query-languages/dax/isodd-function-dax.md +++ b/query-languages/dax/isodd-function-dax.md @@ -1,38 +1,31 @@ --- description: "Learn more about: ISODD" -title: "ISODD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISODD function (DAX)" --- # ISODD -Returns TRUE if number is odd, or FALSE if number is even. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` if number is odd, or `FALSE` if number is even. + +## Syntax + ```dax -ISODD(number) +ISODD(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The value to test. If number is not an integer, it is truncated.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The value to test. If number is not an integer, it is truncated.| + ## Return value -Returns TRUE if number is odd, or FALSE if number is even. - +Returns `TRUE` if number is odd, or `FALSE` if number is even. + ## Remarks -- If number is nonnumeric, ISODD returns the #VALUE! error value. +- If number is nonnumeric, ISODD returns the `#VALUE!` error value. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/isonorafter-function-dax.md b/query-languages/dax/isonorafter-function-dax.md index e69d872c1..5e05596cd 100644 --- a/query-languages/dax/isonorafter-function-dax.md +++ b/query-languages/dax/isonorafter-function-dax.md @@ -1,38 +1,31 @@ --- description: "Learn more about: ISONORAFTER" -title: "ISONORAFTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/21/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISONORAFTER function (DAX)" --- # ISONORAFTER - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + A boolean function that emulates the behavior of a Start At clause and returns true for a row that meets all of the condition parameters. - -Based on the sort order, the first parameter is compared with the second parameter. If the sort order is ascending, the comparison to be done is first parameter greater than the second parameter. If the sort order is descending, the comparison to be done is second parameter less than the first parameter. - -## Syntax - -```DAX -ISONORAFTER(, [, sort_order [, , [, sort_order]]…) + +Based on the sort order, the first parameter is compared with the second parameter. If the sort order is ascending, the comparison to be done is first parameter greater than the second parameter. If the sort order is descending, the comparison to be done is second parameter less than the first parameter. + +## Syntax + +```DAX +ISONORAFTER(, [, sort_order [, , [, sort_order]]…) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|scalar expression|Any expression that returns a scalar value like a column reference or integer or string value. Typically the first parameter is a column reference and the second parameter is a scalar value.| -|sort order|(optional) The order in which the column is sorted. Can be ascending (ASC) or descending (DESC). By default the sort order is ascending.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`scalar expression`|Any expression that returns a scalar value like a column reference or integer or string value. Typically the first parameter is a column reference and the second parameter is a scalar value.| +|`sort order`|(optional) The order in which the column is sorted. Can be ascending (ASC) or descending (DESC). By default the sort order is ascending.| + ## Return value -True or false. +True or false. ## Remarks @@ -42,15 +35,15 @@ This function is similar to [ISAFTER](isafter-function-dax.md). The difference i ## Example -For the following table named, Info: - -|Country|State|Count|Total| -|-----------|---------|---------|---------| -|IND|JK|20|800| -|IND|MH|25|1000| -|IND|WB|10|900| -|USA|CA|5|500| -|USA|WA|10|900| +For the following table named, Info: + +|Country/Region|State|Count|Total| +|-----------|---------|---------|---------| +|IND|JK|20|800| +|IND|MH|25|1000| +|IND|WB|10|900| +|USA|CA|5|500| +|USA|WA|10|900| The following expression: @@ -65,13 +58,13 @@ FILTER ( Returns: -|Country|State|Count|Total| -|-----------|---------|---------|---------| -|IND|MH|25|1000| -|IND|WB|10|900| -|USA|CA|5|500| -|USA|WA|10|900| +|Country/Region|State|Count|Total| +|-----------|---------|---------|---------| +|IND|MH|25|1000| +|IND|WB|10|900| +|USA|CA|5|500| +|USA|WA|10|900| -## See also +## Related content [ISAFTER](isafter-function-dax.md) \ No newline at end of file diff --git a/query-languages/dax/ispmt-function-dax.md b/query-languages/dax/ispmt-function-dax.md index e0170b57c..a89e1bece 100644 --- a/query-languages/dax/ispmt-function-dax.md +++ b/query-languages/dax/ispmt-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: ISPMT" -title: "ISPMT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "ISPMT function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # ISPMT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Calculates the interest paid (or received) for the specified period of a loan (or investment) with even principal payments. ## Syntax @@ -24,12 +18,12 @@ ISPMT(, , , ) ### Parameters -|Term|Definition| -|--------|--------------| -|rate|The interest rate for the investment.| -|per|The period for which you want to find the interest. Must be between 0 and nper-1 (inclusive).| -|nper|The total number of payment periods for the investment.| -|pv|The present value of the investment. For a loan, pv is the loan amount.| +|Term|Definition| +|--------|--------------| +|`rate`|The interest rate for the investment.| +|`per`|The period for which you want to find the interest. Must be between 0 and nper-1 (inclusive).| +|`nper`|The total number of payment periods for the investment.| +|`pv`|The present value of the investment. For a loan, pv is the loan amount.| ## Return Value diff --git a/query-languages/dax/isselectedmeasure-function-dax.md b/query-languages/dax/isselectedmeasure-function-dax.md index 0c2af739c..bddccbdef 100644 --- a/query-languages/dax/isselectedmeasure-function-dax.md +++ b/query-languages/dax/isselectedmeasure-function-dax.md @@ -1,33 +1,26 @@ --- description: "Learn more about: ISSELECTEDMEASURE" -title: "ISSELECTEDMEASURE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISSELECTEDMEASURE function (DAX)" --- # ISSELECTEDMEASURE +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Used by expressions for calculation items to determine the measure that is in context is one of those specified in a list of measures. -## Syntax - +## Syntax + ```dax -ISSELECTEDMEASURE( M1, M2, ... ) +ISSELECTEDMEASURE( M1, M2, ... ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|M1, M2, ...|A list of measures.| - -## Return value + +### Parameters + +|Term|Definition| +|--------|--------------| +|`M1, M2, ...`|A list of measures.| + +## Return value A Boolean indicating whether the measure that is currently in context is one of those specified in the list of parameters. @@ -37,10 +30,10 @@ A Boolean indicating whether the measure that is currently in context is one of - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example The following calculation item expression checks if the current measure is one of those specified in the list of parameters. If the measures are renamed, formula fixup will reflect the name changes in the expression. - + ```dax IF ( ISSELECTEDMEASURE ( [Expense Ratio 1], [Expense Ratio 2] ), @@ -49,8 +42,8 @@ IF ( ) ``` - -## See also -[SELECTEDMEASURE](selectedmeasure-function-dax.md) -[SELECTEDMEASURENAME](selectedmeasurename-function-dax.md) +## Related content + +[SELECTEDMEASURE](selectedmeasure-function-dax.md) +[SELECTEDMEASURENAME](selectedmeasurename-function-dax.md) diff --git a/query-languages/dax/issubtotal-function-dax.md b/query-languages/dax/issubtotal-function-dax.md index f4eb4ea6e..eabc4225e 100644 --- a/query-languages/dax/issubtotal-function-dax.md +++ b/query-languages/dax/issubtotal-function-dax.md @@ -1,22 +1,15 @@ --- description: "Learn more about: ISSUBTOTAL" -title: "ISSUBTOTAL function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/09/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISSUBTOTAL function (DAX)" --- # ISSUBTOTAL +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Creates another column in a [SUMMARIZE](summarize-function-dax.md) expression that returns True if the row contains subtotal values for the column given as argument, otherwise returns False. -## Syntax - +## Syntax + ```dax ISSUBTOTAL() ``` @@ -24,20 +17,20 @@ ISSUBTOTAL() With [SUMMARIZE](summarize-function-dax.md), ```dax -SUMMARIZE(
, [, ]…[, ROLLUP([,< groupBy_columnName>…])][, , {|ISSUBTOTAL()}]…) +SUMMARIZE(
, [, ]…[, ROLLUP([,< groupBy_columnName>…])][, , {|ISSUBTOTAL()}]…) ``` - -### Parameters -|Term|Definition| +### Parameters + +|Term|Definition| |--------|--------------| -|columnName |The name of any column in table of the SUMMARIZE function or any column in a related table to table. | +|`columnName` |The name of any column in table of the SUMMARIZE function or any column in a related table to table. | ## Return value A True value if the row contains a subtotal value for the column given as argument, otherwise returns False. - -## Remarks + +## Remarks - This function can only be used in the expression of a [SUMMARIZE](summarize-function-dax.md) function. diff --git a/query-languages/dax/istext-function-dax.md b/query-languages/dax/istext-function-dax.md index 02c23faa1..f0314a6f4 100644 --- a/query-languages/dax/istext-function-dax.md +++ b/query-languages/dax/istext-function-dax.md @@ -1,58 +1,51 @@ --- description: "Learn more about: ISTEXT" -title: "ISTEXT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ISTEXT function (DAX)" --- # ISTEXT -Checks if a value is text, and returns TRUE or FALSE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks if a value is text, and returns `TRUE` or `FALSE`. + +## Syntax + ```dax -ISTEXT() +ISTEXT() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|value|The value you want to check.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`value`|The value you want to check.| + ## Return value -TRUE if the value is text; otherwise FALSE. +`TRUE` if the value is text; otherwise `FALSE`. ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following examples show the behavior of the ISTEXT function. - +The following examples show the behavior of the ISTEXT function. + ```dax -//RETURNS: Is Text -= IF(ISTEXT("text"), "Is Text", "Is Non-Text") - -//RETURNS: Is Text -= IF(ISTEXT(""), "Is Text", "Is Non-Text") - -//RETURNS: Is Non-Text -= IF(ISTEXT(1), "Is Text", "Is Non-Text") - -//RETURNS: Is Non-Text -= IF(ISTEXT(BLANK()), "Is Text", "Is Non-Text") +//RETURNS: Is Text += IF(ISTEXT("text"), "Is Text", "Is Non-Text") + +//RETURNS: Is Text += IF(ISTEXT(""), "Is Text", "Is Non-Text") + +//RETURNS: Is Non-Text += IF(ISTEXT(1), "Is Text", "Is Non-Text") + +//RETURNS: Is Non-Text += IF(ISTEXT(BLANK()), "Is Text", "Is Non-Text") ``` - -## See also -[Information functions](information-functions-dax.md) +## Related content + +[Information functions](information-functions-dax.md) diff --git a/query-languages/dax/keepfilters-function-dax.md b/query-languages/dax/keepfilters-function-dax.md index 5960989a4..630a589d3 100644 --- a/query-languages/dax/keepfilters-function-dax.md +++ b/query-languages/dax/keepfilters-function-dax.md @@ -1,119 +1,112 @@ --- description: "Learn more about: KEEPFILTERS" -title: "KEEPFILTERS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "KEEPFILTERS function (DAX)" --- # KEEPFILTERS -Modifies how filters are applied while evaluating a CALCULATE or CALCULATETABLE function. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Modifies how filters are applied while evaluating a CALCULATE or CALCULATETABLE function. + +## Syntax + ```dax -KEEPFILTERS() +KEEPFILTERS() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|expression|Any expression.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression`|Any expression.| + ## Return value -A table of values. - +A table of values. + ## Remarks -- You use KEEPFILTERS within the context CALCULATE and CALCULATETABLE functions, to override the standard behavior of those functions. - -- By default, filter arguments s in functions such as CALCULATE are used as the context for evaluating the expression, and as such filter arguments for CALCULATE replace all existing filters over the same columns. The new context effected by the filter argument for CALCULATE affects only existing filters on columns mentioned as part of the filter argument. Filters on columns other than those mentioned in the arguments of CALCULATE or other related functions remain in effect and unaltered. - -- The KEEPFILTERS function allows you to modify this behavior. When you use KEEPFILTERS, any existing filters in the current context are compared with the columns in the filter arguments, and the intersection of those arguments is used as the context for evaluating the expression. The net effect over any one column is that both sets of arguments apply: both the filter arguments used in CALCULATE and the filters in the arguments of the KEEPFILTER function. In other words, whereas CALCULATE filters replace the current context, KEEPFILTERS adds filters to the current context. +- You use KEEPFILTERS within the context CALCULATE and CALCULATETABLE functions, to override the standard behavior of those functions. + +- By default, filter arguments in functions such as CALCULATE are used as the context for evaluating the expression, and as such filter arguments for CALCULATE replace all existing filters over the same columns. The new context effected by the filter argument for CALCULATE affects only existing filters on columns mentioned as part of the filter argument. Filters on columns other than those mentioned in the arguments of CALCULATE or other related functions remain in effect and unaltered. + +- The KEEPFILTERS function allows you to modify this behavior. When you use KEEPFILTERS, any existing filters in the current context are compared with the columns in the filter arguments, and the intersection of those arguments is used as the context for evaluating the expression. The net effect over any one column is that both sets of arguments apply: both the filter arguments used in CALCULATE and the filters in the arguments of the KEEPFILTER function. In other words, whereas CALCULATE filters replace the current context, KEEPFILTERS adds filters to the current context. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example takes you through some common scenarios that demonstrate use of the KEEPFILTERS function as part of a CALCULATE or CALCULATETABLE formula. - -The first three expressions obtain simple data to be used for comparisons: - -- Internet Sales for the state of Washington. - -- Internet Sales for the states of Washington and Oregon (both states combined). - -- Internet Sales for the state of Washington and the province of British Columbia (both regions combined). - -The fourth expression calculates Internet Sales for Washington and Oregon, while the filter for Washington and British Columbia is applied. - -The next expression calculates Internet Sales for Washington and Oregon but uses KEEPFILTERS; the filter for Washington and British Columbia is part of the prior context. - +The following example takes you through some common scenarios that demonstrate use of the KEEPFILTERS function as part of a CALCULATE or CALCULATETABLE formula. + +The first three expressions obtain simple data to be used for comparisons: + +- Internet Sales for the state of Washington. + +- Internet Sales for the states of Washington and Oregon (both states combined). + +- Internet Sales for the state of Washington and the province of British Columbia (both regions combined). + +The fourth expression calculates Internet Sales for Washington and Oregon, while the filter for Washington and British Columbia is applied. + +The next expression calculates Internet Sales for Washington and Oregon but uses KEEPFILTERS; the filter for Washington and British Columbia is part of the prior context. + ```dax -EVALUATE ROW( - "$$ in WA" - , CALCULATE('Internet Sales'[Internet Total Sales] - , 'Geography'[State Province Code]="WA" - ) -, "$$ in WA and OR" - , CALCULATE('Internet Sales'[Internet Total Sales] - , 'Geography'[State Province Code]="WA" - || 'Geography'[State Province Code]="OR" - ) -, "$$ in WA and BC" - , CALCULATE('Internet Sales'[Internet Total Sales] - , 'Geography'[State Province Code]="WA" - || 'Geography'[State Province Code]="BC" - ) -, "$$ in WA and OR ??" - , CALCULATE( - CALCULATE('Internet Sales'[Internet Total Sales] - ,'Geography'[State Province Code]="WA" - || 'Geography'[State Province Code]="OR" - ) - , 'Geography'[State Province Code]="WA" - || 'Geography'[State Province Code]="BC" - ) -, "$$ in WA !!" - , CALCULATE( - CALCULATE('Internet Sales'[Internet Total Sales] - , KEEPFILTERS('Geography'[State Province Code]="WA" - || 'Geography'[State Province Code]="OR" - ) - ) - , 'Geography'[State Province Code]="WA" - || 'Geography'[State Province Code]="BC" - ) -) +EVALUATE ROW( + "$$ in WA" + , CALCULATE('Internet Sales'[Internet Total Sales] + , 'Geography'[State Province Code]="WA" + ) +, "$$ in WA and OR" + , CALCULATE('Internet Sales'[Internet Total Sales] + , 'Geography'[State Province Code]="WA" + || 'Geography'[State Province Code]="OR" + ) +, "$$ in WA and BC" + , CALCULATE('Internet Sales'[Internet Total Sales] + , 'Geography'[State Province Code]="WA" + || 'Geography'[State Province Code]="BC" + ) +, "$$ in WA and OR ??" + , CALCULATE( + CALCULATE('Internet Sales'[Internet Total Sales] + ,'Geography'[State Province Code]="WA" + || 'Geography'[State Province Code]="OR" + ) + , 'Geography'[State Province Code]="WA" + || 'Geography'[State Province Code]="BC" + ) +, "$$ in WA !!" + , CALCULATE( + CALCULATE('Internet Sales'[Internet Total Sales] + , KEEPFILTERS('Geography'[State Province Code]="WA" + || 'Geography'[State Province Code]="OR" + ) + ) + , 'Geography'[State Province Code]="WA" + || 'Geography'[State Province Code]="BC" + ) +) ``` -When this expression is evaluated against the sample database AdventureWorks DW, the following results are obtained. - -|Column|Value| -|----------|---------| -|[$$ in WA]|$ 2,467,248.34| -|[$$ in WA and OR]|$ 3,638,239.88| -|[$$ in WA and BC]|$ 4,422,588.44| -|[$$ in WA and OR ??]|$ 3,638,239.88| -|[$$ in WA !!]|$ 2,467,248.34| - -> [!NOTE] -> The above results were formatted to a table, instead of a single row, for educational purposes. - -First, examine the expression, **[$$ in WA and OR ??]**. You might wonder how this formula could return the value for sales in Washington and Oregon, since the outer CALCULATE expression includes a filter for Washington and British Columbia. The answer is that the default behavior of CALCULATE overrides the outer filters in 'Geography'[State Province Code] and substitutes its own filter arguments, because the filters apply to the same column. - -Next, examine the expression, **[$$ in WA !!]**. You might wonder how this formula could return the value for sales in Washington and nothing else, since the argument filter includes Oregon and the outer CALCULATE expression includes a filter in Washington and British Columbia. The answer is that KEEPFILTERS modifies the default behavior of CALCULATE and adds an additional filter. Because the intersection of filters is used, now the outer filter **'Geography'[State Province Code]="WA" || 'Geography'[State Province Code]="BC")** is added to the filter argument **'Geography'[State Province Code]="WA" || 'Geography'[State Province Code]="OR"**,. Because both filters apply to the same column, the resulting filter **'Geography'[State Province Code]="WA"** is the filter that is applied when evaluating the expression. - -## See also - -[Filter functions](filter-functions-dax.md) -[CALCULATE function](calculate-function-dax.md) -[CALCULATETABLE function](calculatetable-function-dax.md) +When this expression is evaluated against the sample database AdventureWorks DW, the following results are obtained. + +|Column|Value| +|----------|---------| +|`[$$ in WA]`|$ 2,467,248.34| +|`[$$ in WA and OR]`|$ 3,638,239.88| +|`[$$ in WA and BC]`|$ 4,422,588.44| +|`[$$ in WA and OR ??]`|$ 3,638,239.88| +|`[$$ in WA !!]`|$ 2,467,248.34| + +> [!NOTE] +> The above results were formatted to a table, instead of a single row, for educational purposes. + +First, examine the expression, `[$$ in WA and OR ??]`. You might wonder how this formula could return the value for sales in Washington and Oregon, since the outer CALCULATE expression includes a filter for Washington and British Columbia. The answer is that the default behavior of CALCULATE overrides the outer filters in 'Geography'[State Province Code] and substitutes its own filter arguments, because the filters apply to the same column. + +Next, examine the expression, `[$$ in WA !!]`. You might wonder how this formula could return the value for sales in Washington and nothing else, since the argument filter includes Oregon and the outer CALCULATE expression includes a filter in Washington and British Columbia. The answer is that KEEPFILTERS modifies the default behavior of CALCULATE and adds an additional filter. Because the intersection of filters is used, now the outer filter `'Geography'[State Province Code]="WA" || 'Geography'[State Province Code]="BC")` is added to the filter argument `'Geography'[State Province Code]="WA" || 'Geography'[State Province Code]="OR"`,. Because both filters apply to the same column, the resulting filter `'Geography'[State Province Code]="WA"` is the filter that is applied when evaluating the expression. + +## Related content + +[Filter functions](filter-functions-dax.md) +[CALCULATE function](calculate-function-dax.md) +[CALCULATETABLE function](calculatetable-function-dax.md) diff --git a/query-languages/dax/last-function-dax.md b/query-languages/dax/last-function-dax.md new file mode 100644 index 000000000..6778f8068 --- /dev/null +++ b/query-languages/dax/last-function-dax.md @@ -0,0 +1,54 @@ +--- +description: "Learn more about: LAST" +title: "LAST function (DAX)" +--- + +# LAST + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Used in visual calculations only. Retrieves a value in the visual matrix from the last element of an axis. + +## Syntax + +```dax +LAST ( [, ][, ][, ][, reset] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column to be retrieved.| +|`axis`|(Optional) An axis reference. If omitted, the first axis of the Visual Shape definition is used.| +|`orderBy`|(Optional) An ORDERBY() clause with expressions that determine how to sort each partition along the `axis`. If `orderBy` is not provided, the data is sorted by the grouping columns on the default `axis` in ascending order by default.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.
| +|`reset`|(Optional) Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +The value of `column` from the last element of the axis. + +## Remarks + +This function can only be used in a visual calculation. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example + +The following visual calculation returns the sales amount of the last row on ROWS axis, that resets on the lowest parent. + +```dax +LastInternetSalesAmount = LAST ( [Sum of SalesAmount], ROWS, LowestParent ) +``` + +The screenshot below shows the visual matrix and the visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-last.png) + +## Related content + +[FIRST](first-function-dax.md) +[PREVIOUS](previous-function-dax.md) +[NEXT](next-function-dax.md) diff --git a/query-languages/dax/lastdate-function-dax.md b/query-languages/dax/lastdate-function-dax.md index 65d2d5e16..e8ff54d62 100644 --- a/query-languages/dax/lastdate-function-dax.md +++ b/query-languages/dax/lastdate-function-dax.md @@ -1,62 +1,55 @@ --- description: "Learn more about: LASTDATE" -title: "LASTDATE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LASTDATE function (DAX)" --- # LASTDATE -Returns the last date in the current context for the specified column of dates. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns the last date in the current context for the specified column of dates. + +## Syntax + ```dax -LASTDATE() +LASTDATE() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| + ## Return value -A table containing a single column and single row with a date value. - +A table containing a single column and single row with a date value. + ## 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](calculate-function-dax.md). - -- When the current context is a single date, the date returned by the FIRSTDATE and LASTDATE functions will be equal. - -- Technically, the Return value is a table that contains a single column and single value. Therefore, this function can be used as an argument to any function that requires a table in its arguments. Also, the returned value can be used whenever a date value is required. - +- 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](calculate-function-dax.md). + +- When the current context is a single date, the date returned by the FIRSTDATE and LASTDATE functions will be equal. + +- Technically, the Return value is a table that contains a single column and single value. Therefore, this function can be used as an argument to any function that requires a table in its arguments. Also, the returned value can be used whenever a date value is required. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that obtains the last date, for the current context, when a sale was made in the Internet sales channel. - +The following sample formula creates a measure that obtains the last date, for the current context, when a sale was made in the Internet sales channel. + ```dax -= LASTDATE('InternetSales_USD'[SaleDateKey]) += LASTDATE('InternetSales_USD'[SaleDateKey]) ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[FIRSTDATE function](firstdate-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[FIRSTDATE function](firstdate-function-dax.md) [LASTNONBLANK function](lastnonblank-function-dax.md) diff --git a/query-languages/dax/lastnonblank-function-dax.md b/query-languages/dax/lastnonblank-function-dax.md index 11512e17e..f6c256d01 100644 --- a/query-languages/dax/lastnonblank-function-dax.md +++ b/query-languages/dax/lastnonblank-function-dax.md @@ -1,51 +1,44 @@ --- description: "Learn more about: LASTNONBLANK" -title: "LASTNONBLANK function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LASTNONBLANK function (DAX)" --- # LASTNONBLANK -Returns the last value in the column, **column**, filtered by the current context, where the expression is not blank. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns the last value in the column, `column`, filtered by the current context, where the expression is not blank. + +## Syntax + ```dax -LASTNONBLANK(,) +LASTNONBLANK(,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|A column expression.| -|expression|An expression evaluated for blanks for each value of **column**.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A column expression.| +|`expression`|An expression evaluated for blanks for each value of `column`.| + ## Return value -A table containing a single column and single row with the computed last value. - +A table containing a single column and single row with the computed last value. + ## Remarks -- The **column** argument can be any of the following: - - A reference to any column. - - A table with a single column. - - A Boolean expression that defines a single-column table - -- Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). - -- This function is typically used to return the last value of a column for which the expression is not blank. For example, you could get the last value for which there were sales of a product. - +- The `column` argument can be any of the following: + - A reference to any column. + - A table with a single column. + - A Boolean expression that defines a single-column table + +- Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). + +- This function is typically used to return the last value of a column for which the expression is not blank. For example, you could get the last value for which there were sales of a product. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## See also -[FIRSTNONBLANK function](firstnonblank-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[FIRSTNONBLANK function](firstnonblank-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/lastnonblankvalue-function-dax.md b/query-languages/dax/lastnonblankvalue-function-dax.md index 51fd588bf..58a041811 100644 --- a/query-languages/dax/lastnonblankvalue-function-dax.md +++ b/query-languages/dax/lastnonblankvalue-function-dax.md @@ -1,47 +1,41 @@ --- description: "Learn more about: LASTNONBLANKVALUE" -title: "LASTNONBLANKVALUE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "LASTNONBLANKVALUE function (DAX)" --- # LASTNONBLANKVALUE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + Evaluates an expression filtered by the sorted values of a column and returns the last value of the expression that is not blank. - -## Syntax - + +## Syntax + ```dax LASTNONBLANKVALUE(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|A column or an expression that returns a single-column table.| -|expression|An expression evaluated for each value of \.| - -## Return value - -The last non-blank value of \ corresponding to the sorted values of \. - -## Remarks + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A column or an expression that returns a single-column table.| +|`expression`|An expression evaluated for each value of `column`.| + +## Return value + +The last non-blank value of `expression` corresponding to the sorted values of `column`. + +## Remarks - The column argument can be any of the following: - A reference to any column. - A table with a single column. -- This function is different from LASTNONBLANK in that the \ is added to the filter context for the evaluation of \. +- This function is different from LASTNONBLANK in that the `column` is added to the filter context for the evaluation of `expression`. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example The following DAX query, @@ -60,7 +54,7 @@ SUMMARIZECOLUMNS( Returns, |DimProduct[Class]|[LNBV]| -|-----------|---------------|----------| +|-----------|---------------|----------| |L|132.44| |H|137.6| |M|84.97| diff --git a/query-languages/dax/lcm-function-dax.md b/query-languages/dax/lcm-function-dax.md index 8def6f461..246b29187 100644 --- a/query-languages/dax/lcm-function-dax.md +++ b/query-languages/dax/lcm-function-dax.md @@ -1,49 +1,42 @@ --- description: "Learn more about: LCM" -title: "LCM function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LCM function (DAX)" --- # LCM -Returns the least common multiple of integers. The least common multiple is the smallest positive integer that is a multiple of all integer arguments number1, number2, and so on. Use LCM to add fractions with different denominators. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the least common multiple of integers. The least common multiple is the smallest positive integer that is a multiple of all integer arguments number1, number2, and so on. Use LCM to add fractions with different denominators. + +## Syntax + ```dax -LCM(number1, [number2], ...) +LCM(number1, [number2], ...) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number1, number2,...|Number1 is required, subsequent numbers are optional. 1 to 255 values for which you want the least common multiple. If value is not an integer, it is truncated.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number1, number2,...`|Number1 is required, subsequent numbers are optional. 1 to 255 values for which you want the least common multiple. If value is not an integer, it is truncated.| + ## Return value -Returns the least common multiple of integers. - +Returns the least common multiple of integers. + ## Remarks -- If any argument is nonnumeric, LCM returns the #VALUE! error value. - -- If any argument is less than zero, LCM returns the #NUM! error value. - -- If LCM(a,b) >=2^53, LCM returns the #NUM! error value. +- If any argument is nonnumeric, LCM returns the `#VALUE!` error value. + +- If any argument is less than zero, LCM returns the `#NUM!` error value. + +- If LCM(a,b) >=2^53, LCM returns the `#NUM!` error value. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= LCM(5, 2)|Least common multiple of 5 and 2.|10| -|= LCM(24, 36)|Least common multiple of 24 and 36.|72| +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= LCM(5, 2)`|Least common multiple of 5 and 2.|10| +|`= LCM(24, 36)`|Least common multiple of 24 and 36.|72| diff --git a/query-languages/dax/left-function-dax.md b/query-languages/dax/left-function-dax.md index 665b63ad3..3ff13ecd6 100644 --- a/query-languages/dax/left-function-dax.md +++ b/query-languages/dax/left-function-dax.md @@ -1,53 +1,46 @@ --- description: "Learn more about: LEFT" -title: "LEFT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LEFT function (DAX)" --- # LEFT -Returns the specified number of characters from the start of a text string. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the specified number of characters from the start of a text string. + +## Syntax + ```dax -LEFT(, ) +LEFT(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|The text string containing the characters you want to extract, or a reference to a column that contains text.| -|num_chars|(optional) The number of characters you want LEFT to extract; if omitted, 1.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text string containing the characters you want to extract, or a reference to a column that contains text.| +|`num_chars`|(optional) The number of characters you want LEFT to extract; if omitted, 1.| + ## Return value -A text string. - +A text string. + ## Remarks -- Whereas Microsoft Excel contains different functions for working with text in single-byte and double-byte character languages, DAX works with Unicode and stores all characters as the same length; therefore, a single function is enough. - +- Whereas Microsoft Excel contains different functions for working with text in single-byte and double-byte character languages, DAX works with Unicode and stores all characters as the same length; therefore, a single function is enough. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example returns the first five characters of the company name in the column [ResellerName] and the first five letters of the geographical code in the column [GeographyKey] and concatenates them, to create an identifier. - +The following example returns the first five characters of the company city in the column [City] and the first five letters of the reseller key in the column [ResellerKey] and concatenates them, to create an identifier. + ```dax -= CONCATENATE(LEFT('Reseller'[ResellerName],LEFT(GeographyKey,3)) += CONCATENATE ( LEFT ( 'Reseller'[City], 5 ), LEFT ( 'Reseller'[ResellerKey], 5 ) ) ``` -If the **num_chars** argument is a number that is larger than the number of characters available, the function returns the maximum characters available and does not raise an error. For example, the column [GeographyKey] contains numbers such as 1, 12 and 311; therefore the result also has variable length. - -## See also +If the `num_chars` argument is a number that is larger than the number of characters available, the function returns the maximum characters available and does not raise an error. For example, the column [ResellerKey] contains numbers such as 5, 24 and 312; therefore the result also has variable length. + +## Related content [Text functions](text-functions-dax.md) diff --git a/query-languages/dax/len-function-dax.md b/query-languages/dax/len-function-dax.md index 9826042ff..f1262297c 100644 --- a/query-languages/dax/len-function-dax.md +++ b/query-languages/dax/len-function-dax.md @@ -1,48 +1,41 @@ --- description: "Learn more about: LEN" -title: "LEN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/05/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LEN function (DAX)" --- # LEN -Returns the number of characters in a text string. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the number of characters in a text string. + +## Syntax + ```dax -LEN() +LEN() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|The text whose length you want to find, or a column that contains text. Spaces count as characters.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text whose length you want to find, or a column that contains text. Spaces count as characters.| + ## Return value -A whole number indicating the number of characters in the text string. - +A whole number indicating the number of characters in the text string. + ## Remarks -- Whereas Microsoft Excel has different functions for working with single-byte and double-byte character languages, DAX uses Unicode and stores all characters with the same length. - -- LEN always counts each character as 1, no matter what the default language setting is. - -- If you use LEN with a column that contains non-text values, such as dates or Booleans, the function implicitly casts the value to text, using the current column format. - +- Whereas Microsoft Excel has different functions for working with single-byte and double-byte character languages, DAX uses Unicode and stores all characters with the same length. + +- LEN always counts each character as 1, no matter what the default language setting is. + +- If you use LEN with a column that contains non-text values, such as dates or Booleans, the function implicitly casts the value to text, using the current column format. + ## Example -The following formula sums the lengths of addresses in the columns, [AddressLine1] and [AddressLine2]. - +The following formula sums the lengths of addresses in the columns, [AddressLine1] and [AddressLine2]. + ```dax -= LEN([AddressLine1])+LEN([AddressLin2]) += LEN([AddressLine1])+LEN([AddressLin2]) ``` diff --git a/query-languages/dax/linest-function-dax.md b/query-languages/dax/linest-function-dax.md new file mode 100644 index 000000000..e96c5de01 --- /dev/null +++ b/query-languages/dax/linest-function-dax.md @@ -0,0 +1,117 @@ +--- +description: "Learn more about: LINEST" +title: "LINEST function (DAX)" +author: masanto-msft +ms.author: masanto +--- + +# LINEST + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Uses the Least Squares method to calculate a straight line that best fits the given data, then returns a table describing the line. The equation for the line is of the form: y = **Slope1**\*x1 + **Slope2**\*x2 + ... + **Intercept**. + +## Syntax + +```dax +LINEST ( , [, …][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`columnY`|The column of known y-values. Must have scalar type.| +|`columnX`|The columns of known x-values. Must have scalar type. At least one must be provided.| +|`const`|(Optional) A constant `TRUE`/`FALSE` value specifying whether to force the constant **Intercept** to equal 0.
If `TRUE` or omitted, the **Intercept** value is calculated normally; If `FALSE`, the **Intercept** value is set to zero.| + +## Return value + +A single-row table describing the line, plus additional statistics. These are the available columns: + +- **Slope1**, **Slope2**, ..., **SlopeN**: the coefficients corresponding to each x-value; +- **Intercept**: intercept value; +- **StandardErrorSlope1**, **StandardErrorSlope2**, ..., **StandardErrorSlopeN**: the standard error values for the coefficients **Slope1**, **Slope2**, ..., **SlopeN**; +- **StandardErrorIntercept**: the standard error value for the constant **Intercept**; +- **CoefficientOfDetermination**: the coefficient of determination (r²). Compares estimated and actual y-values, and ranges in value from 0 to 1: the higher the value, the higher the correlation in the sample; +- **StandardError**: the standard error for the y estimate; +- **FStatistic**: the F statistic, or the F-observed value. Use the F statistic to determine whether the observed relationship between the dependent and independent variables occurs by chance; +- **DegreesOfFreedom**: the degrees of freedom. Use this value to help you find F-critical values in a statistical table, and determine a confidence level for the model; +- **RegressionSumOfSquares**: the regression sum of squares; +- **ResidualSumOfSquares**: the residual sum of squares. + +## Remarks + +`columnY` and the `columnX`’s must all belong to the same table. + +## Example 1 + +The following DAX query: + +```dax +EVALUATE LINEST( + 'FactInternetSales'[SalesAmount], + 'FactInternetSales'[TotalProductCost] +) +``` + +Returns a single-row table with ten columns: + +|Slope1|Intercept|StandardErrorSlope1|StandardErrorIntercept|CoefficientOfDetermination| +|-----|-----|-----|-----|-----| +|1.67703250456677|6.34550460373026|0.000448675725548806|0.279131821917317|0.995695557281456| + +|StandardError|FStatistic|DegreesOfFreedom|RegressionSumOfSquares|ResidualSumOfSquares| +|-----|-----|-----|-----|-----| +|60.9171030357485|13970688.6139993|60396|51843736761.658|224123120.339218| + +- **Slope1** and **Intercept**: the coefficients of the calculated linear model; +- **StandardErrorSlope1** and **StandardErrorIntercept**: the standard error values for the coefficients above; +- **CoefficientOfDetermination**, **StandardError**, **FStatistic**, **DegreesOfFreedom**, **RegressionSumOfSquares** and **ResidualSumOfSquares**: regression statistics about the model. + +For a given internet sale, this model predicts the sale amount by the following formula: + +``` +SalesAmount = Slope1 * TotalProductCost + Intercept +``` + +## Example 2 + +The following DAX query: + +```dax +EVALUATE LINEST( + 'DimCustomer'[TotalSalesAmount], + 'DimCustomer'[YearlyIncome], + 'DimCustomer'[TotalChildren], + 'DimCustomer'[BirthDate] +) +``` + +Returns a single-row table with fourteen columns: + +- Slope1 +- Slope2 +- Slope3 +- Intercept +- StandardErrorSlope1 +- StandardErrorSlope2 +- StandardErrorSlope3 +- StandardErrorIntercept +- CoefficientOfDetermination +- StandardError +- FStatistic +- DegreesOfFreedom +- RegressionSumOfSquares +- ResidualSumOfSquares + +For a given customer, this model predicts total sales by the following formula (the birth date is automatically converted to a number): + +``` +TotalSalesAmount = Slope1 * YearlyIncome + Slope2 * TotalChildren + Slope3 * BirthDate + Intercept +``` + +## Related content + +[LINESTX](linestx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/linestx-function-dax.md b/query-languages/dax/linestx-function-dax.md new file mode 100644 index 000000000..ad59b7a89 --- /dev/null +++ b/query-languages/dax/linestx-function-dax.md @@ -0,0 +1,123 @@ +--- +description: "Learn more about: LINESTX" +title: "LINESTX function (DAX)" +author: masanto-msft +ms.author: masanto +--- + +# LINESTX + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Uses the Least Squares method to calculate a straight line that best fits the given data, then returns a table describing the line. The data result from expressions evaluated for each row in a table. The equation for the line is of the form: y = **Slope1**\*x1 + **Slope2**\*x2 + ... + **Intercept**. + +## Syntax + +```dax +LINESTX (
, , [, …][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expressions will be evaluated.| +|`expressionY`|The expression to be evaluated for each row of the table, to obtain the known y-values. Must have scalar type. | +|`expressionX`|The expressions to be evaluated for each row of the table, to obtain the known x-values. Must have scalar type. At least one must be provided.| +|`const`|(Optional) A constant `TRUE`/`FALSE` value specifying whether to force the constant **Intercept** to equal 0.
If `TRUE` or omitted, the **Intercept** value is calculated normally; If `FALSE`, the **Intercept** value is set to zero.| + +## Return value + +A single-row table describing the line, plus additional statistics. These are the available columns: + +- **Slope1**, **Slope2**, ..., **SlopeN**: the coefficients corresponding to each x-value; +- **Intercept**: intercept value; +- **StandardErrorSlope1**, **StandardErrorSlope2**, ..., **StandardErrorSlopeN**: the standard error values for the coefficients **Slope1**, **Slope2**, ..., **SlopeN**; +- **StandardErrorIntercept**: the standard error value for the constant **Intercept**; +- **CoefficientOfDetermination**: the coefficient of determination (r²). Compares estimated and actual y-values, and ranges in value from 0 to 1: the higher the value, the higher the correlation in the sample; +- **StandardError**: the standard error for the y estimate; +- **FStatistic**: the F statistic, or the F-observed value. Use the F statistic to determine whether the observed relationship between the dependent and independent variables occurs by chance; +- **DegreesOfFreedom**: the degrees of freedom. Use this value to help you find F-critical values in a statistical table, and determine a confidence level for the model; +- **RegressionSumOfSquares**: the regression sum of squares; +- **ResidualSumOfSquares**: the residual sum of squares. + +## Example 1 + +The following DAX query: + +```dax +DEFINE VAR TotalSalesByRegion = SUMMARIZECOLUMNS( + 'Sales Territory'[Sales Territory Key], + 'Sales Territory'[Population], + "Total Sales", SUM(Sales[Sales Amount]) +) +EVALUATE LINESTX( + 'TotalSalesByRegion', + [Total Sales], + [Population] +) +``` + +Returns a single-row table with ten columns: + +|Slope1|Intercept|StandardErrorSlope1|StandardErrorIntercept|CoefficientOfDetermination| +|-----|-----|-----|-----|-----| +|6.42271517588|-410592.76216|0.24959467764561|307826.343996223|0.973535860750193| + +|StandardError|FStatistic|DegreesOfFreedom|RegressionSumOfSquares|ResidualSumOfSquares| +|-----|-----|-----|-----|-----| +|630758.1747292|662.165707642|18|263446517001130|7161405749781.07| + +- **Slope1** and **Intercept**: the coefficients of the calculated linear model; +- **StandardErrorSlope1** and **StandardErrorIntercept**: the standard error values for the coefficients above; +- **CoefficientOfDetermination**, **StandardError**, **FStatistic**, **DegreesOfFreedom**, **RegressionSumOfSquares** and **ResidualSumOfSquares**: regression statistics about the model. + +For a given sales territory, this model predicts total sales by the following formula: + +``` +Total Sales = Slope1 * Population + Intercept +``` + +## Example 2 + +The following DAX query: + +```dax +DEFINE VAR TotalSalesByCustomer = SUMMARIZECOLUMNS( + 'Customer'[Customer ID], + 'Customer'[Age], + 'Customer'[NumOfChildren], + "Total Sales", SUM(Sales[Sales Amount]) +) +EVALUATE LINESTX( + 'TotalSalesByCustomer', + [Total Sales], + [Age], + [NumOfChildren] +) +``` + +Returns a single-row table with twelve columns: + +|Slope1|Slope2|Intercept|StandardErrorSlope1| +|--|--|--|--| +|69.0435458093763|33.005949841721|-871.118539339539|0.872588875481658| + +|StandardErrorSlope2|StandardErrorIntercept|CoefficientOfDetermination|StandardError| +|--|--|--|--| +|6.21158863903435|26.726292527427|0.984892920482022|68.5715034014342| + +|FStatistic|DegreesOfFreedom|RegressionSumOfSquares|ResidualSumOfSquares| +|--|--|--|--| +|3161.91535144391|97|29734974.9782379|456098.954637092| + +For a given customer, this model predicts total sales by the following formula: + +``` +Total Sales = Slope1 * Age + Slope2 * NumOfChildren + Intercept +``` + +## Related content + +[LINEST](linest-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/ln-function-dax.md b/query-languages/dax/ln-function-dax.md index b5e62a327..f137416e6 100644 --- a/query-languages/dax/ln-function-dax.md +++ b/query-languages/dax/ln-function-dax.md @@ -1,49 +1,42 @@ --- description: "Learn more about: LN" -title: "LN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LN function (DAX)" --- # LN -Returns the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904). - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904). + +## Syntax + ```dax -LN() +LN() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The positive number for which you want the natural logarithm.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The positive number for which you want the natural logarithm.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -LN is the inverse of the EXP function. - +LN is the inverse of the EXP function. + ## Example -The following example returns the natural logarithm of the number in the column, `[Values]`. - +The following example returns the natural logarithm of the number in the column, `[Values]`. + ```dax -= LN([Values]) += LN([Values]) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) -[EXP function](exp-function-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[EXP function](exp-function-dax.md) diff --git a/query-languages/dax/log-function-dax.md b/query-languages/dax/log-function-dax.md index 359bb9207..2d3517545 100644 --- a/query-languages/dax/log-function-dax.md +++ b/query-languages/dax/log-function-dax.md @@ -1,56 +1,49 @@ --- description: "Learn more about: LOG" -title: "LOG function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LOG function (DAX)" --- # LOG -Returns the logarithm of a number to the base you specify. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the logarithm of a number to the base you specify. + +## Syntax + ```dax -LOG(,) +LOG(,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The positive number for which you want the logarithm.| -|base|The base of the logarithm. If omitted, the base is 10.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The positive number for which you want the logarithm.| +|`base`|The base of the logarithm. If omitted, the base is 10.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -You might receive an error if the value is too large to be displayed. - -The function LOG10 is similar, but always returns the common logarithm, meaning the logarithm for the base 10. - +You might receive an error if the value is too large to be displayed. + +The function LOG10 is similar, but always returns the common logarithm, meaning the logarithm for the base 10. + ## Example -The following formulas return the same result, 2. - +The following formulas return the same result, 2. + ```dax -= LOG(100,10) -= LOG(100) -= LOG10(100) += LOG(100,10) += LOG(100) += LOG10(100) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) -[EXP function](exp-function-dax.md) -[LOG function](log-function-dax.md) -[LOG function](log-function-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[EXP function](exp-function-dax.md) +[LOG function](log-function-dax.md) +[LOG function](log-function-dax.md) diff --git a/query-languages/dax/log10-function-dax.md b/query-languages/dax/log10-function-dax.md index e0b65a60f..a2b56a750 100644 --- a/query-languages/dax/log10-function-dax.md +++ b/query-languages/dax/log10-function-dax.md @@ -1,54 +1,47 @@ --- description: "Learn more about: LOG10" -title: "LOG10 function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LOG10 function (DAX)" --- # LOG10 -Returns the base-10 logarithm of a number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the base-10 logarithm of a number. + +## Syntax + ```dax -LOG10() +LOG10() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|A positive number for which you want the base-10 logarithm.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|A positive number for which you want the base-10 logarithm.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -The LOG function lets you change the base of the logarithm, instead of using the base 10. - +The LOG function lets you change the base of the logarithm, instead of using the base 10. + ## Example -The following formulas return the same result, 2: - +The following formulas return the same result, 2: + ```dax -= LOG(100,10) -= LOG(100) -= LOG10(100) += LOG(100,10) += LOG(100) += LOG10(100) ``` - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[EXP function](exp-function-dax.md) -[LOG function](log-function-dax.md) -[LOG function](log-function-dax.md) - + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[EXP function](exp-function-dax.md) +[LOG function](log-function-dax.md) +[LOG function](log-function-dax.md) + diff --git a/query-languages/dax/logical-functions-dax.md b/query-languages/dax/logical-functions-dax.md index ac398751a..88d235cb4 100644 --- a/query-languages/dax/logical-functions-dax.md +++ b/query-languages/dax/logical-functions-dax.md @@ -1,35 +1,27 @@ --- description: "Learn more about: Logical functions" -title: "Logical functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 10/05/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Logical functions (DAX)" --- # Logical functions -Logical functions act upon an expression to return information about the values or sets in the expression. For example, you can use the IF function to check the result of an expression and create conditional results. - +Logical functions act upon an expression to return information about the values or sets in the expression. For example, you can use the IF function to check the result of an expression and create conditional results. + ## In this category |Function |Description | |---------|---------| -|[AND](and-function-dax.md) | Checks whether both arguments are TRUE, and returns TRUE if both arguments are TRUE. | +|[AND](and-function-dax.md) | Checks whether both arguments are `TRUE`, and returns `TRUE` if both arguments are `TRUE`. | |[BITAND](bitand-function-dax.md) | Returns a bitwise 'AND' of two numbers. | |[BITLSHIFT](bitlshift-function-dax.md) | Returns a number shifted left by the specified number of bits. | |[BITOR](bitor-function-dax.md) | Returns a bitwise 'OR' of two numbers. | |[BITRSHIFT](bitrshift-function-dax.md) | Returns a number shifted right by the specified number of bits. | |[BITXOR](bitxor-function-dax.md) | Returns a bitwise 'XOR' of two numbers. | |[COALESCE](coalesce-function-dax.md)|Returns the first expression that does not evaluate to BLANK.| -|[FALSE](false-function-dax.md) | Returns the logical value FALSE. | -|[IF](if-function-dax.md) | Checks a condition, and returns one value when TRUE, otherwise it returns a second value. | -|[IF.EAGER](if-eager-function-dax.md) | Checks a condition, and returns one value when TRUE, otherwise it returns a second value. Uses an *eager* execution plan which always executes the branch expressions regardless of the condition expression. | +|[FALSE](false-function-dax.md) | Returns the logical value `FALSE`. | +|[IF](if-function-dax.md) | Checks a condition, and returns one value when `TRUE`, otherwise it returns a second value. | +|[IF.EAGER](if-eager-function-dax.md) | Checks a condition, and returns one value when `TRUE`, otherwise it returns a second value. Uses an *eager* execution plan which always executes the branch expressions regardless of the condition expression. | |[IFERROR](iferror-function-dax.md) | Evaluates an expression and returns a specified value if the expression returns an error | -|[NOT](not-function-dax.md) | Changes FALSE to TRUE, or TRUE to FALSE. | -|[OR](or-function-dax.md) | Checks whether one of the arguments is TRUE to return TRUE. | +|[NOT](not-function-dax.md) | Changes `FALSE` to `TRUE`, or `TRUE` to `FALSE`. | +|[OR](or-function-dax.md) | Checks whether one of the arguments is `TRUE` to return `TRUE`. | |[SWITCH](switch-function-dax.md) | Evaluates an expression against a list of values and returns one of multiple possible result expressions. | -|[TRUE](true-function-dax.md) | Returns the logical value TRUE. | +|[TRUE](true-function-dax.md) | Returns the logical value `TRUE`. | diff --git a/query-languages/dax/lookup-function-dax.md b/query-languages/dax/lookup-function-dax.md new file mode 100644 index 000000000..8b080599c --- /dev/null +++ b/query-languages/dax/lookup-function-dax.md @@ -0,0 +1,60 @@ +--- +description: "Learn more about: LOOKUP" +title: "LOOKUP function (DAX) | Microsoft Docs" +--- +# LOOKUP + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Returns the value or evaluates the expression from the visual matrix using absolute navigation. Filters can be provided for any axis on the visual matrix. Any omitted filters are inferred from the context. If no single value can be determined, an error is returned. + +## Syntax + +```dax +LOOKUP(, , [, , ]...) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|expression| The expression to evaluate. | +|colref|(Optional) The column to be filtered.| +|expression|(Optional) The value to filter.| + +## Return value + +The value of **expression** after filters are applied. + +If there isn't a match, an error is returned. + +If multiple rows match the filters, an error is returned. + +## Example 1 + +In this example, LOOKUP retrieves the sum of sales for Bikes Category. +The first argument could be a column or a scalar expression. + +```dax +Lookup Example 1 = LOOKUP(SUM([Sales Amount]), [Category], "Bikes") +Lookup Example 2 = LOOKUP([Sales Amount], [Category], "Bikes") +``` + +The screenshot below shows the matrix with two visual calculations. + +![lookup example 1](media/dax-queries/dax-visualcalc-lookup.png) + +## Example 2 +In this example, the **LookupExample2** visual calculation retrieves the sum of Sales for Fiscal Year **FY2018**. Notice that quarter filter from the row will be used since its not specified explicitly, resulting in no results being returned for **FY2019 Q1** to **FY2019 Q4** since the combination of **FY2018** and **FY2019 Q1** to **FY2019 Q4** does not exist. **LookupExample3** explicitly specifies the quarter so does not take into account the current quarter on the row. + +```dax +LookupExample2 = LOOKUP([Sales Amount], [Fiscal Year], "FY2018") +LookupExample3 = LOOKUP([Sales Amount], [Fiscal Year], "FY2018", [Fiscal Quarter], "FY2018 Q1") +``` + +![lookup example 2](media/dax-queries/dax-visualcalc-lookup-example2.png) + + +## Related content + +[LOOKUPWITHTOTALS](lookupwithtotals-function-dax.md) diff --git a/query-languages/dax/lookupvalue-function-dax.md b/query-languages/dax/lookupvalue-function-dax.md index 95b160bcd..43b5b51a5 100644 --- a/query-languages/dax/lookupvalue-function-dax.md +++ b/query-languages/dax/lookupvalue-function-dax.md @@ -1,24 +1,17 @@ --- description: "Learn more about: LOOKUPVALUE" -title: "LOOKUPVALUE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/02/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LOOKUPVALUE function (DAX)" --- # LOOKUPVALUE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the value for the row that meets all criteria specified by one or more search conditions. ## Syntax ```dax -LOOKUPVALUE( +LOOKUPVALUE ( , , @@ -31,37 +24,68 @@ LOOKUPVALUE( |Term|Definition| |--------|--------------| -| result_columnName | The name of an existing column that contains the value you want to return. It cannot be an expression. | -| search_columnName | The name of an existing column. It can be in the same table as result_columnName or in a related table. It cannot be an expression. | -| search_value | The value to search for in search_columnName. | -| alternateResult | (Optional) The value returned when the context for result_columnName has been filtered down to zero or more than one distinct value. When not provided, the function returns BLANK when result_columnName is filtered down to zero value or an error when more than one distinct value. | +| `result_columnName` | The name of an existing column that contains the value you want to return. It cannot be an expression. | +| `search_columnName` | The name of an existing column. It can be in the same table as result_columnName or in a related table. It cannot be an expression. Multiple pairs of search_columnName and search_value can be specified. | +| `search_value` | The value to search for in search_columnName. Multiple pairs of search_columnName and search_value can be specified. | +| `alternateResult` | (Optional) The value returned when the context for result_columnName has been filtered down to zero or more than one distinct value. If not specified, the function returns BLANK when result_columnName is filtered down to zero values or an error when there is more than one distinct value in the context for result_columnName. | ## Return value -The value of **result_column** at the row where all pairs of **search_column** and **search_value** have an exact match. +The value of `result_columnName` at the row where all pairs of `search_columnName` and `search_value` have an exact match. -If there's no match that satisfies all the search values, BLANK or **alternateResult** (if supplied) is returned. In other words, the function won't return a lookup value if only some of the criteria match. +If there isn't a match that satisfies all the search values, BLANK or `alternateResult` (if specified) is returned. In other words, the function doesn't return a lookup value if only some of the criteria match. -If multiple rows match the search values and in all cases **result_column** values are identical, then that value is returned. However, if **result_column** returns different values, an error or **alternateResult** (if supplied) is returned. +If multiple rows match the search values and the values in the `result_columnName` for these rows are identical, then that value is returned. However, if `result_columnName` returns different values, an error or `alternateResult` (if specified) is returned. ## Remarks -- If there is a relationship between the result and search tables, in most cases, using [RELATED](related-function-dax.md) function instead of LOOKUPVALUE is more efficient and provides better performance. +- If there is a relationship between the table that contains the result column and tables that contain the search columns, in most cases, using the [RELATED](related-function-dax.md) function instead of LOOKUPVALUE is more efficient and provides better performance. + +- Multiple pairs of `search_columnName` and `search_value` can be specified. -- The **search_value** and **alternateResult** parameters are evaluated before the function iterates through the rows of the search table. +- The `search_value` and `alternateResult` parameters are evaluated before the function iterates through the rows of the search table. -- Avoid using ISERROR or IFERROR functions to capture an error returned by LOOKUPVALUE. If some inputs to the function will result in an error when a single output value cannot be determined, providing an alternateResult parameter is the most reliable and highest performing way to handle the error. +- Avoid using ISERROR or IFERROR functions to capture an error returned by LOOKUPVALUE. If some inputs to the function result in an error when a single output value cannot be determined, providing an `alternateResult` parameter is the most reliable and highest performing way to handle the error. + +- The `alternateResult` parameter returns an error if specified in a Power Pivot calculated column. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example 1 + +In this example, LOOKUPVALUE is used to search Average Rate for the currency used to pay for the order on the day the order was placed: + +```dax +Exchange Rate = +LOOKUPVALUE ( + 'Currency Rate'[Average Rate], + 'Currency Rate'[CurrencyKey], [CurrencyKey], + 'Currency Rate'[DateKey], [OrderDateKey] +) + +``` -[!INCLUDE [power-bi-dax-sample-model](includes/power-bi-dax-sample-model.md)] +Both the Order Date and Currency are required to find the Average Rate for the correct date and currency. OrderDateKey and CurrencyKey are the keys used to look up the Average Rate in the Currency Rate table. -The following calculated column defined in the **Sales** table uses the LOOKUPVALUE function to return channel values from the **Sales Order** table. +You can use the Exchange Rate to calculate the Sales Amount in local currency with: ```dax -CHANNEL = LOOKUPVALUE('Sales Order'[Channel],'Sales Order'[SalesOrderLineKey],[SalesOrderLineKey]) +Sales Amount Local Currency = [Sales Amount] * [Exchange Rate] + +``` + +## Example 2 + +In this example, the following calculated column defined in the **Sales** table uses the LOOKUPVALUE function to return channel values from the **Sales Order** table. + +```dax +CHANNEL = +LOOKUPVALUE ( + 'Sales Order'[Channel], + 'Sales Order'[SalesOrderLineKey], + [SalesOrderLineKey] +) + ``` However, in this case, because there is a relationship between the **Sales Order** and **Sales** tables, it's more efficient to use the [RELATED](related-function-dax.md) function. @@ -70,7 +94,7 @@ However, in this case, because there is a relationship between the **Sales Order CHANNEL = RELATED('Sales Order'[Channel]) ``` -## See also +## Related content -[RELATED function (DAX)](related-function-dax.md) -[Information functions](information-functions-dax.md) +[RELATED function (DAX)](related-function-dax.md) +[Information functions](information-functions-dax.md) diff --git a/query-languages/dax/lookupwithtotals-function-dax.md b/query-languages/dax/lookupwithtotals-function-dax.md new file mode 100644 index 000000000..c6c26a3c4 --- /dev/null +++ b/query-languages/dax/lookupwithtotals-function-dax.md @@ -0,0 +1,59 @@ +--- +description: "Learn more about: LOOKUPWITHTOTALS" +title: "LOOKUPWITHTOTALS function (DAX) | Microsoft Docs" +--- +# LOOKUPWITHTOTALS + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Returns the value or evaluates the expression from the visual matrix using absolute navigation. Filters can be provided for any axis on the visual matrix. Any omitted filters are treated as referring to the total. If no single value can be determined, an error is returned. + +## Syntax + +```dax +LOOKUPWITHTOTALS(, , [, , ]...) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|expression| The expression to evaluate | +|colref|(Optional) The column to be filtered.| +|expression|(Optional) The value to filter.| + +## Return value + +The value of **expression** after filters are applied. + +If there isn't a match, an error is returned. + +If multiple rows match the filters, an error is returned. + +## Example 1 + +The **Lookupwithtotals** visual calculation retrieves values for **FY2018** and all quarters since no value for quarter was specified as an argument. On the other hand, the **Lookup** visual calculation takes into account the current context. Therefore, the results are different and the **Lookup** visual calculation returns the **Sales Amount** for **FY2018** for each quarter. This also explains why the results for the **Lookup** visual calculation are empty because there is no combination of **FY2019 Q1** to **FY2019 Q4** and **FY2018**. + + +```dax +LOOKUPWITHTOTALExample1 = LOOKUPWITHTOTALS([Sales Amount], [Fiscal Year], "FY2018") + +LookupExample1 = LOOKUP([Sales Amount], [Fiscal Year], "FY2018") +``` + +The screenshot below shows the matrix with two visual calculations. + +![lookupwithTotals example 1](media/dax-queries/dax-visualcalc-lookupwithtotals-example1.png) + +## Example 2 +In this example, **LookupWithTotalExample2** retrieves the sum of sales for Bikes Category. Notices that uses the total for other the dimensions since they were not specified. In other words, those dimensions are not filtered. It's useful when we want to do comparison since the result is locked to one value. + +```dax +LookupWithTotalExample2 = lookupWithTotals([Sales Amount], [Category], "Bikes") +``` + +![lookupwithTotals example 2](media/dax-queries/dax-visualcalc-lookupwithtotals-example2.png) + +## Related content + +[Lookup](lookup-function-dax.md) diff --git a/query-languages/dax/lower-function-dax.md b/query-languages/dax/lower-function-dax.md index f28051d93..2dbf08169 100644 --- a/query-languages/dax/lower-function-dax.md +++ b/query-languages/dax/lower-function-dax.md @@ -1,48 +1,41 @@ --- description: "Learn more about: LOWER" -title: "LOWER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "LOWER function (DAX)" --- # LOWER -Converts all letters in a text string to lowercase. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Converts all letters in a text string to lowercase. + +## Syntax + ```dax -LOWER() +LOWER() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|The text you want to convert to lowercase, or a reference to a column that contains text.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text you want to convert to lowercase, or a reference to a column that contains text.| + ## Return value -Text in lowercase. - +Text in lowercase. + ## Remarks -Characters that are not letters are not changed. For example, the formula `= LOWER("123ABC")` returns **123abc**. - +Characters that are not letters are not changed. For example, the formula `= LOWER("123ABC")` returns `123abc`. + ## Example -The following formula gets each row in the column, [ProductCode], and converts the value to all lowercase. Numbers in the column are not affected. - +The following formula gets each row in the column, [ProductCode], and converts the value to all lowercase. Numbers in the column are not affected. + ```dax -= LOWER('New Products'[ProductCode]) += LOWER('New Products'[ProductCode]) ``` - -## See also -[Text functions](text-functions-dax.md) +## Related content + +[Text functions](text-functions-dax.md) diff --git a/query-languages/dax/matchby-function-dax.md b/query-languages/dax/matchby-function-dax.md new file mode 100644 index 000000000..db6d763d7 --- /dev/null +++ b/query-languages/dax/matchby-function-dax.md @@ -0,0 +1,46 @@ +--- +description: "Learn more about: MATCHBY" +title: "MATCHBY function (DAX)" +author: keshen +--- + +# MATCHBY + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +In window functions, defines the columns that are used to determine how to match data and identify the current row. + +## Syntax + +```dax +MATCHBY ( [[, matchBy_columnName [, …]]] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`matchBy_columnName`| (Optional) The name of an existing column to be used to identify current row in the window function’s `relation`.
RELATED() may also be used to refer to a column in a table related to `relation`.| + +## Return value + +This function does not return a value. + +## Remarks + +This function can only be used within a window function expression. + +## Example + +See [OFFSET](offset-function-dax.md). + +## Related content + +[Understanding ORDERBY, PARTITIONBY, and MATCHBY functions](../dax/best-practices/dax-understand-orderby.md) +[INDEX](index-function-dax.md) +[OFFSET](offset-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[WINDOW](window-function-dax.md) +[RANK](rank-function-dax.md) +[ROWNUMBER](rownumber-function-dax.md) diff --git a/query-languages/dax/math-and-trig-functions-dax.md b/query-languages/dax/math-and-trig-functions-dax.md index d8f4a0dea..e890d59fd 100644 --- a/query-languages/dax/math-and-trig-functions-dax.md +++ b/query-languages/dax/math-and-trig-functions-dax.md @@ -1,19 +1,11 @@ --- description: "Learn more about: Math and Trig functions" -title: "Math and Trig functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/28/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Math and Trig functions (DAX)" --- # Math and Trig functions -The mathematical functions in Data Analysis Expressions (DAX) are very similar to the Excel mathematical and trigonometric functions. This section lists the mathematical functions provided by DAX. - +The mathematical functions in Data Analysis Expressions (DAX) are very similar to the Excel mathematical and trigonometric functions. This section lists the mathematical functions provided by DAX. + ## In this category |Function |Description | @@ -47,6 +39,7 @@ The mathematical functions in Data Analysis Expressions (DAX) are very similar t |[LN](ln-function-dax.md) | Returns the natural logarithm of a number. | |[LOG](log-function-dax.md) | Returns the logarithm of a number to the base you specify. | |[LOG10](log10-function-dax.md) | Returns the base-10 logarithm of a number. | +|[MOD](mod-function-dax.md) | Returns the remainder after a number is divided by a divisor. The result always has the same sign as the divisor. | |[MROUND](mround-function-dax.md) | Returns a number rounded to the desired multiple. | |[ODD](odd-function-dax.md) | Returns number rounded up to the nearest odd integer. | |[PI](pi-function-dax.md) | Returns the value of Pi, 3.14159265358979, accurate to 15 digits. | diff --git a/query-languages/dax/max-function-dax.md b/query-languages/dax/max-function-dax.md index 9583e2902..da2f6ff4d 100644 --- a/query-languages/dax/max-function-dax.md +++ b/query-languages/dax/max-function-dax.md @@ -1,65 +1,58 @@ --- description: "Learn more about: MAX" -title: "MAX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MAX function (DAX)" --- # MAX -Returns the largest value in a column, or between two scalar expressions. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the largest value in a column, or between two scalar expressions. + +## Syntax + ```dax -MAX() +MAX() ``` ```dax MAX(, ) ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column in which you want to find the largest value.| -|expression|Any DAX expression which returns a single value.| - + +|Term|Definition| +|--------|--------------| +|`column`|The column in which you want to find the largest value.| +|`expression`|Any DAX expression which returns a single value.| + ## Return value The largest value. - -## Remarks + +## Remarks - When comparing two expressions, blank is treated as 0 when comparing. That is, Max(1, Blank() ) returns 1, and Max( -1, Blank() ) returns 0. If both arguments are blank, MAX returns a blank. If either expression returns a value which is not allowed, MAX returns an error. -- TRUE/FALSE values are not supported. If you want to evaluate a column of TRUE/FALSE values, use the MAXA function. - +- `TRUE`/`FALSE` values are not supported. If you want to evaluate a column of `TRUE`/`FALSE` values, use the MAXA function. + ## Example 1 -The following example returns the largest value found in the ExtendedAmount column of the InternetSales table. - +The following example returns the largest value found in the ExtendedAmount column of the InternetSales table. + ```dax -= MAX(InternetSales[ExtendedAmount]) += MAX(InternetSales[ExtendedAmount]) ``` ## Example 2 -The following example returns the largest value between the result of two expressions. - +The following example returns the largest value between the result of two expressions. + ```dax = Max([TotalSales], [TotalPurchases]) ``` -## See also +## Related content -[MAXA function](maxa-function-dax.md) -[MAXX function](maxx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +[MAXA function](maxa-function-dax.md) +[MAXX function](maxx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/maxa-function-dax.md b/query-languages/dax/maxa-function-dax.md index 9c273fd46..8235addc7 100644 --- a/query-languages/dax/maxa-function-dax.md +++ b/query-languages/dax/maxa-function-dax.md @@ -1,45 +1,38 @@ --- description: "Learn more about: MAXA" -title: "MAXA function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MAXA function (DAX)" --- # MAXA +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the largest value in a column. - -## Syntax - + +## Syntax + ```dax -MAXA() +MAXA() ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column in which you want to find the largest value.| - + +|Term|Definition| +|--------|--------------| +|`column`|The column in which you want to find the largest value.| + ## Return value -The largest value. - +The largest value. + ## Remarks -- The MAXA function takes as argument a column, and looks for the largest value among the following types of values: - - Numbers - - Dates - -- Logical values, such as TRUE and FALSE. Rows that evaluate to TRUE count as 1; rows that evaluate to FALSE count as 0 (zero). - -- Empty cells are ignored. If the column contains no values that can be used, MAXA returns 0 (zero). +- The MAXA function takes as argument a column, and looks for the largest value among the following types of values: + - Numbers + - Dates + +- Logical values, such as `TRUE` and `FALSE`. Rows that evaluate to `TRUE` count as 1; rows that evaluate to `FALSE` count as 0 (zero). + +- Empty cells are ignored. If the column contains no values that can be used, MAXA returns 0 (zero). - If you want to compare text values, use the MAX function. @@ -47,22 +40,22 @@ The largest value. ## Example 1 -The following example returns the greatest value from a calculated column, named **ResellerMargin**, that computes the difference between list price and reseller price. - +The following example returns the greatest value from a calculated column, named **ResellerMargin**, that computes the difference between list price and reseller price. + ```dax -= MAXA([ResellerMargin]) += MAXA([ResellerMargin]) ``` - + ## Example 2 -The following example returns the largest value from a column that contains dates and times. Therefore, this formula gets the most recent transaction date. - +The following example returns the largest value from a column that contains dates and times. Therefore, this formula gets the most recent transaction date. + ```dax -= MAXA([TransactionDate]) += MAXA([TransactionDate]) ``` - -## See also -[MAX function](max-function-dax.md) -[MAXX function](maxx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[MAX function](max-function-dax.md) +[MAXX function](maxx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/maxx-function-dax.md b/query-languages/dax/maxx-function-dax.md index c4e8b3275..15d865424 100644 --- a/query-languages/dax/maxx-function-dax.md +++ b/query-languages/dax/maxx-function-dax.md @@ -1,68 +1,64 @@ --- description: "Learn more about: MAXX" -title: "MAXX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MAXX function (DAX)" --- # MAXX -Evaluates an expression for each row of a table and returns the largest value. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the highest value that results from evaluating an expression for each row of a table. + +## Syntax + ```dax -MAXX(
,) +MAXX(
,,[]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of the table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of the table.| +|`variant`|(Optional) If `TRUE`, and if there are variant or mixed value types, the highest value based on ORDER BY DESC is returned.| + ## Return value -The largest value. - +The highest value. + ## Remarks -- The **table** argument to the MAXX function can be a table name, or an expression that evaluates to a table. The second argument indicates the expression to be evaluated for each row of the table. - -- Of the values to evaluate, only the following are counted: +- The `table` argument to the MAXX function can be a table name or an expression that evaluates to a table. The second argument indicates the expression to be evaluated for each row of the table. + +- Of the values to evaluate, only the following are counted: - Numbers - Texts - Dates - -- Blank values are skipped. TRUE/FALSE values are not supported. + +- Blank values are skipped. `TRUE`/`FALSE` values are not supported. + +- If the expression has variant or mixed value types such as text and number, then by default MAXX considers only numbers. If ` = `TRUE``, the maximum value is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example 1 -The following formula uses an expression as the second argument to calculate the total amount of taxes and shipping for each order in the table, InternetSales. The expected result is 375.7184. - +The following formula uses an expression as the second argument to calculate the total amount of taxes and shipping for each order in the InternetSales table. The expected result is 375.7184. + ```dax -= MAXX(InternetSales, InternetSales[TaxAmt]+ InternetSales[Freight]) += MAXX(InternetSales, InternetSales[TaxAmt]+ InternetSales[Freight]) ``` - + ## Example 2 -The following formula first filters the table InternetSales, by using a FILTER expression, to return a subset of orders for a specific sales region, defined as [SalesTerritory] = 5. The MAXX function then evaluates the expression used as the second argument for each row of the filtered table, and returns the highest amount for taxes and shipping for just those orders. The expected result is 250.3724. - +The following formula first filters the InternetSales table by using a FILTER expression to return a subset of orders for a specific sales region defined as, [SalesTerritory] = 5. The MAXX function then evaluates the expression used as the second argument for each row of the filtered table and returns the highest amount for taxes and shipping for just those orders. The expected result is 250.3724. + ```dax -= MAXX(FILTER(InternetSales,[SalesTerritoryCode]="5"), InternetSales[TaxAmt]+ InternetSales[Freight]) += MAXX(FILTER(InternetSales,[SalesTerritoryCode]="5"), InternetSales[TaxAmt]+ InternetSales[Freight]) ``` - -## See also -[MAX function](max-function-dax.md) -[MAXA function](maxa-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[MAX function](max-function-dax.md) +[MAXA function](maxa-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/mduration-function-dax.md b/query-languages/dax/mduration-function-dax.md index 57d1e4e16..16777cb65 100644 --- a/query-languages/dax/mduration-function-dax.md +++ b/query-languages/dax/mduration-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: MDURATION" -title: "MDURATION function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "MDURATION function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # MDURATION +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the modified Macauley duration for a security with an assumed par value of \\$100. ## Syntax @@ -24,18 +18,18 @@ MDURATION(, , , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|coupon|The security's annual coupon rate.| -|yld|The security's annual yield.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`coupon`|The security's annual coupon rate.| +|`yld`|The security's annual yield.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/measure-statement-dax.md b/query-languages/dax/measure-statement-dax.md new file mode 100644 index 000000000..e88da2b46 --- /dev/null +++ b/query-languages/dax/measure-statement-dax.md @@ -0,0 +1,46 @@ +--- +description: "Learn more about: MEASURE" +title: "MEASURE keyword (DAX)" +--- +# MEASURE + +Introduces a measure definition in a DEFINE statement of a [DAX query](dax-queries.md). + +## Syntax + +```dax +[DEFINE + ( + MEASURE
[] = + ) + +] + +(EVALUATE
) + +``` + +### Parameters + +|Term|Definition| +|---------|---------| +|`table name`| The name of a table containing the measure. | +|`measure name`| The name of the measure. It cannot be an expression. The name does not have to be unique. The name exists only for the duration of the query. | +|`scalar expression`| A DAX expression that returns a scalar value. | + +## Return value + +The calculated result of the measure expression. + +## Remarks + +- Measure definitions for a query override model measures of the same name for the duration of the query. They will not affect the model measure. + +- The measure expression can be used with any other expression in the same query. + +- To learn more about how MEASURE statements are used, see [DAX queries](dax-queries.md). + +## Related content + +[DEFINE](define-statement-dax.md) +[EVALUATE](evaluate-statement-dax.md) +[VAR](var-dax.md) +[DAX queries](dax-queries.md) diff --git a/query-languages/dax/media/columnstatistics-function-dax/columnstatistics-result-table.png b/query-languages/dax/media/columnstatistics-function-dax/columnstatistics-result-table.png new file mode 100644 index 000000000..8875591e4 Binary files /dev/null and b/query-languages/dax/media/columnstatistics-function-dax/columnstatistics-result-table.png differ diff --git a/query-languages/dax/media/crossfilter-examp-diagview.png b/query-languages/dax/media/crossfilter-examp-diagview.png deleted file mode 100644 index b445d03db..000000000 Binary files a/query-languages/dax/media/crossfilter-examp-diagview.png and /dev/null differ diff --git a/query-languages/dax/media/crossfilter-function/crossfilter-examp-diagview.png b/query-languages/dax/media/crossfilter-function/crossfilter-examp-diagview.png new file mode 100644 index 000000000..0f5263106 Binary files /dev/null and b/query-languages/dax/media/crossfilter-function/crossfilter-examp-diagview.png differ diff --git a/query-languages/dax/media/crossfilter-examp-pivottable1.png b/query-languages/dax/media/crossfilter-function/crossfilter-examp-pivottable1.png similarity index 100% rename from query-languages/dax/media/crossfilter-examp-pivottable1.png rename to query-languages/dax/media/crossfilter-function/crossfilter-examp-pivottable1.png diff --git a/query-languages/dax/media/crossfilter-examp-pivottable2.png b/query-languages/dax/media/crossfilter-function/crossfilter-examp-pivottable2.png similarity index 100% rename from query-languages/dax/media/crossfilter-examp-pivottable2.png rename to query-languages/dax/media/crossfilter-function/crossfilter-examp-pivottable2.png diff --git a/query-languages/dax/media/dax-copilot/copilot-explain-query.png b/query-languages/dax/media/dax-copilot/copilot-explain-query.png new file mode 100644 index 000000000..b7127c384 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/copilot-explain-query.png differ diff --git a/query-languages/dax/media/dax-copilot/copilot-inspire-buttons-get-started.png b/query-languages/dax/media/dax-copilot/copilot-inspire-buttons-get-started.png new file mode 100644 index 000000000..faef2d091 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/copilot-inspire-buttons-get-started.png differ diff --git a/query-languages/dax/media/dax-copilot/copilot-power-bi-desktop.png b/query-languages/dax/media/dax-copilot/copilot-power-bi-desktop.png new file mode 100644 index 000000000..d7bca7f66 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/copilot-power-bi-desktop.png differ diff --git a/query-languages/dax/media/dax-copilot/copilot-power-bi-service-write-dax-queries.png b/query-languages/dax/media/dax-copilot/copilot-power-bi-service-write-dax-queries.png new file mode 100644 index 000000000..2052ea57e Binary files /dev/null and b/query-languages/dax/media/dax-copilot/copilot-power-bi-service-write-dax-queries.png differ diff --git a/query-languages/dax/media/dax-copilot/copilot-run-query.png b/query-languages/dax/media/dax-copilot/copilot-run-query.png new file mode 100644 index 000000000..9a5bdb6e1 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/copilot-run-query.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-conversational-query.png b/query-languages/dax/media/dax-copilot/dax-copilot-conversational-query.png new file mode 100644 index 000000000..59ffa8b24 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-conversational-query.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-explain-query-more.png b/query-languages/dax/media/dax-copilot/dax-copilot-explain-query-more.png new file mode 100644 index 000000000..971c89324 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-explain-query-more.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-explain-query.png b/query-languages/dax/media/dax-copilot/dax-copilot-explain-query.png new file mode 100644 index 000000000..2d58bcb1c Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-explain-query.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-explain-summarize-columns.png b/query-languages/dax/media/dax-copilot/dax-copilot-explain-summarize-columns.png new file mode 100644 index 000000000..a763c4ca3 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-explain-summarize-columns.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-highlight-deff.png b/query-languages/dax/media/dax-copilot/dax-copilot-highlight-deff.png new file mode 100644 index 000000000..49e031c6a Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-highlight-deff.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-highlight-diff.png b/query-languages/dax/media/dax-copilot/dax-copilot-highlight-diff.png new file mode 100644 index 000000000..d882b7ca5 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-highlight-diff.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-new-column-query.png b/query-languages/dax/media/dax-copilot/dax-copilot-new-column-query.png new file mode 100644 index 000000000..5048f30b7 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-new-column-query.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-query-explanation.png b/query-languages/dax/media/dax-copilot/dax-copilot-query-explanation.png new file mode 100644 index 000000000..0dfa7bd35 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-query-explanation.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-run-query.png b/query-languages/dax/media/dax-copilot/dax-copilot-run-query.png new file mode 100644 index 000000000..5048f30b7 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-run-query.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-show-diff.png b/query-languages/dax/media/dax-copilot/dax-copilot-show-diff.png new file mode 100644 index 000000000..24802c3ad Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-show-diff.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-summarize-columns-brief.png b/query-languages/dax/media/dax-copilot/dax-copilot-summarize-columns-brief.png new file mode 100644 index 000000000..d4bb5d26c Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-summarize-columns-brief.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-summarize-columns-more.png b/query-languages/dax/media/dax-copilot/dax-copilot-summarize-columns-more.png new file mode 100644 index 000000000..ad19994f1 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-summarize-columns-more.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-copilot-updated-query.png b/query-languages/dax/media/dax-copilot/dax-copilot-updated-query.png new file mode 100644 index 000000000..cf264f781 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-copilot-updated-query.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-list-products.png b/query-languages/dax/media/dax-copilot/dax-list-products.png new file mode 100644 index 000000000..497ffe456 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-list-products.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-query-list-products.png b/query-languages/dax/media/dax-copilot/dax-query-list-products.png new file mode 100644 index 000000000..f65640a25 Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-query-list-products.png differ diff --git a/query-languages/dax/media/dax-copilot/dax-query-results.png b/query-languages/dax/media/dax-copilot/dax-query-results.png new file mode 100644 index 000000000..d164ac77b Binary files /dev/null and b/query-languages/dax/media/dax-copilot/dax-query-results.png differ diff --git a/query-languages/dax/media/dax-overview-book.png b/query-languages/dax/media/dax-overview/dax-overview-book.png similarity index 100% rename from query-languages/dax/media/dax-overview-book.png rename to query-languages/dax/media/dax-overview/dax-overview-book.png diff --git a/query-languages/dax/media/dax-overview-excel.png b/query-languages/dax/media/dax-overview/dax-overview-excel.png similarity index 100% rename from query-languages/dax/media/dax-overview-excel.png rename to query-languages/dax/media/dax-overview/dax-overview-excel.png diff --git a/query-languages/dax/media/dax-overview-pbid.png b/query-languages/dax/media/dax-overview/dax-overview-pbid.png similarity index 100% rename from query-languages/dax/media/dax-overview-pbid.png rename to query-languages/dax/media/dax-overview/dax-overview-pbid.png diff --git a/query-languages/dax/media/dax-overview-ssms.png b/query-languages/dax/media/dax-overview/dax-overview-ssms.png similarity index 100% rename from query-languages/dax/media/dax-overview-ssms.png rename to query-languages/dax/media/dax-overview/dax-overview-ssms.png diff --git a/query-languages/dax/media/dax-overview-studio.png b/query-languages/dax/media/dax-overview/dax-overview-studio.png similarity index 100% rename from query-languages/dax/media/dax-overview-studio.png rename to query-languages/dax/media/dax-overview/dax-overview-studio.png diff --git a/query-languages/dax/media/dax-overview-te.png b/query-languages/dax/media/dax-overview/dax-overview-te.png similarity index 100% rename from query-languages/dax/media/dax-overview-te.png rename to query-languages/dax/media/dax-overview/dax-overview-te.png diff --git a/query-languages/dax/media/dax-overview-vs.png b/query-languages/dax/media/dax-overview/dax-overview-vs.png similarity index 100% rename from query-languages/dax/media/dax-overview-vs.png rename to query-languages/dax/media/dax-overview/dax-overview-vs.png diff --git a/query-languages/dax/media/dax-queries/dax-evaluate-define-measures.png b/query-languages/dax/media/dax-queries/dax-evaluate-define-measures.png new file mode 100644 index 000000000..286141bc9 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-evaluate-define-measures.png differ diff --git a/query-languages/dax/media/dax-queries/dax-evaluate-define.png b/query-languages/dax/media/dax-queries/dax-evaluate-define.png index 315309d54..c6578eefe 100644 Binary files a/query-languages/dax/media/dax-queries/dax-evaluate-define.png and b/query-languages/dax/media/dax-queries/dax-evaluate-define.png differ diff --git a/query-languages/dax/media/dax-queries/dax-evaluate-orderby.png b/query-languages/dax/media/dax-queries/dax-evaluate-orderby.png index 55c716582..4cfddce35 100644 Binary files a/query-languages/dax/media/dax-queries/dax-evaluate-orderby.png and b/query-languages/dax/media/dax-queries/dax-evaluate-orderby.png differ diff --git a/query-languages/dax/media/dax-queries/dax-evaluate-startat.png b/query-languages/dax/media/dax-queries/dax-evaluate-startat.png index 4df56d86f..2f6e9df72 100644 Binary files a/query-languages/dax/media/dax-queries/dax-evaluate-startat.png and b/query-languages/dax/media/dax-queries/dax-evaluate-startat.png differ diff --git a/query-languages/dax/media/dax-queries/dax-evaluate-topn.png b/query-languages/dax/media/dax-queries/dax-evaluate-topn.png new file mode 100644 index 000000000..1629aece1 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-evaluate-topn.png differ diff --git a/query-languages/dax/media/dax-queries/dax-evaluate.png b/query-languages/dax/media/dax-queries/dax-evaluate.png index dcc32d80d..a7de8846e 100644 Binary files a/query-languages/dax/media/dax-queries/dax-evaluate.png and b/query-languages/dax/media/dax-queries/dax-evaluate.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-collapse.png b/query-languages/dax/media/dax-queries/dax-visualcalc-collapse.png new file mode 100644 index 000000000..9d08ce44f Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-collapse.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-collapseall.png b/query-languages/dax/media/dax-queries/dax-visualcalc-collapseall.png new file mode 100644 index 000000000..63552333d Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-collapseall.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-expand.png b/query-languages/dax/media/dax-queries/dax-visualcalc-expand.png new file mode 100644 index 000000000..8c05c237f Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-expand.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-expandall.png b/query-languages/dax/media/dax-queries/dax-visualcalc-expandall.png new file mode 100644 index 000000000..e849e7a71 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-expandall.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-first.png b/query-languages/dax/media/dax-queries/dax-visualcalc-first.png new file mode 100644 index 000000000..5e1e7fe25 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-first.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-index.png b/query-languages/dax/media/dax-queries/dax-visualcalc-index.png new file mode 100644 index 000000000..0fd4ccb5a Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-index.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-isatlevel.png b/query-languages/dax/media/dax-queries/dax-visualcalc-isatlevel.png new file mode 100644 index 000000000..f67ceabbb Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-isatlevel.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-last.png b/query-languages/dax/media/dax-queries/dax-visualcalc-last.png new file mode 100644 index 000000000..c39329ca7 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-last.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-lookup-example2.png b/query-languages/dax/media/dax-queries/dax-visualcalc-lookup-example2.png new file mode 100644 index 000000000..8811ff141 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-lookup-example2.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-lookup.png b/query-languages/dax/media/dax-queries/dax-visualcalc-lookup.png new file mode 100644 index 000000000..d7ab8c8b5 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-lookup.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-lookupwithtotals-example1.png b/query-languages/dax/media/dax-queries/dax-visualcalc-lookupwithtotals-example1.png new file mode 100644 index 000000000..dea57fb7c Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-lookupwithtotals-example1.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-lookupwithtotals-example2.png b/query-languages/dax/media/dax-queries/dax-visualcalc-lookupwithtotals-example2.png new file mode 100644 index 000000000..b8ba625e4 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-lookupwithtotals-example2.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-movingaverage.png b/query-languages/dax/media/dax-queries/dax-visualcalc-movingaverage.png new file mode 100644 index 000000000..9a0eb4de1 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-movingaverage.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-next.png b/query-languages/dax/media/dax-queries/dax-visualcalc-next.png new file mode 100644 index 000000000..f06d966f7 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-next.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-offset.png b/query-languages/dax/media/dax-queries/dax-visualcalc-offset.png new file mode 100644 index 000000000..fb66bacf5 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-offset.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-previous.png b/query-languages/dax/media/dax-queries/dax-visualcalc-previous.png new file mode 100644 index 000000000..26f9dd948 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-previous.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-range.png b/query-languages/dax/media/dax-queries/dax-visualcalc-range.png new file mode 100644 index 000000000..8965ea0c8 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-range.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-rank.png b/query-languages/dax/media/dax-queries/dax-visualcalc-rank.png new file mode 100644 index 000000000..1cc38b632 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-rank.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-rownumber.png b/query-languages/dax/media/dax-queries/dax-visualcalc-rownumber.png new file mode 100644 index 000000000..b2a6dc8e0 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-rownumber.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-runningsum.png b/query-languages/dax/media/dax-queries/dax-visualcalc-runningsum.png new file mode 100644 index 000000000..1d5ad4b6f Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-runningsum.png differ diff --git a/query-languages/dax/media/dax-queries/dax-visualcalc-window.png b/query-languages/dax/media/dax-queries/dax-visualcalc-window.png new file mode 100644 index 000000000..d1c2711c5 Binary files /dev/null and b/query-languages/dax/media/dax-queries/dax-visualcalc-window.png differ diff --git a/query-languages/dax/media/icons/discouraged.png b/query-languages/dax/media/icons/discouraged.png new file mode 100644 index 000000000..e9ce9dbc5 Binary files /dev/null and b/query-languages/dax/media/icons/discouraged.png differ diff --git a/query-languages/dax/media/icons/no.png b/query-languages/dax/media/icons/no.png new file mode 100644 index 000000000..1aa084e6a Binary files /dev/null and b/query-languages/dax/media/icons/no.png differ diff --git a/query-languages/dax/media/icons/yes.png b/query-languages/dax/media/icons/yes.png new file mode 100644 index 000000000..d2285c5c4 Binary files /dev/null and b/query-languages/dax/media/icons/yes.png differ diff --git a/query-languages/dax/media/info-functions-dax/info-view-columns-dax-query.png b/query-languages/dax/media/info-functions-dax/info-view-columns-dax-query.png new file mode 100644 index 000000000..bb0a0ca89 Binary files /dev/null and b/query-languages/dax/media/info-functions-dax/info-view-columns-dax-query.png differ diff --git a/query-languages/dax/media/info-functions-dax/info-view-measures-dax-query.png b/query-languages/dax/media/info-functions-dax/info-view-measures-dax-query.png new file mode 100644 index 000000000..dff943d1c Binary files /dev/null and b/query-languages/dax/media/info-functions-dax/info-view-measures-dax-query.png differ diff --git a/query-languages/dax/media/info-functions-dax/info-view-relationships-dax-query.png b/query-languages/dax/media/info-functions-dax/info-view-relationships-dax-query.png new file mode 100644 index 000000000..350619b52 Binary files /dev/null and b/query-languages/dax/media/info-functions-dax/info-view-relationships-dax-query.png differ diff --git a/query-languages/dax/media/info-functions-dax/info-view-tables-dax-query.png b/query-languages/dax/media/info-functions-dax/info-view-tables-dax-query.png new file mode 100644 index 000000000..69320dedf Binary files /dev/null and b/query-languages/dax/media/info-functions-dax/info-view-tables-dax-query.png differ diff --git a/query-languages/dax/media/info-view-columns-function-dax/dax-query-example-2.png b/query-languages/dax/media/info-view-columns-function-dax/dax-query-example-2.png new file mode 100644 index 000000000..044919c5b Binary files /dev/null and b/query-languages/dax/media/info-view-columns-function-dax/dax-query-example-2.png differ diff --git a/query-languages/dax/media/info-view-columns-function-dax/measure-example-4-visuals.png b/query-languages/dax/media/info-view-columns-function-dax/measure-example-4-visuals.png new file mode 100644 index 000000000..3e84f4163 Binary files /dev/null and b/query-languages/dax/media/info-view-columns-function-dax/measure-example-4-visuals.png differ diff --git a/query-languages/dax/media/info-view-measures-function-dax/dax-query-example-1.png b/query-languages/dax/media/info-view-measures-function-dax/dax-query-example-1.png new file mode 100644 index 000000000..5e6914f77 Binary files /dev/null and b/query-languages/dax/media/info-view-measures-function-dax/dax-query-example-1.png differ diff --git a/query-languages/dax/media/info-view-measures-function-dax/dax-query-example-2.png b/query-languages/dax/media/info-view-measures-function-dax/dax-query-example-2.png new file mode 100644 index 000000000..89da82565 Binary files /dev/null and b/query-languages/dax/media/info-view-measures-function-dax/dax-query-example-2.png differ diff --git a/query-languages/dax/media/info-view-measures-function-dax/measure-example-4-dax-query.png b/query-languages/dax/media/info-view-measures-function-dax/measure-example-4-dax-query.png new file mode 100644 index 000000000..2e02e52e5 Binary files /dev/null and b/query-languages/dax/media/info-view-measures-function-dax/measure-example-4-dax-query.png differ diff --git a/query-languages/dax/media/info-view-measures-function-dax/measure-example-4-visuals.png b/query-languages/dax/media/info-view-measures-function-dax/measure-example-4-visuals.png new file mode 100644 index 000000000..f47442a94 Binary files /dev/null and b/query-languages/dax/media/info-view-measures-function-dax/measure-example-4-visuals.png differ diff --git a/query-languages/dax/media/info-view-relationships-function-dax/dax-query-example-1.png b/query-languages/dax/media/info-view-relationships-function-dax/dax-query-example-1.png new file mode 100644 index 000000000..ccafb0c24 Binary files /dev/null and b/query-languages/dax/media/info-view-relationships-function-dax/dax-query-example-1.png differ diff --git a/query-languages/dax/media/info-view-relationships-function-dax/dax-query-example-2.png b/query-languages/dax/media/info-view-relationships-function-dax/dax-query-example-2.png new file mode 100644 index 000000000..a49805305 Binary files /dev/null and b/query-languages/dax/media/info-view-relationships-function-dax/dax-query-example-2.png differ diff --git a/query-languages/dax/media/info-view-relationships-function-dax/measure-example-4-dax-query.png b/query-languages/dax/media/info-view-relationships-function-dax/measure-example-4-dax-query.png new file mode 100644 index 000000000..41427ca4d Binary files /dev/null and b/query-languages/dax/media/info-view-relationships-function-dax/measure-example-4-dax-query.png differ diff --git a/query-languages/dax/media/info-view-relationships-function-dax/measure-example-4-visuals.png b/query-languages/dax/media/info-view-relationships-function-dax/measure-example-4-visuals.png new file mode 100644 index 000000000..ebfe9d7d1 Binary files /dev/null and b/query-languages/dax/media/info-view-relationships-function-dax/measure-example-4-visuals.png differ diff --git a/query-languages/dax/media/info-view-tables-function-dax/calculated-table-example-3.png b/query-languages/dax/media/info-view-tables-function-dax/calculated-table-example-3.png new file mode 100644 index 000000000..5f690b7f0 Binary files /dev/null and b/query-languages/dax/media/info-view-tables-function-dax/calculated-table-example-3.png differ diff --git a/query-languages/dax/media/info-view-tables-function-dax/dax-query-example-1.png b/query-languages/dax/media/info-view-tables-function-dax/dax-query-example-1.png new file mode 100644 index 000000000..dda433ce6 Binary files /dev/null and b/query-languages/dax/media/info-view-tables-function-dax/dax-query-example-1.png differ diff --git a/query-languages/dax/media/info-view-tables-function-dax/dax-query-example-2.png b/query-languages/dax/media/info-view-tables-function-dax/dax-query-example-2.png new file mode 100644 index 000000000..eba8f9502 Binary files /dev/null and b/query-languages/dax/media/info-view-tables-function-dax/dax-query-example-2.png differ diff --git a/query-languages/dax/media/info-view-tables-function-dax/measure-example-4-dax-query.png b/query-languages/dax/media/info-view-tables-function-dax/measure-example-4-dax-query.png new file mode 100644 index 000000000..c4786ba2b Binary files /dev/null and b/query-languages/dax/media/info-view-tables-function-dax/measure-example-4-dax-query.png differ diff --git a/query-languages/dax/media/info-view-tables-function-dax/measure-example-4-visuals.png b/query-languages/dax/media/info-view-tables-function-dax/measure-example-4-visuals.png new file mode 100644 index 000000000..a1f8781c9 Binary files /dev/null and b/query-languages/dax/media/info-view-tables-function-dax/measure-example-4-visuals.png differ diff --git a/query-languages/dax/median-function-dax.md b/query-languages/dax/median-function-dax.md index d045ebc1e..1ddb09f78 100644 --- a/query-languages/dax/median-function-dax.md +++ b/query-languages/dax/median-function-dax.md @@ -1,53 +1,47 @@ --- description: "Learn more about: MEDIAN" -title: "MEDIAN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "MEDIAN function (DAX)" --- # MEDIAN - -Returns the median of numbers in a column. - -To return the median of an expresssion evaluated for each row in a table, use [MEDIANX function](medianx-function-dax.md). - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the median of numbers in a column. + +To return the median of an expresssion evaluated for each row in a table, use [MEDIANX function](medianx-function-dax.md). + +## Syntax + ```dax -MEDIAN() +MEDIAN() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column that contains the numbers for which the median is to be computed.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that contains the numbers for which the median is to be computed.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- Only the numbers in the column are counted. Blanks, logical values, and text are ignored. - -- MEDIAN( Table[Column] ) is equivalent to MEDIANX( Table, Table[Column] ). +- Only the numbers in the column are counted. Blanks are ignored. Logical values, dates, and text are not supported. + +- MEDIAN( Table[Column] ) is equivalent to MEDIANX( Table, Table[Column] ). - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following computes the median of a column named Age in a table named Customers: - +The following computes the median of a column named Age in a table named Customers: + ```dax -= MEDIAN( Customers[Age] ) += MEDIAN( Customers[Age] ) ``` - -## See also -[MEDIANX function](medianx-function-dax.md) +## Related content + +[MEDIANX function](medianx-function-dax.md) diff --git a/query-languages/dax/medianx-function-dax.md b/query-languages/dax/medianx-function-dax.md index c38768733..a1ecbbad9 100644 --- a/query-languages/dax/medianx-function-dax.md +++ b/query-languages/dax/medianx-function-dax.md @@ -1,59 +1,52 @@ --- description: "Learn more about: MEDIANX" -title: "MEDIANX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 12/10/2018 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MEDIANX function (DAX)" --- -# MEDIANX) - -Returns the median number of an expression evaluated for each row in a table. - -To return the median of numbers in a column, use [MEDIAN function](median-function-dax.md). - -## Syntax - +# MEDIANX + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the median number of an expression evaluated for each row in a table. + +To return the median of numbers in a column, use [MEDIAN function](median-function-dax.md). + +## Syntax + ```dax -MEDIANX(
, ) +MEDIANX(
, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of the table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of the table.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- The MEDIANX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers for which you want to compute the median, or an expression that evaluates to a column. - +- The MEDIANX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers for which you want to compute the median, or an expression that evaluates to a column. + - Only the numbers in the column are counted. - Logical values and text are ignored. -- MEDIANX does not ignore blanks; however, MEDIAN does ignore blanks +- MEDIANX does not ignore blanks; however, MEDIAN does ignore blanks - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following computes the median age of customers who live in the USA. - +The following computes the median age of customers who live in the USA. + ```dax -= MEDIANX( FILTER(Customers, RELATED( Geography[Country]="USA" ) ), Customers[Age] ) += MEDIANX( FILTER(Customers, RELATED( Geography[Country]="USA" ) ), Customers[Age] ) ``` - -## See also -[MEDIAN function](median-function-dax.md) +## Related content + +[MEDIAN function](median-function-dax.md) diff --git a/query-languages/dax/mid-function-dax.md b/query-languages/dax/mid-function-dax.md index e83f8d7c4..a7fc84d27 100644 --- a/query-languages/dax/mid-function-dax.md +++ b/query-languages/dax/mid-function-dax.md @@ -1,42 +1,35 @@ --- description: "Learn more about: MID" -title: "MID function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 02/11/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MID function (DAX)" --- # MID -Returns a string of characters from the middle of a text string, given a starting position and length. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a string of characters from the middle of a text string, given a starting position and length. + +## Syntax + ```dax -MID(, , ) +MID(, , ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|The text string from which you want to extract the characters, or a column that contains text.| -|start_num|The position of the first character you want to extract. Positions start at 1.| -|num_chars|The number of characters to return.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text string from which you want to extract the characters, or a column that contains text.| +|`start_num`|The position of the first character you want to extract. Positions start at 1.| +|`num_chars`|The number of characters to return.| + ## Return value -A string of text of the specified length. - +A string of text of the specified length. + ## Remarks -Whereas Microsoft Excel has different functions for working with single-byte and double-byte characters languages, DAX uses Unicode and stores all characters with the same length. - -## Examples +Whereas Microsoft Excel has different functions for working with single-byte and double-byte characters languages, DAX uses Unicode and stores all characters with the same length. + +## Examples The following expression, @@ -44,7 +37,7 @@ The following expression, MID("abcde",2,3)) ``` -Returns **"bcd"**. +Returns `"bcd"`. The following expression, @@ -53,7 +46,7 @@ MID('Reseller'[ResellerName],1,5)) ``` Returns the same result as `LEFT([ResellerName],5)`. Both expressions return the first 5 letters of column, `[ResellerName]`. - -## See also -[Text functions](text-functions-dax.md) +## Related content + +[Text functions](text-functions-dax.md) diff --git a/query-languages/dax/min-function-dax.md b/query-languages/dax/min-function-dax.md index 7dfe0ccb0..118bf9ae2 100644 --- a/query-languages/dax/min-function-dax.md +++ b/query-languages/dax/min-function-dax.md @@ -1,24 +1,17 @@ --- description: "Learn more about: MIN" -title: "MIN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MIN function (DAX)" --- # MIN +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the smallest value in a column, or between two scalar expressions. - -## Syntax - + +## Syntax + ```dax -MIN() +MIN() ``` ```dax @@ -26,54 +19,54 @@ MIN(, ) ``` ### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column in which you want to find the smallest value.| -|expression|Any DAX expression which returns a single value.| - + +|Term|Definition| +|--------|--------------| +|`column`|The column in which you want to find the smallest value.| +|`expression`|Any DAX expression which returns a single value.| + ## Return value -The smallest value. - +The smallest value. + ## Remarks -- The MIN function takes a column or two expressions as an argument, and returns the smallest value. The following types of values in the columns are counted: +- The MIN function takes a column or two expressions as an argument, and returns the smallest value. The following types of values in the columns are counted: - Numbers - Texts - - Dates + - Dates - Blanks - When comparing expressions, blank is treated as 0 when comparing. That is, Min(1,Blank() ) returns 0, and Min( -1, Blank() ) returns -1. If both arguments are blank, MIN returns a blank. If either expression returns a value which is not allowed, MIN returns an error. -- TRUE/FALSE values are not supported. If you want to evaluate a column of TRUE/FALSE values, use the MINA function. - +- `TRUE`/`FALSE` values are not supported. If you want to evaluate a column of `TRUE`/`FALSE` values, use the MINA function. + ## Example 1 -The following example returns the smallest value from the calculated column, ResellerMargin. - +The following example returns the smallest value from the calculated column, ResellerMargin. + ```dax -= MIN([ResellerMargin]) += MIN([ResellerMargin]) ``` - + ## Example 2 -The following example returns the smallest value from a column that contains dates and times, TransactionDate. This formula therefore returns the date that is earliest. - +The following example returns the smallest value from a column that contains dates and times, TransactionDate. This formula therefore returns the date that is earliest. + ```dax -= MIN([TransactionDate]) += MIN([TransactionDate]) ``` ## Example 3 -The following example returns the smallest value from the result of two scalar expressions. - +The following example returns the smallest value from the result of two scalar expressions. + ```dax = Min([TotalSales], [TotalPurchases]) ``` -## See also +## Related content -[MINA function](mina-function-dax.md) -[MINX function](minx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +[MINA function](mina-function-dax.md) +[MINX function](minx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/mina-function-dax.md b/query-languages/dax/mina-function-dax.md index 6c7b9471b..254a4b71c 100644 --- a/query-languages/dax/mina-function-dax.md +++ b/query-languages/dax/mina-function-dax.md @@ -1,65 +1,58 @@ --- description: "Learn more about: MINA" -title: "MINA function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MINA function (DAX)" --- # MINA +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the smallest value in a column. - -## Syntax - + +## Syntax + ```dax -MINA() +MINA() ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column for which you want to find the minimum value.| - + +|Term|Definition| +|--------|--------------| +|`column`|The column for which you want to find the minimum value.| + ## Return value -The smallest value. - +The smallest value. + ## Remarks -- The MINA function takes as argument a column that contains numbers, and determines the smallest value as follows: - - If the column contains no values, MINA returns 0 (zero). - - Rows in the column that evaluates to logical values, such as TRUE and FALSE are treated as 1 if TRUE and 0 (zero) if FALSE. - - Empty cells are ignored. - +- The MINA function takes as argument a column that contains numbers, and determines the smallest value as follows: + - If the column contains no values, MINA returns 0 (zero). + - Rows in the column that evaluates to logical values, such as `TRUE` and `FALSE` are treated as 1 if `TRUE` and 0 (zero) if `FALSE`. + - Empty cells are ignored. + - If you want to compare text values, use the MIN function. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example 1 -The following expression returns the minimum freight charge from the table, InternetSales. - +The following expression returns the minimum freight charge from the table, InternetSales. + ```dax -= MINA(InternetSales[Freight]) += MINA(InternetSales[Freight]) ``` - + ## Example 2 -The following expression returns the minimum value in the column, PostalCode. Because the data type of the column is text, the function does not find any values, and the formula returns zero (0). - +The following expression returns the minimum value in the column, PostalCode. Because the data type of the column is text, the function does not find any values, and the formula returns zero (0). + ```dax -= MINA([PostalCode]) += MINA([PostalCode]) ``` - -## See also -[MIN function](min-function-dax.md) -[MINX function](minx-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[MIN function](min-function-dax.md) +[MINX function](minx-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/minute-function-dax.md b/query-languages/dax/minute-function-dax.md index 516444b0a..3f8e974d4 100644 --- a/query-languages/dax/minute-function-dax.md +++ b/query-languages/dax/minute-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: MINUTE" -title: "MINUTE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MINUTE function (DAX)" --- # MINUTE -Returns the minute as a number from 0 to 59, given a date and time value. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the minute as a number from 0 to 59, given a date and time value. + +## Syntax + ```dax -MINUTE() +MINUTE() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|datetime|A **datetime** value or text in an accepted time format, such as 16:48:00 or 4:48 PM.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`datetime`|A `datetime` value or text in an accepted time format, such as 16:48:00 or 4:48 PM.| + ## Return value -An integer number from 0 to 59. - +An integer number from 0 to 59. + ## Remarks -- In contrast to Microsoft Excel, which stores dates and times in a serial numeric format, DAX uses a **datetime** data type for dates and times. You can provide the **datetime** value to the MINUTE function by referencing a column that stores dates and times, by using a date/time function, or by using an expression that returns a date and time. - -- When the **datetime** argument is a text representation of the date and time, the function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. Most locales use the colon (:) as the time separator and any input text using colons as time separators will parse correctly. Verify your locale settings to understand your results. - +- In contrast to Microsoft Excel, which stores dates and times in a serial numeric format, DAX uses a `datetime` data type for dates and times. You can provide the `datetime` value to the MINUTE function by referencing a column that stores dates and times, by using a date/time function, or by using an expression that returns a date and time. + +- When the `datetime` argument is a text representation of the date and time, the function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. Most locales use the colon (:) as the time separator and any input text using colons as time separators will parse correctly. Verify your locale settings to understand your results. + ## Example 1 -The following example returns the minute from the value stored in the **TransactionTime** column of the **Orders** table. - +The following example returns the minute from the value stored in the **TransactionTime** column of the **Orders** table. + ```dax -= MINUTE(Orders[TransactionTime]) += MINUTE(Orders[TransactionTime]) ``` - + ## Example 2 -The following example returns 45, which is the number of minutes in the time 1:45 PM. - +The following example returns 45, which is the number of minutes in the time 1:45 PM. + ```dax -= MINUTE("March 23, 2008 1:45 PM") += MINUTE("March 23, 2008 1:45 PM") ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[HOUR function](hour-function-dax.md) -[YEAR function](year-function-dax.md) -[SECOND function](second-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[HOUR function](hour-function-dax.md) +[YEAR function](year-function-dax.md) +[SECOND function](second-function-dax.md) diff --git a/query-languages/dax/minx-function-dax.md b/query-languages/dax/minx-function-dax.md index 265e9da1a..60c5730b3 100644 --- a/query-languages/dax/minx-function-dax.md +++ b/query-languages/dax/minx-function-dax.md @@ -1,65 +1,61 @@ --- description: "Learn more about: MINX" -title: "MINX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MINX function (DAX)" --- # MINX -Returns the smallest value that results from evaluating an expression for each row of a table. +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the lowest value that results from evaluating an expression for each row of a table. ## Syntax ```dax -MINX(
, < expression>) +MINX(
, < expression>,[]) ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of the table.| - + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of the table.| +|`variant`|(Optional) If `TRUE`, and if there are variant or mixed value types, the lowest value based on ORDER BY ASC is returned.| + ## Return value -A smallest value. - +The lowest value. + ## Remarks -- The MINX function takes as its first argument a table, or an expression that returns a table. The second argument contains the expression that is evaluated for each row of the table. - -- Blank values are skipped. TRUE/FALSE values are not supported. +- The MINX function takes as its first argument a table or an expression that returns a table. The second argument contains the expression that is evaluated for each row of the table. + +- Blank values are skipped. `TRUE`/`FALSE` values are not supported. + +- If the expression has variant or mixed value types such as text and number, then by default MINX considers only numbers. If ` = TRUE`, the minimum value is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example 1 -The following example filters the table, InternetSales, and returns only rows for a specific sales territory. The formula then finds the minimum value in the column, Freight. - +The following example filters the InternetSales table and returns only rows for a specific sales territory. The formula then finds the minimum value in the Freight column. + ```dax -= MINX( FILTER(InternetSales, [SalesTerritoryKey] = 5),[Freight]) += MINX( FILTER(InternetSales, [SalesTerritoryKey] = 5),[Freight]) ``` - + ## Example 2 -The following example uses the same filtered table as in the previous example, but instead of merely looking up values in the column for each row of the filtered table, the function calculates the sum of two columns, Freight and TaxAmt, and returns the smallest value resulting from that calculation. - +The following example uses the same filtered table as in the previous example, but instead of merely looking up values in the column for each row of the filtered table, the function calculates the sum of two columns, Freight and TaxAmt, and returns the lowest value resulting from that calculation. + ```dax -= MINX( FILTER(InternetSales, InternetSales[SalesTerritoryKey] = 5), InternetSales[Freight] + InternetSales[TaxAmt]) += MINX( FILTER(InternetSales, InternetSales[SalesTerritoryKey] = 5), InternetSales[Freight] + InternetSales[TaxAmt]) ``` -In the first example, the names of the columns are unqualified. In the second example, the column names are fully qualified. - -## See also +In the first example, the names of the columns are unqualified. In the second example, the column names are fully qualified. + +## Related content -[MIN function](min-function-dax.md) -[MINA function](mina-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +[MIN function](min-function-dax.md) +[MINA function](mina-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/mod-function-dax.md b/query-languages/dax/mod-function-dax.md index e2c4ed067..3509ff935 100644 --- a/query-languages/dax/mod-function-dax.md +++ b/query-languages/dax/mod-function-dax.md @@ -1,64 +1,57 @@ --- description: "Learn more about: MOD" -title: "MOD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 12/10/2018 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MOD function (DAX)" --- # MOD -Returns the remainder after a number is divided by a divisor. The result always has the same sign as the divisor. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the remainder after a number is divided by a divisor. The result always has the same sign as the divisor. + +## Syntax + ```dax -MOD(, ) +MOD(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number for which you want to find the remainder after the division is performed.| -|divisor|The number by which you want to divide.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number for which you want to find the remainder after the division is performed.| +|`divisor`|The number by which you want to divide.| + ## Return value -A whole number. - +A whole number. + ## Remarks -- If the divisor is 0 (zero), MOD returns an error. You cannot divide by 0. - -- The MOD function can be expressed in terms of the INT function: MOD(n, d) = n - d*INT(n/d) - +- If the divisor is 0 (zero), MOD returns an error. You cannot divide by 0. + +- The MOD function can be expressed in terms of the INT function: MOD(n, d) = n - d*INT(n/d) + ## Example 1 -The following formula returns 1, the remainder of 3 divided by 2. - +The following formula returns 1, the remainder of 3 divided by 2. + ```dax -= MOD(3,2) += MOD(3,2) ``` - + ## Example 2 -The following formula returns -1, the remainder of 3 divided by 2. Note that the sign is always the same as the sign of the divisor. - +The following formula returns -1, the remainder of 3 divided by 2. Note that the sign is always the same as the sign of the divisor. + ```dax -= MOD(-3,-2) += MOD(-3,-2) ``` - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[ROUND function](round-function-dax.md) -[ROUNDUP function](roundup-function-dax.md) -[ROUNDDOWN function](rounddown-function-dax.md) -[MROUND function](mround-function-dax.md) -[INT function](int-function-dax.md) + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[ROUND function](round-function-dax.md) +[ROUNDUP function](roundup-function-dax.md) +[ROUNDDOWN function](rounddown-function-dax.md) +[MROUND function](mround-function-dax.md) +[INT function](int-function-dax.md) diff --git a/query-languages/dax/month-function-dax.md b/query-languages/dax/month-function-dax.md index 33b4e48eb..1a2331e78 100644 --- a/query-languages/dax/month-function-dax.md +++ b/query-languages/dax/month-function-dax.md @@ -1,66 +1,59 @@ --- description: "Learn more about: MONTH" -title: "MONTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MONTH function (DAX)" --- # MONTH -Returns the month as a number from 1 (January) to 12 (December). - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the month as a number from 1 (January) to 12 (December). + +## Syntax + ```dax -MONTH() +MONTH() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|date|A date in **datetime** or text format.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`date`|A date in `datetime` or text format.| + ## Return value -An integer number from 1 to 12. - +An integer number from 1 to 12. + ## Remarks -- In contrast to Microsoft Excel, which stores dates as serial numbers, DAX uses a **datetime** format when working with dates. You can enter the date used as argument to the MONTH function by typing an accepted **datetime** format, by providing a reference to a column that contains dates, or by using an expression that returns a date. - -- Values returned by the YEAR, MONTH and DAY functions will be Gregorian values regardless of the display format for the supplied date value. For example, if the display format of the supplied date is Hijri, the returned values for the YEAR, MONTH and DAY functions will be values associated with the equivalent Gregorian date. - -- When the date argument is a text representation of the date, the function uses the locale and date time settings of the client computer to understand the text value in order to perform the conversion. If the current date time settings represent a date in the format of Month/Day/Year, then the following string "1/8/2009" is interpreted as a datetime value equivalent to January 8th of 2009, and the function yields a result of 1. However, if the current date time settings represent a date in the format of Day/Month/Year, then the same string would be interpreted as a datetime value equivalent to August 1st of 2009, and the function yields a result of 8. - -- If the text representation of the date cannot be correctly converted to a datetime value, the function returns an error. - +- In contrast to Microsoft Excel, which stores dates as serial numbers, DAX uses a `datetime` format when working with dates. You can enter the date used as argument to the MONTH function by typing an accepted `datetime` format, by providing a reference to a column that contains dates, or by using an expression that returns a date. + +- Values returned by the YEAR, MONTH and DAY functions will be Gregorian values regardless of the display format for the supplied date value. For example, if the display format of the supplied date is Hijri, the returned values for the YEAR, MONTH and DAY functions will be values associated with the equivalent Gregorian date. + +- When the date argument is a text representation of the date, the function uses the locale and date time settings of the client computer to understand the text value in order to perform the conversion. If the current date time settings represent a date in the format of Month/Day/Year, then the following string "1/8/2009" is interpreted as a datetime value equivalent to January 8th of 2009, and the function yields a result of 1. However, if the current date time settings represent a date in the format of Day/Month/Year, then the same string would be interpreted as a datetime value equivalent to August 1st of 2009, and the function yields a result of 8. + +- If the text representation of the date cannot be correctly converted to a datetime value, the function returns an error. + ## Example 1 -The following expression returns 3, which is the integer corresponding to March, the month in the **date** argument. - +The following expression returns 3, which is the integer corresponding to March, the month in the `date` argument. + ```dax -= MONTH("March 3, 2008 3:45 PM") += MONTH("March 3, 2008 3:45 PM") ``` - + ## Example 2 -The following expression returns the month from the date in the **TransactionDate** column of the **Orders** table. - +The following expression returns the month from the date in the `TransactionDate` column of the `Orders` table. + ```dax -= MONTH(Orders[TransactionDate]) += MONTH(Orders[TransactionDate]) ``` - -## See also - -[Date and time functions](date-and-time-functions-dax.md) -[HOUR function](hour-function-dax.md) -[MINUTE function](minute-function-dax.md) -[YEAR function](year-function-dax.md) -[SECOND function](second-function-dax.md) + +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[HOUR function](hour-function-dax.md) +[MINUTE function](minute-function-dax.md) +[YEAR function](year-function-dax.md) +[SECOND function](second-function-dax.md) diff --git a/query-languages/dax/movingaverage-function-dax.md b/query-languages/dax/movingaverage-function-dax.md new file mode 100644 index 000000000..dca6df192 --- /dev/null +++ b/query-languages/dax/movingaverage-function-dax.md @@ -0,0 +1,76 @@ +--- +description: "Learn more about: MOVINGAVERAGE" +title: "MOVINGAVERAGE function (DAX)" +ms.service: powerbi +ms.subservice: dax +ms.date: 01/17/2023 +ms.topic: reference +author: masanto-msft +ms.author: masanto +recommendations: false + +--- + +# MOVINGAVERAGE + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Returns a moving average calculated along the given axis of the visual matrix. That is, the average of the given column calculated over the last `windowSize` rows. + +## Syntax + +```dax +MOVINGAVERAGE ( , [, ][, ][, ][, ][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that provides the value for each element.| +|`windowSize`|The number of rows to include in the calculation. Must be a constant value.| +|`includeCurrent`|(Optional) A logical value specifying whether or not to include the current row in the range. Default value is True.| +|`axis`|(Optional) An axis reference, the direction along which the moving average will be calculated. If omitted, the first axis of the Visual Shape definition is used.| +|`orderBy`|(Optional) An ORDERBY() clause with expressions that determine how to sort each partition along the `axis`. If `orderBy` is not provided, the data is sorted by the grouping columns on the default `axis` in ascending order by default.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `axis`.
The supported values are:
  • `DEFAULT`(the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.
| +|`reset`|(Optional) Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +A scalar value, the moving average at the current element of the axis. + +## Remarks + +This function can be used in visual calculations only. + +The `includeCurrent`, `axis`, `orderBy`, `blanks` and `reset` parameters can be omitted. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example 1 + +Given a table that summarizes the total sales for each product category and calendar month, the following DAX query adds a column with the average of total sales for that category in the last 6 months: + +```dax +AvgSalesLast6Months = MOVINGAVERAGE([SalesAmount], 6, Rows) +``` + +The screenshot below shows the visual matrix and the visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-movingaverage.png) + +## Example 2 + +Given the same table, the following DAX query adds a column with the average of total sales for that category in the previous 12 months (not including the current month): + +```dax +AvgSalesPrev12Months = MOVINGAVERAGE([SalesAmount], 12, FALSE, Rows, KEEP) +``` + +## See also + +[INDEX](index-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[RUNNINGSUM](runningsum-function-dax.md) +[WINDOW](window-function-dax.md) diff --git a/query-languages/dax/mround-function-dax.md b/query-languages/dax/mround-function-dax.md index 43f49bc68..7ed69ec60 100644 --- a/query-languages/dax/mround-function-dax.md +++ b/query-languages/dax/mround-function-dax.md @@ -1,70 +1,63 @@ --- description: "Learn more about: MROUND" -title: "MROUND function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "MROUND function (DAX)" --- # MROUND -Returns a number rounded to the desired multiple. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a number rounded to the desired multiple. + +## Syntax + ```dax -MROUND(, ) +MROUND(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number to round.| -|multiple|The multiple of significance to which you want to round the number.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number to round.| +|`multiple`|The multiple of significance to which you want to round the number.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -MROUND rounds up, away from zero, if the remainder of dividing **number** by the specified **multiple** is greater than or equal to half the value of **multiple**. - -## Example: Decimal Places +MROUND rounds up, away from zero, if the remainder of dividing `number` by the specified `multiple` is greater than or equal to half the value of `multiple`. + +## Example: Decimal Places + +The following expression rounds 1.3 to the nearest multiple of .2. The expected result is 1.4. -The following expression rounds 1.3 to the nearest multiple of .2. The expected result is 1.4. - ```dax -= MROUND(1.3,0.2) += MROUND(1.3,0.2) ``` - -## Example: Negative Numbers - -The following expression rounds -10 to the nearest multiple of -3. The expected result is -9. - + +## Example: Negative Numbers + +The following expression rounds -10 to the nearest multiple of -3. The expected result is -9. + ```dax -= MROUND(-10,-3) += MROUND(-10,-3) ``` - -## Example: Error + +## Example: Error The following expression returns an error, because the numbers have different signs. - + ```dax -= MROUND(5,-2) += MROUND(5,-2) ``` - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[ROUND function](round-function-dax.md) -[ROUNDUP function](roundup-function-dax.md) -[ROUNDDOWN function](rounddown-function-dax.md) -[MROUND function](mround-function-dax.md) -[INT function](int-function-dax.md) + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[ROUND function](round-function-dax.md) +[ROUNDUP function](roundup-function-dax.md) +[ROUNDDOWN function](rounddown-function-dax.md) +[MROUND function](mround-function-dax.md) +[INT function](int-function-dax.md) diff --git a/query-languages/dax/naturalinnerjoin-function-dax.md b/query-languages/dax/naturalinnerjoin-function-dax.md index cbe050692..4602a67a3 100644 --- a/query-languages/dax/naturalinnerjoin-function-dax.md +++ b/query-languages/dax/naturalinnerjoin-function-dax.md @@ -1,51 +1,44 @@ --- description: "Learn more about: NATURALINNERJOIN" -title: "NATURALINNERJOIN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/08/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NATURALINNERJOIN function (DAX)" --- # NATURALINNERJOIN - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Performs an inner join of a table with another table. - -## Syntax - + +## Syntax + ```dax -NATURALINNERJOIN(, ) +NATURALINNERJOIN(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|LeftTable|A table expression defining the table on the left side of the join.| -|RightTable|A table expression defining the table on the right side of the join.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`LeftTable`|A table expression defining the table on the left side of the join.| +|`RightTable`|A table expression defining the table on the right side of the join.| + ## Return value -A table which includes only rows for which the values in the common columns specified are present in both tables. The table returned will have the common columns from the left table and other columns from both the tables. - +A table which includes only rows for which the values in the common columns specified are present in both tables. The table returned will have the common columns from the left table and other columns from both the tables. + ## Remarks -- Tables are joined on common columns (by name) in the two tables. If the two tables have no common column names, an error is returned. +- Tables are joined on common columns (by name) in the two tables. If the two tables have no common column names, an error is returned. + +- There is no sort order guarantee for the results. + +- Columns being joined on must have the same data type in both tables. + +- Only columns from the same source table (have the same lineage) are joined on. For example, Products[ProductID], WebSales[ProductdID], StoreSales[ProductdID] with many-to-one relationships between WebSales and StoreSales and the Products table based on the ProductID column, WebSales and StoreSales tables are joined on [ProductID]. -- There is no sort order guarantee for the results. - -- Columns being joined on must have the same data type in both tables. - -- Only columns from the same source table (have the same lineage) are joined on. For example, Products[ProductID], WebSales[ProductdID], StoreSales[ProductdID] with many-to-one relationships between WebSales and StoreSales and the Products table based on the ProductID column, WebSales and StoreSales tables are joined on [ProductID]. - -- Strict comparison semantics are used during join. There is no type coercion; for example, 1 does not equal 1.0. +- Strict comparison semantics are used during join. There is no type coercion; for example, 1 does not equal 1.0. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## See also +## Related content [NATURALLEFTOUTERJOIN](naturalleftouterjoin-function-dax.md) \ No newline at end of file diff --git a/query-languages/dax/naturalleftouterjoin-function-dax.md b/query-languages/dax/naturalleftouterjoin-function-dax.md index 5981ca354..07bc474f2 100644 --- a/query-languages/dax/naturalleftouterjoin-function-dax.md +++ b/query-languages/dax/naturalleftouterjoin-function-dax.md @@ -1,51 +1,44 @@ --- description: "Learn more about: NATURALLEFTOUTERJOIN" -title: "NATURALLEFTOUTERJOIN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/08/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NATURALLEFTOUTERJOIN function (DAX)" --- # NATURALLEFTOUTERJOIN - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Performs a join of the LeftTable with the RightTable by using the Left Outer Join semantics. - -## Syntax - + +## Syntax + ```dax -NATURALLEFTOUTERJOIN(, ) +NATURALLEFTOUTERJOIN(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|LeftTable|A table expression defining the table on the left side of the join.| -|RightTable|A table expression defining the table on the right side of the join.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`LeftTable`|A table expression defining the table on the left side of the join.| +|`RightTable`|A table expression defining the table on the right side of the join.| + ## Return value -A table which includes only rows from RightTable for which the values in the common columns specified are also present in LeftTable. The table returned will have the common columns from the left table and the other columns from both the tables. - +A table which includes only rows from RightTable for which the values in the common columns specified are also present in LeftTable. The table returned will have the common columns from the left table and the other columns from both the tables. + ## Remarks - Tables are joined on common columns (by name) in the two tables. If the two tables have no common column names, an error is returned. -- There is no sort order guarantee for the results. - -- Columns being joined on must have the same data type in both tables. - -- Only columns from the same source table (have the same lineage) are joined on. For example, Products[ProductID], WebSales[ProductdID], StoreSales[ProductdID] with many-to-one relationships between WebSales and StoreSales and the Products table based on the ProductID column, WebSales and StoreSales tables are joined on [ProductID]. - -- Strict comparison semantics are used during join. There is no type coercion; for example, 1 does not equal 1.0. +- There is no sort order guarantee for the results. + +- Columns being joined on must have the same data type in both tables. + +- Only columns from the same source table (have the same lineage) are joined on. For example, Products[ProductID], WebSales[ProductdID], StoreSales[ProductdID] with many-to-one relationships between WebSales and StoreSales and the Products table based on the ProductID column, WebSales and StoreSales tables are joined on [ProductID]. + +- Strict comparison semantics are used during join. There is no type coercion; for example, 1 does not equal 1.0. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## See also +## Related content [NATURALINNERJOIN](naturalinnerjoin-function-dax.md) diff --git a/query-languages/dax/networkdays-dax.md b/query-languages/dax/networkdays-function-dax.md similarity index 54% rename from query-languages/dax/networkdays-dax.md rename to query-languages/dax/networkdays-function-dax.md index fd894fc34..ff47fe11b 100644 --- a/query-languages/dax/networkdays-dax.md +++ b/query-languages/dax/networkdays-function-dax.md @@ -1,18 +1,12 @@ --- description: "Learn more about: NETWORKDAYS" -title: "NETWORKDAYS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.date: 06/20/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NETWORKDAYS function (DAX)" --- # NETWORKDAYS +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the number of whole workdays between two dates (inclusive). Parameters specify which and how many days are weekend days. Weekend days and days specified as holidays are not considered as workdays. ## Syntax @@ -23,12 +17,12 @@ NETWORKDAYS(, [, , ]) ### Parameters -|Term|Definition| -|--------|--------------| -|start_date|A date that represents the start date. The dates for which the difference is to be computed. The start_date can be earlier than, the same as, or later than the end_date.| -|end_date|A date that represents the end date. The dates for which the difference is to be computed. The start_date can be earlier than, the same as, or later than the end_date.| -|weekend|Indicates the days of the week that are weekend days and are not included in the number of whole working days between start_date and end_date. Weekend is a weekend number that specifies when weekends occur.
Weekend number values indicate the following weekend days:
1 or omitted: Saturday, Sunday
2: Sunday, Monday
3: Monday, Tuesday
4: Tuesday, Wednesday
5: Wednesday, Thursday
6: Thursday, Friday
7: Friday, Saturday
11: Sunday only
12: Monday only
13: Tuesday only
14: Wednesday only
15: Thursday only
16: Friday only
17: Saturday only| -|holidays|A column table of one or more dates that are to be excluded from the working day calendar.| +|Term|Definition| +|--------|--------------| +|`start_date`|A date that represents the start date. The dates for which the difference is to be computed. The start_date can be earlier than, the same as, or later than the end_date.| +|`end_date`|A date that represents the end date. The dates for which the difference is to be computed. The start_date can be earlier than, the same as, or later than the end_date.| +|`weekend`|Indicates the days of the week that are weekend days and are not included in the number of whole working days between start_date and end_date. Weekend is a weekend number that specifies when weekends occur.
Weekend number values indicate the following weekend days:
1 or omitted: Saturday, Sunday
2: Sunday, Monday
3: Monday, Tuesday
4: Tuesday, Wednesday
5: Wednesday, Thursday
6: Thursday, Friday
7: Friday, Saturday
11: Sunday only
12: Monday only
13: Tuesday only
14: Wednesday only
15: Thursday only
16: Friday only
17: Saturday only| +|`holidays`|A column table of one or more dates that are to be excluded from the working day calendar.| ## Return Value diff --git a/query-languages/dax/new-dax-functions.md b/query-languages/dax/new-dax-functions.md index 12479edcf..0e5a38382 100644 --- a/query-languages/dax/new-dax-functions.md +++ b/query-languages/dax/new-dax-functions.md @@ -1,14 +1,6 @@ --- description: "Learn more about: New DAX functions" -title: "New DAX functions | Microsoft Docs" -ms.service: powerbi -ms.date: 06/20/2022 -ms.subservice: dax -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "New DAX functions" --- # New DAX functions @@ -18,23 +10,19 @@ While functions and functionality are being updated all the time, only those upd > [!IMPORTANT] > Not all functions are supported in all versions of Power BI Desktop, Analysis Services, and Power Pivot in Excel. New and updated functions are typically first introduced in Power BI Desktop, and then later in Analysis Services, Power Pivot in Excel, and tools. - + ## New functions |Function |Month | Description | |---------|---------|---------| -|[NETWORKDAYS](networkdays-dax.md)| July, 2021 | Returns the number of whole workdays between two dates. | -|[BITAND](bitand-function-dax.md) | November, 2021 | Returns a bitwise 'AND' of two numbers. | -|[BITLSHIFT](bitlshift-function-dax.md) | November, 2021 | Returns a number shifted left by the specified number of bits. | -|[BITOR](bitor-function-dax.md) | November, 2021 | Returns a bitwise 'OR' of two numbers. | -|[BITRSHIFT](bitrshift-function-dax.md) | November, 2021| Returns a number shifted right by the specified number of bits. | -|[BITXOR](bitxor-function-dax.md) | November, 2021 | Returns a bitwise 'XOR' of two numbers. | - -## Updated functions - -|Function | Month |Description| -|---------|---------|---------| -|[CALCULATE](calculate-function-dax.md)| September, 2021 |Support for aggregation functions in boolean filter expressions.| -|[CALCULATETABLE](calculatetable-function-dax.md)| September, 2021 |Support for aggregation functions in boolean filter expressions.| -|[FORMAT](format-function-dax.md)| September, 2021 |Additional locale_name parameter that specifies the name of a locale to be used by format_string.| -|[XIRR](xirr-function-dax.md)| September, 2021 |Additional alternateResult parameter that specifies a result to be returned instead of an error if XIRR cannot determine a solution.| +|[LOOKUPWITHTOTALS](lookupwithtotals-function-dax.md)|June, 2025| Used in visual calculations only. Look up the value when filters are applied. Filters not specified would not be inferred.| +|[LOOKUP](lookup-function-dax.md)|June, 2025| Used in visual calculations only. Look up the value when filters are applied. | +|[FIRST](first-function-dax.md)|January, 2024|Used in visual calculations only. Retrieves a value in the visual matrix from the first row of an axis.| +|[LAST](last-function-dax.md)|January, 2024|Used in visual calculations only. Retrieves a value in the visual matrix from the last row of an axis.| +|[NEXT](next-function-dax.md)|January, 2024|Used in visual calculations only. Retrieves a value in the next row of an axis in the visual matrix.| +|[PREVIOUS](previous-function-dax.md)|January, 2024|Used in visual calculations only. Retrieves a value in the previous row of an axis in the visual matrix. | +|[MATCHBY](matchby-function-dax.md)|May, 2023|Define the columns that are used to to match data and identify the current row, in a window function expression.| +|[RANK](rank-function-dax.md)|April, 2023|Returns the ranking for the current context within the specified partition, sorted by the specified order.| +|[ROWNUMBER](rownumber-function-dax.md)|April, 2023|Returns the unique ranking for the current context within the specified partition, sorted by the specified order.| +|[LINEST](linest-function-dax.md)|February, 2023|Uses the Least Squares method to calculate a straight line that best fits the given data.| +|[LINESTX](linestx-function-dax.md)|February, 2023|Uses the Least Squares method to calculate a straight line that best fits the given data. The data result from expressions evaluated for each row in a table.| diff --git a/query-languages/dax/next-function-dax.md b/query-languages/dax/next-function-dax.md new file mode 100644 index 000000000..9df5d32e3 --- /dev/null +++ b/query-languages/dax/next-function-dax.md @@ -0,0 +1,55 @@ +--- +description: "Learn more about: NEXT" +title: "NEXT function (DAX)" +--- + +# NEXT + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Used in visual calculations only. Retrieves a value in the next element of an axis in the visual matrix. + +## Syntax + +```dax +NEXT ( [, ][, ][, ][, ][, reset] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column to be retrieved.| +|`steps`| (Optional) Indicates the number of rows to go forward to fetch the value. If omitted, **1** is used (the exactly next row).| +|`axis`|(Optional) An axis reference. If omitted, the first axis of the Visual Shape definition is used.| +|`orderBy`|(Optional) An ORDERBY() clause with expressions that determine how to sort each partition along the `axis`. If `orderBy` is not provided, the data is sorted by the grouping columns on the default `axis` in ascending order by default.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `axis`.
The supported values are:
  • `DEFAULT`(the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.
| +|`reset`|(Optional) Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +The value of `column` from the next element of the axis. + +## Remarks + +This function can only be used in a visual calculation. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example + +The following visual calculation returns the sales amount of the next row on ROWS axis, that resets on the lowest parent. + +```dax +NextInternetSalesAmount = NEXT ( [Sum of SalesAmount], ROWS, LowestParent ) +``` + +The screenshot below shows the visual matrix and the visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-next.png) + +## Related content + +[FIRST](first-function-dax.md) +[LAST](last-function-dax.md) +[PREVIOUS](PREVIOUS-function-dax.md) diff --git a/query-languages/dax/nextday-function-dax.md b/query-languages/dax/nextday-function-dax.md index de2130828..a09a1a037 100644 --- a/query-languages/dax/nextday-function-dax.md +++ b/query-languages/dax/nextday-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: NEXTDAY" -title: "NEXTDAY function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NEXTDAY function (DAX)" --- # NEXTDAY -Returns a table that contains a column of all dates from the next day, based on the first date specified in the **dates** column in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of all dates from the next day, based on the first date specified in the `dates` column in the current context. + +## Syntax + ```dax -NEXTDAY() +NEXTDAY() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column containing dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column containing dates.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## Remarks -- This function returns all dates from the next day to the first date in the input parameter. For example, if the first date in the **dates** argument refers to June 10, 2009; then this function returns all dates equal to June 11, 2009. - -- 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. +- This function returns all dates from the next day to the first date in the input parameter. For example, if the first date in the `dates` argument refers to June 10, 2009; then this function returns all dates equal to June 11, 2009. + +- 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](calculate-function-dax.md). -- Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). - - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'next day sales' of Internet sales. - +The following sample formula creates a measure that calculates the 'next day sales' of Internet sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), NEXTDAY('DateTime'[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), NEXTDAY('DateTime'[DateKey])) ``` - -## See also - -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[NEXTQUARTER function](nextquarter-function-dax.md) -[NEXTMONTH function](nextmonth-function-dax.md) -[NEXTYEAR function](nextyear-function-dax.md) + +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[NEXTQUARTER function](nextquarter-function-dax.md) +[NEXTMONTH function](nextmonth-function-dax.md) +[NEXTYEAR function](nextyear-function-dax.md) diff --git a/query-languages/dax/nextmonth-function-dax.md b/query-languages/dax/nextmonth-function-dax.md index a45b0efd5..c0836baf1 100644 --- a/query-languages/dax/nextmonth-function-dax.md +++ b/query-languages/dax/nextmonth-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: NEXTMONTH" -title: "NEXTMONTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NEXTMONTH function (DAX)" --- # NEXTMONTH -Returns a table that contains a column of all dates from the next month, based on the first date in the **dates** column in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of all dates from the next month, based on the first date in the `dates` column in the current context. + +## Syntax + ```dax -NEXTMONTH() +NEXTMONTH() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column containing dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column containing dates.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## Remarks -- This function returns all dates from the next day to the first date in the input parameter. For example, if the first date in the **dates** argument refers to June 10, 2009; then this function returns all dates for the month of July, 2009. - -- 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](calculate-function-dax.md). - +- This function returns all dates from the next day to the first date in the input parameter. For example, if the first date in the `dates` argument refers to June 10, 2009; then this function returns all dates for the month of July, 2009. + +- 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](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'next month sales' for Internet sales. - +The following sample formula creates a measure that calculates the 'next month sales' for Internet sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), NEXTMONTH('DateTime'[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), NEXTMONTH('DateTime'[DateKey])) ``` - -## See also - -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[NEXTDAY function](nextday-function-dax.md) -[NEXTQUARTER function](nextquarter-function-dax.md) -[NEXTYEAR function](nextyear-function-dax.md) + +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[NEXTDAY function](nextday-function-dax.md) +[NEXTQUARTER function](nextquarter-function-dax.md) +[NEXTYEAR function](nextyear-function-dax.md) diff --git a/query-languages/dax/nextquarter-function-dax.md b/query-languages/dax/nextquarter-function-dax.md index efff30c26..3b0caaa3c 100644 --- a/query-languages/dax/nextquarter-function-dax.md +++ b/query-languages/dax/nextquarter-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: NEXTQUARTER" -title: "NEXTQUARTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NEXTQUARTER function (DAX)" --- # NEXTQUARTER -Returns a table that contains a column of all dates in the next quarter, based on the first date specified in the **dates** column, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of all dates in the next quarter, based on the first date specified in the `dates` column, in the current context. + +## Syntax + ```dax -NEXTQUARTER() +NEXTQUARTER() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column containing dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column containing dates.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## Remarks -- This function returns all dates in the next quarter, based on the first date in the input parameter. For example, if the first date in the **dates** column refers to June 10, 2009, this function returns all dates for the quarter July to September, 2009. - -- 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](calculate-function-dax.md). - +- This function returns all dates in the next quarter, based on the first date in the input parameter. For example, if the first date in the `dates` column refers to June 10, 2009, this function returns all dates for the quarter July to September, 2009. + +- 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](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'next quarter sales' for Internet sales. - +The following sample formula creates a measure that calculates the 'next quarter sales' for Internet sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), NEXTQUARTER('DateTime'[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), NEXTQUARTER('DateTime'[DateKey])) ``` - -## See also - -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[NEXTDAY function](nextday-function-dax.md) -[NEXTMONTH function](nextmonth-function-dax.md) -[NEXTYEAR function](nextyear-function-dax.md) + +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[NEXTDAY function](nextday-function-dax.md) +[NEXTMONTH function](nextmonth-function-dax.md) +[NEXTYEAR function](nextyear-function-dax.md) diff --git a/query-languages/dax/nextyear-function-dax.md b/query-languages/dax/nextyear-function-dax.md index cc691b01d..bd2eb405d 100644 --- a/query-languages/dax/nextyear-function-dax.md +++ b/query-languages/dax/nextyear-function-dax.md @@ -1,64 +1,57 @@ --- description: "Learn more about: NEXTYEAR" -title: "NEXTYEAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NEXTYEAR function (DAX)" --- # NEXTYEAR -Returns a table that contains a column of all dates in the next year, based on the first date in the **dates** column, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of all dates in the next year, based on the first date in the `dates` column, in the current context. + +## Syntax + ```dax -NEXTYEAR([,]) +NEXTYEAR([,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column containing dates.| -|year_end_date|(optional) A literal string with a date that defines the year-end date. The default is December 31.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column containing dates.| +|`year_end_date`|(optional) A literal string with a date that defines the year-end date. The default is December 31.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## Remarks -- This function returns all dates in the next year, based on the first date in the input column. For example, if the first date in the **dates** column refers to the year 2007, this function returns all dates for the year 2008. - -- The **dates** argument can be any of the following: +- This function returns all dates in the next year, based on the first date in the input column. For example, if the first date in the `dates` column refers to the year 2007, this function returns all dates for the year 2008. + +- 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](calculate-function-dax.md). - -- The **year_end_date** parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. - + - A Boolean expression that defines a single-column table of date/time values. + +- Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). + +- The `year_end_date` parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'next year sales' for Internet sales. - +The following sample formula creates a measure that calculates the 'next year sales' for Internet sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), NEXTYEAR('DateTime'[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), NEXTYEAR('DateTime'[DateKey])) ``` - -## See also - -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[NEXTDAY function](nextday-function-dax.md) -[NEXTQUARTER function](nextquarter-function-dax.md) -[NEXTMONTH function](nextmonth-function-dax.md) + +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[NEXTDAY function](nextday-function-dax.md) +[NEXTQUARTER function](nextquarter-function-dax.md) +[NEXTMONTH function](nextmonth-function-dax.md) diff --git a/query-languages/dax/nominal-function-dax.md b/query-languages/dax/nominal-function-dax.md index 217bdfcd7..652920c09 100644 --- a/query-languages/dax/nominal-function-dax.md +++ b/query-languages/dax/nominal-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: NOMINAL" -title: "NOMINAL function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "NOMINAL function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # NOMINAL +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the nominal annual interest rate, given the effective rate and the number of compounding periods per year. ## Syntax @@ -24,10 +18,10 @@ NOMINAL(, ) ### Parameters -|Term|Definition| -|--------|--------------| -|effect_rate|The effective interest rate.| -|npery|The number of compounding periods per year.| +|Term|Definition| +|--------|--------------| +|`effect_rate`|The effective interest rate.| +|`npery`|The number of compounding periods per year.| ## Return Value diff --git a/query-languages/dax/nonfilter-function-dax.md b/query-languages/dax/nonfilter-function-dax.md new file mode 100644 index 000000000..1f349a13b --- /dev/null +++ b/query-languages/dax/nonfilter-function-dax.md @@ -0,0 +1,37 @@ +--- +description: "Learn more about: NONFILTER" +title: "NONFILTER function (DAX) | Microsoft Docs" +--- +# NONFILTER + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Modifies how filters are applied while evaluating a GROUPCROSSAPPLY or GROUPCROSSAPPLYTABLE function. + +## Syntax + +```dax +NONFILTER(
) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|table expression|Any table expression.| + +## Return value + +A table of values. + +## Remarks + +- You use NONFILTER within the context GROUPCROSSAPPLY and GROUPCROSSAPPLYTABLE functions, to override the standard behavior of those functions. + +- A NONFILTER makes the table expression permanently hidden from the filter context even if its columns may have lineage. Those columns with lineage act as if they are extension columns. + +## Related content + +[Filter functions](filter-functions-dax.md) +[GROUPCROSSAPPLY function](groupcrossapply-function-dax.md) +[GROUPCROSSAPPLYTABLE function](groupcrossapplytable-function-dax.md) diff --git a/query-languages/dax/nonvisual-function-dax.md b/query-languages/dax/nonvisual-function-dax.md index 43f2bcc59..2ce88bc61 100644 --- a/query-languages/dax/nonvisual-function-dax.md +++ b/query-languages/dax/nonvisual-function-dax.md @@ -1,37 +1,30 @@ --- description: "Learn more about: NONVISUAL" -title: "NONVISUAL function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/01/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NONVISUAL function (DAX)" --- # NONVISUAL +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Marks a value filter in a [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) expression as non-visual. This function can only be used within a [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) expression. -## Syntax - +## Syntax + ```dax NONVISUAL() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -|expression|Any DAX expression that returns a single value (not a table).| +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression`|Any DAX expression that returns a single value (not a table).| ## Return value A table of values. - -## Remarks + +## Remarks - Marks a value filter in [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) as not affecting measure values, but only applying to group-by columns. diff --git a/query-languages/dax/norm-dist-dax.md b/query-languages/dax/norm-dist-dax.md deleted file mode 100644 index a5c248fa9..000000000 --- a/query-languages/dax/norm-dist-dax.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -description: "Learn more about: NORM.DIST" -title: "NORM.DIST function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# NORM.DIST - -Returns the normal distribution for the specified mean and standard deviation. - -## Syntax - -```dax -NORM.DIST(X, Mean, Standard_dev, Cumulative) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|X|The value for which you want the distribution.| -|Mean |The arithmetic mean of the distribution.| -|Standard_dev|The standard deviation of the distribution.| -|Cumulative*|A logical value that determines the form of the function. If cumulative is TRUE, NORM.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.| - -## Return value - -The normal distribution for the specified mean and standard deviation. - -## Remarks - -[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -```dax -EVALUATE { NORM.DIST(42, 40, 1.5, TRUE) } -``` - -Returns - -|[Value] | -|---------| -|0.908788780274132 | - - -## See also - -[NORM.S.DIST function](norm-s-dist-dax.md) -[NORM.INV function](norm-inv-dax.md) -[NORM.S.INV](norm-s-inv-dax.md) diff --git a/query-languages/dax/norm-dist-function-dax.md b/query-languages/dax/norm-dist-function-dax.md new file mode 100644 index 000000000..7393962f1 --- /dev/null +++ b/query-languages/dax/norm-dist-function-dax.md @@ -0,0 +1,50 @@ +--- +description: "Learn more about: NORM.DIST" +title: "NORM.DIST function (DAX)" +--- +# NORM.DIST + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the normal distribution for the specified mean and standard deviation. + +## Syntax + +```dax +NORM.DIST(X, Mean, Standard_dev, Cumulative) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`X`|The value for which you want the distribution.| +|`Mean`|The arithmetic mean of the distribution.| +|`Standard_dev`|The standard deviation of the distribution.| +|`Cumulative*`|A logical value that determines the form of the function. If cumulative is `TRUE`, NORM.DIST returns the cumulative distribution function; if `FALSE`, it returns the probability density function.| + +## Return value + +The normal distribution for the specified mean and standard deviation. + +## Remarks + +[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +```dax +EVALUATE { NORM.DIST(42, 40, 1.5, TRUE) } +``` + +Returns + +|[Value] | +|---------| +|0.908788780274132 | + +## Related content + +[NORM.S.DIST function](norm-s-dist-function-dax.md) +[NORM.INV function](norm-inv-function-dax.md) +[NORM.S.INV](norm-s-inv-function-dax.md) diff --git a/query-languages/dax/norm-inv-dax.md b/query-languages/dax/norm-inv-dax.md deleted file mode 100644 index ed0c2a5ff..000000000 --- a/query-languages/dax/norm-inv-dax.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -description: "Learn more about: NORM.INV" -title: "NORM.INV function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# NORM.INV - -The inverse of the normal cumulative distribution for the specified mean and standard deviation. - - -## Syntax - -```dax -NORM.INV(Probability, Mean, Standard_dev) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Probability|A probability corresponding to the normal distribution.| -|Mean|The arithmetic mean of the distribution.| -|Standard_dev|The standard deviation of the distribution.| - -## Return value - -Returns the inverse of the normal cumulative distribution for the specified mean and standard deviation. - -## Remarks - -[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -```dax -EVALUATE { NORM.INV(0.908789, 40, 1.5) } -``` - -Returns - -|[Value] | -|---------| -|42.00000200956628780274132 | - -## See also - -[NORM.S.INV](norm-s-inv-dax.md) -[NORM.S.DIST function](norm-s-dist-dax.md) -[NORM.DIST function](norm-dist-dax.md) diff --git a/query-languages/dax/norm-inv-function-dax.md b/query-languages/dax/norm-inv-function-dax.md new file mode 100644 index 000000000..c59023be2 --- /dev/null +++ b/query-languages/dax/norm-inv-function-dax.md @@ -0,0 +1,50 @@ +--- +description: "Learn more about: NORM.INV" +title: "NORM.INV function (DAX)" +--- +# NORM.INV + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +The inverse of the normal cumulative distribution for the specified mean and standard deviation. + + +## Syntax + +```dax +NORM.INV(Probability, Mean, Standard_dev) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Probability`|A probability corresponding to the normal distribution.| +|`Mean`|The arithmetic mean of the distribution.| +|`Standard_dev`|The standard deviation of the distribution.| + +## Return value + +Returns the inverse of the normal cumulative distribution for the specified mean and standard deviation. + +## Remarks + +[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +```dax +EVALUATE { NORM.INV(0.908789, 40, 1.5) } +``` + +Returns + +|[Value] | +|---------| +|42.00000200956628780274132 | + +## Related content + +[NORM.S.INV](norm-s-inv-function-dax.md) +[NORM.S.DIST function](norm-s-dist-function-dax.md) +[NORM.DIST function](norm-dist-function-dax.md) diff --git a/query-languages/dax/norm-s-dist-dax.md b/query-languages/dax/norm-s-dist-dax.md deleted file mode 100644 index 48371bafd..000000000 --- a/query-languages/dax/norm-s-dist-dax.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -description: "Learn more about: NORM.S.DIST" -title: "NORM.S.DIST function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# NORM.S.DIST - -Returns the standard normal distribution (has a mean of zero and a standard deviation of one). - -## Syntax - -```dax -NORM.S.DIST(Z, Cumulative) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Z|The value for which you want the distribution.| -|Cumulative|Cumulative is a logical value that determines the form of the function. If cumulative is TRUE, NORM.S.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.| - -## Return value - -The standard normal distribution (has a mean of zero and a standard deviation of one. - -## Remarks - -[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -```dax -EVALUATE { NORM.S.DIST(1.333333, TRUE) } -``` - -Returns - -|[Value] | -|---------| -|0.908788725604095 | - -## See also - -[NORM.INV function](norm-inv-dax.md) -[NORM.DIST function](norm-dist-dax.md) -[NORM.S.INV](norm-s-inv-dax.md) diff --git a/query-languages/dax/norm-s-dist-function-dax.md b/query-languages/dax/norm-s-dist-function-dax.md new file mode 100644 index 000000000..dcd0a363d --- /dev/null +++ b/query-languages/dax/norm-s-dist-function-dax.md @@ -0,0 +1,48 @@ +--- +description: "Learn more about: NORM.S.DIST" +title: "NORM.S.DIST function (DAX)" +--- +# NORM.S.DIST + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the standard normal distribution (has a mean of zero and a standard deviation of one). + +## Syntax + +```dax +NORM.S.DIST(Z, Cumulative) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Z`|The value for which you want the distribution.| +|`Cumulative`|Cumulative is a logical value that determines the form of the function. If cumulative is `TRUE`, NORM.S.DIST returns the cumulative distribution function; if `FALSE`, it returns the probability density function.| + +## Return value + +The standard normal distribution (has a mean of zero and a standard deviation of one. + +## Remarks + +[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +```dax +EVALUATE { NORM.S.DIST(1.333333, TRUE) } +``` + +Returns + +|[Value] | +|---------| +|0.908788725604095 | + +## Related content + +[NORM.INV function](norm-inv-function-dax.md) +[NORM.DIST function](norm-dist-function-dax.md) +[NORM.S.INV](norm-s-inv-function-dax.md) diff --git a/query-languages/dax/norm-s-inv-dax.md b/query-languages/dax/norm-s-inv-function-dax.md similarity index 54% rename from query-languages/dax/norm-s-inv-dax.md rename to query-languages/dax/norm-s-inv-function-dax.md index 139a82be0..c2649b490 100644 --- a/query-languages/dax/norm-s-inv-dax.md +++ b/query-languages/dax/norm-s-inv-function-dax.md @@ -1,42 +1,35 @@ --- description: "Learn more about: NORM.S.INV" -title: "NORM.S.INV function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NORM.S.INV function (DAX)" --- # NORM.S.INV +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the inverse of the standard normal cumulative distribution. The distribution has a mean of zero and a standard deviation of one. -## Syntax - +## Syntax + ```dax NORM.S.INV(Probability) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Probability|A probability corresponding to the normal distribution.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Probability`|A probability corresponding to the normal distribution.| + ## Return value The inverse of the standard normal cumulative distribution. The distribution has a mean of zero and a standard deviation of one. - + ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - +## Example + ```dax EVALUATE { NORM.S.INV(0.908789) } ``` @@ -47,8 +40,8 @@ Returns |---------| |1.33333467304411 | -## See also +## Related content -[NORM.INV](norm-inv-dax.md) -[NORM.S.DIST function](norm-s-dist-dax.md) -[NORM.DIST function](norm-dist-dax.md) +[NORM.INV](norm-inv-function-dax.md) +[NORM.S.DIST function](norm-s-dist-function-dax.md) +[NORM.DIST function](norm-dist-function-dax.md) diff --git a/query-languages/dax/not-function-dax.md b/query-languages/dax/not-function-dax.md index dca889af3..53c4e1468 100644 --- a/query-languages/dax/not-function-dax.md +++ b/query-languages/dax/not-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: NOT" -title: "NOT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NOT function (DAX)" --- # NOT -Changes FALSE to TRUE, or TRUE to FALSE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Changes `FALSE` to `TRUE`, or `TRUE` to `FALSE`. + +## Syntax + ```dax -NOT() +NOT() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|logical|A value or expression that can be evaluated to TRUE or FALSE.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`logical`|A value or expression that can be evaluated to `TRUE` or `FALSE`.| + ## Return value -TRUE OR FALSE. - +`TRUE` OR `FALSE`. + ## Example -The following example retrieves values from the calculated column that was created to illustrate the IF function. For that example, the calculated column was named using the default name, **Calculated Column1**, and contains the following formula: `= IF([Orders]<300,"true","false")` - -The formula checks the value in the column, [Orders], and returns "true" if the number of orders is under 300. - -Now create a new calculated column, **Calculated Column2**, and type the following formula. - +The following example retrieves values from the calculated column that was created to illustrate the IF function. For that example, the calculated column was named using the default name, **Calculated Column1**, and contains the following formula: `= IF([Orders]<300,"true","false")` + +The formula checks the value in the column, [Orders], and returns "true" if the number of orders is under 300. + +Now create a new calculated column, **Calculated Column2**, and type the following formula. + ```dax -= NOT([CalculatedColumn1]) += NOT([CalculatedColumn1]) ``` -For each row in **Calculated Column1**, the values "true" and "false" are interpreted as the logical values TRUE or FALSE, and the NOT function returns the logical opposite of that value. - -## See also +For each row in **Calculated Column1**, the values "true" and "false" are interpreted as the logical values `TRUE` or `FALSE`, and the NOT function returns the logical opposite of that value. + +## Related content -[TRUE function](true-function-dax.md) -[FALSE function](false-function-dax.md) -[IF function](if-function-dax.md) +[TRUE function](true-function-dax.md) +[FALSE function](false-function-dax.md) +[IF function](if-function-dax.md) diff --git a/query-languages/dax/now-function-dax.md b/query-languages/dax/now-function-dax.md index 2b860d9d0..ea62b9580 100644 --- a/query-languages/dax/now-function-dax.md +++ b/query-languages/dax/now-function-dax.md @@ -1,49 +1,42 @@ --- description: "Learn more about: NOW" -title: "NOW function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/08/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "NOW function (DAX)" --- # NOW -Returns the current date and time in **datetime** format. - -The NOW function is useful when you need to display the current date and time on a worksheet or calculate a value based on the current date and time, and have that value updated each time you open the worksheet. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the current date and time in `datetime` format. + +The NOW function is useful when you need to display the current date and time on a worksheet or calculate a value based on the current date and time, and have that value updated each time you open the worksheet. + +## Syntax + ```dax -NOW() +NOW() ``` - + ## Return value -A date (**datetime)**. - -## Remarks +A date (`datetime)`. + +## Remarks + +- The result of the `NOW` function changes only when the column that contains the formula is refreshed. It is not updated continuously. -- The result of the NOW function changes only when the column that contains the formula is refreshed. It is not updated continuously. +- In the Power BI Service, the result of the `NOW` function is always in the UTC timezone. -- In the Power BI Service, the result of the NOW function is always in the UTC timezone. +- The `TODAY` function returns the same date but is not precise with regard to time; the time returned is always 12:00:00 AM and only the date is updated. -- The TODAY function returns the same date but is not precise with regard to time; the time returned is always 12:00:00 AM and only the date is updated. - ## Example -The following example returns the current date and time plus 3.5 days: - +The following example returns the current date and time plus 3.5 days: + ```dax -= NOW()+3.5 += NOW()+3.5 ``` - -## See also -[UTCNOW function](utcnow-function-dax.md) -[TODAY function](today-function-dax.md) +## Related content + +[UTCNOW function](utcnow-function-dax.md) +[TODAY function](today-function-dax.md) diff --git a/query-languages/dax/nper-function-dax.md b/query-languages/dax/nper-function-dax.md index e9b5167d4..432fc118b 100644 --- a/query-languages/dax/nper-function-dax.md +++ b/query-languages/dax/nper-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: NPER" -title: "NPER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "NPER function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # NPER +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the number of periods for an investment based on periodic, constant payments and a constant interest rate. ## Syntax @@ -24,15 +18,15 @@ NPER(, , [, [, ]]) ### Parameters -|Term|Definition| -|--------|--------------| -|rate|The interest rate per period.| -|pmt|The payment made each period; it cannot change over the life of the annuity. Typically, pmt contains principal and interest but no other fees or taxes.| -|pv|The present value, or the lump-sum amount that a series of future payments is worth right now.| -|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 and indicates when payments are due. If type is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`rate`|The interest rate per period.| +|`pmt`|The payment made each period; it cannot change over the life of the annuity. Typically, pmt contains principal and interest but no other fees or taxes.| +|`pv`|The present value, or the lump-sum amount that a series of future payments is worth right now.| +|`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 and indicates when payments are due. If type is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **type** parameter accepts the following values: +The `type` parameter accepts the following values: | **Set type equal to** | **If payments are due** | | --------------------- | ------------------------------ | diff --git a/query-languages/dax/odd-function-dax.md b/query-languages/dax/odd-function-dax.md index 04aefc4fc..5a2dd07be 100644 --- a/query-languages/dax/odd-function-dax.md +++ b/query-languages/dax/odd-function-dax.md @@ -1,50 +1,43 @@ --- description: "Learn more about: ODD" -title: "ODD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ODD function (DAX)" --- # ODD -Returns number rounded up to the nearest odd integer. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns number rounded up to the nearest odd integer. + +## Syntax + ```dax -ODD(number) +ODD(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Required. The value to round.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Required. The value to round.| + ## Return value -Returns number rounded up to the nearest odd integer. - +Returns number rounded up to the nearest odd integer. + ## Remarks -- If number is nonnumeric, ODD returns the #VALUE! error value. - -- Regardless of the sign of number, a value is rounded up when adjusted away from zero. If number is an odd integer, no rounding occurs. +- If `number` is nonnumeric, ODD returns the `#VALUE!` error value. + +- Regardless of the sign of number, a value is rounded up when adjusted away from zero. If number is an odd integer, no rounding occurs. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= ODD(1.5)|Rounds 1.5 up to the nearest odd integer.|3| -|= ODD(3)|Rounds 3 up to the nearest odd integer.|3| -|= ODD(2)|Rounds 2 up to the nearest odd integer.|3| -|= ODD(-1)|Rounds -1 up to the nearest odd integer.|-1| -|= ODD(-2)|Rounds -2 up (away from 0) to the nearest odd integer.|-3| +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= ODD(1.5)`|Rounds 1.5 up to the nearest odd integer.|3| +|`= ODD(3)`|Rounds 3 up to the nearest odd integer.|3| +|`= ODD(2)`|Rounds 2 up to the nearest odd integer.|3| +|`= ODD(-1)`|Rounds -1 up to the nearest odd integer.|-1| +|`= ODD(-2)`|Rounds -2 up (away from 0) to the nearest odd integer.|-3| diff --git a/query-languages/dax/oddfprice-function-dax.md b/query-languages/dax/oddfprice-function-dax.md index 0178de7dd..3e7a598d3 100644 --- a/query-languages/dax/oddfprice-function-dax.md +++ b/query-languages/dax/oddfprice-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: ODDFPRICE" -title: "ODDFPRICE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "ODDFPRICE function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # ODDFPRICE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the price per \\$100 face value of a security having an odd (short or long) first period. ## Syntax @@ -24,21 +18,21 @@ ODDFPRICE(, , , , , , , , , , , , first_coupon > settlement > issue is not satisfied. - - rate < 0. - - pr ≤ 0. - - redemption ≤ 0. - - frequency is any number other than 1, 2, or 4. - - basis < 0 or basis > 4. + - `settlement`, `maturity`, `issue`, or `first_coupon` is not a valid date. + - `maturity` > `first_coupon` > `settlement` > `issue` is not satisfied. + - `rate` < 0. + - `pr` ≤ 0. + - `redemption` ≤ 0. + - `frequency` is any number other than 1, 2, or 4. + - `basis` < 0 or `basis` > 4. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/oddlprice-function-dax.md b/query-languages/dax/oddlprice-function-dax.md index 2e2869a1c..0dcb49f44 100644 --- a/query-languages/dax/oddlprice-function-dax.md +++ b/query-languages/dax/oddlprice-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: ODDLPRICE" -title: "ODDLPRICE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "ODDLPRICE function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # ODDLPRICE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the price per \\$100 face value of a security having an odd (short or long) last coupon period. ## Syntax @@ -24,20 +18,20 @@ ODDLPRICE(, , , , , ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|last_interest|The security's last coupon date.| -|rate|The security's interest rate.| -|yld|The security's annual yield.| -|redemption|The security's redemption value per \\$100 face value.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`last_interest`|The security's last coupon date.| +|`rate`|The security's interest rate.| +|`yld`|The security's annual yield.| +|`redemption`|The security's redemption value per \\$100 face value.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/oddlyield-function-dax.md b/query-languages/dax/oddlyield-function-dax.md index bd158111d..a77bd26ad 100644 --- a/query-languages/dax/oddlyield-function-dax.md +++ b/query-languages/dax/oddlyield-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: ODDLYIELD" -title: "ODDLYIELD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "ODDLYIELD function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # ODDLYIELD +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the yield of a security that has an odd (short or long) last period. ## Syntax @@ -24,20 +18,20 @@ ODDLYIELD(, , , , , , ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|last_interest|The security's last coupon date.| -|rate|The security's interest rate.| -|pr|The security's price.| -|redemption|The security's redemption value per \\$100 face value.| -|frequency|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`last_interest`|The security's last coupon date.| +|`rate`|The security's interest rate.| +|`pr`|The security's price.| +|`redemption`|The security's redemption value per \\$100 face value.| +|`frequency`|The number of coupon payments per year. For annual payments, frequency = 1; for semiannual, frequency = 2; for quarterly, frequency = 4.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/offset-function-dax.md b/query-languages/dax/offset-function-dax.md new file mode 100644 index 000000000..5640c1339 --- /dev/null +++ b/query-languages/dax/offset-function-dax.md @@ -0,0 +1,159 @@ +--- +description: "Learn more about: OFFSET" +title: "OFFSET function (DAX)" +--- + +# OFFSET + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a single row that is positioned either before or after the *current row* within the same table, by a given offset. If the current row cannot be deduced to a single row, multiple rows may be returned. + +## Syntax + +```dax +OFFSET ( [, or ][, ][, ][, ][, ][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`delta`|The number of rows before (negative value) or after (positive value) the current row from which to obtain the data. It can be any DAX expression that returns a scalar value. | +|`relation`|(Optional) A table expression from which the output row is returned. If used in visual calculations, this parameter accepts an axis in the visual shape.
If specified, all columns in `partitionBy` must come from it or a related table.
If omitted:
- `orderBy` must be explicitly specified.
- All `orderBy` and `partitionBy` expressions must be fully qualified column names and come from a single table.
- Defaults to ALLSELECTED() of all columns in `orderBy` and `partitionBy`.| +|`orderBy`|(Optional) An ORDERBY() clause containing the expressions that define how each partition is sorted.
If omitted:
- `relation` must be explicitly specified.
- Defaults to ordering by every column in `relation` that is not already specified in `partitionBy`.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `relation` or `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.

Note, when the `blanks` parameter and blanks in the [ORDERBY()](orderby-function-dax.md) function on individual expressions are both specified, `blanks` on individual orderBy expression takes priority for the relevant orderBy expression, and orderBy expressions without `blanks` being specified will honor the `blanks` parameter on the parent function.| +|`partitionBy`|(Optional) A [PARTITIONBY()](partitionby-function-dax.md) clause containing the columns that define how `relation` is partitioned. If omitted, `relation` is treated as a single partition.| +|`matchBy`|(Optional) A [MATCHBY()](matchby-function-dax.md) clause containing the columns that define how to match data and identify the current row.| +|`reset`|(Optional) Available in visual calculations only. Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +One or more rows from `relation`. + +## Remarks + +Except for columns added by DAX table functions, each column in `relation`, when `matchBy` is not present, or each column in `matchBy` and `partitionBy`, when `matchBy` is present, must have a corresponding outer value to help define the current row on which to operate, with the following behavior: + +- If there is exactly one corresponding outer column, its value is used. +- If there is no corresponding outer column, then: + - OFFSET will first determine all columns that have no corresponding outer column. + - For every combination of existing values for these columns in OFFSET’s parent context, OFFSET is evaluated and a row is returned. + - OFFSET’s final output is a union of these rows. +- If there is more than one corresponding outer column, an error is returned. + +If all of `relation`'s columns were added by DAX table functions, an error is returned. + +If `matchBy` is present, OFFSET will try to use `matchBy` and `partitionBy` columns to identify the row. +If `matchBy` is not present and the columns specified within `orderBy` and `partitionBy` can't uniquely identify every row in `relation`, then: + +- OFFSET will try to find the least number of additional columns required to uniquely identify every row. +- If such columns can be found, OFFSET will automatically append these new columns to `orderBy`, and each partition is sorted using this new set of OrderBy columns. +- If such columns cannot be found, an error is returned. + +An empty table is returned if: + +- The corresponding outer value of an OrderBy or PartitionBy column does not exist within `relation`. +- The `delta` value causes a shift to a row that does not exist within the partition. + +If OFFSET is used within a calculated column defined on the same table as `relation`, and `orderBy` is omitted, an error is returned. + +`reset` can be used in visual calculations only, and cannot be used in combination with `orderBy` or `partitionBy`. If `reset` is present, `axis` can be specified but `relation` cannot. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example 1 - calculated column + +The following DAX query: + +```dax +DEFINE +VAR vRelation = SUMMARIZECOLUMNS ( + DimProductCategory[EnglishProductCategoryName], + DimDate[CalendarYear], + "CurrentYearSales", SUM(FactInternetSales[SalesAmount]) + ) +EVALUATE +ADDCOLUMNS ( + vRelation, + "PreviousYearSales", + SELECTCOLUMNS( + OFFSET ( + -1, + vRelation, + ORDERBY([CalendarYear]), + PARTITIONBY([EnglishProductCategoryName]) + ), + [CurrentYearSales] + ) +) + +``` + +Returns a table that summarizes the total sales for each product category and calendar year, as well as the total sales for that category in the previous year. + +## Example 2 - measure + +The following DAX query: + +```dax +DEFINE +MEASURE DimProduct[CurrentYearSales] = SUM(FactInternetSales[SalesAmount]) +MEASURE DimProduct[PreviousYearSales] = CALCULATE(SUM(FactInternetSales[SalesAmount]), OFFSET(-1, , ORDERBY(DimDate[CalendarYear]))) +EVALUATE +SUMMARIZECOLUMNS ( + DimDate[CalendarYear], + "CurrentYearSales", DimProduct[CurrentYearSales], + "PreviousYearSales", DimProduct[PreviousYearSales] +) +``` + +Uses OFFSET() in a measure to return a table that summarizes the total sales for each calendar year and the total sales for the previous year. + +## Example 3 - calculated column + +The following DAX query: + +```dax +EVALUATE +ADDCOLUMNS ( + FactInternetSales, + "Previous Sales Amount", + SELECTCOLUMNS ( + OFFSET ( + -1, + FactInternetSales, + ORDERBY ( FactInternetSales[SalesAmount], DESC ), + PARTITIONBY ( FactInternetSales[ProductKey] ), + MATCHBY( FactInternetSales[SalesOrderNumber], FactInternetSales[SalesOrderLineNumber] ) + ), + FactInternetSales[SalesAmount] + ) +) +``` + +Returns FactInternetSales table with adding a column, which indicates, for each sale, its previous sale's amount, of the same product, in descending order of sales amount, with current sale being identified by its SalesOrderNumber and SalesOrderLineNumber. Without MATCHBY, the query would return an error since there are no key columns in FactInternetSales table. + +## Example 4 - visual calculation + +The following visual calculation DAX query: + +```dax +SalesRelativeToPreviousMonth = [SalesAmount] - CALCULATE(SUM([SalesAmount]), OFFSET(-1, ROWS, HIGHESTPARENT)) +``` + +Returns the difference in total sales between each month and the previous one within the same year. + +The screenshot below shows the visual matrix and the visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-offset.png) + +## Related content + +[INDEX](index-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[MATCHBY](matchby-function-dax.md) +[WINDOW](window-function-dax.md) +[RANK](rank-function-dax.md) +[ROWNUMBER](rownumber-function-dax.md) diff --git a/query-languages/dax/openingbalancemonth-function-dax.md b/query-languages/dax/openingbalancemonth-function-dax.md index fba54749a..e79181c81 100644 --- a/query-languages/dax/openingbalancemonth-function-dax.md +++ b/query-languages/dax/openingbalancemonth-function-dax.md @@ -1,62 +1,55 @@ --- description: "Learn more about: OPENINGBALANCEMONTH" -title: "OPENINGBALANCEMONTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "OPENINGBALANCEMONTH function (DAX)" --- # OPENINGBALANCEMONTH -Evaluates the **expression** at the first date of the month in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Evaluates the `expression` at the date corresponding to the end of the previous month in the current context. + +## Syntax + ```dax -OPENINGBALANCEMONTH(,[,]) +OPENINGBALANCEMONTH(,[,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|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.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`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. - +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](calculate-function-dax.md). - -- The **filter** expression has restrictions described in the topic, [CALCULATE function](calculate-function-dax.md). +- 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](calculate-function-dax.md). + +- The `filter` expression has restrictions described in the topic, [CALCULATE function](calculate-function-dax.md). - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'Month Start Inventory Value' of the product inventory. - +The following sample formula creates a measure that calculates the 'Month Start Inventory Value' of the product inventory. + ```dax -= OPENINGBALANCEMONTH(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) += OPENINGBALANCEMONTH(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) ``` - -## See also -[OPENINGBALANCEYEAR function](openingbalanceyear-function-dax.md) -[OPENINGBALANCEQUARTER function](openingbalancequarter-function-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[CLOSINGBALANCEMONTH function](closingbalancemonth-function-dax.md) +## Related content + +[OPENINGBALANCEYEAR function](openingbalanceyear-function-dax.md) +[OPENINGBALANCEQUARTER function](openingbalancequarter-function-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[CLOSINGBALANCEMONTH function](closingbalancemonth-function-dax.md) diff --git a/query-languages/dax/openingbalancequarter-function-dax.md b/query-languages/dax/openingbalancequarter-function-dax.md index cbe63b0ed..97ddd3ff8 100644 --- a/query-languages/dax/openingbalancequarter-function-dax.md +++ b/query-languages/dax/openingbalancequarter-function-dax.md @@ -1,62 +1,55 @@ --- description: "Learn more about: OPENINGBALANCEQUARTER" -title: "OPENINGBALANCEQUARTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "OPENINGBALANCEQUARTER function (DAX)" --- # OPENINGBALANCEQUARTER -Evaluates the **expression** at the first date of the quarter, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Evaluates the `expression` at the date corresponding to the end of the previous quarter in the current context. + +## Syntax + ```dax -OPENINGBALANCEQUARTER(,[,]) +OPENINGBALANCEQUARTER(,[,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|expression|An expression that returns a scalar value.| -|dates|A column that contains dates.| -|filte*|(optional) An expression that specifies a filter to apply to the current context.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`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 quarter in the current context. - +A scalar value that represents the `expression` evaluated at the first date of the quarter in the current context. + ## Remarks -- The **dates** argument can be any of the following: - - A reference to a date/time column. +- 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](calculate-function-dax.md). - -- The **filter** expression has restrictions described in the topic, [CALCULATE function](calculate-function-dax.md). + - A Boolean expression that defines a single-column table of date/time values. + +- Constraints on Boolean expressions are described in the topic, [CALCULATE function](calculate-function-dax.md). + +- The `filter` expression has restrictions described in the topic, [CALCULATE function](calculate-function-dax.md). - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'Quarter Start Inventory Value' of the product inventory. - +The following sample formula creates a measure that calculates the 'Quarter Start Inventory Value' of the product inventory. + ```dax -= OPENINGBALANCEQUARTER(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) += OPENINGBALANCEQUARTER(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) ``` - -## See also -[OPENINGBALANCEYEAR function](openingbalanceyear-function-dax.md) -[OPENINGBALANCEMONTH function](openingbalancemonth-function-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[CLOSINGBALANCEQUARTER function](closingbalancequarter-function-dax.md) +## Related content + +[OPENINGBALANCEYEAR function](openingbalanceyear-function-dax.md) +[OPENINGBALANCEMONTH function](openingbalancemonth-function-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[CLOSINGBALANCEQUARTER function](closingbalancequarter-function-dax.md) diff --git a/query-languages/dax/openingbalanceyear-function-dax.md b/query-languages/dax/openingbalanceyear-function-dax.md index 7f22aedc5..cae39c56f 100644 --- a/query-languages/dax/openingbalanceyear-function-dax.md +++ b/query-languages/dax/openingbalanceyear-function-dax.md @@ -1,65 +1,58 @@ --- description: "Learn more about: OPENINGBALANCEYEAR" -title: "OPENINGBALANCEYEAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "OPENINGBALANCEYEAR function (DAX)" --- # OPENINGBALANCEYEAR -Evaluates the **expression** at the first date of the year in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Evaluates the `expression` at the date corresponding to the end of the previous year in the current context. + +## Syntax + ```dax -OPENINGBALANCEYEAR(,[,][,]) +OPENINGBALANCEYEAR(,[,][,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|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.| -|year_end_date|(optional) A literal string with a date that defines the year-end date. The default is December 31.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`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.| +|`year_end_date`|(optional) A literal string with a date that defines the year-end date. The default is December 31.| + ## Return value -A scalar value that represents the **expression** evaluated at the first date of the year in the current context. - +A scalar value that represents the `expression` evaluated at the first date of the year 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](calculate-function-dax.md). - -- The **filter** expression has restrictions described in the topic, [CALCULATE function](calculate-function-dax.md). - -- The **year_end_date** parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. - +- 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](calculate-function-dax.md). + +- The `filter` expression has restrictions described in the topic, [CALCULATE function](calculate-function-dax.md). + +- The `year_end_date` parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'Year Start Inventory Value' of the product inventory. - +The following sample formula creates a measure that calculates the 'Year Start Inventory Value' of the product inventory. + ```dax -= OPENINGBALANCEYEAR(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) += OPENINGBALANCEYEAR(SUMX(ProductInventory,ProductInventory[UnitCost]*ProductInventory[UnitsBalance]),DateTime[DateKey]) ``` - -## See also -[OPENINGBALANCEQUARTER function](openingbalancequarter-function-dax.md) -[OPENINGBALANCEMONTH function](openingbalancemonth-function-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[CLOSINGBALANCEYEAR function](closingbalanceyear-function-dax.md) +## Related content + +[OPENINGBALANCEQUARTER function](openingbalancequarter-function-dax.md) +[OPENINGBALANCEMONTH function](openingbalancemonth-function-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[CLOSINGBALANCEYEAR function](closingbalanceyear-function-dax.md) diff --git a/query-languages/dax/or-function-dax.md b/query-languages/dax/or-function-dax.md index 033b71e7a..d00603b88 100644 --- a/query-languages/dax/or-function-dax.md +++ b/query-languages/dax/or-function-dax.md @@ -1,79 +1,72 @@ --- description: "Learn more about: OR" -title: "OR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "OR function (DAX)" --- # OR -Checks whether one of the arguments is TRUE to return TRUE. The function returns FALSE if both arguments are FALSE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Checks whether one of the arguments is `TRUE` to return `TRUE`. The function returns `FALSE` if both arguments are `FALSE`. + +## Syntax + ```dax -OR(,) +OR(,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|logical_1, logical_2|The logical values you want to test.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`logical_1, logical_2`|The logical values you want to test.| + ## Return value -A Boolean value. The value is TRUE if any of the two arguments is TRUE; the value is FALSE if both the arguments are FALSE. - +A Boolean value. The value is `TRUE` if any of the two arguments is `TRUE`; the value is FALSE if both the arguments are `FALSE`. + ## Remarks -- The **OR** function in DAX accepts only two (2) arguments. If you need to perform an OR operation on multiple expressions, you can create a series of calculations or, better, use the OR operator (**||**) to join all of them in a simpler expression. - -- The function evaluates the arguments until the first TRUE argument, then returns TRUE. - +- The `OR` function in DAX accepts only two (2) arguments. If you need to perform an OR operation on multiple expressions, you can create a series of calculations or, better, use the OR operator (**||**) to join all of them in a simpler expression. + +- The function evaluates the arguments until the first `TRUE` argument, then returns `TRUE`. + ## Example -The following example shows how to use the OR function to obtain the sales people that belong to the Circle of Excellence. The Circle of Excellence recognizes those who have achieved more than a million dollars in Touring Bikes sales or sales of over two and a half million dollars in 2007. +The following example shows how to use the OR function to obtain the sales people that belong to the Circle of Excellence. The Circle of Excellence recognizes those who have achieved more than a million dollars in Touring Bikes sales or sales of over two and a half million dollars in 2007. ```dax -IF( OR( CALCULATE(SUM('ResellerSales_USD'[SalesAmount_USD]), 'ProductSubcategory'[ProductSubcategoryName]="Touring Bikes") > 1000000 - , CALCULATE(SUM('ResellerSales_USD'[SalesAmount_USD]), 'DateTime'[CalendarYear]=2007) > 2500000 - ) - , "Circle of Excellence" - , "" - ) +IF( OR( CALCULATE(SUM('ResellerSales_USD'[SalesAmount_USD]), 'ProductSubcategory'[ProductSubcategoryName]="Touring Bikes") > 1000000 + , CALCULATE(SUM('ResellerSales_USD'[SalesAmount_USD]), 'DateTime'[CalendarYear]=2007) > 2500000 + ) + , "Circle of Excellence" + , "" + ) ``` Returns - -|Row Labels|2005|2006|2007|2008|-|Grand Total| -|-------------------|--------|----|----|----|----|----| -|Abbas, Syed E||||||| -|Alberts, Amy E||||||| -|Ansman-Wolfe, Pamela O||||||| -|Blythe, Michael G|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| -|Campbell, David R||||||| -|Carson, Jillian|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| -|Ito, Shu K||||||| -|Jiang, Stephen Y||||||| -|Mensa-Annan, Tete A||||||| -|Mitchell, Linda C|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| -|Pak, Jae B|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| -|Reiter, Tsvi Michael||||||| -|Saraiva, José Edvaldo|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| -|Tsoflias, Lynn N||||||| -|Valdez, Rachel B||||||| -|Vargas, Garrett R||||||| -|Varkey Chudukatil, Ranjit R||||||Circle of Excellence| -|Grand Total|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| - -## See also - -[Logical functions](logical-functions-dax.md) + +|Row Labels|2005|2006|2007|2008|-|Grand Total| +|-------------------|--------|----|----|----|----|----| +|Abbas, Syed E||||||| +|Alberts, Amy E||||||| +|Ansman-Wolfe, Pamela O||||||| +|Blythe, Michael G|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| +|Campbell, David R||||||| +|Carson, Jillian|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| +|Ito, Shu K||||||| +|Jiang, Stephen Y||||||| +|Mensa-Annan, Tete A||||||| +|Mitchell, Linda C|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| +|Pak, Jae B|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| +|Reiter, Tsvi Michael||||||| +|Saraiva, José Edvaldo|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| +|Tsoflias, Lynn N||||||| +|Valdez, Rachel B||||||| +|Vargas, Garrett R||||||| +|Varkey Chudukatil, Ranjit R||||||Circle of Excellence| +|Grand Total|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence|Circle of Excellence| + +## Related content + +[Logical functions](logical-functions-dax.md) diff --git a/query-languages/dax/orderby-function-dax.md b/query-languages/dax/orderby-function-dax.md new file mode 100644 index 000000000..10c307d8a --- /dev/null +++ b/query-languages/dax/orderby-function-dax.md @@ -0,0 +1,47 @@ +--- +description: "Learn more about: ORDERBY" +title: "ORDERBY function (DAX)" +--- + +# ORDERBY + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Defines the expressions that determine the sort order within each of a window function’s partitions. + +## Syntax + +```dax +ORDERBY ( [[, [, [, ]] …]] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`orderBy_expression`|(Optional) Any scalar expression that will be used used to sort the data within each of a window function’s partitions.| +|`order`|(Optional) A two-part value of the form "`OrderDirection` [`BlankHandling`]".

`OrderDirection` specifies how to sort `orderBy_expression` values (i.e. ascending or descending). Valid values include:
`DESC`. Alternative value: `0`(zero)/`FALSE`. Sorts in descending order of values of `orderBy_expression`.
`ASC`. Alternative value: `1`/`TRUE`. Sorts in ascending order of values of `orderBy_expression`. This is the default value if `order` is omitted.

`BlankHandling` part is optional. It specifies how blanks are ordered. Valid values include:
`BLANKS DEFAULT`. This is the default value. The behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
`BLANKS FIRST`. Blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
`BLANKS LAST`. Blanks are always ordered on the end, regardless of ascending or descending sorting order.| + +## Return value + +This function does not return a value. + +## Remarks + +This function can only be used within a window function expression. + +## Example + +See [OFFSET](offset-function-dax.md). + +## Related content + +[Understanding ORDERBY, PARTITIONBY, and MATCHBY functions](../dax/best-practices/dax-understand-orderby.md) +[INDEX](index-function-dax.md) +[OFFSET](offset-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[MATCHBY](matchby-function-dax.md) +[WINDOW](window-function-dax.md) +[RANK](rank-function-dax.md) +[ROWNUMBER](rownumber-function-dax.md) + diff --git a/query-languages/dax/orderby-statement-dax.md b/query-languages/dax/orderby-statement-dax.md index 6856001b2..b81d77076 100644 --- a/query-languages/dax/orderby-statement-dax.md +++ b/query-languages/dax/orderby-statement-dax.md @@ -1,51 +1,37 @@ --- description: "Learn more about: ORDER BY" -title: "ORDER BY keyword (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ORDER BY keyword (DAX)" --- # ORDER BY - -Defines the sort order of query results returned by an EVALUATE statement in a [DAX query](dax-queries.md). -## Syntax - +Introduces a statement that defines sort order of query results returned by an EVALUATE statement in a [DAX query](dax-queries.md). + +## Syntax + ```dax -ORDER BY { [{ASC | DESC}]} +[ORDER BY { [{ASC | DESC}]}[, …]] ``` - -### Arguments - -|Term|Definition| -|--------|--------------| -|expression|Any DAX expression that returns a single scalar value.| -|ASC|(default) Ascending sort order.| -|DESC|Descending sort order.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression`|Any DAX expression that returns a single scalar value.| +|`ASC`|(default) Ascending sort order.| +|`DESC`|Descending sort order.| + ## Return value The result of an EVALUATE statement in ascending (ASC) or descending (DESC) order. -## Example +## Remarks -```dax -EVALUATE( - 'Internet Sales' - ) -ORDER BY - 'Internet Sales'[Order Date] -``` +To learn more about how ORDER BY statements are used, see [DAX queries](dax-queries.md). -Returns all rows and columns from the Internet Sales table, ordered by Order Date, as a table. - -## See also +## Related content -[DAX queries](dax-queries.md) -[EVALUATE](evaluate-statement-dax.md) +[START AT](startat-statement-dax.md) +[EVALUATE](evaluate-statement-dax.md) +[VAR](var-dax.md) +[DEFINE](define-statement-dax.md) +[DAX queries](dax-queries.md) \ No newline at end of file diff --git a/query-languages/dax/other-functions-dax.md b/query-languages/dax/other-functions-dax.md index c9b8c2cb5..702f10a35 100644 --- a/query-languages/dax/other-functions-dax.md +++ b/query-languages/dax/other-functions-dax.md @@ -1,22 +1,17 @@ --- description: "Learn more about: Other functions" -title: "Other functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/17/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Other functions (DAX)" --- # Other functions These functions perform unique actions that cannot be defined by any of the categories. - -## In this category + +## In this category |Function |Description | |---------|---------| |[BLANK](blank-function-dax.md) | Returns a blank. | -|[ERROR](error-function.md) | Raises an error with an error message. | +|[ERROR](error-function-dax.md) | Raises an error with an error message. | +|[EVALUATEANDLOG](evaluateandlog-function-dax.md) | Returns the value of the first argument and logs it in a DAX Evaluation Log profiler event. | +|[TOCSV](tocsv-function-dax.md) | Returns a table as a string in CSV format. | +|[TOJSON](tojson-function-dax.md) | Returns a table as a string in JSON format. | diff --git a/query-languages/dax/parallelperiod-function-dax.md b/query-languages/dax/parallelperiod-function-dax.md index a6574b531..65ad61007 100644 --- a/query-languages/dax/parallelperiod-function-dax.md +++ b/query-languages/dax/parallelperiod-function-dax.md @@ -1,69 +1,62 @@ --- description: "Learn more about: PARALLELPERIOD" -title: "PARALLELPERIOD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PARALLELPERIOD function (DAX)" --- # PARALLELPERIOD -Returns a table that contains a column of dates that represents a period parallel to the dates in the specified **dates** column, in the current context, with the dates shifted a number of intervals either forward in time or back in time. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of dates that represents a period parallel to the dates in the specified `dates` column, in the current context, with the dates shifted a number of intervals either forward in time or back in time. + +## Syntax + ```dax -PARALLELPERIOD(,,) +PARALLELPERIOD(,,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| -|number_of_intervals|An integer that specifies the number of intervals to add to or subtract from the dates.| -|interval|The interval by which to shift the dates. The value for interval can be one of the following: `year`, `quarter`, `month`.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| +|`number_of_intervals`|An integer that specifies the number of intervals to add to or subtract from the dates.| +|`interval`|The interval by which to shift the dates. The value for interval can be one of the following: `year`, `quarter`, `month`.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## Remarks -- This function takes the current set of dates in the column specified by **dates**, shifts the first date and the last date the specified number of intervals, and then returns all contiguous dates between the two shifted dates. If the interval is a partial range of month, quarter, or year then any partial months in the result are also filled out to complete the entire interval. - -- 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](calculate-function-dax.md). - -- If the number specified for **number_of_intervals** is positive, the dates in **dates** are moved forward in time; if the number is negative, the dates in **dates** are shifted back in time. - -- The **interval** parameter is an enumeration, not a set of strings; therefore values should not be enclosed in quotation marks. Also, the values: `year`, `quarter`, `month` should be spelled in full when using them. - -- The result table includes only dates that appear in the values of the underlying table column. - -- The PARALLELPERIOD function is similar to the DATEADD function except that PARALLELPERIOD always returns full periods at the given granularity level instead of the partial periods that DATEADD returns. For example, if you have a selection of dates that starts at June 10 and finishes at June 21 of the same year, and you want to shift that selection forward by one month then the PARALLELPERIOD function will return all dates from the next month (July 1 to July 31); however, if DATEADD is used instead, then the result will include only dates from July 10 to July 21. - +- This function takes the current set of dates in the column specified by `dates`, shifts the first date and the last date the specified number of intervals, and then returns all contiguous dates between the two shifted dates. If the interval is a partial range of month, quarter, or year then any partial months in the result are also filled out to complete the entire interval. + +- 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](calculate-function-dax.md). + +- If the number specified for `number_of_intervals` is positive, the dates in `dates` are moved forward in time; if the number is negative, the dates in `dates` are shifted back in time. + +- The `interval` parameter is an enumeration, not a set of strings; therefore values should not be enclosed in quotation marks. Also, the values: `year`, `quarter`, `month` should be spelled in full when using them. + +- The result table includes only dates that appear in the values of the underlying table column. + +- The PARALLELPERIOD function is similar to the DATEADD function except that PARALLELPERIOD always returns full periods at the given granularity level instead of the partial periods that DATEADD returns. For example, if you have a selection of dates that starts at June 10 and finishes at June 21 of the same year, and you want to shift that selection forward by one month then the PARALLELPERIOD function will return all dates from the next month (July 1 to July 31); however, if DATEADD is used instead, then the result will include only dates from July 10 to July 21. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the previous year sales for Internet sales. - +The following sample formula creates a measure that calculates the previous year sales for Internet sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PARALLELPERIOD(DateTime[DateKey],-1,year)) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PARALLELPERIOD(DateTime[DateKey],-1,year)) ``` - -## See also -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[DATEADD function](dateadd-function-dax.md) +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[DATEADD function](dateadd-function-dax.md) diff --git a/query-languages/dax/parent-and-child-functions-dax.md b/query-languages/dax/parent-and-child-functions-dax.md index 2622ddb06..04c95a047 100644 --- a/query-languages/dax/parent-and-child-functions-dax.md +++ b/query-languages/dax/parent-and-child-functions-dax.md @@ -1,25 +1,17 @@ --- description: "Learn more about: Parent and Child functions" -title: "Parent and Child functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Parent and Child functions (DAX)" --- # Parent and Child functions -These functions manage data that is presented as parent/child hierarchies. To learn more, see [Understanding functions for Parent-Child Hierarchies in DAX](understanding-functions-for-parent-child-hierarchies-in-dax.md). - +These functions manage data that is presented as parent/child hierarchies. To learn more, see [Understanding functions for Parent-Child Hierarchies in DAX](understanding-functions-for-parent-child-hierarchies-in-dax.md). + ## In this category |Function |Description | |---------|---------| |[PATH](path-function-dax.md) | Returns a delimited text string with the identifiers of all the parents of the current identifier. | -|[PATHCONTAINS](pathcontains-function-dax.md) | Returns TRUE if the specified *item* exists within the specified *path*. | -|[PATHITEM](pathitem-function-dax.md) | Returns the item at the specified *position* from a string resulting from evaluation of a PATH function. | -|[PATHITEMREVERSE](pathitemreverse-function-dax.md) | Returns the item at the specified *position* from a string resulting from evaluation of a PATH function. | +|[PATHCONTAINS](pathcontains-function-dax.md) | Returns `TRUE` if the specified `item` exists within the specified `path`. | +|[PATHITEM](pathitem-function-dax.md) | Returns the item at the specified `position` from a string resulting from evaluation of a PATH function. | +|[PATHITEMREVERSE](pathitemreverse-function-dax.md) | Returns the item at the specified `position` from a string resulting from evaluation of a PATH function. | |[PATHLENGTH](pathlength-function-dax.md) | Returns the number of parents to the specified item in a given PATH result, including self. | diff --git a/query-languages/dax/partitionby-function-dax.md b/query-languages/dax/partitionby-function-dax.md new file mode 100644 index 000000000..ac0b419e0 --- /dev/null +++ b/query-languages/dax/partitionby-function-dax.md @@ -0,0 +1,45 @@ +--- +description: "Learn more about: PARTITIONBY" +title: "PARTITIONBY function (DAX)" +--- + +# PARTITIONBY + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Defines the columns that are used to partition a window function’s `relation` parameter. + +## Syntax + +```dax +PARTITIONBY ( [[, partitionBy_columnName [, …]]] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`partitionBy_columnName`| (Optional) 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 + +This function does not return a value. + +## Remarks + +This function can only be used within a window function expression. + +## Example + +See [OFFSET](offset-function-dax.md). + +## Related content + +[Understanding ORDERBY, PARTITIONBY, and MATCHBY functions](../dax/best-practices/dax-understand-orderby.md) +[INDEX](index-function-dax.md) +[OFFSET](offset-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[MATCHBY](matchby-function-dax.md) +[WINDOW](window-function-dax.md) +[RANK](rank-function-dax.md) +[ROWNUMBER](rownumber-function-dax.md) \ No newline at end of file diff --git a/query-languages/dax/path-function-dax.md b/query-languages/dax/path-function-dax.md index 3f198faa9..2fc163902 100644 --- a/query-languages/dax/path-function-dax.md +++ b/query-languages/dax/path-function-dax.md @@ -1,56 +1,49 @@ --- description: "Learn more about: PATH" -title: "PATH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PATH function (DAX)" --- # PATH -Returns a delimited text string with the identifiers of all the parents of the current identifier, starting with the oldest and continuing until current. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a delimited text string with the identifiers of all the parents of the current identifier, starting with the oldest and continuing until current. + +## Syntax + ```dax -PATH(, ) +PATH(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -| ID_columnName | The name of an existing column containing the unique identifier for rows in the table. This cannot be an expression. The data type of the value in *ID_columnName* must be text or integer, and must also be the same data type as the column referenced in *parent_columnName*.| -| parent_columnName | The name of an existing column containing the unique identifier for the parent of the current row. This cannot be an expression. The data type of the value in *parent_columnName* data type must be text or integer, and must be the same data type as the value in *ID_columnName*. | - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`ID_columnName`| The name of an existing column containing the unique identifier for rows in the table. This cannot be an expression. The data type of the value in `ID_columnName` must be text or integer, and must also be the same data type as the column referenced in `parent_columnName`.| +|`parent_columnName`| The name of an existing column containing the unique identifier for the parent of the current row. This cannot be an expression. The data type of the value in `parent_columnName` data type must be text or integer, and must be the same data type as the value in `ID_columnName`. | + ## Return value -A delimited text string containing the identifiers of all the parents to the current identifier. - +A delimited text string containing the identifiers of all the parents to the current identifier. + ## Remarks -- This function is used in tables that have some kind of internal hierarchy, to return the items that are related to the current row value. For example, in an Employees table that contains employees, the managers of employees, and the managers of the managers, you can return the path that connects an employee to his or her manager. - -- The path is not constrained to a single level of parent-child relationships; it can return related rows that are several levels up from the specified starting row. - - The delimiter used to separate the ascendants is the vertical bar, '|'. - - The values in *ID_columnName* and *parent_columnName* must have the same data type, text or integer. - - Values in *parent_columnName* must be present in *ID_columnName*. That is, you cannot look up a parent if there is no value at the child level. - - If *parent_columnName* is BLANK then PATH() returns *ID_columnName* value. In other words, if you look for the manager of an employee but the *parent_columnName* column has no data, the PATH function returns just the employee ID. - - If *ID_columnName* has duplicates and *parent_columnName* is the same for those duplicates then PATH() returns the common *parent_columnName* value; however, if *parent_columnName* value is different for those duplicates then PATH() returns an error. In other words, if you have two listings for the same employee ID and they have the same manager ID, the PATH function returns the ID for that manager. However, if there are two identical employee IDs that have different manager IDs, the PATH function returns an error. - - If *ID_columnName* is BLANK then PATH() returns BLANK. - - If *ID_columnName* contains a vertical bar '|' then PATH() returns an error. - +- This function is used in tables that have some kind of internal hierarchy, to return the items that are related to the current row value. For example, in an Employees table that contains employees, the managers of employees, and the managers of the managers, you can return the path that connects an employee to his or her manager. + +- The path is not constrained to a single level of parent-child relationships; it can return related rows that are several levels up from the specified starting row. + - The delimiter used to separate the ascendants is the vertical bar, `|`. + - The values in `ID_columnName` and `parent_columnName` must have the same data type, text or integer. + - Values in `parent_columnName` must be present in `ID_columnName`. That is, you cannot look up a parent if there is no value at the child level. + - If `parent_columnName` is `BLANK` then `PATH()` returns `ID_columnName` value. In other words, if you look for the manager of an employee but the `parent_columnName` column has no data, the PATH function returns just the employee ID. + - If `ID_columnName` has duplicates and `parent_columnName` is the same for those duplicates then `PATH()` returns the common `parent_columnName` value; however, if `parent_columnName` value is different for those duplicates then `PATH()` returns an error. In other words, if you have two listings for the same employee ID and they have the same manager ID, the PATH function returns the ID for that manager. However, if there are two identical employee IDs that have different manager IDs, the PATH function returns an error. + - If `ID_columnName` is `BLANK` then `PATH()` returns `BLANK`. + - If `ID_columnName` contains a vertical bar `|` then `PATH()` returns an error. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example creates a calculated column that lists all the managers for each employee. - +The following example creates a calculated column that lists all the managers for each employee. + ```dax -= PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey]) += PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey]) ``` diff --git a/query-languages/dax/pathcontains-function-dax.md b/query-languages/dax/pathcontains-function-dax.md index fe6b81017..16a5c01ea 100644 --- a/query-languages/dax/pathcontains-function-dax.md +++ b/query-languages/dax/pathcontains-function-dax.md @@ -1,47 +1,40 @@ --- description: "Learn more about: PATHCONTAINS" -title: "PATHCONTAINS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 12/10/2018 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PATHCONTAINS function (DAX)" --- # PATHCONTAINS -Returns **TRUE** if the specified *item* exists within the specified *path*. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns `TRUE` if the specified `item` exists within the specified `path`. + +## Syntax + ```dax -PATHCONTAINS(, ) +PATHCONTAINS(, ) ``` - + ### Parameters -|Term|Definition| -|--------|--------------| -| path | A string created as the result of evaluating a PATH function. | -| item | A text expression to look for in the path result. | +|Term|Definition| +|--------|--------------| +|`path`| A string created as the result of evaluating a PATH function. | +|`item`| A text expression to look for in the path result. | ## Return value -A value of **TRUE** if *item* exists in *path*; otherwise **FALSE**. - +A value of `TRUE` if `item` exists in `path`; otherwise `FALSE`. + ## Remarks -- If *item* is an integer number it is converted to text and then the function is evaluated. If conversion fails then the function returns an error. - +- If `item` is an integer number it is converted to text and then the function is evaluated. If conversion fails then the function returns an error. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example creates a calculated column that takes a manager ID and checks a set of employees. If the manager ID is among the list of managers returned by the PATH function, the PATHCONTAINS function returns true; otherwise it returns false. - +The following example creates a calculated column that takes a manager ID and checks a set of employees. If the manager ID is among the list of managers returned by the PATH function, the PATHCONTAINS function returns true; otherwise it returns false. + ```dax -= PATHCONTAINS(PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey]), "23") += PATHCONTAINS(PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey]), "23") ``` diff --git a/query-languages/dax/pathitem-function-dax.md b/query-languages/dax/pathitem-function-dax.md index 493dade01..2b2a624da 100644 --- a/query-languages/dax/pathitem-function-dax.md +++ b/query-languages/dax/pathitem-function-dax.md @@ -1,58 +1,51 @@ --- description: "Learn more about: PATHITEM" -title: "PATHITEM function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PATHITEM function (DAX)" --- # PATHITEM -Returns the item at the specified *position* from a string resulting from evaluation of a PATH function. Positions are counted from left to right. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] +Returns the item at the specified `position` from a string resulting from evaluation of a PATH function. Positions are counted from left to right. + +## Syntax + ```dax -PATHITEM(, [, ]) +PATHITEM(, [, ]) ``` - + ### Parameters -|Term|Definition| -|--------|--------------| -| path | A text string in the form of the results of a PATH function. | -| position | An integer expression with the position of the item to be returned. | -| type | (Optional)An enumeration that defines the data type of the result: | +|Term|Definition| +|--------|--------------| +|`path`| A text string in the form of the results of a PATH function. | +|`position`| An integer expression with the position of the item to be returned. | +|`type`| (Optional)An enumeration that defines the data type of the result: | #### type enumeration |Enumeration|Alternate Enumeration|Description| |-----|-----|-----| -|TEXT|0|Results are returned with the data type text. (default).| -|INTEGER|1|Results are returned as integers.| - +|`TEXT`|0|Results are returned with the data type text. (default).| +|`INTEGER`|1|Results are returned as integers.| + ## Return value -The identifier returned by the PATH function at the specified position in the list of identifiers. Items returned by the PATH function are ordered by most distant to current. - -## Remarks - -- This function can be used to return a specific level from a hierarchy returned by a PATH function. For example, you could return just the skip-level managers for all employees. - -- If you specify a number for *position* that is less than one (1) or greater than the number of elements in *path*, the PATHITEM function returns BLANK - -- If *type* is not a valid enumeration element an error is returned. - +The identifier returned by the PATH function at the specified position in the list of identifiers. Items returned by the PATH function are ordered by most distant to current. + +## Remarks + +- This function can be used to return a specific level from a hierarchy returned by a PATH function. For example, you could return just the skip-level managers for all employees. + +- If you specify a number for `position` that is less than one (1) or greater than the number of elements in `path`, the PATHITEM function returns BLANK + +- If `type` is not a valid enumeration element an error is returned. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example returns the third tier manager of the current employee; it takes the employee and manager IDs as the input to a PATH function that returns a string with the hierarchy of parents to current employee. From that string PATHITEM returns the third entry as an integer. - +The following example returns the third tier manager of the current employee; it takes the employee and manager IDs as the input to a PATH function that returns a string with the hierarchy of parents to current employee. From that string PATHITEM returns the third entry as an integer. + ```dax -= PATHITEM(PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey]), 3, 1) += PATHITEM(PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey]), 3, 1) ``` diff --git a/query-languages/dax/pathitemreverse-function-dax.md b/query-languages/dax/pathitemreverse-function-dax.md index 2b32bd6fa..e9a07512e 100644 --- a/query-languages/dax/pathitemreverse-function-dax.md +++ b/query-languages/dax/pathitemreverse-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: PATHITEMREVERSE" -title: "PATHITEMREVERSE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PATHITEMREVERSE function (DAX)" --- # PATHITEMREVERSE -Returns the item at the specified *position* from a string resulting from evaluation of a PATH function. Positions are counted backwards from right to left. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the item at the specified `position` from a string resulting from evaluation of a PATH function. Positions are counted backwards from right to left. + +## Syntax + ```dax -PATHITEMREVERSE(, [, ]) +PATHITEMREVERSE(, [, ]) ``` - + ### Parameters -|Term|Definition| -|--------|--------------| -| path | A text string resulting from evaluation of a PATH function. | -| position | An integer expression with the position of the item to be returned. Position is counted backwards from right to left. | -| type | (Optional)An enumeration that defines the data type of the result: | +|Term|Definition| +|--------|--------------| +|`path`| A text string resulting from evaluation of a PATH function. | +|`position`| An integer expression with the position of the item to be returned. Position is counted backwards from right to left. | +|`type`| (Optional)An enumeration that defines the data type of the result: | #### type enumeration |Enumeration|Alternate Enumeration|Description| |-----|-----|-----| -|TEXT|0|Results are returned with the data type text. (default).| -|INTEGER|1|Results are returned as integers.| +|`TEXT`|0|Results are returned with the data type text. (default).| +|`INTEGER`|1|Results are returned as integers.| ## Return value -The n-position ascendant in the given path, counting from current to the oldest. - -## Remarks - -- This function can be used to get an individual item from a hierarchy resulting from a PATH function. - -- This function reverses the standard order of the hierarchy, so that closest items are listed first, For example, if the PATh function returns a list of managers above an employee in a hierarchy, the PATHITEMREVERSE function returns the employee's immediate manager in position 2 because position 1 contains the employee's id. - -- If the number specified for *position* is less than one (1) or greater than the number of elements in *path*, the PATHITEM function returns BLANK. - -- If *type* is not a valid enumeration element an error is returned. - +The n-position ascendant in the given path, counting from current to the oldest. + +## Remarks + +- This function can be used to get an individual item from a hierarchy resulting from a PATH function. + +- This function reverses the standard order of the hierarchy, so that closest items are listed first, For example, if the PATh function returns a list of managers above an employee in a hierarchy, the PATHITEMREVERSE function returns the employee's immediate manager in position 2 because position 1 contains the employee's id. + +- If the number specified for `position` is less than one (1) or greater than the number of elements in `path`, the PATHITEM function returns BLANK. + +- If `type` is not a valid enumeration element an error is returned. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example takes an employee ID column as the input to a PATH function, and reverses the list of grandparent elements that are returned. The position specified is 3 and the return type is 1; therefore, the PATHITEMREVERSE function returns an integer representing the manager two levels up from the employee. - +The following example takes an employee ID column as the input to a PATH function, and reverses the list of grandparent elements that are returned. The position specified is 3 and the return type is 1; therefore, the PATHITEMREVERSE function returns an integer representing the manager two levels up from the employee. + ```dax -= PATHITEMREVERSE(PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey]), 3, 1) += PATHITEMREVERSE(PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey]), 3, 1) ``` diff --git a/query-languages/dax/pathlength-function-dax.md b/query-languages/dax/pathlength-function-dax.md index 5db542f5a..2be10bde5 100644 --- a/query-languages/dax/pathlength-function-dax.md +++ b/query-languages/dax/pathlength-function-dax.md @@ -1,43 +1,36 @@ --- description: "Learn more about: PATHLENGTH" -title: "PATHLENGTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PATHLENGTH function (DAX)" --- # PATHLENGTH -Returns the number of parents to the specified item in a given PATH result, including self. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] +Returns the number of parents to the specified item in a given PATH result, including self. + +## Syntax + ```dax -PATHLENGTH() +PATHLENGTH() ``` -### Parameters +### Parameters + +|Term|Definition| +|--------|--------------| +|`path`| A text expression resulting from evaluation of a PATH function. | -|Term|Definition| -|--------|--------------| -| path | A text expression resulting from evaluation of a PATH function. | - ## Return value -The number of items that are parents to the specified item in a given PATH result, including the specified item. - +The number of items that are parents to the specified item in a given PATH result, including the specified item. + ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example takes an employee ID as input to a PATH function and returns a list of the managers above that employee in the hierarchy, The PATHLENGTH function takes that result and counts the different levels of employees and managers, including the employee you started with. - +The following example takes an employee ID as input to a PATH function and returns a list of the managers above that employee in the hierarchy, The PATHLENGTH function takes that result and counts the different levels of employees and managers, including the employee you started with. + ```dax -= PATHLENGTH(PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey])) += PATHLENGTH(PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey])) ``` diff --git a/query-languages/dax/pduration-function-dax.md b/query-languages/dax/pduration-function-dax.md index 899bcd9fc..1b301066c 100644 --- a/query-languages/dax/pduration-function-dax.md +++ b/query-languages/dax/pduration-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: PDURATION" -title: "PDURATION function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "PDURATION function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # PDURATION +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the number of periods required by an investment to reach a specified value. ## Syntax @@ -24,11 +18,11 @@ PDURATION(, , ) ### Parameters -|Term|Definition| -|--------|--------------| -|rate|The interest rate per period.| -|pv|The present value of the investment.| -|fv|The desired future value of the investment.| +|Term|Definition| +|--------|--------------| +|`rate`|The interest rate per period.| +|`pv`|The present value of the investment.| +|`fv`|The desired future value of the investment.| ## Return Value diff --git a/query-languages/dax/percentile-exc-function-dax.md b/query-languages/dax/percentile-exc-function-dax.md index 9e9a6cbad..48c012c75 100644 --- a/query-languages/dax/percentile-exc-function-dax.md +++ b/query-languages/dax/percentile-exc-function-dax.md @@ -1,53 +1,46 @@ --- description: "Learn more about: PERCENTILE.EXC" -title: "PERCENTILE.EXC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PERCENTILE.EXC function (DAX)" --- # PERCENTILE.EXC - -Returns the k-th percentile of values in a range, where k is in the range 0..1, exclusive. - -To return the percentile number of an expression evaluated for each row in a table, use [PERCENTILEX.EXC function](percentilex-exc-function-dax.md). - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the k-th percentile of values in a range, where k is in the range 0..1, exclusive. + +To return the percentile number of an expression evaluated for each row in a table, use [PERCENTILEX.EXC function](percentilex-exc-function-dax.md). + +## Syntax + ```dax -PERCENTILE.EXC(, ) +PERCENTILE.EXC(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|A column containing the values that define relative standing.| -|k|The percentile value in the range 0..1, exclusive.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A column containing the values that define relative standing.| +|`k`|The percentile value in the range 0..1, exclusive.| + ## Return value -The k-th percentile of values in a range, where k is in the range 0..1, exclusive. - +The k-th percentile of values in a range, where k is in the range 0..1, exclusive. + ## Remarks -- If column is empty, BLANK() is returned. - -- If k is zero or blank, percentile rank of 1/(n+1) returns the smallest value. If zero, it is out of range and an error is returned. - -- If k is nonnumeric or outside the range 0 to 1, an error is returned. - -- If k is not a multiple of 1/(n + 1), PERCENTILE.EXC will interpolate to determine the value at the k-th percentile. - -- PERCENTILE.EXC will interpolate when the value for the specified percentile is between two values in the array. If it cannot interpolate for the k percentile specified, an error is returned. +- If column is empty, BLANK() is returned. + +- If k is zero or blank, percentile rank of 1/(n+1) returns the smallest value. If zero, it is out of range and an error is returned. + +- If k is nonnumeric or outside the range 0 to 1, an error is returned. + +- If k is not a multiple of 1/(n + 1), PERCENTILE.EXC will interpolate to determine the value at the k-th percentile. + +- PERCENTILE.EXC will interpolate when the value for the specified percentile is between two values in the array. If it cannot interpolate for the k percentile specified, an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## See also +## Related content -[PERCENTILEX.EXC](percentilex-exc-function-dax.md) +[PERCENTILEX.EXC](percentilex-exc-function-dax.md) diff --git a/query-languages/dax/percentile-inc-function-dax.md b/query-languages/dax/percentile-inc-function-dax.md index f56328af2..77a314a74 100644 --- a/query-languages/dax/percentile-inc-function-dax.md +++ b/query-languages/dax/percentile-inc-function-dax.md @@ -1,53 +1,46 @@ --- description: "Learn more about: PERCENTILE.INC" -title: "PERCENTILE.INC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PERCENTILE.INC function (DAX)" --- # PERCENTILE.INC - -Returns the k-th percentile of values in a range, where k is in the range 0..1, inclusive. - -To return the percentile number of an expression evaluated for each row in a table, use [PERCENTILEX.INC](percentilex-inc-function-dax.md). - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the k-th percentile of values in a range, where k is in the range 0..1, inclusive. + +To return the percentile number of an expression evaluated for each row in a table, use [PERCENTILEX.INC](percentilex-inc-function-dax.md). + +## Syntax + ```dax -PERCENTILE.INC(, ) +PERCENTILE.INC(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|A column containing the values that define relative standing.| -|k|The percentile value in the range 0..1, inclusive.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|A column containing the values that define relative standing.| +|`k`|The percentile value in the range 0..1, inclusive.| + ## Return value -The k-th percentile of values in a range, where k is in the range 0..1, inclusive. - +The k-th percentile of values in a range, where k is in the range 0..1, inclusive. + ## Remarks -- If column is empty, BLANK() is returned. - -- If k is zero or blank, percentile rank of 1/(n+1) returns the smallest value. If zero, it is out of range and an error is returned. - -- If k is nonnumeric or outside the range 0 to 1, an error is returned. - -- If k is not a multiple of 1/(n + 1), PERCENTILE.INC will interpolate to determine the value at the k-th percentile. - -- PERCENTILE.INC will interpolate when the value for the specified percentile is between two values in the array. If it cannot interpolate for the k percentile specified, an error is returned. +- If column is empty, BLANK() is returned. + +- If k is zero or blank, percentile rank of 1/(n+1) returns the smallest value. If zero, it is out of range and an error is returned. + +- If k is nonnumeric or outside the range 0 to 1, an error is returned. + +- If k is not a multiple of 1/(n + 1), PERCENTILE.INC will interpolate to determine the value at the k-th percentile. + +- PERCENTILE.INC will interpolate when the value for the specified percentile is between two values in the array. If it cannot interpolate for the k percentile specified, an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## See also +## Related content -[PERCENTILEX.INC](percentilex-inc-function-dax.md) +[PERCENTILEX.INC](percentilex-inc-function-dax.md) diff --git a/query-languages/dax/percentilex-exc-function-dax.md b/query-languages/dax/percentilex-exc-function-dax.md index 87c926079..371c899c4 100644 --- a/query-languages/dax/percentilex-exc-function-dax.md +++ b/query-languages/dax/percentilex-exc-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: PERCENTILEX.EXC" -title: "PERCENTILEX.EXC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PERCENTILEX.EXC function (DAX)" --- # PERCENTILEX.EXC - -Returns the percentile number of an expression evaluated for each row in a table. - -To return the percentile of numbers in a column, use [PERCENTILE.EXC function](percentile-exc-function-dax.md). - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the percentile number of an expression evaluated for each row in a table. + +To return the percentile of numbers in a column, use [PERCENTILE.EXC function](percentile-exc-function-dax.md). + +## Syntax + ```dax -PERCENTILEX.EXC(
, , k) +PERCENTILEX.EXC(
, , k) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of the table.| -|k|The desired percentile value in the range 0 to 1 exclusive.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of the table.| +|`k`|The desired percentile value in the range 0 to 1 exclusive.| + ## Return value -The percentile number of an expression evaluated for each row in a table. - +The percentile number of an expression evaluated for each row in a table. + ## Remarks -- If k is zero or blank, percentile rank of 1/(n+1) returns the smallest value. If zero, it is out of range and an error is returned. - -- If k is nonnumeric or outside the range 0 to 1, an error is returned. - -- If k is not a multiple of 1/(n + 1), PERCENTILEX.EXC will interpolate to determine the value at the k-th percentile. - -- PERCENTILEX.EXC will interpolate when the value for the specified percentile is between two values in the array. If it cannot interpolate for the k percentile specified, an error is returned. +- If k is zero or blank, percentile rank of 1/(n+1) returns the smallest value. If zero, it is out of range and an error is returned. + +- If k is nonnumeric or outside the range 0 to 1, an error is returned. + +- If k is not a multiple of 1/(n + 1), PERCENTILEX.EXC will interpolate to determine the value at the k-th percentile. + +- PERCENTILEX.EXC will interpolate when the value for the specified percentile is between two values in the array. If it cannot interpolate for the k percentile specified, an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## See also +## Related content -[PERCENTILE.EXC](percentile-exc-function-dax.md) +[PERCENTILE.EXC](percentile-exc-function-dax.md) diff --git a/query-languages/dax/percentilex-inc-function-dax.md b/query-languages/dax/percentilex-inc-function-dax.md index 5fbc1f0f2..498764ca3 100644 --- a/query-languages/dax/percentilex-inc-function-dax.md +++ b/query-languages/dax/percentilex-inc-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: PERCENTILEX.INC" -title: "PERCENTILEX.INC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PERCENTILEX.INC function (DAX)" --- # PERCENTILEX.INC - -Returns the percentile number of an expression evaluated for each row in a table. - -To return the percentile of numbers in a column, use [PERCENTILE.INC](percentile-inc-function-dax.md). - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the percentile number of an expression evaluated for each row in a table. + +To return the percentile of numbers in a column, use [PERCENTILE.INC](percentile-inc-function-dax.md). + +## Syntax + ```dax -PERCENTILEX.INC(
, ;, k) +PERCENTILEX.INC(
, ;, k) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of the table.| -|k|The desired percentile value in the range 0 to 1 inclusive.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of the table.| +|`k`|The desired percentile value in the range 0 to 1 inclusive.| + ## Return value -The percentile number of an expression evaluated for each row in a table. - +The percentile number of an expression evaluated for each row in a table. + ## Remarks -- If k is zero or blank, percentile rank of 1/(n - 1) returns the smallest value. If zero, it is out of range and an error is returned. - -- If k is nonnumeric or outside the range 0 to 1, an error is returned. - -- If k is not a multiple of 1/(n - 1), PERCENTILEX.EXC will interpolate to determine the value at the k-th percentile. - -- PERCENTILEX.INC will interpolate when the value for the specified percentile is between two values in the array. If it cannot interpolate for the k percentile specified, an error is returned. +- If k is zero or blank, percentile rank of 1/(n - 1) returns the smallest value. If zero, it is out of range and an error is returned. + +- If k is nonnumeric or outside the range 0 to 1, an error is returned. + +- If k is not a multiple of 1/(n - 1), PERCENTILEX.EXC will interpolate to determine the value at the k-th percentile. + +- PERCENTILEX.INC will interpolate when the value for the specified percentile is between two values in the array. If it cannot interpolate for the k percentile specified, an error is returned. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## See also +## Related content -[PERCENTILE.INC](percentile-inc-function-dax.md) +[PERCENTILE.INC](percentile-inc-function-dax.md) diff --git a/query-languages/dax/permut-function-dax.md b/query-languages/dax/permut-function-dax.md index 12aaf5c46..9caf4b2cf 100644 --- a/query-languages/dax/permut-function-dax.md +++ b/query-languages/dax/permut-function-dax.md @@ -1,54 +1,47 @@ --- description: "Learn more about: PERMUT" -title: "PERMUT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PERMUT function (DAX)" --- # PERMUT -Returns the number of permutations for a given number of objects that can be selected from number objects. A permutation is any set or subset of objects or events where internal order is significant. Permutations are different from combinations, for which the internal order is not significant. Use this function for lottery-style probability calculations. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the number of permutations for a given number of objects that can be selected from number objects. A permutation is any set or subset of objects or events where internal order is significant. Permutations are different from combinations, for which the internal order is not significant. Use this function for lottery-style probability calculations. + +## Syntax + ```dax -PERMUT(number, number_chosen) +PERMUT(number, number_chosen) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Required. An integer that describes the number of objects.| -|number_chosen|Required. An integer that describes the number of objects in each permutation.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Required. An integer that describes the number of objects.| +|`number_chosen`|Required. An integer that describes the number of objects in each permutation.| + ## Return value -Returns the number of permutations for a given number of objects that can be selected from number objects - +Returns the number of permutations for a given number of objects that can be selected from number objects + ## Remarks -- Both arguments are truncated to integers. +- Both arguments are truncated to integers. -- If number or number_chosen is nonnumeric, PERMUT returns the #VALUE! error value. +- If number or number_chosen is nonnumeric, PERMUT returns the `#VALUE!` error value. -- If number ≤ 0 or if number_chosen < 0, PERMUT returns the #NUM! error value. +- If number ≤ 0 or if number_chosen < 0, PERMUT returns the `#NUM!` error value. -- If number < number_chosen, PERMUT returns the #NUM! error value. +- If number < number_chosen, PERMUT returns the `#NUM!` error value. -- The equation for the number of permutations is: +- The equation for the number of permutations is: $$P\_{k,n} = \frac{n!}{(n-k)!}$$ - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example In the following formula, permutations possible for a group of 3 objects where 2 are chosen: diff --git a/query-languages/dax/pi-function-dax.md b/query-languages/dax/pi-function-dax.md index ecabbb4c1..876b13dd5 100644 --- a/query-languages/dax/pi-function-dax.md +++ b/query-languages/dax/pi-function-dax.md @@ -1,42 +1,35 @@ --- description: "Learn more about: PI" -title: "PI function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PI function (DAX)" --- # PI -Returns the value of Pi, 3.14159265358979, accurate to 15 digits. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the value of Pi, 3.14159265358979, accurate to 15 digits. + +## Syntax + ```dax -PI() +PI() ``` - + ## Return value -A decimal number with the value of Pi, 3.14159265358979, accurate to 15 digits. - +A decimal number with the value of Pi, 3.14159265358979, accurate to 15 digits. + ## Remarks -Pi is a mathematical constant. In DAX, Pi is represented as a real number accurate to 15 digits, the same as Excel. - +Pi is a mathematical constant. In DAX, Pi is represented as a real number accurate to 15 digits, the same as Excel. + ## Example -The following formula calculates the area of a circle given the radius in the column, `[Radius]`. - +The following formula calculates the area of a circle given the radius in the column, `[Radius]`. + ```dax -= PI()*([Radius]*2) += PI()*([Radius]*2) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) diff --git a/query-languages/dax/pmt-function-dax.md b/query-languages/dax/pmt-function-dax.md index db49c518b..54d99fe5c 100644 --- a/query-languages/dax/pmt-function-dax.md +++ b/query-languages/dax/pmt-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: PMT" -title: "PMT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "PMT function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # PMT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Calculates the payment for a loan based on constant payments and a constant interest rate. ## Syntax @@ -24,17 +18,17 @@ PMT(, , [, [, ]]) ### Parameters -|Term|Definition| -|--------|--------------| -|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. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`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. The accepted values are listed below this table.| -The **type** parameter accepts the following values: +The `type` parameter accepts the following values: -| **Set type equal to** | **If payments are due** | +| **Set `type` equal to** | **If payments are due** | | --------------------- | ------------------------------ | | 0 or omitted | At the end of the period | | 1 | At the beginning of the period | @@ -51,10 +45,10 @@ The amount of a single loan payment. - 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. +- `type` is rounded to the nearest integer. - An error is returned if: - - nper < 1 + - `nper < 1` **Tip**: To find the total amount paid over the duration of the loan, multiply the returned PMT value by nper. diff --git a/query-languages/dax/poisson-dist-function-dax.md b/query-languages/dax/poisson-dist-function-dax.md index bda023ea7..9b3e22736 100644 --- a/query-languages/dax/poisson-dist-function-dax.md +++ b/query-languages/dax/poisson-dist-function-dax.md @@ -1,55 +1,48 @@ --- description: "Learn more about: POISSON.DIST" -title: "POISSON.DIST function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "POISSON.DIST function (DAX)" --- # POISSON.DIST -Returns the Poisson distribution. A common application of the Poisson distribution is predicting the number of events over a specific time, such as the number of cars arriving at a toll plaza in 1 minute. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the Poisson distribution. A common application of the Poisson distribution is predicting the number of events over a specific time, such as the number of cars arriving at a toll plaza in 1 minute. + +## Syntax + ```dax -POISSON.DIST(x,mean,cumulative) +POISSON.DIST(x,mean,cumulative) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|x|Required. The number of events.| -|mean|Required. The expected numeric value.| -|cumulative|Required. A logical value that determines the form of the probability distribution returned. If cumulative is TRUE, POISSON.DIST returns the cumulative Poisson probability that the number of random events occurring will be between zero and x inclusive; if FALSE, it returns the Poisson probability mass function that the number of events occurring will be exactly x.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`x`|Required. The number of events.| +|`mean`|Required. The expected numeric value.| +|`cumulative`|Required. A logical value that determines the form of the probability distribution returned. If cumulative is `TRUE`, POISSON.DIST returns the cumulative Poisson probability that the number of random events occurring will be between zero and x inclusive; if `FALSE`, it returns the Poisson probability mass function that the number of events occurring will be exactly x.| + ## Return value -Returns the Poisson distribution. - +Returns the Poisson distribution. + ## Remarks -- If x is not an integer, it is rounded. +- If x is not an integer, it is rounded. -- If x or mean is nonnumeric, POISSON.DIST returns the #VALUE! error value. +- If x or mean is nonnumeric, POISSON.DIST returns the `#VALUE!` error value. -- If x < 0, POISSON.DIST returns the #NUM! error value. +- If x < 0, POISSON.DIST returns the `#NUM!` error value. -- If mean < 0, POISSON.DIST returns the #NUM! error value. +- If mean < 0, POISSON.DIST returns the `#NUM!` error value. -- POISSON.DIST is calculated as follows. +- POISSON.DIST is calculated as follows. - - For cumulative = FALSE: + - For cumulative = `FALSE`: $$\text{POISSON} = \frac{e^{-\lambda} \lambda^{x}}{x!}$$ - - For cumulative = TRUE: + - For cumulative = `TRUE`: $$\text{CUMPOISSON} = \sum^{x}\_{k=0} \frac{e^{-\lambda} \lambda^{x}}{k!}$$ diff --git a/query-languages/dax/power-function-dax.md b/query-languages/dax/power-function-dax.md index a4a345031..bf7dc4aaa 100644 --- a/query-languages/dax/power-function-dax.md +++ b/query-languages/dax/power-function-dax.md @@ -1,45 +1,38 @@ --- description: "Learn more about: POWER" -title: "POWER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "POWER function (DAX)" --- # POWER -Returns the result of a number raised to a power. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the result of a number raised to a power. + +## Syntax + ```dax -POWER(, ) +POWER(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The base number, which can be any real number.| -|power|The exponent to which the base number is raised.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The base number, which can be any real number.| +|`power`|The exponent to which the base number is raised.| + ## Return value -A decimal number. - +A decimal number. + ## Example -The following example returns 25. - +The following example returns 25. + ```dax -= POWER(5,2) += POWER(5,2) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) diff --git a/query-languages/dax/ppmt-function-dax.md b/query-languages/dax/ppmt-function-dax.md index d936a03f6..a95dce82d 100644 --- a/query-languages/dax/ppmt-function-dax.md +++ b/query-languages/dax/ppmt-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: PPMT" -title: "PPMT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "PPMT function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # PPMT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the payment on the principal for a given period for an investment based on periodic, constant payments and a constant interest rate. ## Syntax @@ -24,18 +18,18 @@ PPMT(, , , [, [, ]]) ### Parameters -|Term|Definition| -|--------|--------------| -|rate|The interest rate for the loan.| -|per|Specifies the period. Must be between 1 and nper (inclusive).| -|nper|The total number of payment periods in an annuity.| -|pv|The present value — the total amount that a series of future payments is worth now.| -|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. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`rate`|The interest rate for the loan.| +|`per`|Specifies the period. Must be between 1 and nper (inclusive).| +|`nper`|The total number of payment periods in an annuity.| +|`pv`|The present value — the total amount that a series of future payments is worth now.| +|`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. The accepted values are listed below this table.| -The **type** parameter accepts the following values: +The `type` parameter accepts the following values: -| **Set type equal to** | **If payments are due** | +| **Set `type` equal to** | **If payments are due** | | --------------------- | ------------------------------ | | 0 or omitted | At the end of the period | | 1 | At the beginning of the period | @@ -48,13 +42,13 @@ The payment on the principal for a given period. ## Remarks -- 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. +- 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: - - per < 1 or per > nper - - nper < 1 + - `per < 1` or `per > nper` + - `nper < 1` - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/previous-function-dax.md b/query-languages/dax/previous-function-dax.md new file mode 100644 index 000000000..aed025a8c --- /dev/null +++ b/query-languages/dax/previous-function-dax.md @@ -0,0 +1,55 @@ +--- +description: "Learn more about: PREVIOUS" +title: "PREVIOUS function (DAX)" +--- + +# PREVIOUS + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Used in visual calculations only. Retrieves a value in the previous element of an axis in the visual matrix. + +## Syntax + +```dax +PREVIOUS ( [, ][, ][, ][, ][, reset] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column to be retrieved.| +|`steps`| (Optional) Indicates the number of rows to go backward to fetch the value. If omitted, `1` is used (the exactly previous row).| +|`axis`|(Optional) An axis reference. If omitted, the first axis of the Visual Shape definition is used.| +|`orderBy`|(Optional) An ORDERBY() clause with expressions that determine how to sort each partition along the `axis`. If `orderBy` is not provided, the data is sorted by the grouping columns on the default `axis` in ascending order by default.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.
| +|`reset`|(Optional) Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +The value of `column` from the previous element of the axis. + +## Remarks + +This function can only be used in a visual calculation. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example + +The following visual calculation returns the sales amount of the previous row on ROWS axis, that resets on the lowest parent. + +```dax +PreviousInternetSalesAmount = PREVIOUS ( [Sum of SalesAmount], ROWS, LowestParent ) +``` + +The screenshot below shows the visual matrix and the visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-previous.png) + +## Related content + +[FIRST](first-function-dax.md) +[LAST](last-function-dax.md) +[NEXT](next-function-dax.md) diff --git a/query-languages/dax/previousday-function-dax.md b/query-languages/dax/previousday-function-dax.md index 02bd3e460..8e490a994 100644 --- a/query-languages/dax/previousday-function-dax.md +++ b/query-languages/dax/previousday-function-dax.md @@ -1,61 +1,55 @@ --- description: "Learn more about: PREVIOUSDAY" -title: "PREVIOUSDAY function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PREVIOUSDAY function (DAX)" --- # PREVIOUSDAY -Returns a table that contains a column of all dates representing the day that is previous to the first date in the **dates** column, in the current context. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of all dates representing the day that is previous to the first date in the `dates` column, in the current context. + +## Syntax + ```dax -PREVIOUSDAY() +PREVIOUSDAY() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column containing dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column containing dates.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## Remarks -- This function determines the first date in the input parameter, and then returns all dates corresponding to the day previous to that first date. For example, if the first date in the **dates** argument refers to June 10, 2009; this function returns all dates equal to June 9, 2009. - -- 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](calculate-function-dax.md). - +- This function determines the first date in the input parameter, and then returns all dates corresponding to the day previous to that first date. For example, if the first date in the `dates` argument refers to June 10, 2009; this function returns all dates equal to June 9, 2009. + +- 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](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'previous day sales' for Internet sales. - +The following sample formula creates a measure that calculates the 'previous day sales' for Internet sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSDAY('DateTime'[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSDAY('DateTime'[DateKey])) ``` - -## See also - -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[PREVIOUSMONTH function](previousmonth-function-dax.md) -[PREVIOUSQUARTER function](previousquarter-function-dax.md) -[PREVIOUSYEAR function](previousyear-function-dax.md) - + +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[PREVIOUSMONTH function](previousmonth-function-dax.md) +[PREVIOUSQUARTER function](previousquarter-function-dax.md) +[PREVIOUSYEAR function](previousyear-function-dax.md) + diff --git a/query-languages/dax/previousmonth-function-dax.md b/query-languages/dax/previousmonth-function-dax.md index 9009d4638..eac05333f 100644 --- a/query-languages/dax/previousmonth-function-dax.md +++ b/query-languages/dax/previousmonth-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: PREVIOUSMONTH" -title: "PREVIOUSMONTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PREVIOUSMONTH function (DAX)" --- # PREVIOUSMONTH -Returns a table that contains a column of all dates from the previous month, based on the first date in the **Dates** column, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of all dates from the previous month, based on the first date in the `` column, in the current context. + +## Syntax + ```dax -PREVIOUSMONTH() +PREVIOUSMONTH() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Dates|A column containing dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Dates`|A column containing dates.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## Remarks -- This function returns all dates from the previous month, using the first date in the column used as input. For example, if the first date in the **Dates** argument refers to June 10, 2009, this function returns all dates for the month of May, 2009. - -- 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](calculate-function-dax.md). - +- This function returns all dates from the previous month, using the first date in the column used as input. For example, if the first date in the `Dates` argument refers to June 10, 2009, this function returns all dates for the month of May, 2009. + +- 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](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'previous month sales' for Internet sales. +The following sample formula creates a measure that calculates the 'previous month sales' for sales. ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSMONTH('DateTime'[DateKey])) += CALCULATE ( SUM ( 'Sales'[Sales Amount] ), PREVIOUSMONTH ( 'Date'[Date] ) ) ``` - -## See also - -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[PREVIOUSDAY](previousday-function-dax.md) -[PREVIOUSQUARTER](previousquarter-function-dax.md) -[PREVIOUSYEAR](previousyear-function-dax.md) + +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[PREVIOUSDAY](previousday-function-dax.md) +[PREVIOUSQUARTER](previousquarter-function-dax.md) +[PREVIOUSYEAR](previousyear-function-dax.md) diff --git a/query-languages/dax/previousquarter-function-dax.md b/query-languages/dax/previousquarter-function-dax.md index 261f5f235..517afc787 100644 --- a/query-languages/dax/previousquarter-function-dax.md +++ b/query-languages/dax/previousquarter-function-dax.md @@ -1,61 +1,54 @@ --- description: "Learn more about: PREVIOUSQUARTER" -title: "PREVIOUSQUARTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PREVIOUSQUARTER function (DAX)" --- # PREVIOUSQUARTER -Returns a table that contains a column of all dates from the previous quarter, based on the first date in the **dates** column, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of all dates from the previous quarter, based on the first date in the `dates` column, in the current context. + +## Syntax + ```dax -PREVIOUSQUARTER() +PREVIOUSQUARTER() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column containing dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column containing dates.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## Remarks -- This function returns all dates from the previous quarter, using the first date in the input column. For example, if the first date in the **dates** argument refers to June 10, 2009, this function returns all dates for the quarter January to March, 2009. - -- 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](calculate-function-dax.md). - +- This function returns all dates from the previous quarter, using the first date in the input column. For example, if the first date in the `dates` argument refers to June 10, 2009, this function returns all dates for the quarter January to March, 2009. + +- 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](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'previous quarter sales' for Internet sales. - +The following sample formula creates a measure that calculates the 'previous quarter sales' for Internet sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSQUARTER('DateTime'[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSQUARTER('DateTime'[DateKey])) ``` - -## See also -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[PREVIOUSMONTH](previousmonth-function-dax.md) -[PREVIOUSDAY](previousday-function-dax.md) +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[PREVIOUSMONTH](previousmonth-function-dax.md) +[PREVIOUSDAY](previousday-function-dax.md) [PREVIOUSYEAR](previousyear-function-dax.md) diff --git a/query-languages/dax/previousyear-function-dax.md b/query-languages/dax/previousyear-function-dax.md index f08d84319..d90b0efd7 100644 --- a/query-languages/dax/previousyear-function-dax.md +++ b/query-languages/dax/previousyear-function-dax.md @@ -1,64 +1,57 @@ --- description: "Learn more about: PREVIOUSYEAR" -title: "PREVIOUSYEAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PREVIOUSYEAR function (DAX)" --- # PREVIOUSYEAR -Returns a table that contains a column of all dates from the previous year, given the last date in the **dates** column, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of all dates from the previous year, given the last date in the `dates` column, in the current context. + +## Syntax + ```dax -PREVIOUSYEAR([,]) +PREVIOUSYEAR([,]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column containing dates.| -|year_end_date|(optional) A literal string with a date that defines the year-end date. The default is December 31.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column containing dates.| +|`year_end_date`|(optional) A literal string with a date that defines the year-end date. The default is December 31.| + ## Return value -A table containing a single column of date values. - +A table containing a single column of date values. + ## Remarks -- This function returns all dates from the previous year given the latest date in the input parameter. For example, if the latest date in the **dates** argument refers to the year 2009, then this function returns all dates for the year of 2008, up to the specified **year_end_date**. - -- The **dates** argument can be any of the following: +- This function returns all dates from the previous year given the latest date in the input parameter. For example, if the latest date in the `dates` argument refers to the year 2009, then this function returns all dates for the year of 2008, up to the specified `year_end_date`. + +- 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](calculate-function-dax.md). - -- The **year_end_date** parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. - + - A Boolean expression that defines a single-column table of date/time values. + +- Constraints on Boolean expressions are described in the topic, [CALCULATE](calculate-function-dax.md). + +- The `year_end_date` parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is ignored. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the previous year sales for Internet sales. - +The following sample formula creates a measure that calculates the previous year sales for Internet sales. + ```dax -= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSYEAR('DateTime'[DateKey])) += CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSYEAR('DateTime'[DateKey])) ``` - -## See also - -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions](date-and-time-functions-dax.md) -[PREVIOUSMONTH](previousmonth-function-dax.md) -[PREVIOUSDAY](previousday-function-dax.md) -[PREVIOUSQUARTER](previousquarter-function-dax.md) + +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[PREVIOUSMONTH](previousmonth-function-dax.md) +[PREVIOUSDAY](previousday-function-dax.md) +[PREVIOUSQUARTER](previousquarter-function-dax.md) diff --git a/query-languages/dax/price-function-dax.md b/query-languages/dax/price-function-dax.md index 325bba1e6..4329d435b 100644 --- a/query-languages/dax/price-function-dax.md +++ b/query-languages/dax/price-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: PRICE" -title: "PRICE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "PRICE function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # PRICE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the price per \\$100 face value of a security that pays periodic interest. ## Syntax @@ -24,19 +18,19 @@ PRICE(, , , , , [, , , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|discount|The security's discount rate.| -|redemption|The security's redemption value per \\$100 face value.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`discount`|The security's discount rate.| +|`redemption`|The security's redemption value per \\$100 face value.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | `Day count basis` | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/pricemat-function-dax.md b/query-languages/dax/pricemat-function-dax.md index 4a34d7aa5..b087167fa 100644 --- a/query-languages/dax/pricemat-function-dax.md +++ b/query-languages/dax/pricemat-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: PRICEMAT" -title: "PRICEMAT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "PRICEMAT function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # PRICEMAT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the price per \\$100 face value of a security that pays interest at maturity. ## Syntax @@ -24,18 +18,18 @@ PRICEMAT(, , , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|issue|The security's issue date.| -|rate|The security's interest rate at date of issue.| -|yld|The security's annual yield.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`issue`|The security's issue date.| +|`rate`|The security's interest rate at date of issue.| +|`yld`|The security's annual yield.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/product-function-dax.md b/query-languages/dax/product-function-dax.md index 9aeba078d..1c7b73cf8 100644 --- a/query-languages/dax/product-function-dax.md +++ b/query-languages/dax/product-function-dax.md @@ -1,54 +1,47 @@ --- description: "Learn more about: PRODUCT" -title: "PRODUCT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PRODUCT function (DAX)" --- # PRODUCT - -Returns the product of the numbers in a column. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the product of the numbers in a column. + +## Syntax + ```dax -PRODUCT() +PRODUCT() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column that contains the numbers for which the product is to be computed.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that contains the numbers for which the product is to be computed.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- To return the product of an expression evaluated for each row in a table, use [PRODUCTX function](productx-function-dax.md). +- To return the product of an expression evaluated for each row in a table, use [PRODUCTX function](productx-function-dax.md). - Only the numbers in the column are counted. Blanks, logical values, and text are ignored. For example, - `PRODUCT( Table[Column] )` is equivalent to `PRODUCTX( Table, Table[Column] )`. + `PRODUCT( Table[Column] )` is equivalent to `PRODUCTX( Table, Table[Column] )`. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following computes the product of the AdjustedRates column in an Annuity table: - +The following computes the product of the AdjustedRates column in an Annuity table: + ```dax -= PRODUCT( Annuity[AdjustedRates] ) += PRODUCT( Annuity[AdjustedRates] ) ``` - -## See also -[PRODUCTX](productx-function-dax.md) +## Related content + +[PRODUCTX](productx-function-dax.md) diff --git a/query-languages/dax/productx-function-dax.md b/query-languages/dax/productx-function-dax.md index a2e1d1e3e..bb40aae41 100644 --- a/query-languages/dax/productx-function-dax.md +++ b/query-languages/dax/productx-function-dax.md @@ -1,55 +1,48 @@ --- description: "Learn more about: PRODUCTX" -title: "PRODUCTX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "PRODUCTX function (DAX)" --- # PRODUCTX -Returns the product of an expression evaluated for each row in a table. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the product of an expression evaluated for each row in a table. + +## Syntax + ```dax -PRODUCTX(
, ) +PRODUCTX(
, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of the table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of the table.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- To return the product of the numbers in a column, use [PRODUCT](product-function-dax.md). +- To return the product of the numbers in a column, use [PRODUCT](product-function-dax.md). + +- The PRODUCTX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers for which you want to compute the product, or an expression that evaluates to a column. -- The PRODUCTX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers for which you want to compute the product, or an expression that evaluates to a column. - -- Only the numbers in the column are counted. Blanks, logical values, and text are ignored. +- Only the numbers in the column are counted. Blanks, logical values, and text are ignored. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following computes the future value of an investment: - +The following computes the future value of an investment: + ```dax -= [PresentValue] * PRODUCTX( AnnuityPeriods, 1+[FixedInterestRate] ) += [PresentValue] * PRODUCTX( AnnuityPeriods, 1+[FixedInterestRate] ) ``` - -## See also -[PRODUCT](product-function-dax.md) +## Related content + +[PRODUCT](product-function-dax.md) diff --git a/query-languages/dax/pv-function-dax.md b/query-languages/dax/pv-function-dax.md index fedffdcf8..52a6440b6 100644 --- a/query-languages/dax/pv-function-dax.md +++ b/query-languages/dax/pv-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: PV" -title: "PV function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "PV function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # PV +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Calculates the present value of a loan or an investment, based on a constant interest rate. You can use PV with either periodic, constant payments (such as a mortgage or other loan), and/or a future value that's your investment goal. ## Syntax @@ -24,17 +18,17 @@ PV(, , [, [, ]]) ### Parameters -|Term|Definition| -|--------|--------------| -|rate|The interest rate per period. For example, if you obtain an automobile loan at a 10 percent annual interest rate and make monthly payments, your interest rate per month is 0.1/12, or 0.0083. You would enter 0.1/12, or 0.0083, into the formula as the rate.| -|nper|The total number of payment periods in an annuity. For example, if you get a four-year car loan and make monthly payments, your loan has 4*12 (or 48) periods. You would enter 48 into the formula for nper.| -|pmt|The payment made each period that cannot change over the life of the annuity. Typically, pmt includes principal and interest but no other fees or taxes. For example, the monthly payments on a \\$10,000, four-year car loan at 12 percent are \\$263.33. You would enter -263.33 into the formula as the pmt.| -|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. For example, if you want to save \\$50,000 to pay for a special project in 18 years, then \\$50,000 is the future value. You could then make a conservative guess at an interest rate and determine how much you must save each month.| -|type|(Optional) The number 0 or 1 which indicates when payments are due. If type is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`rate`|The interest rate per period. For example, if you obtain an automobile loan at a 10 percent annual interest rate and make monthly payments, your interest rate per month is 0.1/12, or 0.0083. You would enter 0.1/12, or 0.0083, into the formula as the rate.| +|`nper`|The total number of payment periods in an annuity. For example, if you get a four-year car loan and make monthly payments, your loan has 4*12 (or 48) periods. You would enter 48 into the formula for nper.| +|`pmt`|The payment made each period that cannot change over the life of the annuity. Typically, pmt includes principal and interest but no other fees or taxes. For example, the monthly payments on a \\$10,000, four-year car loan at 12 percent are \\$263.33. You would enter -263.33 into the formula as the pmt.| +|`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. For example, if you want to save \\$50,000 to pay for a special project in 18 years, then \\$50,000 is the future value. You could then make a conservative guess at an interest rate and determine how much you must save each month.| +|`type`|(Optional) The number 0 or 1 which indicates when payments are due. If type is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **type** parameter accepts the following values: +The `type` parameter accepts the following values: -| **Set type equal to** | **If payments are due** | +| **Set `type` equal to** | **If payments are due** | | --------------------- | ------------------------------ | | 0 or omitted | At the end of the period | | 1 | At the beginning of the period | @@ -48,16 +42,16 @@ The present value of a loan or investment. - 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 12 percent annual interest, 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. - The following functions apply to annuities: - - CUMIPMT - - CUMPRINC - - FV - - IPMT - - PMT - - PPMT - - PV - - RATE - - XIRR - - XNPV + - `CUMIPMT` + - `CUMPRINC` + - `FV` + - `IPMT` + - `PMT` + - `PPMT` + - `PV` + - `RATE` + - `XIRR` + - `XNPV` - An annuity is a series of constant cash payments made over a continuous period. For example, a car loan or a mortgage is an annuity. For more information, see the description for each annuity function. diff --git a/query-languages/dax/quarter-function-dax.md b/query-languages/dax/quarter-function-dax.md index 34acd51ba..93580ce9a 100644 --- a/query-languages/dax/quarter-function-dax.md +++ b/query-languages/dax/quarter-function-dax.md @@ -1,37 +1,30 @@ --- description: "Learn more about: QUARTER" -title: "QUARTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "QUARTER function (DAX)" --- # QUARTER +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the quarter as a number from 1 (January – March) to 4 (October – December). - -## Syntax - + +## Syntax + ```dax QUARTER() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|date|A date.| - -## Return value - -An integer number from 1 to 4. - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`date`|A date.| + +## Return value + +An integer number from 1 to 4. + ## Remarks If the input value is BLANK, the output value is also BLANK. @@ -39,7 +32,7 @@ If the input value is BLANK, the output value is also BLANK. ## Example 1 The following DAX query: - + ```dax EVALUATE { QUARTER(DATE(2019, 2, 1)), QUARTER(DATE(2018, 12, 31)) } ``` @@ -54,7 +47,7 @@ Returns: ## Example 2 The following DAX query: - + ```dax EVALUATE ADDCOLUMNS( @@ -74,8 +67,8 @@ Returns: |3/31/2008 | 1 | | 4/1/2008 | 2 | -## See also +## Related content -[YEAR](year-function-dax.md) -[MONTH](month-function-dax.md) +[YEAR](year-function-dax.md) +[MONTH](month-function-dax.md) [DAY](day-function-dax.md) diff --git a/query-languages/dax/quotient-function-dax.md b/query-languages/dax/quotient-function-dax.md index a8ce71a4c..5aa649553 100644 --- a/query-languages/dax/quotient-function-dax.md +++ b/query-languages/dax/quotient-function-dax.md @@ -1,55 +1,48 @@ --- description: "Learn more about: QUOTIENT" -title: "QUOTIENT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "QUOTIENT function (DAX)" --- # QUOTIENT -Performs division and returns only the integer portion of the division result. Use this function when you want to discard the remainder of division. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Performs division and returns only the integer portion of the division result. Use this function when you want to discard the remainder of division. + +## Syntax + ```dax -QUOTIENT(, ) +QUOTIENT(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|numerator|The dividend, or number to divide.| -|denominator|The divisor, or number to divide by.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`numerator`|The dividend, or number to divide.| +|`denominator`|The divisor, or number to divide by.| + ## Return value -A whole number. - +A whole number. + ## Remarks -- If either argument is non-numeric, QUOTIENT returns the **#VALUE!** error value. - -- You can use a column reference instead of a literal value for either argument. However, if the column that you reference contains a 0 (zero), an error is returned for the entire column of values. - +- If either argument is non-numeric, QUOTIENT returns the `#VALUE!` error value. + +- You can use a column reference instead of a literal value for either argument. However, if the column that you reference contains a 0 (zero), an error is returned for the entire column of values. + ## Example -The following formulas return the same result, 2. - +The following formulas return the same result, 2. + ```dax = QUOTIENT(5,2) ``` ```dax -= QUOTIENT(10/2,2) += QUOTIENT(10/2,2) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) diff --git a/query-languages/dax/radians-function-dax.md b/query-languages/dax/radians-function-dax.md index b4fe7bcb1..134137697 100644 --- a/query-languages/dax/radians-function-dax.md +++ b/query-languages/dax/radians-function-dax.md @@ -1,34 +1,27 @@ --- description: "Learn more about: RADIANS" -title: "RADIANS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "RADIANS function (DAX)" --- # RADIANS -Converts degrees to radians. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Converts degrees to radians. + +## Syntax + ```dax -RADIANS(angle) +RADIANS(angle) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|angle|Required. An angle in degrees that you want to convert.| - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= RADIANS(270)|270 degrees as radians (4.712389 or 3π/2 radians)|4.712389| + +### Parameters + +|Term|Definition| +|--------|--------------| +|`angle`|Required. An angle in degrees that you want to convert.| + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= RADIANS(270)`|270 degrees as radians (4.712389 or 3π/2 radians)|4.712389| diff --git a/query-languages/dax/rand-function-dax.md b/query-languages/dax/rand-function-dax.md index d34d542a7..63948867f 100644 --- a/query-languages/dax/rand-function-dax.md +++ b/query-languages/dax/rand-function-dax.md @@ -1,44 +1,37 @@ --- description: "Learn more about: RAND" -title: "RAND function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "RAND function (DAX)" --- # RAND -Returns a random number greater than or equal to 0 and less than 1, evenly distributed. The number that is returned changes each time the cell containing this function is recalculated. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a random number greater than or equal to 0 and less than 1, evenly distributed. The number that is returned changes each time the cell containing this function is recalculated. + +## Syntax + ```dax -RAND() +RAND() ``` - + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- Recalculation depends on various factors, including whether the model is set to **Manual** or **Automatic** recalculation mode, and whether data has been refreshed. - -- RAND and other volatile functions that do not have fixed values are not always recalculated. For example, execution of a query or filtering will usually not cause such functions to be re-evaluated. However, the results for these functions will be recalculated when the entire column is recalculated. These situations include refresh from an external data source or manual editing of data that causes re-evaluation of formulas that contain these functions. - -- RAND is always recalculated if the function is used in the definition of a measure. - -- RAND function cannot return a result of zero, to prevent errors such as division by zero. - +- Recalculation depends on various factors, including whether the model is set to `Manual` or `Automatic` recalculation mode, and whether data has been refreshed. + +- RAND and other volatile functions that do not have fixed values are not always recalculated. For example, execution of a query or filtering will usually not cause such functions to be re-evaluated. However, the results for these functions will be recalculated when the entire column is recalculated. These situations include refresh from an external data source or manual editing of data that causes re-evaluation of formulas that contain these functions. + +- RAND is always recalculated if the function is used in the definition of a measure. + +- RAND function cannot return a result of zero, to prevent errors such as division by zero. + ## Examples -To generate a random real number between two other numbers, use: - +To generate a random real number between two other numbers, use: + ```dax = RAND()*(b-a)+a @@ -65,8 +58,8 @@ INT(RAND()*100) ``` -## See also +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[Statistical functions](statistical-functions-dax.md) -[Math and Trig functions](math-and-trig-functions-dax.md) -[Statistical functions](statistical-functions-dax.md) - diff --git a/query-languages/dax/randbetween-function-dax.md b/query-languages/dax/randbetween-function-dax.md index ec83b6deb..55ee49bae 100644 --- a/query-languages/dax/randbetween-function-dax.md +++ b/query-languages/dax/randbetween-function-dax.md @@ -1,50 +1,43 @@ --- description: "Learn more about: RANDBETWEEN" -title: "RANDBETWEEN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "RANDBETWEEN function (DAX)" --- # RANDBETWEEN -Returns a random number in the range between two numbers you specify. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a random number in the range between two numbers you specify. + +## Syntax + ```dax -RANDBETWEEN(,) +RANDBETWEEN(,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Bottom|The smallest integer the function will return.| -|Top|The largest integer the function will return.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Bottom`|The smallest integer the function will return.| +|`Top`|The largest integer the function will return.| + ## Return value -A whole number. - +A whole number. + ## Remarks [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following formula returns a random number between 1 and 10. - +The following formula returns a random number between 1 and 10. + ```dax -= RANDBETWEEN(1,10) += RANDBETWEEN(1,10) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) -[Statistical functions](statistical-functions-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/range-function-dax.md b/query-languages/dax/range-function-dax.md new file mode 100644 index 000000000..6472bc876 --- /dev/null +++ b/query-languages/dax/range-function-dax.md @@ -0,0 +1,74 @@ +--- +description: "Learn more about: RANGE function" +title: "RANGE function (DAX)" +ms.service: powerbi +ms.subservice: dax +ms.date: 01/17/2023 +ms.topic: reference +author: masanto-msft +ms.author: masanto +recommendations: false + +--- + +# RANGE + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Returns an interval of rows within the given axis, relative to the current row. This interval will be comprised of either the last `step` rows before the current one, or the first `step` rows after the current one. + +## Syntax + +```dax +RANGE ( [, ][, ][, ][, ][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`step`|The number of rows before (negative value) or after (positive value) the current row to include in the range. Must be a constant value.
- If negative, the window will contain the last -step rows before the current row.
- Otherwise, the window will contain the first step rows after the current row.| +|`includeCurrent`|(Optional) A logical value specifying whether or not to include the current row in the range. Default value is True.| +|`axis`|(Optional) An axis reference, the direction along which the interval will be created. If omitted, the first axis of the Visual Shape definition is used.| +|`orderBy`|(Optional) An ORDERBY() clause with expressions that determine how to sort each partition along the `axis`. If `orderBy` is not provided, the data is sorted by the grouping columns on the default `axis` in ascending order by default.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.
| +|`reset`|(Optional) Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +An interval of data rows. + +## Remarks + +This function can be used in visual calculations only. + +The `includeCurrent`, `axis`, `orderBy`, `blanks` and `reset` parameters can be omitted. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example 1 + +Given a table that summarizes the total sales for each product category and month, the following DAX query adds a column with the total sales in the last 6 months: + +```dax +TotalSalesLast6Months = CALCULATE(SUM([SalesAmount]), RANGE(-5, Rows)) +``` + +The screenshot below shows the visual matrix and the visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-range.png) + +## Example 2 + +Given the same table, the following DAX query adds a column with the total sales in the following 12 months, not including the current month: + +```dax +TotalSalesFollowingYear = CALCULATE(SUM([SalesAmount]), RANGE(12, FALSE, Rows, KEEP)) +``` + +## See also + +[INDEX](index-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[WINDOW](window-function-dax.md) diff --git a/query-languages/dax/rank-eq-function-dax.md b/query-languages/dax/rank-eq-function-dax.md index 054a7710e..e9a702999 100644 --- a/query-languages/dax/rank-eq-function-dax.md +++ b/query-languages/dax/rank-eq-function-dax.md @@ -1,67 +1,60 @@ --- description: "Learn more about: RANK.EQ" -title: "RANK.EQ function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "RANK.EQ function (DAX)" --- # RANK.EQ -Returns the ranking of a number in a list of numbers. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the ranking of a number in a list of numbers. + +## Syntax + ```dax -RANK.EQ(, [, ]) +RANK.EQ(, [, ]) ``` - + ### Parameters -|Term|Definition| -|--------|--------------| -|value |Any DAX expression that returns a single scalar value whose rank is to be found. The expression is to be evaluated exactly once, before the function is evaluated, and it's value passed to the argument list. | -|columnName |The name of an existing column against which ranks will be determined. It cannot be an expression or a column created using these functions: ADDCOLUMNS, ROW or SUMMARIZE. | -|order |(Optional) A value that specifies how to rank *number*, low to high or high to low: | +|Term|Definition| +|--------|--------------| +|`value` |Any DAX expression that returns a single scalar value whose rank is to be found. The expression is to be evaluated exactly once, before the function is evaluated, and it's value passed to the argument list. | +|`columnName` |The name of an existing column against which ranks will be determined. It cannot be an expression or a column created using these functions: `ADDCOLUMNS`, `ROW`, or `SUMMARIZE`. | +|`order` |(Optional) A value that specifies how to rank *numbers*, low to high or high to low: | #### order values -|value|alternate value|Description| -|-----|-----|-----| -|0 (zero)|FALSE|Ranks in descending order of *columnName*. If *value* is equal to the highest number in *columnName* then **RANK.EQ** is 1.| -|1|TRUE|Ranks in ascending order of *columnName*. If *value* is equal to the lowest number in *columnName* then **RANK.EQ** is 1.| - +|value|alternate value|Description| +|-----|-----|-----| +|`0` (zero)|`FALSE`|Ranks in descending order of `columnName`. If `value` is equal to the highest number in `columnName` then `RANK.EQ` is 1.| +|`1`|`TRUE`|Ranks in ascending order of `columnName`. If `value` is equal to the lowest number in `columnName` then `RANK.EQ` is 1.| + ## Return value -A number indicating the rank of *value* among the numbers in *columnName*. - -## Remarks - -- *columnName* cannot refer to any column created using these functions: ADDCOLUMNS, ROW or SUMMARIZE.I - -- If *value* is not in *columnName* or value is a blank, then *RANK.EQ* returns a blank value. - -- Duplicate values of *value* receive the same rank value; the next rank value assigned will be the rank value plus the number of duplicate values. For example if five (5) values are tied with a rank of 11 then the next value will receive a rank of 16 (11 + 5). +A number indicating the rank of `value` among the numbers in `columnName`. + +## Remarks + +- `columnName` cannot refer to any column created using these functions: ADDCOLUMNS, ROW or SUMMARIZE.I + +- If `value` is not in `columnName` or value is a blank, then *RANK.EQ* returns a blank value. + +- Duplicate values of `value` receive the same rank value; the next rank value assigned will be the rank value plus the number of duplicate values. For example if five (5) values are tied with a rank of 11 then the next value will receive a rank of 16 (11 + 5). - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example 1 -The following example creates a calculated column that ranks the values in SalesAmount_USD, from the *InternetSales_USD* table, against all numbers in the same column. - +The following example creates a calculated column that ranks the values in SalesAmount_USD, from the *InternetSales_USD* table, against all numbers in the same column. + ```dax -= RANK.EQ(InternetSales_USD[SalesAmount_USD], InternetSales_USD[SalesAmount_USD]) += RANK.EQ(InternetSales_USD[SalesAmount_USD], InternetSales_USD[SalesAmount_USD]) ``` - + ## Example 2 -The following example ranks a subset of values against a given sample. Assume that you have a table of local students with their performance in a specific national test and, also, you have the entire set of scores in that national test. The following calculated column will give you the national ranking for each of the local students. - +The following example ranks a subset of values against a given sample. Assume that you have a table of local students with their performance in a specific national test and, also, you have the entire set of scores in that national test. The following calculated column will give you the national ranking for each of the local students. + ```dax -= RANK.EQ(Students[Test_Score], NationalScores[Test_Score]) += RANK.EQ(Students[Test_Score], NationalScores[Test_Score]) ``` diff --git a/query-languages/dax/rank-function-dax.md b/query-languages/dax/rank-function-dax.md new file mode 100644 index 000000000..9f32859e0 --- /dev/null +++ b/query-languages/dax/rank-function-dax.md @@ -0,0 +1,96 @@ +--- +description: "Learn more about: RANK" +title: "RANK function (DAX)" +author: rahulten +--- + +# RANK + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the ranking for the current context within the specified partition, sorted by the specified order. If a match cannot be found then then rank is blank. + +## Syntax + +```dax +RANK ( [][, or ][, ][, ][, ][, ][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`ties`|(Optional) Defines how to handle the ranking when two or more rows are tied.
If specified, the supported value is either DENSE, or SKIP.
If omitted:
- Defaults to SKIP | +|`relation`|(Optional) A table expression from which the output row is returned. If used in visual calculations, this parameter accepts an axis in the visual shape.
If specified, all columns in `orderBy` and `partitionBy` must come from it.
If omitted:
- `orderBy` must be explicitly specified.
- All `orderBy` and `partitionBy` columns must be fully qualified and come from a single table.
- Defaults to ALLSELECTED() of all columns in `orderBy` and `partitionBy`.| +|`orderBy`|(Optional) An ORDERBY() clause containing the columns that define how each partition is sorted.
If omitted:
- `relation` must be explicitly specified.
- Defaults to ordering by every column in `relation` that is not already specified in `partitionBy`.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `relation` or `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.

Note, when the `blanks` parameter and blanks in the [ORDERBY()](orderby-function-dax.md) function on individual expressions are both specified, `blanks` on individual orderBy expression takes priority for the relevant orderBy expression, and orderBy expressions without `blanks` being specified will honor the `blanks` parameter on the parent function.| +|`partitionBy`|(Optional) A [PARTITIONBY()](partitionby-function-dax.md) clause containing the columns that define how `relation` is partitioned. If omitted, `relation` is treated as a single partition.| +|`matchBy`|(Optional) A [MATCHBY()](matchby-function-dax.md) clause containing the columns that define how to match data and identify the current row.| +|`reset`|(Optional) Available in visual calculations only. Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +The rank number for the current context. + +## Remarks + +- Each `orderBy`, `partitionBy`, and `matchBy` column must have a corresponding outer value to help define the current row on which to operate, with the following behavior: + + - If there is exactly one corresponding outer column, its value is used. + - If there is no corresponding outer column, then: + - RANK will first determine all `orderBy`, `partitionBy`, and `matchBy` columns that have no corresponding outer column. + - For every combination of existing values for these columns in RANK parent context, RANK is evaluated and a row is returned. + - RANK’s final output is a rank number. +- If `matchBy` is present, then RANK will try to use columns in `matchBy` and `partitionBy` to idenfity the current row. +- If the columns specified within `orderBy` and `partitionBy` cannot uniquely identify every row in `relation`, then two or more rows may have the same ranking and the ranking will be determined by the ties parameter. +- RANK returns a blank value for total rows. It's recommended that you test your expression thoroughly. +- RANK does not compare to RANKX as SUM compares to SUMX. +- `reset` can be used in visual calculations only, and cannot be used in combination with `orderBy` or `partitionBy`. If `reset` is present, `axis` can be specified but `relation` cannot. +- If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example 1 - calculated column + +The following DAX query: + +```dax +EVALUATE +ADDCOLUMNS( + 'DimGeography', + "Rank", + RANK( + DENSE, + 'DimGeography', + ORDERBY( + 'DimGeography'[StateProvinceName], desc, + 'DimGeography'[City], asc), + LAST, + PARTITIONBY( + 'DimGeography'[EnglishCountryRegionName]))) +ORDER BY [EnglishCountryRegionName] asc, [StateProvinceName] desc, [City] asc +``` + +Returns a table that ranks each geography with the same EnglishCountryRegionName, by their StateProvinceName and City. Blank `orderBy` column values are sorted on the end. + +## Example 2 - visual calculation + +The following visual calculation DAX queries: + +```dax +SalesRankWithinYear = RANK(DENSE, ORDERBY([SalesAmount], DESC), PARTITIONBY([CalendarYear])) + +SalesRankAllHistory = RANK(DENSE, ORDERBY([SalesAmount], DESC)) +``` + +Create two columns that rank each month by the total sales, both within each year, and the entire history. + +The screenshot below shows the visual matrix and the first visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-rank.png) + +## Related content + +[INDEX](index-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[WINDOW](window-function-dax.md) +[ROWNUMBER](rownumber-function-dax.md) diff --git a/query-languages/dax/rankx-function-dax.md b/query-languages/dax/rankx-function-dax.md index 12f6eda20..e7dd57c79 100644 --- a/query-languages/dax/rankx-function-dax.md +++ b/query-languages/dax/rankx-function-dax.md @@ -1,75 +1,68 @@ --- description: "Learn more about: RANKX" -title: "RANKX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 04/05/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "RANKX function (DAX)" --- # RANKX -Returns the ranking of a number in a list of numbers for each row in the *table* argument. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the ranking of a number in a list of numbers for each row in the `table` argument. + +## Syntax + ```dax -RANKX(
, [, [, [, ]]]) +RANKX(
, [, [, [, ]]]) ``` - + ### Parameters -**table** -Any DAX expression that returns a table of data over which the expression is evaluated. - -**expression** -Any DAX expression that returns a single scalar value. The expression is evaluated for each row of *table*, to generate all possible values for ranking. See the remarks section to understand the function behavior when *expression* evaluates to BLANK. - -**value** -(Optional) Any DAX expression that returns a single scalar value whose rank is to be found. See the remarks section to understand the function's behavior when *value* is not found in the expression. - -When the *value* parameter is omitted, the value of expression at the current row is used instead. - -**order** -(Optional) A value that specifies how to rank *value*, low to high or high to low: +`table` +Any DAX expression that returns a table of data over which the expression is evaluated. + +`expression` +Any DAX expression that returns a single scalar value. The expression is evaluated for each row of `table`, to generate all possible values for ranking. See the remarks section to understand the function behavior when `expression` evaluates to BLANK. + +`value` +(Optional) Any DAX expression that returns a single scalar value whose rank is to be found. See the remarks section to understand the function's behavior when `value` is not found in the expression. + +When the `value` parameter is omitted, the value of expression at the current row is used instead. + +`order` +(Optional) A value that specifies how to rank `value`, low to high or high to low: |value|alternate value|Description| |-----|-----|-----| -|0 (zero)|FALSE|Ranks in descending order of values of expression. If value is equal to the highest number in expression then RANKX returns 1.

This is the default value when order parameter is omitted.| -|1|TRUE|Ranks in ascending order of expression. If value is equal to the lowest number in expression then RANKX returns 1.| - -**ties** -(Optional) An enumeration that defines how to determine ranking when there are ties. - -|enumeration|Description| -|-----|-----| -|Skip|The next rank value, after a tie, is the rank value of the tie plus the count of tied values. For example if five (5) values are tied with a rank of 11 then the next value will receive a rank of 16 (11 + 5).

This is the default value when *ties* parameter is omitted.| -|Dense|The next rank value, after a tie, is the next rank value. For example if five (5) values are tied with a rank of 11 then the next value will receive a rank of 12.| - +|0 (zero)|`FALSE`|Ranks in descending order of values of expression. If value is equal to the highest number in expression then RANKX returns 1.

This is the default value when order parameter is omitted.| +|1|`TRUE`|Ranks in ascending order of expression. If value is equal to the lowest number in expression then RANKX returns 1.| + +`ties` +(Optional) An enumeration that defines how to determine ranking when there are ties. + +|enumeration|Description| +|-----|-----| +|`Skip`|The next rank value, after a tie, is the rank value of the tie plus the count of tied values. For example if five (5) values are tied with a rank of 11 then the next value will receive a rank of 16 (11 + 5).

This is the default value when `ties` parameter is omitted.| +|`Dense`|The next rank value, after a tie, is the next rank value. For example if five (5) values are tied with a rank of 11 then the next value will receive a rank of 12.| + ## Return value -The rank number of *value* among all possible values of *expression* evaluated for all rows of *table* numbers. - -## Remarks - -- If *expression* or *value* evaluates to BLANK it is treated as a 0 (zero) for all expressions that result in a number, or as an empty text for all text expressions. - -- If *value* is not among all possible values of *expression* then RANKX temporarily adds *value* to the values from *expression* and re-evaluates RANKX to determine the proper rank of *value*. - -- Optional arguments might be skipped by placing an empty comma (,) in the argument list, i.e. RANKX(Inventory, [InventoryCost],,,"Dense") +The rank number of `value` among all possible values of `expression` evaluated for all rows of `table` numbers. + +## Remarks -- Equality related comparisons (=, \< \>, \>= and \<=) between values with the *Decimal Number* data type can potentialy return unexpected results when using RANKX function. Incorrect results can occur because values with *Decimal Number* data type are stored as IEEE Standard 754 floating point numbers and have inherent limitations in their precision. To avoid unexpected results, change the data type to *Fixed Decimal Number* or do a forced rounding using [ROUND](/dax/round-function-dax). +- If `expression` or `value` evaluates to BLANK it is treated as a 0 (zero) for all expressions that result in a number, or as an empty text for all text expressions. + +- If `value` is not among all possible values of `expression` then RANKX temporarily adds `value` to the values from `expression` and re-evaluates RANKX to determine the proper rank of `value`. + +- Optional arguments might be skipped by placing an empty comma (,) in the argument list, such as `RANKX(Inventory, [InventoryCost],,,"Dense")`. + +- Equality related comparisons (`=`, `<`, `>`, `>=` and `<=`) between values with the *Decimal Number* data type can potentially return unexpected results when using RANKX function. Incorrect results can occur because values with *Decimal Number* data type are stored as IEEE Standard 754 floating point numbers and have inherent limitations in their precision. To avoid unexpected results, change the data type to *Fixed Decimal Number* or do a forced rounding using [ROUND](/dax/round-function-dax). - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following calculated column in the Products table calculates the sales ranking for each product in the Internet channel. - +The following calculated column in the Products table calculates the sales ranking for each product in the Internet channel. + ```dax -= RANKX(ALL(Products), SUMX(RELATEDTABLE(InternetSales), [SalesAmount])) += RANKX(ALL(Products), SUMX(RELATEDTABLE(InternetSales), [SalesAmount])) ``` diff --git a/query-languages/dax/rate-function-dax.md b/query-languages/dax/rate-function-dax.md index 3c9ed0a8b..1d1a10e02 100644 --- a/query-languages/dax/rate-function-dax.md +++ b/query-languages/dax/rate-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: RATE" -title: "RATE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "RATE function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # RATE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the interest rate per period of an annuity. RATE is calculated by iteration and can have zero or more solutions. If the successive results of RATE do not converge to within 0.0000001 after 20 iterations, an error is returned. ## Syntax @@ -24,18 +18,18 @@ RATE(, , [, [, [, ]]]) ### Parameters -|Term|Definition| -|--------|--------------| -|nper|The total number of payment periods in an annuity.| -|pmt|The payment made each period and cannot change over the life of the annuity. Typically, pmt includes principal and interest but no other fees or taxes.| -|pv|The present value — the total amount that a series of future payments is worth now.| -|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 0 (the future value of a loan, for example, is 0).| -|type|(Optional) The number 0 or 1 which indicates when payments are due. If type is omitted, it is assumed to be 0. The accepted values are listed below this table.| -|guess|(Optional) Your guess for what the rate will be.
- If omitted, it is assumed to be 10%.
- If RATE does not converge, try different values for guess. RATE usually converges if guess is between 0 and 1.| +|Term|Definition| +|--------|--------------| +|`nper`|The total number of payment periods in an annuity.| +|`pmt`|The payment made each period and cannot change over the life of the annuity. Typically, pmt includes principal and interest but no other fees or taxes.| +|`pv`|The present value — the total amount that a series of future payments is worth now.| +|`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 0 (the future value of a loan, for example, is 0).| +|`type`|(Optional) The number 0 or 1 which indicates when payments are due. If type is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|`guess`|(Optional) Your guess for what the rate will be.
- If omitted, it is assumed to be 10%.
- If RATE does not converge, try different values for guess. RATE usually converges if guess is between 0 and 1.| -The **type** parameter accepts the following values: +The `type` parameter accepts the following values: -| **Set type equal to** | **If payments are due** | +| **Set `type` equal to** | **If payments are due** | | --------------------- | ------------------------------ | | 0 or omitted | At the end of the period | | 1 | At the beginning of the period | diff --git a/query-languages/dax/received-function-dax.md b/query-languages/dax/received-function-dax.md index 0bab658a6..c9baa7a59 100644 --- a/query-languages/dax/received-function-dax.md +++ b/query-languages/dax/received-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: RECEIVED" -title: "RECEIVED function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "RECEIVED function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # RECEIVED +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the amount received at maturity for a fully invested security. ## Syntax @@ -24,17 +18,17 @@ RECEIVED(, , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|investment|The amount invested in the security.| -|discount|The security's discount rate.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`investment`|The amount invested in the security.| +|`discount`|The security's discount rate.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/related-function-dax.md b/query-languages/dax/related-function-dax.md index f25ddacee..0a1b63df3 100644 --- a/query-languages/dax/related-function-dax.md +++ b/query-languages/dax/related-function-dax.md @@ -1,101 +1,94 @@ --- description: "Learn more about: RELATED" -title: "RELATED function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/14/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "RELATED function (DAX)" --- # RELATED -Returns a related value from another table. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Returns a related value from another table. + +## Syntax + ```dax -RELATED() +RELATED() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column that contains the values you want to retrieve.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that contains the values you want to retrieve.| + ## Return value -A single value that is related to the current row. - +A single value that is related to the current row. + ## Remarks -- The RELATED function requires that a relationship exists between the current table and the table with related information. You specify the column that contains the data that you want, and the function follows an existing many-to-one relationship to fetch the value from the specified column in the related table. If a relationship does not exist, you must create a relationship. - -- When the RELATED function performs a lookup, it examines all values in the specified table regardless of any filters that may have been applied. - -- The RELATED function needs a row context; therefore, it can only be used in calculated column expression, where the current row context is unambiguous, or as a nested function in an expression that uses a table scanning function. A table scanning function, such as SUMX, gets the value of the current row value and then scans another table for instances of that value. +- The RELATED function requires that a relationship exists between the current table and the table with related information. You specify the column that contains the data that you want, and the function follows an existing many-to-one relationship to fetch the value from the specified column in the related table. If a relationship does not exist, you must create a relationship. + +- When the RELATED function performs a lookup, it examines all values in the specified table regardless of any filters that may have been applied. + +- The RELATED function needs a row context; therefore, it can only be used in calculated column expression, where the current row context is unambiguous, or as a nested function in an expression that uses a table scanning function. A table scanning function, such as SUMX, gets the value of the current row value and then scans another table for instances of that value. - The RELATED function cannot be used to fetch a column across a [limited relationship](/power-bi/transform-model/desktop-relationships-understand#limited-relationships). - + ## Example -In the following example, the measure Non USA Internet Sales is created to produce a sales report that excludes sales in the United States. In order to create the measure, the InternetSales_USD table must be filtered to exclude all sales that belong to the United States in the SalesTerritory table. The United States, as a country, appears 5 times in the SalesTerritory table; once for each of the following regions: Northwest, Northeast, Central, Southwest, and Southeast. - -The first approach to filter the Internet Sales, in order to create the measure, could be to add a filter expression like the following: - +In the following example, the measure Non USA Internet Sales is created to produce a sales report that excludes sales in the United States. In order to create the measure, the InternetSales_USD table must be filtered to exclude all sales that belong to the United States in the SalesTerritory table. The United States, as a country, appears 5 times in the SalesTerritory table; once for each of the following regions: Northwest, Northeast, Central, Southwest, and Southeast. + +The first approach to filter the Internet Sales, in order to create the measure, could be to add a filter expression like the following: + ```dax FILTER('InternetSales_USD' , 'InternetSales_USD'[SalesTerritoryKey]<>1 && 'InternetSales_USD'[SalesTerritoryKey]<>2 && 'InternetSales_USD'[SalesTerritoryKey]<>3 && 'InternetSales_USD'[SalesTerritoryKey]<>4 && 'InternetSales_USD'[SalesTerritoryKey]<>5) -``` - -However, this approach is counterintuitive, prone to typing errors, and might not work if any of the existing regions is split in the future. - -A better approach would be to use the existing relationship between InternetSales_USD and SalesTerritory and explicitly state that the country must be different from the United States. To do so, create a filter expression like the following: - +``` + +However, this approach is counterintuitive, prone to typing errors, and might not work if any of the existing regions is split in the future. + +A better approach would be to use the existing relationship between InternetSales_USD and SalesTerritory and explicitly state that the country must be different from the United States. To do so, create a filter expression like the following: + ```dax FILTER( 'InternetSales_USD', RELATED('SalesTerritory'[SalesTerritoryCountry])<>"United States") ``` - -This expression uses the RELATED function to lookup the country value in the SalesTerritory table, starting with the value of the key column, SalesTerritoryKey, in the InternetSales_USD table. The result of the lookup is used by the filter function to determine if the InternetSales_USD row is filtered or not. - -> [!NOTE] -> If the example does not work, you might need to create a relationship between the tables. - + +This expression uses the RELATED function to lookup the country value in the SalesTerritory table, starting with the value of the key column, SalesTerritoryKey, in the InternetSales_USD table. The result of the lookup is used by the filter function to determine if the InternetSales_USD row is filtered or not. + +> [!NOTE] +> If the example does not work, you might need to create a relationship between the tables. + ```dax -= SUMX(FILTER( 'InternetSales_USD' - , RELATED('SalesTerritory'[SalesTerritoryCountry]) - <>"United States" - ) - ,'InternetSales_USD'[SalesAmount_USD]) += SUMX(FILTER( 'InternetSales_USD' + , RELATED('SalesTerritory'[SalesTerritoryCountry]) + <>"United States" + ) + ,'InternetSales_USD'[SalesAmount_USD]) ``` -The following table shows only totals for each region, to prove that the filter expression in the measure, Non USA Internet Sales, works as intended. - -|:::no-loc text="Row Labels":::|:::no-loc text="Internet Sales":::|:::no-loc text="Non USA Internet Sales":::| -|--------------|------------------|--------------------------| -|Australia|$4,999,021.84|$4,999,021.84| -|Canada|$1,343,109.10|$1,343,109.10| -|France|$2,490,944.57|$2,490,944.57| -|Germany|$2,775,195.60|$2,775,195.60| -|United Kingdom|$5,057,076.55|$5,057,076.55| -|United States|$9,389,479.79|| -|Grand Total|$26,054,827.45|$16,665,347.67| - -The following shows what that you might get if you used this measure in a report table visual: - +The following table shows only totals for each region, to prove that the filter expression in the measure, Non USA Internet Sales, works as intended. + +|:::no-loc text="Row Labels":::|:::no-loc text="Internet Sales":::|:::no-loc text="Non USA Internet Sales":::| +|--------------|------------------|--------------------------| +|Australia|$4,999,021.84|$4,999,021.84| +|Canada|$1,343,109.10|$1,343,109.10| +|France|$2,490,944.57|$2,490,944.57| +|Germany|$2,775,195.60|$2,775,195.60| +|United Kingdom|$5,057,076.55|$5,057,076.55| +|United States|$9,389,479.79|| +|Grand Total|$26,054,827.45|$16,665,347.67| + +The following shows what that you might get if you used this measure in a report table visual: + |:::no-loc text="Row Labels":::|:::no-loc text="Accessories":::|:::no-loc text="Bikes":::|:::no-loc text="Clothing":::|:::no-loc text="Grand Total":::| -|--------------------------|-----------------|----|----|----| -|2005||$1,526,481.95||$1,526,481.95| -|2006||$3,554,744.04||$3,554,744.04| -|2007|$156,480.18|$5,640,106.05|$70,142.77|$5,866,729.00| -|2008|$228,159.45|$5,386,558.19|$102,675.04|$5,717,392.68| -|Grand Total|$384,639.63|$16,107,890.23|$172,817.81|$16,665,347.67| - -## See also - -[RELATEDTABLE](relatedtable-function-dax.md) -[Filter functions](filter-functions-dax.md) +|--------------------------|-----------------|----|----|----| +|2005||$1,526,481.95||$1,526,481.95| +|2006||$3,554,744.04||$3,554,744.04| +|2007|$156,480.18|$5,640,106.05|$70,142.77|$5,866,729.00| +|2008|$228,159.45|$5,386,558.19|$102,675.04|$5,717,392.68| +|Grand Total|$384,639.63|$16,107,890.23|$172,817.81|$16,665,347.67| + +## Related content + +[RELATEDTABLE](relatedtable-function-dax.md) +[Filter functions](filter-functions-dax.md) diff --git a/query-languages/dax/relatedtable-function-dax.md b/query-languages/dax/relatedtable-function-dax.md index 2c13dfc25..0845a3154 100644 --- a/query-languages/dax/relatedtable-function-dax.md +++ b/query-languages/dax/relatedtable-function-dax.md @@ -1,65 +1,58 @@ --- description: "Learn more about: RELATEDTABLE" -title: "RELATEDTABLE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "RELATEDTABLE function (DAX)" --- # RELATEDTABLE -Evaluates a table expression in a context modified by the given filters. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Evaluates a table expression in a context modified by the given filters. + +## Syntax + ```dax -RELATEDTABLE() +RELATEDTABLE() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|tableName|The name of an existing table using standard DAX syntax. It cannot be an expression.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`tableName`|The name of an existing table using standard DAX syntax. It cannot be an expression.| + ## Return value -A table of values. - +A table of values. + ## Remarks -- The RELATEDTETABLE function changes the context in which the data is filtered, and evaluates the expression in the new context that you specify. - -- This function is a shortcut for CALCULATETABLE function with no logical expression. +- The RELATEDTABLE function changes the context in which the data is filtered, and evaluates the expression in the new context that you specify. + +- This function is a shortcut for CALCULATETABLE function with no logical expression. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example uses the RELATEDTABLE function to create a calculated column with the Internet Sales in the Product Category table: +The following example uses the RELATEDTABLE function to create a calculated column with the Internet Sales in the Product Category table: ```dax -= SUMX( RELATEDTABLE('InternetSales_USD') - , [SalesAmount_USD]) += SUMX( RELATEDTABLE('InternetSales_USD') + , [SalesAmount_USD]) ``` -The following table shows the results: +The following table shows the results: + +|:::no-loc text="Product Category Key":::|:::no-loc text="Product Category AlternateKey":::|:::no-loc text="Product Category Name":::|:::no-loc text="Internet Sales":::| +|-----|------|------|------| +|1|1|Bikes|$28,318,144.65| +|2|2|Components|| +|3|3|Clothing|$339,772.61| +|4|4|Accessories|$700,759.96| + -|:::no-loc text="Product Category Key":::|:::no-loc text="Product Category AlternateKey":::|:::no-loc text="Product Category Name":::|:::no-loc text="Internet Sales":::| -|-----|------|------|------| -|1|1|Bikes|$28,318,144.65| -|2|2|Components|| -|3|3|Clothing|$339,772.61| -|4|4|Accessories|$700,759.96| - - -## See also +## Related content -[CALCULATETABLE](calculatetable-function-dax.md) +[CALCULATETABLE](calculatetable-function-dax.md) [Filter functions](filter-functions-dax.md) diff --git a/query-languages/dax/relationship-functions-dax.md b/query-languages/dax/relationship-functions-dax.md index ce6566536..df2aeb7ee 100644 --- a/query-languages/dax/relationship-functions-dax.md +++ b/query-languages/dax/relationship-functions-dax.md @@ -1,14 +1,6 @@ --- description: "Learn more about: Relationship functions" -title: "Relationship functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/24/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Relationship functions (DAX)" --- # Relationship functions @@ -18,7 +10,7 @@ Functions in this category are for managing and utilizing relationships between |Function |Description | |---------|---------| -|[CROSSFILTER ](crossfilter-function.md) | Specifies the cross-filtering direction to be used in a calculation for a relationship that exists between two columns. | +|[CROSSFILTER ](crossfilter-function-dax.md) | Specifies the cross-filtering direction to be used in a calculation for a relationship that exists between two columns. | |[RELATED](related-function-dax.md) | Returns a related value from another table. | |[RELATEDTABLE](relatedtable-function-dax.md) | Evaluates a table expression in a context modified by the given filters. | |[USERELATIONSHIP](userelationship-function-dax.md) | Specifies the relationship to be used in a specific calculation as the one that exists between columnName1 and columnName2. | diff --git a/query-languages/dax/removefilters-function-dax.md b/query-languages/dax/removefilters-function-dax.md index a54181f17..35f086749 100644 --- a/query-languages/dax/removefilters-function-dax.md +++ b/query-languages/dax/removefilters-function-dax.md @@ -1,38 +1,31 @@ --- description: "Learn more about: REMOVEFILTERS" -title: "REMOVEFILTERS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "REMOVEFILTERS function (DAX)" --- # REMOVEFILTERS +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Clear filters from the specified tables or columns. - -## Syntax - + +## Syntax + ```dax REMOVEFILTERS([
| [, [, [,…]]]]) ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table that you want to clear filters on. | -|column|The column that you want to clear filters on.| - + +|Term|Definition| +|--------|--------------| +|table|The table that you want to clear filters on. | +|column|The column that you want to clear filters on.| + ## Return value N/A. See remarks. - -## Remarks + +## Remarks - REMOVEFILTERS can only be used to clear filters but not to return a table. diff --git a/query-languages/dax/replace-function-dax.md b/query-languages/dax/replace-function-dax.md index 9e7213eca..039ebd4c7 100644 --- a/query-languages/dax/replace-function-dax.md +++ b/query-languages/dax/replace-function-dax.md @@ -1,54 +1,47 @@ --- description: "Learn more about: REPLACE" -title: "REPLACE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "REPLACE function (DAX)" --- # REPLACE -REPLACE replaces part of a text string, based on the number of characters you specify, with a different text string. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +REPLACE replaces part of a text string, based on the number of characters you specify, with a different text string. + +## Syntax + ```dax -REPLACE(, , , ) +REPLACE(, , , ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|old_text|The string of text that contains the characters you want to replace, or a reference to a column that contains text.| -|start_num|The position of the character in **old_text** that you want to replace with **new_text**.| -|num_chars|The number of characters that you want to replace. **Warning:** If the argument, *num_chars*, is a blank or references a column that evaluates to a blank, the string for *new_text* is inserted at the position, *start_num*, without replacing any characters. This is the same behavior as in Excel.| -|new_text|The replacement text for the specified characters in **old_text**.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`old_text`|The string of text that contains the characters you want to replace, or a reference to a column that contains text.| +|`start_num`|The position of the character in `old_text` that you want to replace with `new_text`.| +|`num_chars`|The number of characters that you want to replace. **Warning:** If the argument, `num_chars`, is a blank or references a column that evaluates to a blank, the string for `new_text` is inserted at the position, `start_num`, without replacing any characters. This is the same behavior as in Excel.| +|`new_text`|The replacement text for the specified characters in `old_text`.| + ## Return value -A text string. - +A text string. + ## Remarks -- Whereas Microsoft Excel has different functions for use with single-byte and double-byte character languages, DAX uses Unicode and therefore stores all characters as the same length. - +- Whereas Microsoft Excel has different functions for use with single-byte and double-byte character languages, DAX uses Unicode and therefore stores all characters as the same length. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following formula creates a new calculated column that replaces the first two characters of the product code in column, [ProductCode], with a new two-letter code, OB. - +The following formula creates a new calculated column that replaces the first two characters of the product code in column, [ProductCode], with a new two-letter code, OB. + ```dax -= REPLACE('New Products'[Product Code],1,2,"OB") += REPLACE('New Products'[Product Code],1,2,"OB") ``` - -## See also -[Text functions](text-functions-dax.md) -[SUBSTITUTE function](substitute-function-dax.md) +## Related content + +[Text functions](text-functions-dax.md) +[SUBSTITUTE function](substitute-function-dax.md) diff --git a/query-languages/dax/rept-function-dax.md b/query-languages/dax/rept-function-dax.md index 84404b32d..7394e4519 100644 --- a/query-languages/dax/rept-function-dax.md +++ b/query-languages/dax/rept-function-dax.md @@ -1,67 +1,60 @@ --- description: "Learn more about: REPT" -title: "REPT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "REPT function (DAX)" --- # REPT -Repeats text a given number of times. Use REPT to fill a cell with a number of instances of a text string. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Repeats text a given number of times. Use REPT to fill a cell with a number of instances of a text string. + +## Syntax + ```dax -REPT(, ) +REPT(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|The text you want to repeat.| -|num_times|A positive number specifying the number of times to repeat text.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text you want to repeat.| +|`num_times`|A positive number specifying the number of times to repeat text.| + ## Return value -A string containing the changes. - +A string containing the changes. + ## Remarks -- If **number_times** is 0 (zero), REPT returns a blank. - -- If **number_times** is not an integer, it is truncated. - -- The result of the REPT function cannot be longer than 32,767 characters, or REPT returns an error. +- If `num_times` is 0 (zero), REPT returns a blank. + +- If `num_times` is not an integer, it is truncated. -## Example: Repeating Literal Strings +- The result of the REPT function cannot be longer than 32,767 characters, or REPT returns an error. + +## Example: Repeating Literal Strings + +The following example returns the string, 85, repeated three times. -The following example returns the string, 85, repeated three times. - ```dax -= REPT("85",3) += REPT("85",3) ``` - -## Example: Repeating Column Values - -The following example returns the string in the column, [MyText], repeated for the number of times in the column, [MyNumber]. Because the formula extends for the entire column, the resulting string depends on the text and number value in each row. - + +## Example: Repeating Column Values + +The following example returns the string in the column, [MyText], repeated for the number of times in the column, [MyNumber]. Because the formula extends for the entire column, the resulting string depends on the text and number value in each row. + ```dax -= REPT([MyText],[MyNumber]) += REPT([MyText],[MyNumber]) ``` - -|MyText|MyNumber|CalculatedColumn1| -|----------|------------|---------------------| -|Text|2|TextText| -|Number|0|| -|85|3|858585| - -## See also - -[Text functions](text-functions-dax.md) + +|MyText|MyNumber|CalculatedColumn1| +|----------|------------|---------------------| +|Text|2|TextText| +|Number|0|| +|85|3|858585| + +## Related content + +[Text functions](text-functions-dax.md) diff --git a/query-languages/dax/right-function-dax.md b/query-languages/dax/right-function-dax.md index bb7f27fcb..e54344c42 100644 --- a/query-languages/dax/right-function-dax.md +++ b/query-languages/dax/right-function-dax.md @@ -1,64 +1,57 @@ --- description: "Learn more about: RIGHT" -title: "RIGHT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "RIGHT function (DAX)" --- # RIGHT -RIGHT returns the last character or characters in a text string, based on the number of characters you specify. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +RIGHT returns the last character or characters in a text string, based on the number of characters you specify. + +## Syntax + ```dax -RIGHT(, ) +RIGHT(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|The text string that contains the characters you want to extract, or a reference to a column that contains text.| -|num_chars|(optional) The number of characters you want RIGHT to extract; is omitted, 1. You can also use a reference to a column that contains numbers.| - -If the column reference does not contain text, it is implicitly cast as text. - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text string that contains the characters you want to extract, or a reference to a column that contains text.| +|`num_chars`|(optional) The number of characters you want RIGHT to extract; is omitted, 1. You can also use a reference to a column that contains numbers.| + +If the column reference does not contain text, it is implicitly cast as text. + ## Return value -A text string containing the specified right-most characters. - +A text string containing the specified right-most characters. + ## Remarks -- RIGHT always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is. - +- RIGHT always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example: Returning a Fixed Number of Characters -The following formula returns the last two digits of the product code in the New Products table. - +## Example: Returning a Fixed Number of Characters + +The following formula returns the last two digits of the product code in the New Products table. + ```dax -= RIGHT('New Products'[ProductCode],2) += RIGHT('New Products'[ProductCode],2) ``` - -## Example: Using a Column Reference to Specify Character Count -The following formula returns a variable number of digits from the product code in the New Products table, depending on the number in the column, MyCount. If there is no value in the column, MyCount, or the value is a blank, RIGHT also returns a blank. - +## Example: Using a Column Reference to Specify Character Count + +The following formula returns a variable number of digits from the product code in the New Products table, depending on the number in the column, MyCount. If there is no value in the column, MyCount, or the value is a blank, RIGHT also returns a blank. + ```dax -= RIGHT('New Products'[ProductCode],[MyCount]) += RIGHT('New Products'[ProductCode],[MyCount]) ``` - -## See also -[Text functions](text-functions-dax.md) -[LEFT](left-function-dax.md) -[MID](mid-function-dax.md) - +## Related content + +[Text functions](text-functions-dax.md) +[LEFT](left-function-dax.md) +[MID](mid-function-dax.md) + diff --git a/query-languages/dax/rollup-function-dax.md b/query-languages/dax/rollup-function-dax.md index 50801ef22..622a479c2 100644 --- a/query-languages/dax/rollup-function-dax.md +++ b/query-languages/dax/rollup-function-dax.md @@ -1,20 +1,13 @@ --- description: "Learn more about: ROLLUP" -title: "ROLLUP function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/01/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ROLLUP function (DAX)" --- # ROLLUP +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Modifies the behavior of the [SUMMARIZE](summarize-function-dax.md) function by adding rollup rows to the result on columns defined by the groupBy_columnName parameter. This function can only be used within a [SUMMARIZE](summarize-function-dax.md) expression. - + ## Syntax ```dax @@ -24,21 +17,21 @@ ROLLUP ( [, [, … ] ] ) With SUMMARIZE, ```dax -SUMMARIZE(
, [, ]…[, ROLLUP([,< groupBy_columnName>…])][, , ]…) +SUMMARIZE(
, [, ]…[, ROLLUP([,< groupBy_columnName>…])][, , ]…) ``` - -### Parameters -|Term|Definition| -|--------|--------------| +### Parameters + +|Term|Definition| +|--------|--------------| | groupBy_columnName | The qualified name of an existing column or ROLLUPGROUP function to be used to create summary groups based on the values found in it. This parameter cannot be an expression. | ## Return value This function does not return a value. It only specifies the set of columns to be subtotaled. - -## Remarks - + +## Remarks + This function can only be used within a [SUMMARIZE](summarize-function-dax.md) expression. ## Example diff --git a/query-languages/dax/rollupaddissubtotal-function-dax.md b/query-languages/dax/rollupaddissubtotal-function-dax.md index e51b31f23..7a24b177a 100644 --- a/query-languages/dax/rollupaddissubtotal-function-dax.md +++ b/query-languages/dax/rollupaddissubtotal-function-dax.md @@ -1,40 +1,33 @@ --- description: "Learn more about: ROLLUPADDISSUBTOTAL" -title: "ROLLUPADDISSUBTOTAL function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/09/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ROLLUPADDISSUBTOTAL function (DAX)" --- # ROLLUPADDISSUBTOTAL +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Modifies the behavior of the [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) function by adding rollup/subtotal rows to the result based on the groupBy_columnName columns. This function can only be used within a [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) expression. - -## Syntax - + +## Syntax + ```dax ROLLUPADDISSUBTOTAL ( [], , [, [] [, , [, [] [, … ] ] ] ] ) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -|grandtotalFilter|(Optional) Filter to be applied to the grandtotal level.| -|groupBy_columnName|Name of an existing column used to create summary groups based on the values found in it. Cannot be an expression.| +### Parameters + +|Term|Definition| +|--------|--------------| +|`grandtotalFilter`|(Optional) Filter to be applied to the grandtotal level.| +|`groupBy_columnName`|Name of an existing column used to create summary groups based on the values found in it. Cannot be an expression.| |name |Name of an ISSUBTOTAL column. The values of the column are calculated using the ISSUBTOTAL function.| -|groupLevelFilter|(Optional) Filter to be applied to the current level.| +|`groupLevelFilter`|(Optional) Filter to be applied to the current level.| ## Return value The function does not return a value. - -## Remarks + +## Remarks None diff --git a/query-languages/dax/rollupgroup-function-dax.md b/query-languages/dax/rollupgroup-function-dax.md index 8ee046923..2303f269e 100644 --- a/query-languages/dax/rollupgroup-function-dax.md +++ b/query-languages/dax/rollupgroup-function-dax.md @@ -1,38 +1,31 @@ --- description: "Learn more about: ROLLUPGROUP" -title: "ROLLUPGROUP function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/09/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ROLLUPGROUP function (DAX)" --- # ROLLUPGROUP +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Modifies the behavior of the [SUMMARIZE](summarize-function-dax.md) and [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) functions by adding rollup rows to the result on columns defined by the the groupBy_columnName parameter. This function can only be used within a [SUMMARIZE](summarize-function-dax.md) or [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) expression. - -## Syntax - + +## Syntax + ```dax ROLLUPGROUP ( [, [, … ] ] ) ``` - -### Parameters -|Term|Definition| -|--------|--------------| +### Parameters + +|Term|Definition| +|--------|--------------| | groupBy_columnName | The qualified name of an existing column or ROLLUPGROUP function to be used to create summary groups based on the values found in it. This parameter cannot be an expression. | ## Return value This function does not return a value. It marks a set of columns to be treated as a single group during subtotaling by [ROLLUP](rollup-function-dax.md) or [ROLLUPADDISSUBTOTAL](rollupaddissubtotal-function-dax.md). - -## Remarks - + +## Remarks + ROLLUPGROUP can only be used as a groupBy_columnName argument to [ROLLUP](rollup-function-dax.md), [ROLLUPADDISSUBTOTAL](rollupaddissubtotal-function-dax.md), or [ROLLUPISSUBTOTAL](rollupissubtotal-function-dax.md). ## Example diff --git a/query-languages/dax/rollupissubtotal-function-dax.md b/query-languages/dax/rollupissubtotal-function-dax.md index 686ce8335..af950155f 100644 --- a/query-languages/dax/rollupissubtotal-function-dax.md +++ b/query-languages/dax/rollupissubtotal-function-dax.md @@ -1,39 +1,32 @@ --- description: "Learn more about: ROLLUPISSUBTOTAL" -title: "ROLLUPISSUBTOTAL function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/09/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ROLLUPISSUBTOTAL function (DAX)" --- # ROLLUPISSUBTOTAL +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Pairs rollup groups with the column added by [ROLLUPADDISSUBTOTAL](rollupaddissubtotal-function-dax.md). This function can only be used within an [ADDMISSINGITEMS](addmissingitems-function-dax.md) expression. - -## Syntax - + +## Syntax + ```dax ROLLUPISSUBTOTAL ( [], , [, [] [, , [, [] [, … ] ] ] ] ) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -|grandTotalFilter|(Optional) Filter to be applied to the grandtotal level.| -|groupBy_columnName|Name of an existing column used to create summary groups based on the values found in it. Cannot be an expression.| +### Parameters + +|Term|Definition| +|--------|--------------| +|`grandTotalFilter`|(Optional) Filter to be applied to the grandtotal level.| +|`groupBy_columnName`|Name of an existing column used to create summary groups based on the values found in it. Cannot be an expression.| |isSubtotal_columnName |Name of an ISSUBTOTAL column. The values of the column are calculated using the ISSUBTOTAL function. | -|groupLevelFilter|(Optional) Filter to be applied to the current level.| +|`groupLevelFilter`|(Optional) Filter to be applied to the current level.| ## Return value None - -## Remarks + +## Remarks This function can only be used within an [ADDMISSINGITEMS](addmissingitems-function-dax.md) expression. diff --git a/query-languages/dax/round-function-dax.md b/query-languages/dax/round-function-dax.md index a75766b1d..5dbf4f3d5 100644 --- a/query-languages/dax/round-function-dax.md +++ b/query-languages/dax/round-function-dax.md @@ -1,72 +1,71 @@ --- description: "Learn more about: ROUND" -title: "ROUND function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ROUND function (DAX)" --- # ROUND -Rounds a number to the specified number of digits. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Rounds a number to the specified number of digits. + +## Syntax + ```dax -ROUND(, ) +ROUND(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number you want to round.| -|num_digits|The number of digits to which you want to round. A negative value rounds digits to the left of the decimal point; a value of zero rounds to the nearest integer.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number you want to round.| +|`num_digits`|The number of digits to which you want to round. A negative value rounds digits to the left of the decimal point; a value of zero rounds to the nearest integer.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- If **num_digits** is greater than 0 (zero), then number is rounded to the specified number of decimal places. - -- If **num_digits** is 0, the number is rounded to the nearest integer. - -- If **num_digits** is less than 0, the number is rounded to the left of the decimal point. - +- If `num_digits` is greater than 0 (zero), then number is rounded to the specified number of decimal places. + +- If `num_digits` is 0, the number is rounded to the nearest integer. + +- If `num_digits` is less than 0, the number is rounded to the left of the decimal point. + +- Ties are broken by rounding half away from zero (also known as commercial rounding). + | Examples | Result | + | --- | --- | + | `= ROUND(1.15, 1)` | 1.2 | + | `= ROUND(-1.15, 1)` | -1.2 | + - Related functions - - To always round up (away from zero), use the ROUNDUP function. - - To always round down (toward zero), use the ROUNDDOWN function. - - To round a number to a specific multiple (for example, to round to the nearest multiple of 0.5), use the MROUND function. - - Use the functions TRUNC and INT to obtain the integer portion of the number. - + - To always round up (away from zero), use the ROUNDUP function. + - To always round down (toward zero), use the ROUNDDOWN function. + - To round a number to a specific multiple (for example, to round to the nearest multiple of 0.5), use the MROUND function. + - Use the functions TRUNC and INT to obtain the integer portion of the number. + ## Example 1 -The following formula rounds 2.15 up, to one decimal place. The expected result is 2.2. - +The following formula rounds 2.15 up, to one decimal place. The expected result is 2.2. + ```dax -= ROUND(2.15,1) += ROUND(2.15,1) ``` - + ## Example 2 -The following formula rounds 21.5 to one decimal place to the left of the decimal point. The expected result is 20. - +The following formula rounds 21.5 to one decimal place to the left of the decimal point. The expected result is 20. + ```dax -= ROUND(21.5,-1) += ROUND(21.5,-1) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) -[ROUND](round-function-dax.md) -[ROUNDDOWN](rounddown-function-dax.md) -[MROUND](mround-function-dax.md) -[INT](int-function-dax.md) -[TRUNC](trunc-function-dax.md) - + +## Related content +[Math and Trig functions](math-and-trig-functions-dax.md) +[ROUND](round-function-dax.md) +[ROUNDDOWN](rounddown-function-dax.md) +[MROUND](mround-function-dax.md) +[INT](int-function-dax.md) +[TRUNC](trunc-function-dax.md) + diff --git a/query-languages/dax/rounddown-function-dax.md b/query-languages/dax/rounddown-function-dax.md index e369e0626..d052b2089 100644 --- a/query-languages/dax/rounddown-function-dax.md +++ b/query-languages/dax/rounddown-function-dax.md @@ -1,68 +1,61 @@ --- description: "Learn more about: ROUNDDOWN" -title: "ROUNDDOWN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ROUNDDOWN function (DAX)" --- # ROUNDDOWN -Rounds a number down, toward zero. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Rounds a number down, toward zero. + +## Syntax + ```dax -ROUNDDOWN(, ) +ROUNDDOWN(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|A real number that you want rounded down.| -|num_digits|The number of digits to which you want to round. Negative rounds to the left of the decimal point; zero to the nearest integer.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|A real number that you want rounded down.| +|`num_digits`|The number of digits to which you want to round. Negative rounds to the left of the decimal point; zero to the nearest integer.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- If **num_digits** is greater than 0 (zero), then the value in **number** is rounded down to the specified number of decimal places. - -- If **num_digits** is 0, then the value in **number** is rounded down to the nearest integer. - -- If **num_digits** is less than 0, then the value in **number** is rounded down to the left of the decimal point. +- If `num_digits` is greater than 0 (zero), then the value in `number` is rounded down to the specified number of decimal places. + +- If `num_digits` is 0, then the value in `number` is rounded down to the nearest integer. + +- If `num_digits` is less than 0, then the value in `number` is rounded down to the left of the decimal point. + +- ROUNDDOWN behaves like ROUND, except that it always rounds a number down. The INT function also rounds down, but with INT the result is always an integer, whereas with ROUNDDOWN you can control the precision of the result. -- ROUNDDOWN behaves like ROUND, except that it always rounds a number down. The INT function also rounds down, but with INT the result is always an integer, whereas with ROUNDDOWN you can control the precision of the result. - ## Example 1 -The following example rounds 3.14159 down to three decimal places. The expected result is 3.141. - +The following example rounds 3.14159 down to three decimal places. The expected result is 3.141. + ```dax -= ROUNDDOWN(3.14159,3) += ROUNDDOWN(3.14159,3) ``` - + ## Example 2 -The following example rounds the value of 31415.92654 down to 2 decimal places to the left of the decimal. The expected result is 31400. - +The following example rounds the value of 31415.92654 down to 2 decimal places to the left of the decimal. The expected result is 31400. + ```dax -= ROUNDDOWN(31415.92654, -2) += ROUNDDOWN(31415.92654, -2) ``` - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[ROUND](round-function-dax.md) -[ROUNDUP](roundup-function-dax.md) -[ROUNDDOWN](rounddown-function-dax.md) -[MROUND](mround-function-dax.md) -[INT](int-function-dax.md) + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[ROUND](round-function-dax.md) +[ROUNDUP](roundup-function-dax.md) +[ROUNDDOWN](rounddown-function-dax.md) +[MROUND](mround-function-dax.md) +[INT](int-function-dax.md) diff --git a/query-languages/dax/roundup-function-dax.md b/query-languages/dax/roundup-function-dax.md index b97d46a88..b1e7e0300 100644 --- a/query-languages/dax/roundup-function-dax.md +++ b/query-languages/dax/roundup-function-dax.md @@ -1,85 +1,78 @@ --- description: "Learn more about: ROUNDUP" -title: "ROUNDUP function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ROUNDUP function (DAX)" --- # ROUNDUP -Rounds a number up, away from 0 (zero). - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Rounds a number up, away from 0 (zero). + +## Syntax + ```dax -ROUNDUP(, ) +ROUNDUP(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|A real number that you want to round up.| -|num_digits|The number of digits to which you want to round. A negative value for **num_digits** rounds to the left of the decimal point; if **num_digits** is zero or is omitted, **number** is rounded to the nearest integer.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|A real number that you want to round up.| +|`num_digits`|The number of digits to which you want to round. A negative value for `num_digits` rounds to the left of the decimal point; if `num_digits` is zero or is omitted, `number` is rounded to the nearest integer.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- If **num_digits** is greater than 0 (zero), then the number is rounded up to the specified number of decimal places. - -- If **num_digits** is 0, then number is rounded up to the nearest integer. - -- If **num_digits** is less than 0, then number is rounded up to the left of the decimal point. - -- ROUNDUP behaves like ROUND, except that it always rounds a number up. - +- If `num_digits` is greater than 0 (zero), then the number is rounded up to the specified number of decimal places. + +- If `num_digits` is 0, then number is rounded up to the nearest integer. + +- If `num_digits` is less than 0, then number is rounded up to the left of the decimal point. + +- ROUNDUP behaves like ROUND, except that it always rounds a number up. + ## Example -The following formula rounds Pi to four decimal places. The expected result is 3.1416. - +The following formula rounds Pi to four decimal places. The expected result is 3.1416. + ```dax -= ROUNDUP(PI(),4) += ROUNDUP(PI(),4) ``` - -## Example: Decimals as Second Argument -The following formula rounds 1.3 to the nearest multiple of 0.2. The expected result is 2. +## Example: Decimals as Second Argument + +The following formula rounds 1.3 to the nearest multiple of 0.2. The expected result is 2. ```dax -= ROUNDUP(1.3,0.2) += ROUNDUP(1.3,0.2) ``` - -## Example: Negative Number as Second Argument - -The following formula rounds the value in the column, **FreightCost**, with the expected results shown in the following table: - + +## Example: Negative Number as Second Argument + +The following formula rounds the value in the column, **FreightCost**, with the expected results shown in the following table: + ```dax -= ROUNDUP([Values],-1) += ROUNDUP([Values],-1) ``` -When **num_digits** is less than zero, the number of places to the left of the decimal sign is increased by the value you specify. - -|FreightCost|Expected Result| -|---------------|-------------------| -|13.25|20| -|2.45|10| -|25.56|30| -|1.34|10| -|345.01|350| - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[ROUND](round-function-dax.md) -[ROUNDDOWN](rounddown-function-dax.md) -[MROUND](mround-function-dax.md) -[INT](int-function-dax.md) +When `num_digits` is less than zero, the number of places to the left of the decimal sign is increased by the value you specify. + +|FreightCost|Expected Result| +|---------------|-------------------| +|13.25|20| +|2.45|10| +|25.56|30| +|1.34|10| +|345.01|350| + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[ROUND](round-function-dax.md) +[ROUNDDOWN](rounddown-function-dax.md) +[MROUND](mround-function-dax.md) +[INT](int-function-dax.md) diff --git a/query-languages/dax/row-function-dax.md b/query-languages/dax/row-function-dax.md index 659dcf0e8..a9983c245 100644 --- a/query-languages/dax/row-function-dax.md +++ b/query-languages/dax/row-function-dax.md @@ -1,48 +1,41 @@ --- description: "Learn more about: ROW function" -title: "ROW function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "ROW function (DAX)" --- # ROW function -Returns a table with a single row containing values that result from the expressions given to each column. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table with a single row containing values that result from the expressions given to each column. + +## Syntax + ```dax -ROW(, [[,, ]…]) +ROW(, [[,, ]…]) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| name| The name given to the column, enclosed in double quotes. | -| expression| Any DAX expression that returns a single scalar value to populate. *name*. | +### Parameters + +|Term|Definition| +|--------|--------------| +|`name`| The name given to the column, enclosed in double quotes. | +|`expression`| Any DAX expression that returns a single scalar value to populate. `name`. | ## Return value -A single row table - +A single row table + ## Remarks -- Arguments must always come in pairs of *name* and *expression*. +- Arguments must always come in pairs of `name` and `expression`. + +- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - ## Example -The following example returns a single row table with the total sales for internet and resellers channels. - +The following example returns a single row table with the total sales for internet and resellers channels. + ```dax -ROW("Internet Total Sales (USD)", SUM(InternetSales_USD[SalesAmount_USD]), - "Resellers Total Sales (USD)", SUM(ResellerSales_USD[SalesAmount_USD])) +ROW("Internet Total Sales (USD)", SUM(InternetSales_USD[SalesAmount_USD]), + "Resellers Total Sales (USD)", SUM(ResellerSales_USD[SalesAmount_USD])) ``` diff --git a/query-languages/dax/rownumber-function-dax.md b/query-languages/dax/rownumber-function-dax.md new file mode 100644 index 000000000..1b67088ee --- /dev/null +++ b/query-languages/dax/rownumber-function-dax.md @@ -0,0 +1,101 @@ +--- +description: "Learn more about: ROWNUMBER" +title: "ROWNUMBER function (DAX)" +author: rahulten +--- +# ROWNUMBER + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the unique ranking for the current context within the specified partition, sorted by the specified order. If a match cannot be found then rownumber is blank. + +## Syntax + +```dax +ROWNUMBER ( [ or ][, ][, ][, ][, ][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`relation`|(Optional) A table expression from which the output row is returned. If used in visual calculations, this parameter accepts an axis in the visual shape.
If specified, all columns in `orderBy` and `partitionBy` must come from it.
If omitted:
- `orderBy` must be explicitly specified.
- All `orderBy` and `partitionBy` columns must be fully qualified and come from a single table.
- Defaults to ALLSELECTED() of all columns in `orderBy` and `partitionBy`.| +|`orderBy`|(Optional) An ORDERBY() clause containing the columns that define how each partition is sorted.
If omitted:
- `relation` must be explicitly specified.
- Defaults to ordering by every column in `relation` that is not already specified in `partitionBy`.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `relation` or `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.

Note, when the `blanks` parameter and blanks in the [ORDERBY()](orderby-function-dax.md) function on individual expressions are both specified, `blanks` on individual orderBy expression takes priority for the relevant orderBy expression, and orderBy expressions without `blanks` being specified will honor the `blanks` parameter on the parent function.| +|`partitionBy`|(Optional) A [PARTITIONBY()](partitionby-function-dax.md) clause containing the columns that define how `relation` is partitioned. If omitted, `relation` is treated as a single partition.| +|`matchBy`|(Optional) A [MATCHBY()](matchby-function-dax.md) clause containing the columns that define how to match data and identify the current row.| +|`reset`|(Optional) Available in visual calculations only. Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +The rownumber number for the current context. + +## Remarks + +Each `orderBy`, `partitionBy`, and `matchBy` column must have a corresponding outer value to help define the current row on which to operate, with the following behavior: + +- If there is exactly one corresponding outer column, its value is used. +- If there is no corresponding outer column, then: + - ROWNUMBER will first determine all `orderBy`, `partitionBy`, and `matchBy` columns that have no corresponding outer column. + - For every combination of existing values for these columns in ROWNUMBER parent context, ROWNUMBER is evaluated and a row is returned. + - ROWNUMBER’s final output is a union of these rows. +- If there is more than one corresponding outer column, an error is returned. + +If `matchBy` is present, then ROWNUMBER will try to use columns in `matchBy` and `partitionBy` to idenfity the current row. +If the columns specified within `orderBy` and `partitionBy` cannot uniquely identify every row in `relation`, then: + +- ROWNUMBER will try to find the least number of additional columns required to uniquely identify every row. +- If such columns can be found, ROWNUMBER will + - Try to find the least number of additional columns required to uniquely identify every row. + - Automatically append these new columns to `orderBy` clause. + - Sort each partition using this new set of orderBy columns. +- If such columns cannot be found and the function detects a tie at runtime, an error is returned. + +`reset` can be used in visual calculations only, and cannot be used in combination with `orderBy` or `partitionBy`. If `reset` is present, `axis` can be specified but `relation` cannot. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example 1 - calculated column + +The following DAX query: + +```dax +EVALUATE +ADDCOLUMNS( + 'DimGeography', + "UniqueRank", + ROWNUMBER( + 'DimGeography', + ORDERBY( + 'DimGeography'[StateProvinceName], desc, + 'DimGeography'[City], asc), + PARTITIONBY( + 'DimGeography'[EnglishCountryRegionName]))) +ORDER BY [EnglishCountryRegionName] asc, [StateProvinceName] desc, [City] asc +``` + +Returns a table that uniquely ranks each geography with the same EnglishCountryRegionName, by their StateProvinceName and City. + +## Example 2 - visual calculation + +The following visual calculation DAX queries: + +```dax +SalesRankWithinYear = ROWNUMBER(ORDERBY([SalesAmount], DESC), PARTITIONBY([CalendarYear])) + +SalesRankAllHistory = ROWNUMBER(ORDERBY([SalesAmount], DESC)) +``` + +Create two columns that uniquely rank each month by the total sales, both within each year, and the entire history. + +The screenshot below shows the visual matrix and the first visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-rownumber.png) + +## Related content + +[INDEX](index-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[WINDOW](window-function-dax.md) +[RANK](rank-function-dax.md) diff --git a/query-languages/dax/rri-function-dax.md b/query-languages/dax/rri-function-dax.md index 166b939f7..fd6bb4a38 100644 --- a/query-languages/dax/rri-function-dax.md +++ b/query-languages/dax/rri-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: RRI" -title: "RRI function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "RRI function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # RRI +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns an equivalent interest rate for the growth of an investment. ## Syntax @@ -24,11 +18,11 @@ RRI(, , ) ### Parameters -|Term|Definition| -|--------|--------------| -|nper|The number of periods for the investment.| -|pv|The present value of the investment.| -|fv|The future value of the investment.| +|Term|Definition| +|--------|--------------| +|`nper`|The number of periods for the investment.| +|`pv`|The present value of the investment.| +|`fv`|The future value of the investment.| ## Return Value diff --git a/query-languages/dax/runningsum-function-dax.md b/query-languages/dax/runningsum-function-dax.md new file mode 100644 index 000000000..c0e91ab7e --- /dev/null +++ b/query-languages/dax/runningsum-function-dax.md @@ -0,0 +1,66 @@ +--- +description: "Learn more about: RUNNINGSUM" +title: "RUNNINGSUM function (DAX)" +ms.service: powerbi +ms.subservice: dax +ms.date: 6/16/2025 +ms.topic: reference +author: masanto-msft +ms.author: masanto +recommendations: false + +--- + +# RUNNINGSUM + +[!INCLUDE[applies-to-visual-calculations](includes/applies-to-visual-calculations.md)] + +Returns a running sum calculated along the given axis of the visual matrix. That is, the sum of the given column calculated over all elements up to the current element of an axis. + +## Syntax + +```dax +RUNNINGSUM ( [, ][, ][, ][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that provides the value for each element.| +|`axis`|(Optional) An axis reference, the direction along which the running sum will be calculated. If omitted, the first axis of the Visual Shape definition is used.| +|`orderBy`|(Optional) An ORDERBY() clause with expressions that determine how to sort each partition along the `axis`. If `orderBy` is not provided, the data is sorted by the grouping columns on the default `axis` in ascending order by default.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.
| +|`reset`|(Optional) Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +A scalar value, the running sum up to the current element of the axis. + +## Remarks + +This function can be used in visual calculations only. + +The `axis`, `orderBy`, `blanks` and `reset` parameters can be omitted. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example + +Given a table that summarizes the total sales for each product category and calendar year, the following DAX query adds a column with the total sales for that category up to a given year. + +```dax +SalesUpToDate = RUNNINGSUM([SalesAmount], Rows) +``` + +The screenshot below shows the visual matrix and the visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-runningsum.png) + +## See also + +[INDEX](index-function-dax.md) +[MOVINGAVERAGE](movingaverage-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[WINDOW](window-function-dax.md) diff --git a/query-languages/dax/sameperiodlastyear-function-dax.md b/query-languages/dax/sameperiodlastyear-function-dax.md index 50ab24b68..060f4740f 100644 --- a/query-languages/dax/sameperiodlastyear-function-dax.md +++ b/query-languages/dax/sameperiodlastyear-function-dax.md @@ -1,61 +1,64 @@ --- description: "Learn more about: SAMEPERIODLASTYEAR" -title: "SAMEPERIODLASTYEAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SAMEPERIODLASTYEAR function (DAX)" --- # SAMEPERIODLASTYEAR -Returns a table that contains a column of dates shifted one year back in time from the dates in the specified **dates** column, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns a table that contains a column of dates shifted one year back in time from the dates in the specified `dates` column, in the current context. + +## Syntax + ```dax -SAMEPERIODLASTYEAR() +SAMEPERIODLASTYEAR() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|**dates**|A column containing dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column containing dates.| + ## Return value -A single-column table of date values. - +A single-column table of date values. + ## 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. +- 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](calculate-function-dax.md). + +- The dates returned are the same as the dates returned by this equivalent formula: `DATEADD(dates, -1, year)` -- Constraints on Boolean expressions are described in the topic, [CALCULATE](calculate-function-dax.md). - -- The dates returned are the same as the dates returned by this equivalent formula: `DATEADD(dates, -1, year)` - - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the previous year sales of Reseller sales. +The following sample formula creates a measure that calculates the previous year sales of Reseller sales. + +```dax += CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]), SAMEPERIODLASTYEAR(DateTime[DateKey])) +``` + +## Special behavior + +When the selection includes last two days of month, SAMEPERIODLASTYEAR will use "extension" semantics and will include the days till the end of month. For example, when Feb 27 and 28 of 2009 are included in the selection, SAMEPERIODLASTYEAR will return Feb 27 to 29 of 2008. + +This behavior only happens when last two days of month are included in the selection. If only Feb 27 is selected, it will go to Feb 27. ```dax -= CALCULATE(SUM(ResellerSales_USD[SalesAmount_USD]), SAMEPERIODLASTYEAR(DateTime[DateKey])) += SAMEPERIODLASTYEAR(DateTime[DateKey]) ``` - -## See also - -[Time intelligence functions](time-intelligence-functions-dax.md) -[Date and time functions ](date-and-time-functions-dax.md) -[PREVIOUSYEAR](previousyear-function-dax.md) -[PARALLELPERIOD](parallelperiod-function-dax.md) - + +## Related content + +[Time intelligence functions](time-intelligence-functions-dax.md) +[Date and time functions ](date-and-time-functions-dax.md) +[PREVIOUSYEAR](previousyear-function-dax.md) +[PARALLELPERIOD](parallelperiod-function-dax.md) + diff --git a/query-languages/dax/sample-function-dax.md b/query-languages/dax/sample-function-dax.md index 7e20e8b01..c5fcccb2d 100644 --- a/query-languages/dax/sample-function-dax.md +++ b/query-languages/dax/sample-function-dax.md @@ -1,42 +1,35 @@ --- description: "Learn more about: SAMPLE" -title: "SAMPLE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SAMPLE function (DAX)" --- # SAMPLE -Returns a sample of N rows from the specified table. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a sample of N rows from the specified table. + +## Syntax + ```dax -SAMPLE(,
, , [[, , []]…]) +SAMPLE(,
, , [[, , []]…]) ``` - -### Parameters -|Term|Definition| +### Parameters + +|Term|Definition| |---------|---------| -|n_value | 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 | Any DAX expression that returns a table of data from where to extract the 'n' sample rows. | -|orderBy_expression | (Optional) Any scalar DAX expression where the result value is evaluated for each row of *table*. | -|order | (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*. | - +|`n_value` | 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` | Any DAX expression that returns a table of data from where to extract the 'n' sample rows. | +|`orderBy_expression` | Any scalar DAX expression where the result value is evaluated for each row of `table`. | +|`order` | (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 -A table consisting of a sample of N rows of *table* or an empty table if *n_value* is 0 (zero) or less. 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. +A table consisting of a sample of N rows of `table` or an empty table if `n_value` is 0 (zero) or less. 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. diff --git a/query-languages/dax/sampleaxiswithlocalminmax-function-dax.md b/query-languages/dax/sampleaxiswithlocalminmax-function-dax.md new file mode 100644 index 000000000..4021822c8 --- /dev/null +++ b/query-languages/dax/sampleaxiswithlocalminmax-function-dax.md @@ -0,0 +1,60 @@ +--- +description: "Learn more about: SAMPLEAXISWITHLOCALMINMAX" +title: "SAMPLEAXISWITHLOCALMINMAX function (DAX)" +author: jterh +--- + +# SAMPLEAXISWITHLOCALMINMAX + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a sample subset from a Table that is obtained by binning the primary X-axis into equal-sized bins and preserving the local min/max for each bin across different series. + +## Syntax + +```dax +SAMPLEAXISWITHLOCALMINMAX(,
, , , [ [, ...] ], [, [, ] [, ] [, ]) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Size`|Number of rows in the sample to return| +|`Table`|Any DAX expression that returns a table of data from where to return a sample subset from.| +|`Axis`|The numerical or datetime column from Table to be binned.| +|`Measure`| Column reference from Table to be sampled. At least one Measure is required, but you can specify multiple.| +|`MinResolution`| Minimum number of selected rows that spans the full non-empty range of X| +|`DynamicSeries`| (Optional) Column to be used as series. You can specify zero, or or multiple.| +|`DynamicSeriesSelectionCriteria`| (Optional) Decides which series values to retain if not all DynamicSeries can be preserved. Valid values are `NONE` or `ALPHABETICAL`| +|`DynamicSeriesSelectionOrder`| (Optional) Decides to use ascending or descending sorting on the criteria identified by DynamicSeriesSelectionCriteria. Valid values are `ASC` or `DESC`.| +|`MaxResolution`| Maximum number of selected rows for a line that spans the full non-empty range of X| +|`MaxDynamicSeries`|Maximum allowed DynamicSeries. If the number of DynamicSeries is higher than MaxDynamicSeries remove DynamicSeries based on DynamicSeriesSelectionCriteria.| +|`MaxIterations`|Maximum number of iterations to try to reach the Size number of rows. | + +## Return Value + +The sample from Table consisting of Size number of rows. + +## Remarks +- If the number of rows in Table are less than the specified Size, then no binning will occur and all rows will be returned. +- The selected bin-sizes will be less than MinResolution +- SAMPLEAXISWITHLOCALMINMAX is used by Power BI to reduce the number of points in a line chart with a continuous (numeric) X-axis. +- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +The following DAX query: + +```dax +EVALUATE +SAMPLEAXISWITHLOCALMINMAX( + 10, + SELECTCOLUMNS ( Sales, "x", [Unit Price], "y", [Sales Amount] ), + [x], + [y], + 10 + ) +``` + +Returns a 10 row (or less) sample subset of Table that is binned by Unit Price and sampled on Sales Amount. \ No newline at end of file diff --git a/query-languages/dax/samplecartesianpointsbycover-function-dax.md b/query-languages/dax/samplecartesianpointsbycover-function-dax.md new file mode 100644 index 000000000..70469a93e --- /dev/null +++ b/query-languages/dax/samplecartesianpointsbycover-function-dax.md @@ -0,0 +1,57 @@ +--- +description: "Learn more about: SAMPLECARTESIANPOINTSBYCOVER" +title: "SAMPLECARTESIANPOINTSBYCOVER function (DAX) | Microsoft Docs" +author: jajin7 +--- + +# SAMPLECARTESIANPOINTSBYCOVER + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a sample subset from a Table that is obtained by plotting the rows as points in 2D space and removing overlapping points. + +## Syntax + +```dax +SAMPLECARTESIANPOINTSBYCOVER(,
, , [, ] [, ] [, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|Size|Number of rows in the sample to return| +|Table|Any DAX expression that returns a table of data from where to return a sample subset from.| +|XAxis|The numerical XAxis column from the Table.| +|YAxis|The numerical YAxis column from the Table.| +|Radius|(Optional) The numerical Radius column from the Table.| +|MaxMinRatio|(Optional) When Radius is specified, MaxMinRatio has to be specified and defines the ratio between the maximum and the minimum radiuses of drawn points. See remarks for more details.| +|MaxBlankRatio|(Optional) When Radius is specified, MaxBlankRatio has to be specified and defines the ratio between the maximum and blank radiuses of the drawn points. See remarks for more details. | + +## Return Value + +The sample from Table consisting of Size number of rows. + +## Remarks +- If Size is less than or equal to 0, SAMPLECARTESIANPOINTSBYCOVER returns an empty table +- If Radius is specified, MaxMinRatio and MaxBlankRatio need to be specified and set to a value larger than 1. If not, SAMPLECARTESIANPOINTSBYCOVER returns an error +- Set MaxMinRatio to the maximum of Radius divided by the minimum of Radius. For example, if the minimum Radius is 20 and the maximum Radius is 60, the MaxMinRatio parameter should be set to 60/20 = 3. +- Set MaxBlankRatio to the maximum of Radius divided by the Radius for blank values. For example, if the maximum Radius is 60 and the Radius for blank values is 6, then MaxBlankRatio should be set to 60/6 = 10. + +- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +The following DAX query: + +```dax +EVALUATE +SAMPLECARTESIANPOINTSBYCOVER ( + 1000, + SELECTCOLUMNS ( Sales, "x", [Unit Price], "y", [Sales Amount] ), + [x], + [y] +) +``` + +Returns a 1000 row sample from unique points from the Sales table in a 2D space defined by Unit Price as the X axis and Sales Amount as the Y axis. \ No newline at end of file diff --git a/query-languages/dax/search-function-dax.md b/query-languages/dax/search-function-dax.md index e99768ee7..29e2f9023 100644 --- a/query-languages/dax/search-function-dax.md +++ b/query-languages/dax/search-function-dax.md @@ -1,59 +1,52 @@ --- description: "Learn more about: SEARCH" -title: "SEARCH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 03/14/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SEARCH function (DAX)" --- # SEARCH -Returns the number of the character at which a specific character or text string is first found, reading left to right. Search is case-insensitive and accent sensitive. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the number of the character at which a specific character or text string is first found, reading left to right. Search is case-insensitive and accent sensitive. + +## Syntax + ```dax -SEARCH(, [, [][, ]]) +SEARCH(, [, [][, ]]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|find_text|The text that you want to find.

You can use wildcard characters — the question mark (?) and asterisk (\*) — in **find_text**. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.| -|within_text|The text in which you want to search for **find_text**, or a column containing text.| -|start_num|(optional) The character position in **within_text** at which you want to start searching. If omitted, 1.| -|NotFoundValue|(optional, but strongly recommended) The value that should be returned when the operation does not find a matching substring, typically 0, -1, or BLANK(). If not specified, an error is returned.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`find_text`|The text that you want to find.

You can use wildcard characters — the question mark (?) and asterisk (\*) — in `find_text`. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.| +|`within_text`|The text in which you want to search for `find_text`, or a column containing text.| +|`start_num`|(optional) The character position in `within_text` at which you want to start searching. If omitted, 1.| +|`NotFoundValue`|(optional, but strongly recommended) The value that should be returned when the operation does not find a matching substring, typically 0, -1, or BLANK(). If not specified, an error is returned.| + ## Return value -The number of the starting position of the first text string from the first character of the second text string. - -## Remarks - -- The search function is case insensitive. Searching for "N" will find the first occurrence of 'N' or 'n'. +The number of the starting position of the first text string from the first character of the second text string. + +## Remarks + +- The search function is case insensitive. Searching for "N" will find the first occurrence of 'N' or 'n'. -- The search function is accent sensitive. Searching for "á" will find the first occurrence of 'á' but no occurrences of 'a', 'à', or the capitalized versions 'A', 'Á'. +- The search function is accent sensitive. Searching for "á" will find the first occurrence of 'á' but no occurrences of 'a', 'à', or the capitalized versions 'A', 'Á'. -- You can use the SEARCH function to determine the location of a character or text string within another text string, and then use the MID function to return the text, or use the REPLACE function to change the text. +- You can use the SEARCH function to determine the location of a character or text string within another text string, and then use the MID function to return the text, or use the REPLACE function to change the text. + +- If the `find_text` cannot be found in `within_text`, the formula returns an error. This behavior is like Excel, which returns #VALUE if the substring is not found. Nulls in `within_text` will be interpreted as an empty string in this context. -- If the **find_text** cannot be found in **within_text**, the formula returns an error. This behavior is like Excel, which returns #VALUE if the substring is not found. Nulls in **within_text** will be interpreted as an empty string in this context. - - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example The following DAX query finds the position of the first letter of "cycle", in the string that contains the reseller name. If not found, Blank is returned. -SEARCH is case-insensitive. In this example, if "cycle" or "Cycle" is used in the \ argument, results are returned for either case. Use [FIND](FIND-function-dax.md) for case-sensitive. +SEARCH is case-insensitive. In this example, if "cycle" or "Cycle" is used in the `find_text` argument, results are returned for either case. Use [FIND](FIND-function-dax.md) for case-sensitive. [!INCLUDE [power-bi-dax-sample-model](includes/power-bi-dax-sample-model.md)] - + ```dax EVALUATE CALCULATETABLE ( @@ -65,7 +58,7 @@ CALCULATETABLE ( ) ``` -Returns, +Returns, |Reseller |Business Type | Position of cycle | |---------|---------|---------| @@ -80,8 +73,8 @@ Returns, |Helmets and Cycles |Value Added Reseller| 13 | |Jumbo Bikes |Specialty Bike Shop| | -## See also +## Related content -[FIND](find-function-dax.md) -[REPLACE](replace-function-dax.md) -[Text functions](text-functions-dax.md) +[FIND](find-function-dax.md) +[REPLACE](replace-function-dax.md) +[Text functions](text-functions-dax.md) diff --git a/query-languages/dax/second-function-dax.md b/query-languages/dax/second-function-dax.md index 75ed4d7b6..6787c8ca1 100644 --- a/query-languages/dax/second-function-dax.md +++ b/query-languages/dax/second-function-dax.md @@ -1,65 +1,58 @@ --- description: "Learn more about: SECOND" -title: "SECOND function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SECOND function (DAX)" --- # SECOND -Returns the seconds of a time value, as a number from 0 to 59. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the seconds of a time value, as a number from 0 to 59. + +## Syntax + ```dax -SECOND(
, [], , ], …) +SELECTCOLUMNS(
, [], , [], …) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -| Table| Any DAX expression that returns a table. | -| Name | The name given to the column, enclosed in double quotes. | -| Expression |Any expression that returns a scalar value like a column reference, integer, or string value.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Table`| Any DAX expression that returns a table. | +|`Name` | The name given to the column, enclosed in double quotes. | +|`Expression` |Any expression that returns a scalar value like a column reference, integer, or string value.| + ## Return value -A table with the same number of rows as the table specified as the first argument. The returned table has one column for each pair of \, \ arguments, and each expression is evaluated in the context of a row from the specified \
argument. - -## Remarks +A table with the same number of rows as the table specified as the first argument. The returned table has one column for each pair of `Name`, `Expression` arguments, and each expression is evaluated in the context of a row from the specified `Table` argument. -SELECTCOLUMNS has the same signature as ADDCOLUMNS, and has the same behavior except that instead of starting with the \
specified, SELECTCOLUMNS starts with an empty table before adding columns. +## Remarks + +SELECTCOLUMNS has the same signature as ADDCOLUMNS, and has the same behavior except that instead of starting with the `Table` specified, SELECTCOLUMNS starts with an empty table before adding columns. [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example + +## Example For the following table named **Customer**: -Country |State |Count |Total +Country |State |Count |Total ---------|---------|---------|--------- IND | JK | 20 | 800 IND | MH | 25 | 1000 diff --git a/query-languages/dax/selectedmeasure-function-dax.md b/query-languages/dax/selectedmeasure-function-dax.md index 763886c5b..ac5950a19 100644 --- a/query-languages/dax/selectedmeasure-function-dax.md +++ b/query-languages/dax/selectedmeasure-function-dax.md @@ -1,49 +1,53 @@ --- description: "Learn more about: SELECTEDMEASURE" -title: "SELECTEDMEASURE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SELECTEDMEASURE function (DAX)" --- # SELECTEDMEASURE -Used by expressions for calculation items to reference the measure that is in context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Used by expressions for calculation items or dynamic format strings to reference the measure that is in context. + +## Syntax + ```dax SELECTEDMEASURE() ``` - -### Parameters - -None - -## Return value -A reference to the measure that is currently in context when the calculation item is evaluated. +### Parameters + +None + +## Return value + +A reference to the measure that is currently in context when the calculation item or format string is evaluated. ## Remarks -- Can only be referenced in the expression for a calculation item. +- Can only be referenced in the expression for a calculation item or format string. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example The following calculation item expression calculates the year-to-date for whatever the measure is in context. - + ```dax CALCULATE(SELECTEDMEASURE(), DATESYTD(DimDate[Date])) ``` - -## See also -[SELECTEDMEASURENAME](selectedmeasurename-function-dax.md) -[ISSELECTEDMEASURE](isselectedmeasure-function-dax.md) +The following expression can be used to dynamically adjust the format string of a measure based upon whether a value is the hundreds, thousands, or millions. + +```dax +SWITCH( +TRUE(), +SELECTEDMEASURE() < 1000,"$#,##0", //Values less than 1000 have no text after them +SELECTEDMEASURE() < 1000000, "$#,##0,.0 K", //Values between 1000 and 1000000 are formatted as #.## K +"$#,##0,,.0 M" //Values greater than 1000000 are formatted as #.## M +) +``` + +## Related content + +[SELECTEDMEASURENAME](selectedmeasurename-function-dax.md) +[ISSELECTEDMEASURE](isselectedmeasure-function-dax.md) diff --git a/query-languages/dax/selectedmeasureformatstring-function-dax.md b/query-languages/dax/selectedmeasureformatstring-function-dax.md index f3067870d..8b5e0ddfc 100644 --- a/query-languages/dax/selectedmeasureformatstring-function-dax.md +++ b/query-languages/dax/selectedmeasureformatstring-function-dax.md @@ -1,31 +1,24 @@ --- description: "Learn more about: SELECTEDMEASUREFORMATSTRING" -title: "SELECTEDMEASUREFORMATSTRING function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SELECTEDMEASUREFORMATSTRING function (DAX)" --- # SELECTEDMEASUREFORMATSTRING +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Used by expressions for calculation items to retrieve the format string of the measure that is in context. - -## Syntax - + +## Syntax + ```dax SELECTEDMEASUREFORMATSTRING() ``` - -### Parameters - -None - -## Return value + +### Parameters + +None + +## Return value A string holding the format string of the measure that is currently in context when the calculation item is evaluated. @@ -35,15 +28,15 @@ A string holding the format string of the measure that is currently in context w - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example +## Example The following expression is evaluated by the Format String Expression property for a calculation item. If there is a single currency in filter context, the format string is retrieved from the DimCurrency[FormatString] column; otherwise the format string of the measure in context is used. - + ```dax SELECTEDVALUE( DimCurrency[FormatString], SELECTEDMEASUREFORMATSTRING() ) ``` - -## See also -[SELECTEDMEASURE](selectedmeasure-function-dax.md) -[ISSELECTEDMEASURE](isselectedmeasure-function-dax.md) +## Related content + +[SELECTEDMEASURE](selectedmeasure-function-dax.md) +[ISSELECTEDMEASURE](isselectedmeasure-function-dax.md) diff --git a/query-languages/dax/selectedmeasurename-function-dax.md b/query-languages/dax/selectedmeasurename-function-dax.md index 758bb208a..63f9dae89 100644 --- a/query-languages/dax/selectedmeasurename-function-dax.md +++ b/query-languages/dax/selectedmeasurename-function-dax.md @@ -1,31 +1,24 @@ --- description: "Learn more about: SELECTEDMEASURENAME" -title: "SELECTEDMEASURENAME function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SELECTEDMEASURENAME function (DAX)" --- # SELECTEDMEASURENAME +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + Used by expressions for calculation items to determine the measure that is in context by name. - -## Syntax - + +## Syntax + ```dax SELECTEDMEASURENAME() ``` - -### Parameters - -None - -## Return value + +### Parameters + +None + +## Return value A string value holding the name of the measure that is currently in context when the calculation item is evaluated. @@ -35,10 +28,10 @@ A string value holding the name of the measure that is currently in context when - This function is often used for debugging purposes when authoring calculation groups. -## Example +## Example The following calculation item expression checks if the current measure is Expense Ratio and conditionally applies calculation logic. Since the check is based on a string comparison, it is not subject to formula fixup and will not benefit from object renaming being automatically reflected. For a similar comparison that would benefit from formula fixup, please see the ISSLECTEDMEASURE function instead. - + ```dax IF ( SELECTEDMEASURENAME = "Expense Ratio", @@ -46,8 +39,8 @@ IF ( DIVIDE ( SELECTEDMEASURE (), COUNTROWS ( DimDate ) ) ) ``` - -## See also -[SELECTEDMEASURE](selectedmeasure-function-dax.md) -[ISSELECTEDMEASURE](isselectedmeasure-function-dax.md) +## Related content + +[SELECTEDMEASURE](selectedmeasure-function-dax.md) +[ISSELECTEDMEASURE](isselectedmeasure-function-dax.md) diff --git a/query-languages/dax/selectedvalue-function-dax.md b/query-languages/dax/selectedvalue-function-dax.md new file mode 100644 index 000000000..058533bd2 --- /dev/null +++ b/query-languages/dax/selectedvalue-function-dax.md @@ -0,0 +1,64 @@ +--- +description: "Learn more about: SELECTEDVALUE" +title: "SELECTEDVALUE function" +--- +# SELECTEDVALUE + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult. + +## Syntax + +```dax +SELECTEDVALUE([, ]) +``` + +### Parameters + +|Term|Definition| +|----------|--------------| +| `columnName` |The name of an existing column, using standard DAX syntax. It cannot be an expression. | +| `alternateResult` |(Optional) The value returned when the context for columnName has been filtered down to zero or more than one distinct value. When not provided, the default value is BLANK().| + +## Return value + +The value when the context for columnName has been filtered down to one distinct value only. Else, alternateResult. + +## Remarks + +- An equivalent expression for `SELECTEDVALUE(, )` is `IF(HASONEVALUE(), VALUES(), )`. + +- To learn more about best practices when using SELECTEDVALUE, see [Use SELECTEDVALUE instead of VALUES in DAX](best-practices/dax-selectedvalue.md). + +- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +The following DAX query: + +```dax +DEFINE + MEASURE DimProduct[Selected Color] = SELECTEDVALUE(DimProduct[Color], "No Single Selection") +EVALUATE + SUMMARIZECOLUMNS + (ROLLUPADDISSUBTOTAL(DimProduct[Color], "Is Total"), + "Selected Color", [Selected Color])ORDER BY [Is Total] ASC, + [Color] ASC +``` + +Returns the following: + +DimProduct[Color] |[Is Total] |[Selected Color] +---------|---------|---------| +Black | `FALSE` | Black | +Blue | `FALSE` | Blue | +Grey | `FALSE` | Grey | +Multi | `FALSE` | Multi | +NA | `FALSE` | NA | +Red | `FALSE` | Red | +Silver | `FALSE` | Silver | +Silver/Black | `FALSE` | Silver/Black | +White | `FALSE` | White | +Yellow | `FALSE` | Yellow | +|``| `TRUE` | No Single Selection| diff --git a/query-languages/dax/selectedvalue-function.md b/query-languages/dax/selectedvalue-function.md deleted file mode 100644 index 3ffb99781..000000000 --- a/query-languages/dax/selectedvalue-function.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -description: "Learn more about: SELECTEDVALUE" -title: "SELECTEDVALUE function | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# SELECTEDVALUE - -Returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult. - -## Syntax - -```dax -SELECTEDVALUE([, ]) -``` - -### Parameters - -|Term|Definition| -|----------|--------------| -| columnName |The name of an existing column, using standard DAX syntax. It cannot be an expression. | -| alternateResult |(Optional) The value returned when the context for columnName has been filtered down to zero or more than one distinct value. When not provided, the default value is BLANK().| - -## Return value - -The value when the context for columnName has been filtered down to one distinct value only. Else, alternateResult. - -## Remarks - -- An equivalent expression for `SELECTEDVALUE(, )` is `IF(HASONEVALUE(), VALUES(), )`. - -- To learn more about best practices when using SELECTEDVALUE, see [Use SELECTEDVALUE instead of VALUES in DAX](best-practices/dax-selectedvalue.md). - -- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -The following DAX query: - -```dax -DEFINE - MEASURE DimProduct[Selected Color] = SELECTEDVALUE(DimProduct[Color], "No Single Selection") -EVALUATE - SUMMARIZECOLUMNS - (ROLLUPADDISSUBTOTAL(DimProduct[Color], "Is Total"), - "Selected Color", [Selected Color])ORDER BY [Is Total] ASC, - [Color] ASC -``` - -Returns the following: - -DimProduct[Color] |[Is Total] |[Selected Color] ----------|---------|---------| -Black | FALSE | Black | -Blue | FALSE | Blue | -Grey | FALSE | Grey | -Multi | FALSE | Multi | -NA | FALSE | NA | -Red | FALSE | Red | -Silver | FALSE | Silver | -Silver/Black | FALSE | Silver/Black | -White | FALSE | White | -Yellow | FALSE | Yellow | -| | TRUE | No Single Selection| diff --git a/query-languages/dax/shadowcluster-function-dax.md b/query-languages/dax/shadowcluster-function-dax.md new file mode 100644 index 000000000..a985d62b3 --- /dev/null +++ b/query-languages/dax/shadowcluster-function-dax.md @@ -0,0 +1,38 @@ +--- +description: "Learn more about: SHADOWCLUSTER" +title: "SHADOWCLUSTER function (DAX) | Microsoft Docs" +--- +# SHADOWCLUSTER + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Modifies how filters are applied while evaluating a GROUPCROSSAPPLY or GROUPCROSSAPPLYTABLE function. + +## Syntax + +```dax +SHADOWCLUSTER(
) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|table expression|Any table expression.| + +## Return value + +A table of values. + +## Remarks + +- You use SHADOWCLUSTER within the context GROUPCROSSAPPLY and GROUPCROSSAPPLYTABLE functions, to override the standard behavior of those functions. + +- When a table is marked as SHADOWCLUSTER, it is marked internally as a "shadow" table expression so that it is only enabled in an ALLSELECTED context. + + +## Related content + +[Filter functions](filter-functions-dax.md) +[GROUPCROSSAPPLY function](groupcrossapply-function-dax.md) +[GROUPCROSSAPPLYTABLE function](groupcrossapplytable-function-dax.md) diff --git a/query-languages/dax/sign-function-dax.md b/query-languages/dax/sign-function-dax.md index 73d83304f..ae0b88b8e 100644 --- a/query-languages/dax/sign-function-dax.md +++ b/query-languages/dax/sign-function-dax.md @@ -1,50 +1,43 @@ --- description: "Learn more about: SIGN" -title: "SIGN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SIGN function (DAX)" --- # SIGN -Determines the sign of a number, the result of a calculation, or a value in a column. The function returns 1 if the number is positive, 0 (zero) if the number is zero, or -1 if the number is negative. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Determines the sign of a number, the result of a calculation, or a value in a column. The function returns 1 if the number is positive, 0 (zero) if the number is zero, or -1 if the number is negative. + +## Syntax + ```dax -SIGN() +SIGN() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Any real number, a column that contains numbers, or an expression that evaluates to a number.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Any real number, a column that contains numbers, or an expression that evaluates to a number.| + ## Return value -A whole number. The possible Return values are 1, 0, and -1. - -|Return value|Description| -|----------------|---------------| -|1|The number is positive| -|0|The number is zero| -|-1|The number is negative| - +A whole number. The possible Return values are 1, 0, and -1. + +|Return value|Description| +|----------------|---------------| +|1|The number is positive| +|0|The number is zero| +|-1|The number is negative| + ## Example -The following formula returns the sign of the result of the expression that calculates sale price minus cost. - +The following formula returns the sign of the result of the expression that calculates sale price minus cost. + ```dax -= SIGN( ([Sale Price] - [Cost]) ) += SIGN( ([Sale Price] - [Cost]) ) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) diff --git a/query-languages/dax/sin-function-dax.md b/query-languages/dax/sin-function-dax.md index fd7bae895..a3344eb4f 100644 --- a/query-languages/dax/sin-function-dax.md +++ b/query-languages/dax/sin-function-dax.md @@ -1,45 +1,38 @@ --- description: "Learn more about: SIN" -title: "SIN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SIN function (DAX)" --- # SIN -Returns the sine of the given angle. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the sine of the given angle. + +## Syntax + ```dax -SIN(number) +SIN(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Required. The angle in radians for which you want the sine.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Required. The angle in radians for which you want the sine.| + ## Return value -Returns the sine of the given angle. - +Returns the sine of the given angle. + ## Remarks -If an argument is in degrees, multiply it by PI()/180 or use the RADIANS function to convert it to radians. - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= SIN(PI())|Sine of pi radians (0, approximately).|0.0| -|= SIN(PI()/2)|Sine of pi/2 radians.|1.0| -|= SIN(30*PI()/180)|Sine of 30 degrees.|0.5| -|= SIN(RADIANS(30))|Sine of 30 degrees.|0.5| +If an argument is in degrees, multiply it by `PI()/180` or use the RADIANS function to convert it to radians. + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= SIN(PI())`|Sine of pi radians (0, approximately).|0.0| +|`= SIN(PI()/2)`|Sine of pi/2 radians.|1.0| +|`= SIN(30*PI()/180)`|Sine of 30 degrees.|0.5| +|`= SIN(RADIANS(30))`|Sine of 30 degrees.|0.5| diff --git a/query-languages/dax/sinh-function-dax.md b/query-languages/dax/sinh-function-dax.md index 8258d014d..9c82540c8 100644 --- a/query-languages/dax/sinh-function-dax.md +++ b/query-languages/dax/sinh-function-dax.md @@ -1,45 +1,38 @@ --- description: "Learn more about: SINH" -title: "SINH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SINH function (DAX)" --- # SINH -Returns the hyperbolic sine of a number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the hyperbolic sine of a number. + +## Syntax + ```dax -SINH(number) +SINH(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Required. Any real number.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Required. Any real number.| + ## Return value -Returns the hyperbolic sine of a number. - +Returns the hyperbolic sine of a number. + ## Remarks -- The formula for the hyperbolic sine is: +- The formula for the hyperbolic sine is: $$\text{SINH}(z) = \frac{e^{z} - e^{-z}}{2}$$ - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example + +## Example Probability of obtaining a result of less than 1.03 seconds. diff --git a/query-languages/dax/sln-function-dax.md b/query-languages/dax/sln-function-dax.md index b01343444..773ccdd7d 100644 --- a/query-languages/dax/sln-function-dax.md +++ b/query-languages/dax/sln-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: SLN" -title: "SLN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "SLN function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # SLN +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the straight-line depreciation of an asset for one period. ## Syntax @@ -24,11 +18,11 @@ SLN(, , ) ### Parameters -|Term|Definition| -|--------|--------------| -|cost|The initial cost of the asset.| -|salvage|The value at the end of the depreciation (sometimes called the salvage value of the asset).| -|life|The number of periods over which the asset is depreciated (sometimes called the useful life of the asset).| +|Term|Definition| +|--------|--------------| +|`cost`|The initial cost of the asset.| +|`salvage`|The value at the end of the depreciation (sometimes called the salvage value of the asset).| +|`life`|The number of periods over which the asset is depreciated (sometimes called the useful life of the asset).| ## Return Value @@ -36,7 +30,7 @@ The straight-line depreciation for one period. ## Remarks -- An error is returned if: +- An error is returned if: life = 0. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/sqrt-function-dax.md b/query-languages/dax/sqrt-function-dax.md index 547e750c7..d55b3b7d3 100644 --- a/query-languages/dax/sqrt-function-dax.md +++ b/query-languages/dax/sqrt-function-dax.md @@ -1,48 +1,41 @@ --- description: "Learn more about: SQRT" -title: "SQRT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SQRT function (DAX)" --- # SQRT -Returns the square root of a number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the square root of a number. + +## Syntax + ```dax -SQRT() +SQRT() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number for which you want the square root, a column that contains numbers, or an expression that evaluates to a number.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number for which you want the square root, a column that contains numbers, or an expression that evaluates to a number.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -If the number is negative, the SQRT function returns an error. - +If the number is negative, the SQRT function returns an error. + ## Example -The following formula, - +The following formula, + ```dax -= SQRT(25) += SQRT(25) ``` - -## See also -[Math and Trig functions](math-and-trig-functions-dax.md) +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) diff --git a/query-languages/dax/sqrtpi-function-dax.md b/query-languages/dax/sqrtpi-function-dax.md index 6fd08fabf..7b99b4b28 100644 --- a/query-languages/dax/sqrtpi-function-dax.md +++ b/query-languages/dax/sqrtpi-function-dax.md @@ -1,39 +1,32 @@ --- description: "Learn more about: SQRTPI" -title: "SQRTPI function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SQRTPI function (DAX)" --- # SQRTPI -Returns the square root of (number * pi). - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the square root of (number * pi). + +## Syntax + ```dax -SQRTPI(number) +SQRTPI(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Required. The number by which pi is multiplied.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Required. The number by which pi is multiplied.| + ## Return value -Returns the square root of (number * pi). +Returns the square root of (number * pi). + +## Example -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= SQRTPI(1)|Square root of pi.|1.772454| -|= SQRTPI(2)|Square root of 2 * pi.|2.506628| +|Formula|Description|Result| +|-----------|---------------|----------| +|`= SQRTPI(1)`|Square root of pi.|1.772454| +|`= SQRTPI(2)`|Square root of 2 * pi.|2.506628| diff --git a/query-languages/dax/startat-statement-dax.md b/query-languages/dax/startat-statement-dax.md new file mode 100644 index 000000000..fff388265 --- /dev/null +++ b/query-languages/dax/startat-statement-dax.md @@ -0,0 +1,34 @@ +--- +description: "Learn more about: START AT" +title: "START AT keyword (DAX)" +--- +# START AT + +Introduces a statement that defines the starting value at which the query results of an ORDER BY clause in an EVALUATE statement in a [DAX query](dax-queries.md) are returned. + +## Syntax + +```dax +[START AT {|} [, …]] +``` + +## Parameters + +|Term |Definition | +|---------|---------| +| `value` | A constant value. Cannot be an expression. | +| `parameter` | The name of a parameter in an XMLA statement prefixed with an `@` character. | + +## Remarks + +- START AT arguments have a one-to-one correspondence with the columns in the ORDER BY statement. There can be as many arguments in the START AT statement as there are in the ORDER BY statement, but not more. The first argument in the START AT statement defines the starting value in column 1 of the ORDER BY columns. The second argument in the START AT statement defines the starting value in column 2 of the ORDER BY columns within the rows that meet the first value for column 1. + +- To learn more about how START AT statements are used, see [DAX queries](dax-queries.md). + +## Related content + +[ORDER BY](orderby-statement-dax.md) +[EVALUATE](evaluate-statement-dax.md) +[VAR](var-dax.md) +[DEFINE](define-statement-dax.md) +[DAX queries](dax-queries.md) diff --git a/query-languages/dax/startofmonth-function-dax.md b/query-languages/dax/startofmonth-function-dax.md index 81a265c28..f4406f00a 100644 --- a/query-languages/dax/startofmonth-function-dax.md +++ b/query-languages/dax/startofmonth-function-dax.md @@ -1,57 +1,50 @@ --- description: "Learn more about: STARTOFMONTH" -title: "STARTOFMONTH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "STARTOFMONTH function (DAX)" --- # STARTOFMONTH -Returns the first date of the month in the current context for the specified column of dates. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] +Returns the first date of the month in the current context for the specified column of dates. + +## Syntax + ```dax -STARTOFMONTH() +STARTOFMONTH() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| + ## Return value -A table containing a single column and single row with a date value. - +A table containing a single column and single row with a date value. + ## Remarks -- The **dates** argument can be any of the following: - - A reference to a date/time column. +- 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](calculate-function-dax.md). - + - A Boolean expression that defines a single-column table of date/time values. + +- Constraints on Boolean expressions are described in the topic, [CALCULATE](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that returns the start of the month, for the current context. - +The following sample formula creates a measure that returns the start of the month, for the current context. + ```dax -= STARTOFMONTH(DateTime[DateKey]) += STARTOFMONTH(DateTime[DateKey]) ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[STARTOFYEAR](startofyear-function-dax.md) -[STARTOFQUARTER](startofquarter-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[STARTOFYEAR](startofyear-function-dax.md) +[STARTOFQUARTER](startofquarter-function-dax.md) diff --git a/query-languages/dax/startofquarter-function-dax.md b/query-languages/dax/startofquarter-function-dax.md index e8ade03da..5da2d55f8 100644 --- a/query-languages/dax/startofquarter-function-dax.md +++ b/query-languages/dax/startofquarter-function-dax.md @@ -1,57 +1,50 @@ --- description: "Learn more about: STARTOFQUARTER" -title: "STARTOFQUARTER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "STARTOFQUARTER function (DAX)" --- # STARTOFQUARTER -Returns the first date of the quarter in the current context for the specified column of dates. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns the first date of the quarter in the current context for the specified column of dates. + +## Syntax + ```dax -STARTOFQUARTER() +STARTOFQUARTER() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| + ## Return value -A table containing a single column and single row with a date value. - +A table containing a single column and single row with a date value. + ## 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](calculate-function-dax.md). - +- 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](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that returns the start of the quarter, for the current context. - +The following sample formula creates a measure that returns the start of the quarter, for the current context. + ```dax -= STARTOFQUARTER(DateTime[DateKey]) += STARTOFQUARTER(DateTime[DateKey]) ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[STARTOFYEAR](startofyear-function-dax.md) -[STARTOFMONTH](startofmonth-function-dax.md) + +## Related content +[Date and time functions](date-and-time-functions-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[STARTOFYEAR](startofyear-function-dax.md) +[STARTOFMONTH](startofmonth-function-dax.md) diff --git a/query-languages/dax/startofyear-function-dax.md b/query-languages/dax/startofyear-function-dax.md index bc9d3330a..0c0d81c3d 100644 --- a/query-languages/dax/startofyear-function-dax.md +++ b/query-languages/dax/startofyear-function-dax.md @@ -1,59 +1,52 @@ --- description: "Learn more about: STARTOFYEAR" -title: "STARTOFYEAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "STARTOFYEAR function (DAX)" --- # STARTOFYEAR -Returns the first date of the year in the current context for the specified column of dates. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Returns the first date of the year in the current context for the specified column of dates. + +## Syntax + ```dax -STARTOFYEAR() +STARTOFYEAR() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|dates|A column that contains dates.| -|YearEndDate|(Optional) A year end date value.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`dates`|A column that contains dates.| +|`YearEndDate`|(Optional) A year end date value.| + ## Return value -A table containing a single column and single row with a date value. - +A table containing a single column and single row with a date value. + ## 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](calculate-function-dax.md). - +- 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](calculate-function-dax.md). + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that returns the start of the year, for the current context. - +The following sample formula creates a measure that returns the start of the year, for the current context. + ```dax -= STARTOFYEAR(DateTime[DateKey]) += STARTOFYEAR(DateTime[DateKey]) ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[Time intelligence functions](time-intelligence-functions-dax.md) -[STARTOFQUARTER](startofquarter-function-dax.md) -[STARTOFMONTH ](startofmonth-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[Time intelligence functions](time-intelligence-functions-dax.md) +[STARTOFQUARTER](startofquarter-function-dax.md) +[STARTOFMONTH ](startofmonth-function-dax.md) diff --git a/query-languages/dax/statements-dax.md b/query-languages/dax/statements-dax.md index e23ebb066..c8b0eb171 100644 --- a/query-languages/dax/statements-dax.md +++ b/query-languages/dax/statements-dax.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Statements" -title: "Statements(DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Statements(DAX)" --- # Statements -## In this category +## In this category |Statement |Description | |---------|---------| -|[DEFINE](define-statement-dax.md) | (Keyword) Defines entities that exist only for the duration of a DAX query. | -|[EVALUATE](evaluate-statement-dax.md) | (Keyword) A statement required to execute a DAX query. | -|[ORDER BY](orderby-statement-dax.md) | (Keyword) Defines one or more expressions used to sort results of a DAX query. | +|[DEFINE](define-statement-dax.md) |(Keyword) Introduces one or more entity definitions that can be applied to one or more EVALUATE statements.| +|[EVALUATE](evaluate-statement-dax.md) | (Keyword) Introduces a statement containing a table expression required to execute a DAX query. | +|[MEASURE](measure-statement-dax.md) |(Keyword) Introduces a measure definition that can be used in one or more EVALUATE statements in a query. | +|[ORDER BY](orderby-statement-dax.md) |(Keyword) Introduces a statement that defines the sort order of query results returned by an EVALUATE statement. | +|[START AT](startat-statement-dax.md) |(Keyword) Introduces a statement that defines the starting value at which the query results of an ORDER BY statement are returned. | |[VAR](var-dax.md) | (Keyword) Stores the result of an expression as a named variable, which can then be passed as an argument to other measure expressions. | diff --git a/query-languages/dax/statistical-functions-dax.md b/query-languages/dax/statistical-functions-dax.md index 12419d64b..df784bcc1 100644 --- a/query-languages/dax/statistical-functions-dax.md +++ b/query-languages/dax/statistical-functions-dax.md @@ -1,19 +1,11 @@ --- description: "Learn more about: Statistical functions" -title: "Statistical functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/28/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Statistical functions (DAX)" --- # Statistical functions Statistical functions calculate values related to statistical distributions and probability, such as standard deviation and number of permutations. - + ## In this category |Function |Description | @@ -31,12 +23,14 @@ Statistical functions calculate values related to statistical distributions and |[EXPON.DIST](expon-dist-function-dax.md) | Returns the exponential distribution. | |[GEOMEAN](geomean-function-dax.md) | Returns the geometric mean of the numbers in a column. | |[GEOMEANX](geomeanx-function-dax.md) | Returns the geometric mean of an expression evaluated for each row in a table. | +|[LINEST](linest-function-dax.md)|Uses the Least Squares method to calculate a straight line that best fits the given data.| +|[LINESTX](linestx-function-dax.md)|Uses the Least Squares method to calculate a straight line that best fits the given data. The data result from expressions evaluated for each row in a table.| |[MEDIAN](median-function-dax.md) | Returns the median of numbers in a column. | |[MEDIANX](medianx-function-dax.md) | Returns the median number of an expression evaluated for each row in a table. | -|[NORM.DIST](norm-dist-dax.md) | Returns the normal distribution for the specified mean and standard deviation. | -|[NORM.INV](norm-inv-dax.md) | The inverse of the normal cumulative distribution for the specified mean and standard deviation. | -|[NORM.S.DIST](norm-s-dist-dax.md) | Returns the standard normal distribution (has a mean of zero and a standard deviation of one). | -|[NORM.S.INV](norm-s-inv-dax.md) | Returns the inverse of the standard normal cumulative distribution. | +|[NORM.DIST](norm-dist-function-dax.md) | Returns the normal distribution for the specified mean and standard deviation. | +|[NORM.INV](norm-inv-function-dax.md) | The inverse of the normal cumulative distribution for the specified mean and standard deviation. | +|[NORM.S.DIST](norm-s-dist-function-dax.md) | Returns the standard normal distribution (has a mean of zero and a standard deviation of one). | +|[NORM.S.INV](norm-s-inv-function-dax.md) | Returns the inverse of the standard normal cumulative distribution. | |[PERCENTILE.EXC](percentile-exc-function-dax.md) | Returns the k-th percentile of values in a range, where k is in the range 0..1, exclusive. | |[PERCENTILE.INC](percentile-inc-function-dax.md) | Returns the k-th percentile of values in a range, where k is in the range 0..1, inclusive. | |[PERCENTILEX.EXC](percentilex-exc-function-dax.md) | Returns the percentile number of an expression evaluated for each row in a table. | @@ -44,17 +38,17 @@ Statistical functions calculate values related to statistical distributions and |[PERMUT](permut-function-dax.md) | Returns the number of permutations for a given number of objects that can be selected from number objects. | |[POISSON.DIST](poisson-dist-function-dax.md) | Returns the Poisson distribution. | |[RANK.EQ](rank-eq-function-dax.md) | Returns the ranking of a number in a list of numbers. | -|[RANKX](rankx-function-dax.md) | Returns the ranking of a number in a list of numbers for each row in the *table* argument. | +|[RANKX](rankx-function-dax.md) | Returns the ranking of a number in a list of numbers for each row in the `table` argument. | |[SAMPLE](sample-function-dax.md) | Returns a sample of N rows from the specified table. | |[STDEV.P](stdev-p-function-dax.md) | Returns the standard deviation of the entire population. | |[STDEV.S](stdev-s-function-dax.md) | Returns the standard deviation of a sample population. | |[STDEVX.P](stdevx-p-function-dax.md) | Returns the standard deviation of the entire population. | |[STDEVX.S](stdevx-s-function-dax.md) | Returns the standard deviation of a sample population. | -|[T.DIST](t-dist-dax.md) | Returns the Student's left-tailed t-distribution. | -|[T.DIST.2T](t-dist-2t-dax.md) | Returns the two-tailed Student's t-distribution. | -|[T.DIST.RT](t-dist-rt-dax.md) | Returns the right-tailed Student's t-distribution. | -|[T.INV](t-inv-dax.md) | Returns the left-tailed inverse of the Student's t-distribution. | -|[T.INV.2t](t-inv-2t-dax.md) | Returns the two-tailed inverse of the Student's t-distribution. | +|[T.DIST](t-dist-function-dax.md) | Returns the Student's left-tailed t-distribution. | +|[T.DIST.2T](t-dist-2t-function-dax.md) | Returns the two-tailed Student's t-distribution. | +|[T.DIST.RT](t-dist-rt-function-dax.md) | Returns the right-tailed Student's t-distribution. | +|[T.INV](t-inv-function-dax.md) | Returns the left-tailed inverse of the Student's t-distribution. | +|[T.INV.2t](t-inv-2t-function-dax.md) | Returns the two-tailed inverse of the Student's t-distribution. | |[VAR.P](var-p-function-dax.md) | Returns the variance of the entire population. | |[VAR.S](var-s-function-dax.md) | Returns the variance of a sample population. | |[VARX.P](varx-p-function-dax.md) | Returns the variance of the entire population. | diff --git a/query-languages/dax/stdev-p-function-dax.md b/query-languages/dax/stdev-p-function-dax.md index 38a8d9c62..eb2e7ae65 100644 --- a/query-languages/dax/stdev-p-function-dax.md +++ b/query-languages/dax/stdev-p-function-dax.md @@ -1,56 +1,49 @@ --- description: "Learn more about: STDEV.P" -title: "STDEV.P function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "STDEV.P function (DAX)" --- # STDEV.P -Returns the standard deviation of the entire population. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the standard deviation of the entire population. + +## Syntax + ```dax -STDEV.P() +STDEV.P() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| columnName | The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. | - +### Parameters + +|Term|Definition| +|--------|--------------| +| `columnName` | The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. | + ## Return value -A number representing the standard deviation of the entire population. - -## Remarks - -- STDEV.P assumes that the column refers to the entire population. If your data represents a sample of the population, then compute the standard deviation by using STDEV.S. - -- STDEV.P uses the following formula: - - √[∑(x - x̃)2/n] - +A number representing the standard deviation of the entire population. + +## Remarks + +- STDEV.P assumes that the column refers to the entire population. If your data represents a sample of the population, then compute the standard deviation by using STDEV.S. + +- STDEV.P uses the following formula: + + √[∑(x - x̃)2/n] + where x̃ is the average value of x for the entire population and n is the population size. - -- Blank rows are filtered out from *columnName* and not considered in the calculations. - -- An error is returned if *columnName* contains less than 2 non-blank rows - + +- Blank rows are filtered out from `columnName` and not considered in the calculations. + +- An error is returned if `columnName` contains less than 2 non-blank rows + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows the formula for a measure that calculates the standard deviation of the column, SalesAmount_USD, when the table InternetSales_USD is the entire population. - +The following example shows the formula for a measure that calculates the standard deviation of the column, SalesAmount_USD, when the table InternetSales_USD is the entire population. + ```dax -= STDEV.P(InternetSales_USD[SalesAmount_USD]) += STDEV.P(InternetSales_USD[SalesAmount_USD]) ``` diff --git a/query-languages/dax/stdev-s-function-dax.md b/query-languages/dax/stdev-s-function-dax.md index 6dcb6a019..6e95e890f 100644 --- a/query-languages/dax/stdev-s-function-dax.md +++ b/query-languages/dax/stdev-s-function-dax.md @@ -1,58 +1,51 @@ --- description: "Learn more about: STDEV.S" -title: "STDEV.S function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "STDEV.S function (DAX)" --- # STDEV.S -Returns the standard deviation of a sample population. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the standard deviation of a sample population. + +## Syntax + ```dax -STDEV.S() +STDEV.S() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| columnName | The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. | +### Parameters + +|Term|Definition| +|--------|--------------| +| `columnName` | The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. | ## Return value -A number that represents the standard deviation of a sample population. - -## Exceptions - -## Remarks - -- STDEV.S assumes that the column refers to a sample of the population. If your data represents the entire population, then compute the standard deviation by using STDEV.P. - -- STDEV.S uses the following formula: - - √[∑(x - x̃)2/(n-1)] - - where x̃ is the average value of x for the sample population and n is the population size. - -- Blank rows are filtered out from *columnName* and not considered in the calculations. - -- An error is returned if *columnName* contains less than 2 non-blank rows. - +A number that represents the standard deviation of a sample population. + +## Exceptions + +## Remarks + +- STDEV.S assumes that the column refers to a sample of the population. If your data represents the entire population, then compute the standard deviation by using STDEV.P. + +- STDEV.S uses the following formula: + + √[∑(x - x̃)2/(n-1)] + + where x̃ is the average value of x for the sample population and n is the population size. + +- Blank rows are filtered out from `columnName` and not considered in the calculations. + +- An error is returned if `columnName` contains less than 2 non-blank rows. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows the formula for a measure that calculates the standard deviation of the column, SalesAmount_USD, when the table InternetSales_USD is the sample population. - +The following example shows the formula for a measure that calculates the standard deviation of the column, SalesAmount_USD, when the table InternetSales_USD is the sample population. + ```dax -= STDEV.S(InternetSales_USD[SalesAmount_USD]) += STDEV.S(InternetSales_USD[SalesAmount_USD]) ``` diff --git a/query-languages/dax/stdevx-p-function-dax.md b/query-languages/dax/stdevx-p-function-dax.md index d9d5b8f0c..63685ea06 100644 --- a/query-languages/dax/stdevx-p-function-dax.md +++ b/query-languages/dax/stdevx-p-function-dax.md @@ -1,57 +1,50 @@ --- description: "Learn more about: STDEVX.P" -title: "STDEVX.P function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "STDEVX.P function (DAX)" --- # STDEVX.P -Returns the standard deviation of the entire population. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the standard deviation of the entire population. + +## Syntax + ```dax -STDEVX.P(
, ) +STDEVX.P(
, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -| table | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | -|expression | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table` | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | +|`expression` | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | + ## Return value -A number that represents the standard deviation of the entire population. - -## Remarks - -- STDEVX.P evaluates *expression* for each row of *table* and returns the standard deviation of expression assuming that table refers to the entire population. If the data in *table* represents a sample of the population, you should compute the standard deviation by using STDEVX.S instead. - -- STDEVX.P uses the following formula: - - √[∑(x - x̃)2/n] - +A number that represents the standard deviation of the entire population. + +## Remarks + +- STDEVX.P evaluates `expression` for each row of `table` and returns the standard deviation of expression assuming that table refers to the entire population. If the data in `table` represents a sample of the population, you should compute the standard deviation by using STDEVX.S instead. + +- STDEVX.P uses the following formula: + + √[∑(x - x̃)2/n] + where x̃ is the average value of x for the entire population and n is the population size. - -- Blank rows are filtered out from *columnName* and not considered in the calculations. - -- An error is returned if *columnName* contains less than 2 non-blank rows - + +- Blank rows are filtered out from `columnName` and not considered in the calculations. + +- An error is returned if `columnName` contains less than 2 non-blank rows + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows the formula for a calculated column that calculates the standard deviation of the unit price per product, when the formula is used in the *Product* table. - +The following example shows the formula for a calculated column that calculates the standard deviation of the unit price per product, when the formula is used in the *Product* table. + ```dax -= STDEVX.P(RELATEDTABLE(InternetSales_USD), InternetSales_USD[UnitPrice_USD] – (InternetSales_USD[DiscountAmount_USD]/InternetSales_USD[OrderQuantity])) += STDEVX.P(RELATEDTABLE(InternetSales_USD), InternetSales_USD[UnitPrice_USD] – (InternetSales_USD[DiscountAmount_USD]/InternetSales_USD[OrderQuantity])) ``` diff --git a/query-languages/dax/stdevx-s-function-dax.md b/query-languages/dax/stdevx-s-function-dax.md index b4d402833..69ae262b0 100644 --- a/query-languages/dax/stdevx-s-function-dax.md +++ b/query-languages/dax/stdevx-s-function-dax.md @@ -1,59 +1,52 @@ --- description: "Learn more about: STDEVX.S" -title: "STDEVX.S function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "STDEVX.S function (DAX)" --- # STDEVX.S -Returns the standard deviation of a sample population. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the standard deviation of a sample population. + +## Syntax + ```dax -STDEVX.S(
, ) +STDEVX.S(
, ) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| table | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | -|expression | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | +### Parameters + +|Term|Definition| +|--------|--------------| +|`table` | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | +|`expression` | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | ## Return value -A number with the standard deviation of a sample population. - -## Exceptions - -## Remarks - -- STDEVX.S evaluates *expression* for each row of *table* and returns the standard deviation of *expression* assuming that *table* refers to a sample of the population. If *table* represents the entire population, then compute the standard deviation by using STDEVX.P. - -- STDEVX.S uses the following formula: - - √[∑(x - x̃)2/(n-1)] - +A number with the standard deviation of a sample population. + +## Exceptions + +## Remarks + +- STDEVX.S evaluates `expression` for each row of `table` and returns the standard deviation of `expression` assuming that `table` refers to a sample of the population. If `table` represents the entire population, then compute the standard deviation by using STDEVX.P. + +- STDEVX.S uses the following formula: + + √[∑(x - x̃)2/(n-1)] + where x̃ is the average value of x for the entire population and n is the population size. - -- Blank rows are filtered out from *columnName* and not considered in the calculations. - -- An error is returned if *columnName* contains less than 2 non-blank rows. - + +- Blank rows are filtered out from `columnName` and not considered in the calculations. + +- An error is returned if `columnName` contains less than 2 non-blank rows. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows the formula for a calculated column that estimates the standard deviation of the unit price per product for a sample population, when the formula is used in the Product table. - +The following example shows the formula for a calculated column that estimates the standard deviation of the unit price per product for a sample population, when the formula is used in the Product table. + ```dax -= STDEVX.S(RELATEDTABLE(InternetSales_USD), InternetSales_USD[UnitPrice_USD] – (InternetSales_USD[DiscountAmount_USD]/InternetSales_USD[OrderQuantity])) += STDEVX.S(RELATEDTABLE(InternetSales_USD), InternetSales_USD[UnitPrice_USD] – (InternetSales_USD[DiscountAmount_USD]/InternetSales_USD[OrderQuantity])) ``` diff --git a/query-languages/dax/substitute-function-dax.md b/query-languages/dax/substitute-function-dax.md index 317160c3b..bf96c72ae 100644 --- a/query-languages/dax/substitute-function-dax.md +++ b/query-languages/dax/substitute-function-dax.md @@ -1,56 +1,49 @@ --- description: "Learn more about: SUBSTITUTE" -title: "SUBSTITUTE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SUBSTITUTE function (DAX)" --- # SUBSTITUTE -Replaces existing text with new text in a text string. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Replaces existing text with new text in a text string. + +## Syntax + ```dax -SUBSTITUTE(, , , ) +SUBSTITUTE(, , , ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|The text in which you want to substitute characters, or a reference to a column containing text.| -|old_text|The existing text that you want to replace.| -|new_text|The text you want to replace **old_text** with.| -|instance_num|(optional) The occurrence of **old_text** you want to replace. If omitted, every instance of **old_text** is replaced| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text in which you want to substitute characters, or a reference to a column containing text.| +|`old_text`|The existing text that you want to replace.| +|`new_text`|The text you want to replace `old_text` with.| +|`instance_num`|(optional) The occurrence of `old_text` you want to replace. If omitted, every instance of `old_text` is replaced| + ## Return value -A string of text. - +A string of text. + ## Remarks -- Use the SUBSTITUTE function when you want to replace specific text in a text string; use the REPLACE function when you want to replace any text of variable length that occurs in a specific location in a text string. - -- The SUBSTITUTE function is case-sensitive. If case does not match between **text** and **old_text**, SUBSTITUTE will not replace the text. - +- Use the SUBSTITUTE function when you want to replace specific text in a text string; use the REPLACE function when you want to replace any text of variable length that occurs in a specific location in a text string. + +- The SUBSTITUTE function is case-sensitive. If case does not match between `text` and `old_text`, SUBSTITUTE will not replace the text. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example: Substitution within a String -The following formula creates a copy of the column [Product Code] that substitutes the new product code **NW** for the old product code **PA** wherever it occurs in the column. - +## Example: Substitution within a String + +The following formula creates a copy of the column [Product Code] that substitutes the new product code `NW` for the old product code `PA` wherever it occurs in the column. + ```dax -= SUBSTITUTE([Product Code], "NW", "PA") += SUBSTITUTE([Product Code], "NW", "PA") ``` - -## See also -[Text functions](text-functions-dax.md) -[REPLACE](replace-function-dax.md) +## Related content + +[Text functions](text-functions-dax.md) +[REPLACE](replace-function-dax.md) diff --git a/query-languages/dax/substitutewithindex-function-dax.md b/query-languages/dax/substitutewithindex-function-dax.md index d352255ac..b5d16a32a 100644 --- a/query-languages/dax/substitutewithindex-function-dax.md +++ b/query-languages/dax/substitutewithindex-function-dax.md @@ -1,44 +1,37 @@ --- description: "Learn more about: SUBSTITUTEWITHINDEX" -title: "SUBSTITUTEWITHINDEX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SUBSTITUTEWITHINDEX function (DAX)" --- # SUBSTITUTEWITHINDEX - -Returns a table which represents a left semijoin of the two tables supplied as arguments. The semijoin is performed by using common columns, determined by common column names and common data type . The columns being joined on are replaced with a single column in the returned table which is of type integer and contains an index. The index is a reference into the right join table given a specified sort order. - -Columns in the right/second table supplied which do not exist in the left/first table supplied are not included in the returned table and are not used to join on. - -The index starts at 0 (0-based) and is incremented by one for each additional row in the right/second join table supplied. The index is based on the sort order specified for the right/second join table. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Returns a table which represents a left semijoin of the two tables supplied as arguments. The semijoin is performed by using common columns, determined by common column names and common data type . The columns being joined on are replaced with a single column in the returned table which is of type integer and contains an index. The index is a reference into the right join table given a specified sort order. + +Columns in the right/second table supplied which do not exist in the left/first table supplied are not included in the returned table and are not used to join on. + +The index starts at 0 (0-based) and is incremented by one for each additional row in the right/second join table supplied. The index is based on the sort order specified for the right/second join table. + +## Syntax + ```dax -SUBSTITUTEWITHINDEX(
, , , [, [][, , []]…]) +SUBSTITUTEWITHINDEX(
, , , [, [][, , []]…]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|A table to be filtered by performing a left semijoin with the table specified as the third argument (indexColumnsTable). This is the table on the left side of the left semijoin so the table returned includes the same columns as this table except that all common columns of the two tables will be replaced with a single index column in the table returned.| -|indexColumnName|A string which specifies the name of the index column which is replacing all the common columns in the two tables supplied as arguments to this function.| -|indexColumnsTable|The second table for the left semijoin. This is the table on the right side of the left semijoin. Only values present in this table will be returned by the function. Also, the columns of this table (based on column names) will be replaced with a single index column in the table returned by this function.| -|orderBy_expression|Any DAX expression where the result value is used to specify the desired sort order of the indexColumnsTable table for generating correct index values. The sort order specified for the indexColumnsTable table defines the index of each row in the table and that index is used in the table returned to represent combinations of values in the indexColumnsTable as they appear in the table supplied as the first argument to this function.| -|order|(Optional) A value that specifies how to sort orderBy_expression values, ascending or descending:

Value: **Desc**. Alternative value: **0**(zero)/**FALSE**. Sorts in descending order of values of orderBy_expression. This is the default value when order parameter is omitted.

Value: **ASC**. Alternative value: **1**/**TRUE**. Ranks in ascending order of orderBy_expression.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|A table to be filtered by performing a left semijoin with the table specified as the third argument (indexColumnsTable). This is the table on the left side of the left semijoin so the table returned includes the same columns as this table except that all common columns of the two tables will be replaced with a single index column in the table returned.| +|`indexColumnName`|A string which specifies the name of the index column which is replacing all the common columns in the two tables supplied as arguments to this function.| +|`indexColumnsTable`|The second table for the left semijoin. This is the table on the right side of the left semijoin. Only values present in this table will be returned by the function. Also, the columns of this table (based on column names) will be replaced with a single index column in the table returned by this function.| +|`orderBy_expression`|Any DAX expression where the result value is used to specify the desired sort order of the indexColumnsTable table for generating correct index values. The sort order specified for the indexColumnsTable table defines the index of each row in the table and that index is used in the table returned to represent combinations of values in the indexColumnsTable as they appear in the table supplied as the first argument to this function.| +|`order`|(Optional) A value that specifies how to sort orderBy_expression values, ascending or descending:

Value: `Desc`. Alternative value: `0`(zero)/`FALSE`. Sorts in descending order of values of orderBy_expression. This is the default value when order parameter is omitted.

Value: `ASC`. Alternative value: `1`/`TRUE`. Ranks in ascending order of orderBy_expression.| + ## Return value -A table which includes only those values present in the indexColumnsTable table and which has an index column instead of all columns present (by name) in the indexColumnsTable table. - +A table which includes only those values present in the indexColumnsTable table and which has an index column instead of all columns present (by name) in the indexColumnsTable table. + ## Remarks - This function does not guarantee any result sort order. diff --git a/query-languages/dax/sum-function-dax.md b/query-languages/dax/sum-function-dax.md index d89d2f465..0e40b54d2 100644 --- a/query-languages/dax/sum-function-dax.md +++ b/query-languages/dax/sum-function-dax.md @@ -1,48 +1,41 @@ --- description: "Learn more about: SUM" -title: "SUM function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SUM function (DAX)" --- # SUM -Adds all the numbers in a column. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Adds all the numbers in a column. + +## Syntax + ```dax -SUM() +SUM() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|column|The column that contains the numbers to sum.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`column`|The column that contains the numbers to sum.| + ## Return value -A decimal number. - -## Remarks - -If you want to filter the values that you are summing, you can use the SUMX function and specify an expression to sum over. - +A decimal number. + +## Remarks + +If you want to filter the values that you are summing, you can use the SUMX function and specify an expression to sum over. + ## Example -The following example adds all the numbers that are contained in the column, Amt, from the table, Sales. - +The following example adds all the numbers that are contained in the column, Amt, from the table, Sales. + ```dax -= SUM(Sales[Amt]) += SUM(Sales[Amt]) ``` - -## See also + +## Related content [SUMX](sumx-function-dax.md) diff --git a/query-languages/dax/summarize-function-dax.md b/query-languages/dax/summarize-function-dax.md index 23f045497..c4e1877f0 100644 --- a/query-languages/dax/summarize-function-dax.md +++ b/query-languages/dax/summarize-function-dax.md @@ -1,211 +1,204 @@ --- description: "Learn more about: SUMMARIZE" -title: "SUMMARIZE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/02/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SUMMARIZE function (DAX)" --- # SUMMARIZE -Returns a summary table for the requested totals over a set of groups. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a summary table for the requested totals over a set of groups. + +## Syntax + ```dax SUMMARIZE (
, [, ]…[, , ]…) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| table | Any DAX expression that returns a table of data. | -| groupBy_ColumnName | (Optional) The qualified name of an existing column used to create summary groups based on the values found in it. This parameter cannot be an expression. | -| name | The name given to a total or summarize column, enclosed in double quotes. | -| expression |Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | +### Parameters + +|Term|Definition| +|--------|--------------| +| `table` | Any DAX expression that returns a table of data. | +| `groupBy_ColumnName` | (Optional) The qualified name of an existing column used to create summary groups based on the values found in it. This parameter cannot be an expression. | +| `name` | The name given to a total or summarize column, enclosed in double quotes. | +| `expression` |Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | ## Return value -A table with the selected columns for the *groupBy_columnName* arguments and the summarized columns designed by the name arguments. - -## Remarks - -- Each column for which you define a name must have a corresponding expression; otherwise, an error is returned. The first argument, name, defines the name of the column in the results. The second argument, expression, defines the calculation performed to obtain the value for each row in that column. +A table with the selected columns for the `groupBy_columnName` arguments and the summarized columns designed by the name arguments. -- groupBy_columnName must be either in *table* or in a related table to *table*. +## Remarks -- Each name must be enclosed in double quotation marks. +- Each column for which you define a name must have a corresponding expression; otherwise, an error is returned. The first argument, name, defines the name of the column in the results. The second argument, expression, defines the calculation performed to obtain the value for each row in that column. -- The function groups a selected set of rows into a set of summary rows by the values of one or more groupBy_columnName columns. One row is returned for each group. +- groupBy_columnName must be either in `table` or in a related table to `table`. + +- Each name must be enclosed in double quotation marks. + +- The function groups a selected set of rows into a set of summary rows by the values of one or more groupBy_columnName columns. One row is returned for each group. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example returns a summary of the reseller sales grouped around the calendar year and the product category name, this result table allows you to do analysis over the reseller sales by year and product category. - +The following example returns a summary of the reseller sales grouped around the calendar year and the product category name, this result table allows you to do analysis over the reseller sales by year and product category. + ```dax -SUMMARIZE(ResellerSales_USD - , DateTime[CalendarYear] - , ProductCategory[ProductCategoryName] - , "Sales Amount (USD)", SUM(ResellerSales_USD[SalesAmount_USD]) - , "Discount Amount (USD)", SUM(ResellerSales_USD[DiscountAmount]) - ) +SUMMARIZE(ResellerSales_USD + , DateTime[CalendarYear] + , ProductCategory[ProductCategoryName] + , "Sales Amount (USD)", SUM(ResellerSales_USD[SalesAmount_USD]) + , "Discount Amount (USD)", SUM(ResellerSales_USD[DiscountAmount]) + ) ``` -The following table shows a preview of the data as it would be received by any function expecting to receive a table: - -|**DateTime[CalendarYear]**|**ProductCategory[ProductCategoryName]**|**[Sales Amount (USD)]**|**[Discount Amount (USD)]**| -|---------|---------|---------|---------| -|2008|Bikes|12968255.42|36167.6592| -|2005|Bikes|6958251.043|4231.1621| -|2006|Bikes|18901351.08|178175.8399| -|2007|Bikes|24256817.5|276065.992| -|2008|Components|2008052.706|39.9266| -|2005|Components|574256.9865|0| -|2006|Components|3428213.05|948.7674| -|2007|Components|5195315.216|4226.0444| -|2008|Clothing|366507.844|4151.1235| -|2005|Clothing|31851.1628|90.9593| -|2006|Clothing|455730.9729|4233.039| -|2007|Clothing|815853.2868|12489.3835| -|2008|Accessories|153299.924|865.5945| -|2005|Accessories|18594.4782|4.293| -|2006|Accessories|86612.7463|1061.4872| -|2007|Accessories|275794.8403|4756.6546| - +The following table shows a preview of the data as it would be received by any function expecting to receive a table: + +|**DateTime[CalendarYear]**|**ProductCategory[ProductCategoryName]**|**[Sales Amount (USD)]**|**[Discount Amount (USD)]**| +|---------|---------|---------|---------| +|2008|Bikes|12968255.42|36167.6592| +|2005|Bikes|6958251.043|4231.1621| +|2006|Bikes|18901351.08|178175.8399| +|2007|Bikes|24256817.5|276065.992| +|2008|Components|2008052.706|39.9266| +|2005|Components|574256.9865|0| +|2006|Components|3428213.05|948.7674| +|2007|Components|5195315.216|4226.0444| +|2008|Clothing|366507.844|4151.1235| +|2005|Clothing|31851.1628|90.9593| +|2006|Clothing|455730.9729|4233.039| +|2007|Clothing|815853.2868|12489.3835| +|2008|Accessories|153299.924|865.5945| +|2005|Accessories|18594.4782|4.293| +|2006|Accessories|86612.7463|1061.4872| +|2007|Accessories|275794.8403|4756.6546| + ## With ROLLUP The addition of the [ROLLUP](rollup-function-dax.md) syntax modifies the behavior of the SUMMARIZE function by adding rollup rows to the result on the groupBy_columnName columns. [ROLLUP](rollup-function-dax.md) can only be used within a SUMMARIZE expression. ### Example -The following example adds rollup rows to the Group-By columns of the SUMMARIZE function call: - +The following example adds rollup rows to the Group-By columns of the SUMMARIZE function call: + ```dax -SUMMARIZE(ResellerSales_USD - , ROLLUP( DateTime[CalendarYear], ProductCategory[ProductCategoryName]) - , "Sales Amount (USD)", SUM(ResellerSales_USD[SalesAmount_USD]) - , "Discount Amount (USD)", SUM(ResellerSales_USD[DiscountAmount]) -) +SUMMARIZE(ResellerSales_USD + , ROLLUP( DateTime[CalendarYear], ProductCategory[ProductCategoryName]) + , "Sales Amount (USD)", SUM(ResellerSales_USD[SalesAmount_USD]) + , "Discount Amount (USD)", SUM(ResellerSales_USD[DiscountAmount]) +) ``` -Returns the following table, - -|**DateTime[CalendarYear]**|**ProductCategory[ProductCategoryName]**|**[Sales Amount (USD)]**|**[Discount Amount (USD)]**| -|---------|---------|---------|---------| -|2008|Bikes|12968255.42|36167.6592| -|2005|Bikes|6958251.043|4231.1621| -|2006|Bikes|18901351.08|178175.8399| -|2007|Bikes|24256817.5|276065.992| -|2008|Components|2008052.706|39.9266| -|2005|Components|574256.9865|0| -|2006|Components|3428213.05|948.7674| -|2007|Components|5195315.216|4226.0444| -|2008|Clothing|366507.844|4151.1235| -|2005|Clothing|31851.1628|90.9593| -|2006|Clothing|455730.9729|4233.039| -|2007|Clothing|815853.2868|12489.3835| -|2008|Accessories|153299.924|865.5945| -|2005|Accessories|18594.4782|4.293| -|2006|Accessories|86612.7463|1061.4872| -|2007|Accessories|275794.8403|4756.6546| -|2008||15496115.89|41224.3038| -|2005||7582953.67|4326.4144| -|2006||22871907.85|184419.1335| -|2007||30543780.84|297538.0745| -|||76494758.25|527507.9262| - +Returns the following table, + +|**DateTime[CalendarYear]**|**ProductCategory[ProductCategoryName]**|**[Sales Amount (USD)]**|**[Discount Amount (USD)]**| +|---------|---------|---------|---------| +|2008|Bikes|12968255.42|36167.6592| +|2005|Bikes|6958251.043|4231.1621| +|2006|Bikes|18901351.08|178175.8399| +|2007|Bikes|24256817.5|276065.992| +|2008|Components|2008052.706|39.9266| +|2005|Components|574256.9865|0| +|2006|Components|3428213.05|948.7674| +|2007|Components|5195315.216|4226.0444| +|2008|Clothing|366507.844|4151.1235| +|2005|Clothing|31851.1628|90.9593| +|2006|Clothing|455730.9729|4233.039| +|2007|Clothing|815853.2868|12489.3835| +|2008|Accessories|153299.924|865.5945| +|2005|Accessories|18594.4782|4.293| +|2006|Accessories|86612.7463|1061.4872| +|2007|Accessories|275794.8403|4756.6546| +|2008||15496115.89|41224.3038| +|2005||7582953.67|4326.4144| +|2006||22871907.85|184419.1335| +|2007||30543780.84|297538.0745| +|||76494758.25|527507.9262| + ## With ROLLUPGROUP The addition of [ROLLUPGROUP](rollupgroup-function-dax.md) inside a [ROLLUP](rollup-function-dax.md) syntax can be used to prevent partial subtotals in rollup rows. [ROLLUPGROUP](rollupgroup-function-dax.md) can only be used within a [ROLLUP](rollup-function-dax.md), [ROLLUPADDISSUBTOTAL](rollupaddissubtotal-function-dax.md), or [ROLLUPISSUBTOTAL](rollupissubtotal-function-dax.md) expression. ### Example -The following example shows only the grand total of all years and categories without the subtotal of each year with all categories: - +The following example shows only the grand total of all years and categories without the subtotal of each year with all categories: + ```dax -SUMMARIZE(ResellerSales_USD - , ROLLUP(ROLLUPGROUP( DateTime[CalendarYear], ProductCategory[ProductCategoryName])) - , "Sales Amount (USD)", SUM(ResellerSales_USD[SalesAmount_USD]) - , "Discount Amount (USD)", SUM(ResellerSales_USD[DiscountAmount]) -) +SUMMARIZE(ResellerSales_USD + , ROLLUP(ROLLUPGROUP( DateTime[CalendarYear], ProductCategory[ProductCategoryName])) + , "Sales Amount (USD)", SUM(ResellerSales_USD[SalesAmount_USD]) + , "Discount Amount (USD)", SUM(ResellerSales_USD[DiscountAmount]) +) ``` -Returns the following table, - -|**DateTime[CalendarYear]**|**ProductCategory[ProductCategoryName]**|**[Sales Amount (USD)]**|**[Discount Amount (USD)]**| -|---------|---------|---------|---------| -|2008|Bikes|12968255.42|36167.6592| -|2005|Bikes|6958251.043|4231.1621| -|2006|Bikes|18901351.08|178175.8399| -|2007|Bikes|24256817.5|276065.992| -|2008|Components|2008052.706|39.9266| -|2005|Components|574256.9865|0| -|2006|Components|3428213.05|948.7674| -|2007|Components|5195315.216|4226.0444| -|2008|Clothing|366507.844|4151.1235| -|2005|Clothing|31851.1628|90.9593| -|2006|Clothing|455730.9729|4233.039| -|2007|Clothing|815853.2868|12489.3835| -|2008|Accessories|153299.924|865.5945| -|2005|Accessories|18594.4782|4.293| -|2006|Accessories|86612.7463|1061.4872| -|2007|Accessories|275794.8403|4756.6546| -|||76494758.25|527507.9262| - +Returns the following table, + +|**DateTime[CalendarYear]**|**ProductCategory[ProductCategoryName]**|**[Sales Amount (USD)]**|**[Discount Amount (USD)]**| +|---------|---------|---------|---------| +|2008|Bikes|12968255.42|36167.6592| +|2005|Bikes|6958251.043|4231.1621| +|2006|Bikes|18901351.08|178175.8399| +|2007|Bikes|24256817.5|276065.992| +|2008|Components|2008052.706|39.9266| +|2005|Components|574256.9865|0| +|2006|Components|3428213.05|948.7674| +|2007|Components|5195315.216|4226.0444| +|2008|Clothing|366507.844|4151.1235| +|2005|Clothing|31851.1628|90.9593| +|2006|Clothing|455730.9729|4233.039| +|2007|Clothing|815853.2868|12489.3835| +|2008|Accessories|153299.924|865.5945| +|2005|Accessories|18594.4782|4.293| +|2006|Accessories|86612.7463|1061.4872| +|2007|Accessories|275794.8403|4756.6546| +|||76494758.25|527507.9262| + ## With ISSUBTOTAL With [ISSUBTOTAL](issubtotal-function-dax.md), you can create another column in the SUMMARIZE expression that returns True if the row contains subtotal values for the column given as argument to [ISSUBTOTAL](issubtotal-function-dax.md), otherwise returns False. [ISSUBTOTAL](issubtotal-function-dax.md) can only be used within a SUMMARIZE expression. - + ### Example -The following sample generates an [ISSUBTOTAL](issubtotal-function-dax.md) column for each of the [ROLLUP](rollup-function-dax.md) columns in the given SUMMARIZE function call: - +The following sample generates an [ISSUBTOTAL](issubtotal-function-dax.md) column for each of the [ROLLUP](rollup-function-dax.md) columns in the given SUMMARIZE function call: + ```dax -SUMMARIZE(ResellerSales_USD - , ROLLUP( DateTime[CalendarYear], ProductCategory[ProductCategoryName]) - , "Sales Amount (USD)", SUM(ResellerSales_USD[SalesAmount_USD]) - , "Discount Amount (USD)", SUM(ResellerSales_USD[DiscountAmount]) - , "Is Sub Total for DateTimeCalendarYear", ISSUBTOTAL(DateTime[CalendarYear]) - , "Is Sub Total for ProductCategoryName", ISSUBTOTAL(ProductCategory[ProductCategoryName]) -) +SUMMARIZE(ResellerSales_USD + , ROLLUP( DateTime[CalendarYear], ProductCategory[ProductCategoryName]) + , "Sales Amount (USD)", SUM(ResellerSales_USD[SalesAmount_USD]) + , "Discount Amount (USD)", SUM(ResellerSales_USD[DiscountAmount]) + , "Is Sub Total for DateTimeCalendarYear", ISSUBTOTAL(DateTime[CalendarYear]) + , "Is Sub Total for ProductCategoryName", ISSUBTOTAL(ProductCategory[ProductCategoryName]) +) ``` Returns the following table, - -|**[Is Sub Total for DateTimeCalendarYear]**|**[Is Sub Total for ProductCategoryName]**|**DateTime[CalendarYear]**|**ProductCategory[ProductCategoryName]**|**[Sales Amount (USD)]**|**[Discount Amount (USD)]**| -|---------|---------|---------|---------|---------|---------| -|FALSE|FALSE||||| -|FALSE|FALSE|2008|Bikes|12968255.42|36167.6592| -|FALSE|FALSE|2005|Bikes|6958251.043|4231.1621| -|FALSE|FALSE|2006|Bikes|18901351.08|178175.8399| -|FALSE|FALSE|2007|Bikes|24256817.5|276065.992| -|FALSE|FALSE|2008|Components|2008052.706|39.9266| -|FALSE|FALSE|2005|Components|574256.9865|0| -|FALSE|FALSE|2006|Components|3428213.05|948.7674| -|FALSE|FALSE|2007|Components|5195315.216|4226.0444| -|FALSE|FALSE|2008|Clothing|366507.844|4151.1235| -|FALSE|FALSE|2005|Clothing|31851.1628|90.9593| -|FALSE|FALSE|2006|Clothing|455730.9729|4233.039| -|FALSE|FALSE|2007|Clothing|815853.2868|12489.3835| -|FALSE|FALSE|2008|Accessories|153299.924|865.5945| -|FALSE|FALSE|2005|Accessories|18594.4782|4.293| -|FALSE|FALSE|2006|Accessories|86612.7463|1061.4872| -|FALSE|FALSE|2007|Accessories|275794.8403|4756.6546| -|FALSE|TRUE||||| -|FALSE|TRUE|2008||15496115.89|41224.3038| -|FALSE|TRUE|2005||7582953.67|4326.4144| -|FALSE|TRUE|2006||22871907.85|184419.1335| -|FALSE|TRUE|2007||30543780.84|297538.0745| -|TRUE|TRUE|||76494758.25|527507.9262| - -## See also + +|**[Is Sub Total for DateTimeCalendarYear]**|**[Is Sub Total for ProductCategoryName]**|**DateTime[CalendarYear]**|**ProductCategory[ProductCategoryName]**|**[Sales Amount (USD)]**|**[Discount Amount (USD)]**| +|---------|---------|---------|---------|---------|---------| +|`FALSE`|`FALSE`||||| +|`FALSE`|`FALSE`|2008|Bikes|12968255.42|36167.6592| +|`FALSE`|`FALSE`|2005|Bikes|6958251.043|4231.1621| +|`FALSE`|`FALSE`|2006|Bikes|18901351.08|178175.8399| +|`FALSE`|`FALSE`|2007|Bikes|24256817.5|276065.992| +|`FALSE`|`FALSE`|2008|Components|2008052.706|39.9266| +|`FALSE`|`FALSE`|2005|Components|574256.9865|0| +|`FALSE`|`FALSE`|2006|Components|3428213.05|948.7674| +|`FALSE`|`FALSE`|2007|Components|5195315.216|4226.0444| +|`FALSE`|`FALSE`|2008|Clothing|366507.844|4151.1235| +|`FALSE`|`FALSE`|2005|Clothing|31851.1628|90.9593| +|`FALSE`|`FALSE`|2006|Clothing|455730.9729|4233.039| +|`FALSE`|`FALSE`|2007|Clothing|815853.2868|12489.3835| +|`FALSE`|`FALSE`|2008|Accessories|153299.924|865.5945| +|`FALSE`|`FALSE`|2005|Accessories|18594.4782|4.293| +|`FALSE`|`FALSE`|2006|Accessories|86612.7463|1061.4872| +|`FALSE`|`FALSE`|2007|Accessories|275794.8403|4756.6546| +|`FALSE`|`TRUE`||||| +|`FALSE`|`TRUE`|2008||15496115.89|41224.3038| +|`FALSE`|`TRUE`|2005||7582953.67|4326.4144| +|`FALSE`|`TRUE`|2006||22871907.85|184419.1335| +|`FALSE`|`TRUE`|2007||30543780.84|297538.0745| +|`TRUE`|`TRUE`|||76494758.25|527507.9262| + +## Related content [SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) diff --git a/query-languages/dax/summarizecolumns-function-dax.md b/query-languages/dax/summarizecolumns-function-dax.md index fbcc742aa..0f55863b1 100644 --- a/query-languages/dax/summarizecolumns-function-dax.md +++ b/query-languages/dax/summarizecolumns-function-dax.md @@ -1,73 +1,66 @@ --- description: "Learn more about: SUMMARIZECOLUMNS" -title: "SUMMARIZECOLUMNS function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 09/02/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SUMMARIZECOLUMNS function (DAX)" --- # SUMMARIZECOLUMNS -Returns a summary table over a set of groups. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Returns a summary table over a set of groups. + +## Syntax + ```dax -SUMMARIZECOLUMNS( [, < groupBy_columnName >]…, []…[, , ]…) +SUMMARIZECOLUMNS( [, < groupBy_columnName >]…, []…[, , ]…) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|groupBy_columnName|A fully qualified column reference (Table[Column]) to a base table for which the distinct values are included in the returned table. Each groupBy_columnName column is cross-joined (different tables) or auto-existed (same table) with the subsequent specified columns.| -|filterTable|A table expression which is added to the filter context of all columns specified as groupBy_columnName arguments. The values present in the filter table are used to filter before cross-join/auto-exist is performed.| -|name|A string representing the column name to use for the subsequent expression specified.| -|expression|Any DAX expression that returns a single value (not a table).| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`groupBy_columnName`|A fully qualified column reference (Table[Column]) to a base table for which the distinct values are included in the returned table. Each groupBy_columnName column is cross-joined (different tables) or auto-existed (same table) with the subsequent specified columns.| +|`filterTable`|A table expression which is added to the filter context of all columns specified as groupBy_columnName arguments. The values present in the filter table are used to filter before cross-join/auto-exist is performed.| +|`name`|A string representing the column name to use for the subsequent expression specified.| +|`expression`|Any DAX expression that returns a single value (not a table).| + ## Return value -A table which includes combinations of values from the supplied columns based on the grouping specified. Only rows for which at least one of the supplied expressions return a non-blank value are included in the table returned. If all expressions evaluate to BLANK/NULL for a row, that row is not included in the table returned. - +A table which includes combinations of values from the supplied columns based on the grouping specified. Only rows for which at least one of the supplied expressions return a non-blank value are included in the table returned. If all expressions evaluate to BLANK/NULL for a row, that row is not included in the table returned. + ## Remarks -- This function does not guarantee any sort order for the results. - -- A column cannot be specified more than once in the groupBy_columnName parameter. For example, the following formula is invalid. - - `SUMMARIZECOLUMNS( Sales[StoreId], Sales[StoreId] )` +- This function does not guarantee any sort order for the results. + +- A column cannot be specified more than once in the groupBy_columnName parameter. For example, the following formula is invalid. + + `SUMMARIZECOLUMNS( Sales[StoreId], Sales[StoreId] )` - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Filter context - -Consider the following query: - + +Consider the following query: + ```dax SUMMARIZECOLUMNS ( 'Sales Territory'[Category], FILTER('Customer', 'Customer' [First Name] = "Alicia") ) ``` - -In this query, without a measure the groupBy columns do not contain any columns from the FILTER expression (for example, from Customer table). The filter is not applied to the groupBy columns. The Sales Territory and Customer tables may be indirectly related through the Reseller sales fact table. Since they're not directly related, the filter expression is a no-op and the groupBy columns are not impacted. - -However, with this query: - + +In this query, without a measure the groupBy columns do not contain any columns from the FILTER expression (for example, from Customer table). The filter is not applied to the groupBy columns. The Sales Territory and Customer tables may be indirectly related through the Reseller sales fact table. Since they're not directly related, the filter expression is a no-op and the groupBy columns are not impacted. + +However, with this query: + ```dax SUMMARIZECOLUMNS ( 'Sales Territory'[Category], 'Customer' [Education], FILTER('Customer', 'Customer'[First Name] = "Alicia") ) -``` - -The groupBy columns contain a column which is impacted by the filter and that filter is applied to the groupBy results. - +``` + +The groupBy columns contain a column which is impacted by the filter and that filter is applied to the groupBy results. + ## With IGNORE The [IGNORE](ignore-function-dax.md) syntax can be used to modify the behavior of the SUMMARIZECOLUMNS function by omitting specific expressions from the BLANK/NULL evaluation. Rows for which all expressions not using [IGNORE](ignore-function-dax.md) return BLANK/NULL will be excluded independent of whether the expressions which do use [IGNORE](ignore-function-dax.md) evaluate to BLANK/NULL or not. [IGNORE](ignore-function-dax.md) can only be used within a SUMMARIZECOLUMNS expression. @@ -81,39 +74,39 @@ SUMMARIZECOLUMNS( "BlankIfTotalQtyIsNot3", IF( SUM( Sales[Qty] )=3, 3 ) ) ``` - -This rolls up the Sales[CustomerId] column, creating a subtotal for all customers in the given grouping. Without [IGNORE](ignore-function-dax.md), the result is: - -|CustomerId|TotalQty|BlankIfTotalQtyIsNot3| -|--------------|------------|-------------------------| -|A|5|| -|B|3|3| -|C|3|3| - + +This rolls up the Sales[CustomerId] column, creating a subtotal for all customers in the given grouping. Without [IGNORE](ignore-function-dax.md), the result is: + +|CustomerId|Total Qty|BlankIfTotalQtyIsNot3| +|--------------|------------|-------------------------| +|A|5|| +|B|3|3| +|C|3|3| + With [IGNORE](ignore-function-dax.md), - -|CustomerId|TotalQty|BlankIfTotalQtyIsNot3| -|--------------|------------|-------------------------| -|B|3|3| -|C|3|3| - + +|CustomerId|Total Qty|BlankIfTotalQtyIsNot3| +|--------------|------------|-------------------------| +|B|3|3| +|C|3|3| + All expression ignored, - + ```dax SUMMARIZECOLUMNS( Sales[CustomerId], "Blank", - IGNORE( Blank() ), "BlankIfTotalQtyIsNot5", + IGNORE( BLANK() ), "BlankIfTotalQtyIsNot5", IGNORE( IF( SUM( Sales[Qty] )=5, 5 ) ) ) ``` - -Even though both expressions return blank for some rows, they're included since there are no unignored expressions which return blank. - -|CustomerId|TotalQty|BlankIfTotalQtyIsNot3| -|--------------|------------|-------------------------| -|A||5| -|B||| -|C||| + +Even though both expressions return blank for some rows, they're included since there are no unignored expressions which return blank. + +|CustomerId|Blank|BlankIfTotalQtyIsNot5| +|--------------|------------|-------------------------| +|A||5| +|B||| +|C||| ## With NONVISUAL @@ -164,13 +157,13 @@ Returns the result where [Visual Total Sales] is the total across the two select |---------|---------|---------| |2007 | 9,791,060.30 | 19,561,960.04 | |2008 | 9,770,899.74 | 19,561,960.04 | - + ## With ROLLUPADDISSUBTOTAL The addition of the [ROLLUPADDISSUBTOTAL](rollupaddissubtotal-function-dax.md) syntax modifies the behavior of the SUMMARIZECOLUMNS function by adding rollup/subtotal rows to the result based on the groupBy_columnName columns. [ROLLUPADDISSUBTOTAL](rollupaddissubtotal-function-dax.md) can only be used within a SUMMARIZECOLUMNS expression. - + ### Example with single subtotal - + ```dax DEFINE VAR vCategoryFilter = @@ -192,9 +185,9 @@ EVALUATE [IsSubcategorySubtotal] DESC, [Subcategory] ``` - + Returns the following table, - + |Category |Subcategory |IsCategorySubtotal |IsSubcategorySubtotal |Total Qty |---------|---------|---------|---------|---------| | | | True | True | 60398 | @@ -202,67 +195,171 @@ Returns the following table, |Accessories | Bike Racks | False | False | 328 | |Bikes | Mountain Bikes | False | False | 4970 | |Clothing | | False | True | 9101 | - + ### Example with multiple subtotals - + ```dax -SUMMARIZECOUMNS ( +SUMMARIZECOLUMNS ( Regions[State], ROLLUPADDISSUBTOTAL ( Sales[CustomerId], "IsCustomerSubtotal" ), ROLLUPADDISSUBTOTAL ( Sales[Date], "IsDateSubtotal"), "Total Qty", SUM( Sales[Qty] ) ) ``` - -Sales is grouped by state, by customer, by date, with subtotals for 1. Sales by state, by date 2. Sales by State, by Customer 3. Rolled up on both customer and date leading to sales by state. - + +Sales is grouped by state, by customer, by date, with subtotals for 1. Sales by state, by date 2. Sales by State, by Customer 3. Rolled up on both customer and date leading to sales by state. + Returns the following table, - -|CustomerID|IsCustomerSubtotal|State|Total Qty|Date|IsDateSubtotal| -|--------------|----------------------|---------|-------------|--------|------------------| -|A|FALSE|WA|5|7/10/2014|| -|B|FALSE|WA|1|7/10/2014|| -|B|FALSE|WA|2|7/11/2014|| -|C|FALSE|OR|2|7/10/2014|| -|C|FALSE|OR|1|7/11/2014|| -||TRUE|WA|6|7/10/2014|| -||TRUE|WA|2|7/11/2014|| -||TRUE|OR|2|7/10/2014|| -||TRUE|OR|1|7/11/2014|| -|A|FALSE|WA|5||TRUE| -|B|FALSE|WA|3||TRUE| -|C|FALSE|OR|3||TRUE| -||TRUE|WA|8||TRUE| -||TRUE|OR|3||TRUE| - + +|CustomerID|IsCustomerSubtotal|State|Total Qty|Date|IsDateSubtotal| +|--------------|----------------------|---------|-------------|--------|------------------| +|A|`FALSE`|WA|5|7/10/2014|| +|B|`FALSE`|WA|1|7/10/2014|| +|B|`FALSE`|WA|2|7/11/2014|| +|C|`FALSE`|OR|2|7/10/2014|| +|C|`FALSE`|OR|1|7/11/2014|| +||`TRUE`|WA|6|7/10/2014|| +||`TRUE`|WA|2|7/11/2014|| +||`TRUE`|OR|2|7/10/2014|| +||`TRUE`|OR|1|7/11/2014|| +|A|`FALSE`|WA|5||`TRUE`| +|B|`FALSE`|WA|3||`TRUE`| +|C|`FALSE`|OR|3||`TRUE`| +||`TRUE`|WA|8||`TRUE`| +||`TRUE`|OR|3||`TRUE`| + ## With ROLLUPGROUP Like with the [SUMMARIZE](summarize-function-dax.md) function, [ROLLUPGROUP](rollupgroup-function-dax.md) can be used together with [ROLLUPADDISSUBTOTAL](rollupaddissubtotal-function-dax.md) to specify which summary groups/granularities (subtotals) to include, reducing the number of subtotal rows returned. [ROLLUPGROUP](rollupgroup-function-dax.md) can only be used within a SUMMARIZECOLUMNS or [SUMMARIZE](summarize-function-dax.md) expression. - + ### Example with multiple subtotals - + ```dax SUMMARIZECOLUMNS( ROLLUPADDISSUBTOTAL( Sales[CustomerId], "IsCustomerSubtotal" ), ROLLUPADDISSUBTOTAL(ROLLUPGROUP(Regions[City], Regions[State]), "IsCityStateSubtotal"),"Total Qty", SUM( Sales[Qty] ) ) -``` - +``` + Still grouped by City and State, but rolled together when reporting a subtotal returns the following table, -|State|CustomerId|IsCustomerSubtotal|Total Qty|City|IsCityStateSubtotal| -|---------|--------------|----------------------|-------------|--------|-----------------------| -|WA|A|FALSE|2|Bellevue|FALSE| -|WA|B|FALSE|2|Bellevue|FALSE| -|WA|A|FALSE|3|Redmond|FALSE| -|WA|B|FALSE|1|Redmond|FALSE| -|OR|C|FALSE|3|Portland|FALSE| -|WA||TRUE|4|Bellevue|FALSE| -|WA||TRUE|4|Redmond|FALSE| -|OR||TRUE|3|Portland|FALSE| -||A|FALSE|5||FALSE| -||B|FALSE|3||TRUE| -||C|FALSE|3||TRUE| -|||TRUE|11||TRUE| - -## See also +|State|CustomerId|IsCustomerSubtotal|Total Qty|City|IsCityStateSubtotal| +|---------|--------------|----------------------|-------------|--------|-----------------------| +|WA|A|`FALSE`|2|Bellevue|`FALSE`| +|WA|B|`FALSE`|2|Bellevue|`FALSE`| +|WA|A|`FALSE`|3|Redmond|`FALSE`| +|WA|B|`FALSE`|1|Redmond|`FALSE`| +|OR|C|`FALSE`|3|Portland|`FALSE`| +|WA||`TRUE`|4|Bellevue|`FALSE`| +|WA||`TRUE`|4|Redmond|`FALSE`| +|OR||`TRUE`|3|Portland|`FALSE`| +||A|`FALSE`|5||`FALSE`| +||B|`FALSE`|3||`TRUE`| +||C|`FALSE`|3||`TRUE`| +|||`TRUE`|11||`TRUE`| + +## Contextual SummarizeColumns ## +### Background +Until February 2023, SUMMARIZECOLUMNS did not support evaluation within a context transition at all. In products released before that month, this limitation made SUMMARIZECOLUMNS not useful in most of the measures – it was not possible to call a measure SUMMARIZECOLUMNS in any case of context transition, including other SUMMARIZECOLUMNS statements. + +From February 2023, the context transition was supported in a few scenarios, but not in all the conditions. The supported and restricted cases are as follows: + +| SummarizeColumns Type | External Filter with single column | External Filter with more than one column | External GroupBy Columns | +| -------- | ------- | ------- | ------- | +| SummarizeColumns with GroupBy only | OK | OK | OK | +| SummarizeColumns with Filters/Measures | OK | ERROR | ERROR | + +From June 2024, we are enabling contextual SummarizeColumns which allows SummarizeColumns to be evaluated in any context transition, SummarizeColumns in measure is now fully supported: + +| SummarizeColumns Type | External Filter with single column | External Filter with more than one column | External GroupBy Columns | +| -------- | ------- | ------- | ------- | +| SummarizeColumns with GroupBy only | OK | OK | OK | +| SummarizeColumns with Filters/Measures | OK | OK | OK | + +However, this update also includes changes to the behavior of SummarizeColumns, which may alter the results of existing expressions: + +### SelfValue semantics for external filters ### +We are introducing a semantic concept named SelfValue, which alters how filters from external tables interact with GroupBy columns in SummarizeColumns. This change disallows filters from a different table to affect the GroupBy columns, even if the tables are related through a filter-by relationship. +An example illustrating the impact of this change involves the following expression: + +``` +CalculateTable( + SummarizeColumns( + 'Reseller Sales'[ResellerKey], + 'Reseller Sales'[ProductKey] + ), + Treatas({(229)}, 'Product'[Product Key]) +) +``` + +Before this update, the TreatAs filter would apply to the GroupBy operation within SummarizeColumns, leveraging the relationship between 'Product'[Product Key] and 'Reseller Sales'[ProductKey]. Consequently, the query results would only include rows where 'Reseller Sales'[ProductKey] equals 229. +However, after the update, GroupBy columns within SummarizeColumns will no longer be filtered by columns from external tables, even if a relationship exists between them. Therefore, in the example above, the GroupBy column 'Reseller Sales'[ProductKey] will not be filtered by the 'Product'[ProductKey] column. As a result, the query will include rows where 'Reseller Sales'[ProductKey] is not equal to 229. + +If you prefer to retain the previous behavior, you can rewrite the expression using Summarize instead of SummarizeColumns, as shown below: +``` +CalculateTable( + SUMMARIZE( + 'Reseller Sales', + [ResellerKey], + [ProductKey] + ), + Treatas({(229)}, 'Product'[Product Key]) +) +``` +This rewritten expression preserves the original semantics where the GroupBy operation is not affected by the SelfValue restriction introduced by the update. + +### Row validation for groupby columns fully covered by Treatas ### + +Prior to this update, within a SummarizeColumns function, if all GroupBy columns from a specific table were fully covered by a single Treatas filter from that same table, as shown below: + +``` +SummarizeColumns( + Geography[Country], + Geography[State], + Treatas( + {("United States", "Alberta")}, + Geography[Country], + Geography[State] + ) +) +``` +The result of the above query would include whatever rows were specified in the Treatas filter, regardless of whether they were valid or not. For instance, the result would be a single-row table ("United States", "Alberta"), even if no such row with [Country] = "United States" and [State] = "Alberta" existed in the 'Geography' table. + +This issue was known and has been addressed by the update. After the update, such invalid rows will be filtered out, and only valid rows from the GroupBy table will be returned. Therefore, the result for the query above would be empty, as there are no valid rows matching the specified [Country] and [State] values in the 'Geography' table. + +### Disallow mixed Keepfilters/overriddefilters on same table/cluster ### + +The recent update has introduced a temporary restriction that triggers an error message stating: +``` +"SummarizeColumns filters with keepfilters behavior and overridefilters behavior are mixed within one cluster, which is not allowed. Consider adding keepfilters() to all filters of summarizecolumns." +``` +This error occurs when both normal filters (which override existing filters) and filters with KeepFilters specified are present within the same table/cluster. For example: +``` +Evaluate CalculateTable( + SummarizeColumns( + Product[Color], + KeepFilters( + TreatAs( + {( "Washington")} + , Geography[State] + ) + ), + TreatAs( + {("United States"), ("Canada")} + , Geography[Country] + ) + ) + ,TreatAs({("Alberta")}, Geography[State]) + ,TreatAs({("Canada")}, Geography[Country]) +) +``` +In the above expression, there are two filters on the 'Geography' table: one with KeepFilters specified and one without. These filters overlap with external filters on different columns. Currently, this configuration is not allowed because internally, the two filters are clustered into one, and the system cannot determine the correct filter overriding behavior for the clustered filter overall in such cases. + +Please note that this restriction is temporary. We are actively developing solutions to remove this limitation in future updates. If you encounter this error, we advise adjusting the filters within SummarizeColumns by adding or removing KeepFilters as necessary to ensure consistent overriding behavior on each table. + +### ValueFilterBehavior ### + +ValueFilterBehavior is a model property that controls how value filter is applied to filter context. Please check out details in [Work with value filter behavior](/power-bi/transform-model/value-filter-behavior). + + +## Related content [SUMMARIZE](summarize-function-dax.md) diff --git a/query-languages/dax/sumx-function-dax.md b/query-languages/dax/sumx-function-dax.md index 0c063fbcc..59bcd0cca 100644 --- a/query-languages/dax/sumx-function-dax.md +++ b/query-languages/dax/sumx-function-dax.md @@ -1,58 +1,53 @@ --- description: "Learn more about: SUMX" -title: "SUMX function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/07/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SUMX function (DAX)" --- # SUMX -Returns the sum of an expression evaluated for each row in a table. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the sum of an expression evaluated for each row in a table. + +## Syntax + ```dax -SUMX(
, ) +SUMX(
, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|The table containing the rows for which the expression will be evaluated.| -|expression|The expression to be evaluated for each row of the table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|The table containing the rows for which the expression will be evaluated.| +|`expression`|The expression to be evaluated for each row of the table.| + ## Return value -A decimal number. - +A decimal number. + ## Remarks -- The SUMX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers you want to sum, or an expression that evaluates to a column. - -- Only the numbers in the column are counted. Blanks, logical values, and text are ignored. - -- For more complex examples of SUMX in formulas, see [ALL](all-function-dax.md) and [CALCULATETABLE](calculatetable-function-dax.md). +- The SUMX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers you want to sum, or an expression that evaluates to a column. + +- The SUMX is an [iterator function](dax-glossary.md#iterator-function). + +- Only the numbers in the column are counted. Blanks, logical values, and text are ignored. + +- For more complex examples of SUMX in formulas, see [ALL](all-function-dax.md) and [CALCULATETABLE](calculatetable-function-dax.md). - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following example first filters the table, InternetSales, on the expression, 'InternetSales[SalesTerritoryID] = 5`, and then returns the sum of all values in the Freight column. In other words, the expression returns the sum of freight charges for only the specified sales area. - +The following example first filters the table, InternetSales, on the expression, 'InternetSales[SalesTerritoryID] = 5`, and then returns the sum of all values in the Freight column. In other words, the expression returns the sum of freight charges for only the specified sales area. + ```dax -= SUMX(FILTER(InternetSales, InternetSales[SalesTerritoryID]=5),[Freight]) += SUMX(FILTER(InternetSales, InternetSales[SalesTerritoryID]=5),[Freight]) ``` -If you do not need to filter the column, use the SUM function. The SUM function is similar to the Excel function of the same name, except that it takes a column as a reference. - -## See also +If you do not need to filter the column, use the SUM function. The SUM function is similar to the Excel function of the same name, except that it takes a column as a reference. + +## Related content -[SUM](sum-function-dax.md) -[Statistical functions](statistical-functions-dax.md) +[SUM](sum-function-dax.md) +[Statistical functions](statistical-functions-dax.md) diff --git a/query-languages/dax/switch-function-dax.md b/query-languages/dax/switch-function-dax.md index 0c5897e8c..30dab5b5d 100644 --- a/query-languages/dax/switch-function-dax.md +++ b/query-languages/dax/switch-function-dax.md @@ -1,50 +1,95 @@ --- description: "Learn more about: SWITCH" -title: "SWITCH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "SWITCH function (DAX)" --- # SWITCH -Evaluates an expression against a list of values and returns one of multiple possible result expressions. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Evaluates an expression against a list of values and returns one of multiple possible result expressions. This function can be used to avoid having multiple nested [IF](if-function-dax.md) statements. + +## Syntax + ```dax -SWITCH(, , [, , ]…[, ]) +SWITCH(, , [, , ]…[, ]) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| expression | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | -| value | A constant value to be matched with the results of *expression*. | -|result |Any scalar expression to be evaluated if the results of *expression* match the corresponding *value*. | -|else |Any scalar expression to be evaluated if the result of *expression* doesn't match any of the *value* arguments. | +### Parameters + +|Term|Definition| +|--------|--------------| +|`expression` | Any DAX expression that returns a single scalar value where the expression is to be evaluated multiple times (for each row/context). | +|`value` | A constant value to be matched with the results of `expression`. | +|`result` |Any scalar expression to be evaluated if the results of `expression` match the corresponding `value`. | +|`else` |Any scalar expression to be evaluated if the result of `expression` doesn't match any of the `value` arguments. | ## Return value -A scalar value coming from one of the *result* expressions, if there was a match with *value*, or from the *else* expression, if there was no match with any *value*. - +If there’s a match with a `value`, a scalar value from the corresponding `result` is returned. If there isn’t a match with a `value`, a value from `else` is returned. If none of the `values` match and `else` isn’t specified, BLANK is returned. + ## Remarks -All result expressions and the else expression must be of the same data type. - -## Example +- The `expression` to be evaluated can be a constant value or an expression. A common use of this function is to set the first parameter to `TRUE`. See examples below. +- All `result` expressions and the `else` expression must be of the same data type. +- The order of conditions matters. As soon as one `value` matches, the corresponding `result` is returned, and other subsequent `values` aren’t evaluated. Make sure the most restrictive `values` to be evaluated are specified before less restrictive `values`. See examples below. + +## Examples + +A common use of SWITCH is to compare `expression` with constant `values`. The following example creates a calculated column of month names: + +```dax += SWITCH ( + [Month Number Of Year], + 1, "January", + 2, "February", + 3, "March", + 4, "April", + 5, "May", + 6, "June", + 7, "July", + 8, "August", + 9, "September", + 10, "October", + 11, "November", + 12, "December", + "Unknown month number" + ) +``` + +Another common use of SWITCH is to replace multiple nested IF statements. This is accomplished by setting expression to `TRUE`, as shown in the following example, which compares Reorder Point and Safety Stock Level on products to identify potential risks of running out of stock: -The following example creates a calculated column of month names. - ```dax -= SWITCH([Month], 1, "January", 2, "February", 3, "March", 4, "April" - , 5, "May", 6, "June", 7, "July", 8, "August" - , 9, "September", 10, "October", 11, "November", 12, "December" - , "Unknown month number" ) += SWITCH ( + TRUE, + [Reorder Point] > [Safety Stock Level], "Good: Safety stock level exceeded", + [Reorder Point] = [Safety Stock Level], "Minimal: Safety stock level met", + [Reorder Point] < [Safety Stock Level], "At risk: Safety stock level not met", + ISBLANK ( [Reorder Point] ), "Incomplete: Reorder point not set", + ISBLANK ( [Safety Stock Level] ), "Incomplete: Safety stock level not set", + "Unknown" + ) + +``` + +The order of `values` matters. In the following example, the second `result` is never returned because the first value is less restrictive than the second. The result in this example is always `A` or `C`, but never `B`. + +```dax += SWITCH ( + TRUE, + Product[Standard Cost] < 100, "A", + Product[Standard Cost] < 10, "B", + "C" + ) + +``` + +The following statement returns an error because the data types in the `result` arguments are different. Keep in mind that the data types in all `result` and `else` arguments must be the same. + +```dax += SWITCH ( + [Class], + "L", "Large", + "H", 0.1 + ) + ``` diff --git a/query-languages/dax/syd-function-dax.md b/query-languages/dax/syd-function-dax.md index 85e03f796..a9104d295 100644 --- a/query-languages/dax/syd-function-dax.md +++ b/query-languages/dax/syd-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: SYD" -title: "SYD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "SYD function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # SYD +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the sum-of-years' digits depreciation of an asset for a specified period. ## Syntax @@ -24,12 +18,12 @@ SYD(, , , ) ### Parameters -|Term|Definition| -|--------|--------------| -|cost|The initial cost of the asset.| -|salvage|The value at the end of the depreciation (sometimes called the salvage value of the asset).| -|life|The number of periods over which the asset is depreciated (sometimes called the useful life of the asset).| -|per|The period. Must use the same units as life. Must be between 1 and life (inclusive).| +|Term|Definition| +|--------|--------------| +|`cost`|The initial cost of the asset.| +|`salvage`|The value at the end of the depreciation (sometimes called the salvage value of the asset).| +|`life`|The number of periods over which the asset is depreciated (sometimes called the useful life of the asset).| +|`per`|The period. Must use the same units as life. Must be between 1 and life (inclusive).| ## Return Value diff --git a/query-languages/dax/t-dist-2t-dax.md b/query-languages/dax/t-dist-2t-dax.md deleted file mode 100644 index 1a8c77d7c..000000000 --- a/query-languages/dax/t-dist-2t-dax.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -description: "Learn more about: T.DIST.2T" -title: "T.DIST.2T function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# T.DIST.2T - -Returns the two-tailed Student's t-distribution. - -## Syntax - -```dax -T.DIST.2T(X,Deg_freedom) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|X|The numeric value at which to evaluate the distribution.| -|Deg_freedom |An integer indicating the number of degrees of freedom.| - -## Return value - -The two-tailed Student's t-distribution. - -## Remarks - -[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -```dax -EVALUATE { T.DIST.2T(1.959999998, 60) } -``` - -Returns - -|[Value] | -|---------| -|0.054644929975921 | - -## See also - -[T.DIST](t-dist-dax.md) -[T.DIST.RT](t-dist-rt-dax.md) -[T.INV](t-inv-dax.md) -[T.INV.2t](t-inv-2t-dax.md) - diff --git a/query-languages/dax/t-dist-2t-function-dax.md b/query-languages/dax/t-dist-2t-function-dax.md new file mode 100644 index 000000000..7c52d9c34 --- /dev/null +++ b/query-languages/dax/t-dist-2t-function-dax.md @@ -0,0 +1,50 @@ +--- +description: "Learn more about: T.DIST.2T" +title: "T.DIST.2T function (DAX)" +--- +# T.DIST.2T + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the two-tailed Student's t-distribution. + +## Syntax + +```dax +T.DIST.2T(X,Deg_freedom) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`X`|The numeric value at which to evaluate the distribution.| +|`Deg_freedom` |An integer indicating the number of degrees of freedom.| + +## Return value + +The two-tailed Student's t-distribution. + +## Remarks + +[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +```dax +EVALUATE { T.DIST.2T(1.959999998, 60) } +``` + +Returns + +|[Value] | +|---------| +|0.054644929975921 | + +## Related content + +[T.DIST](t-dist-function-dax.md) +[T.DIST.RT](t-dist-rt-function-dax.md) +[T.INV](t-inv-function-dax.md) +[T.INV.2t](t-inv-2t-function-dax.md) + diff --git a/query-languages/dax/t-dist-dax.md b/query-languages/dax/t-dist-dax.md deleted file mode 100644 index 8f6d27e9e..000000000 --- a/query-languages/dax/t-dist-dax.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -description: "Learn more about: T.DIST" -title: "T.DIST function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# T.DIST - -Returns the Student's left-tailed t-distribution. - -## Syntax - -```dax -T.DIST(X,Deg_freedom,Cumulative) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|X|The numeric value at which to evaluate the distribution.| -|Deg_freedom |An integer indicating the number of degrees of freedom.| -|Cumulative|A logical value that determines the form of the function. If cumulative is TRUE, T.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.| - -## Return value - -The Student's left-tailed t-distribution. - -## Remarks - -[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -```dax -EVALUATE { T.DIST(60, 1, TRUE) } -``` - -Returns, - -|[Value] | -|---------| -|0.994695326367377 | - -## See also - -[T.DIST.2T](t-dist-2t-dax.md) -[T.DIST.RT](t-dist-rt-dax.md) -[T.INV](t-inv-dax.md) -[T.INV.2t](t-inv-2t-dax.md) - diff --git a/query-languages/dax/t-dist-function-dax.md b/query-languages/dax/t-dist-function-dax.md new file mode 100644 index 000000000..4bd84fad2 --- /dev/null +++ b/query-languages/dax/t-dist-function-dax.md @@ -0,0 +1,51 @@ +--- +description: "Learn more about: T.DIST" +title: "T.DIST function (DAX)" +--- +# T.DIST + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the Student's left-tailed t-distribution. + +## Syntax + +```dax +T.DIST(X,Deg_freedom,Cumulative) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`X`|The numeric value at which to evaluate the distribution.| +|`Deg_freedom` |An integer indicating the number of degrees of freedom.| +|`Cumulative`|A logical value that determines the form of the function. If cumulative is `TRUE`, T.DIST returns the cumulative distribution function; if `FALSE`, it returns the probability density function.| + +## Return value + +The Student's left-tailed t-distribution. + +## Remarks + +[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +```dax +EVALUATE { T.DIST(60, 1, TRUE) } +``` + +Returns, + +|[Value] | +|---------| +|0.994695326367377 | + +## Related content + +[T.DIST.2T](t-dist-2t-function-dax.md) +[T.DIST.RT](t-dist-rt-function-dax.md) +[T.INV](t-inv-function-dax.md) +[T.INV.2t](t-inv-2t-function-dax.md) + diff --git a/query-languages/dax/t-dist-rt-dax.md b/query-languages/dax/t-dist-rt-dax.md deleted file mode 100644 index 217dd9bb5..000000000 --- a/query-languages/dax/t-dist-rt-dax.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -description: "Learn more about: T.DIST.RT" -title: "T.DIST.RT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# T.DIST.RT - -Returns the right-tailed Student's t-distribution. - -## Syntax - -```dax -T.DIST.RT(X,Deg_freedom) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|X|The numeric value at which to evaluate the distribution.| -|Deg_freedom |An integer indicating the number of degrees of freedom.| - -## Return value - -The right-tailed Student's t-distribution. - -## Remarks - -[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -```dax -EVALUATE { T.DIST.RT(1.959999998, 60) } -``` - -Returns - -|[Value] | -|---------| -|0.0273224649879605 | - -## See also - -[T.DIST](t-dist-dax.md) -[T.DIST.2T](t-dist-2t-dax.md) -[T.INV](t-inv-dax.md) -[T.INV.2t](t-inv-2t-dax.md) diff --git a/query-languages/dax/t-dist-rt-function-dax.md b/query-languages/dax/t-dist-rt-function-dax.md new file mode 100644 index 000000000..1ec325a21 --- /dev/null +++ b/query-languages/dax/t-dist-rt-function-dax.md @@ -0,0 +1,49 @@ +--- +description: "Learn more about: T.DIST.RT" +title: "T.DIST.RT function (DAX)" +--- +# T.DIST.RT + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the right-tailed Student's t-distribution. + +## Syntax + +```dax +T.DIST.RT(X,Deg_freedom) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`X`|The numeric value at which to evaluate the distribution.| +|`Deg_freedom` |An integer indicating the number of degrees of freedom.| + +## Return value + +The right-tailed Student's t-distribution. + +## Remarks + +[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +```dax +EVALUATE { T.DIST.RT(1.959999998, 60) } +``` + +Returns + +|[Value] | +|---------| +|0.0273224649879605 | + +## Related content + +[T.DIST](t-dist-function-dax.md) +[T.DIST.2T](t-dist-2t-function-dax.md) +[T.INV](t-inv-function-dax.md) +[T.INV.2t](t-inv-2t-function-dax.md) diff --git a/query-languages/dax/t-inv-2t-dax.md b/query-languages/dax/t-inv-2t-dax.md deleted file mode 100644 index a2a9fd5e4..000000000 --- a/query-languages/dax/t-inv-2t-dax.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -description: "Learn more about: T.INV.2T" -title: "T.INV.2T function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# T.INV.2T - -Returns the two-tailed inverse of the Student's t-distribution. - -## Syntax - -```dax -T.INV.2T(Probability,Deg_freedom) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Probability|The probability associated with the Student's t-distribution.| -|Deg_freedom|The number of degrees of freedom with which to characterize the distribution.| - -## Return value - -The two-tailed inverse of the Student's t-distribution. - -## Remarks - -[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -```dax -EVALUATE { T.INV.2T(0.546449, 60) } -``` - -Returns - -|[Value] | -|---------| -|0.606533075825759 | - -## See also - -[T.INV](t-inv-dax.md) -[T.DIST](t-dist-dax.md) -[T.DIST.2T](t-dist-2t-dax.md) -[T.DIST.RT](t-dist-rt-dax.md) diff --git a/query-languages/dax/t-inv-2t-function-dax.md b/query-languages/dax/t-inv-2t-function-dax.md new file mode 100644 index 000000000..56ef07956 --- /dev/null +++ b/query-languages/dax/t-inv-2t-function-dax.md @@ -0,0 +1,49 @@ +--- +description: "Learn more about: T.INV.2T" +title: "T.INV.2T function (DAX)" +--- +# T.INV.2T + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the two-tailed inverse of the Student's t-distribution. + +## Syntax + +```dax +T.INV.2T(Probability,Deg_freedom) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Probability`|The probability associated with the Student's t-distribution.| +|`Deg_freedom`|The number of degrees of freedom with which to characterize the distribution.| + +## Return value + +The two-tailed inverse of the Student's t-distribution. + +## Remarks + +[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +```dax +EVALUATE { T.INV.2T(0.546449, 60) } +``` + +Returns + +|[Value] | +|---------| +|0.606533075825759 | + +## Related content + +[T.INV](t-inv-function-dax.md) +[T.DIST](t-dist-function-dax.md) +[T.DIST.2T](t-dist-2t-function-dax.md) +[T.DIST.RT](t-dist-rt-function-dax.md) diff --git a/query-languages/dax/t-inv-dax.md b/query-languages/dax/t-inv-dax.md deleted file mode 100644 index 4cba343d6..000000000 --- a/query-languages/dax/t-inv-dax.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -description: "Learn more about: T.INV" -title: "T.INV function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - ---- -# T.INV - -Returns the left-tailed inverse of the Student's t-distribution. - -## Syntax - -```dax -T.INV(Probability,Deg_freedom) -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Probability|The probability associated with the Student's t-distribution.| -|Deg_freedom|The number of degrees of freedom with which to characterize the distribution.| - -## Return value - -The left-tailed inverse of the Student's t-distribution. - -## Remarks - -[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - -## Example - -```dax -EVALUATE { T.INV(0.75, 2) } -``` - -Returns - -|[Value] | -|---------| -|0.816496580927726 | - -## See also - -[T.INV.2T](t-inv-2t-dax.md) -[T.DIST](t-dist-dax.md) -[T.DIST.2T](t-dist-2t-dax.md) -[T.DIST.RT](t-dist-rt-dax.md) diff --git a/query-languages/dax/t-inv-function-dax.md b/query-languages/dax/t-inv-function-dax.md new file mode 100644 index 000000000..327107f02 --- /dev/null +++ b/query-languages/dax/t-inv-function-dax.md @@ -0,0 +1,49 @@ +--- +description: "Learn more about: T.INV" +title: "T.INV function (DAX)" +--- +# T.INV + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the left-tailed inverse of the Student's t-distribution. + +## Syntax + +```dax +T.INV(Probability,Deg_freedom) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Probability`|The probability associated with the Student's t-distribution.| +|`Deg_freedom`|The number of degrees of freedom with which to characterize the distribution.| + +## Return value + +The left-tailed inverse of the Student's t-distribution. + +## Remarks + +[!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Example + +```dax +EVALUATE { T.INV(0.75, 2) } +``` + +Returns + +|[Value] | +|---------| +|0.816496580927726 | + +## Related content + +[T.INV.2T](t-inv-2t-function-dax.md) +[T.DIST](t-dist-function-dax.md) +[T.DIST.2T](t-dist-2t-function-dax.md) +[T.DIST.RT](t-dist-rt-function-dax.md) diff --git a/query-languages/dax/table-constructor.md b/query-languages/dax/table-constructor.md index d19ddbb4d..bf1ea34f2 100644 --- a/query-languages/dax/table-constructor.md +++ b/query-languages/dax/table-constructor.md @@ -1,37 +1,28 @@ --- description: "Learn more about: Table constructor" -title: "Table constructor | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/23/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "Table constructor" --- # Table constructor Returns a table of one or more columns. - -## Syntax - + +## Syntax + ```dax { , , … } { ( , , … ), ( , , … ), … } ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|scalarExprN|Any DAX expression that returns a scalar value.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`scalarExprN`|Any DAX expression that returns a scalar value.| + ## Return value A table of one or more columns. When there is only one column, the name of the column is Value. When there are N columns where N > 1, the names of the columns from left to right are Value1, Value2, …, ValueN. - + ## Remarks - The first syntax returns a table of a single column. The second syntax returns a table of one or more columns. @@ -77,7 +68,7 @@ EVALUATE Returns, -[Value1] |[Value2] |[Value3] |[Value4] +[Value1] |[Value2] |[Value3] |[Value4] ---------|---------|---------|--------- 1.5 | 1/1/2017 | 199.99 | A 2.5 | 1/2/2017 | 249.99 | B @@ -97,5 +88,5 @@ Returns the following table of a single column of String data type: |---------| |1 | |1/1/2017 | -|TRUE | +|``TRUE`` | |A | diff --git a/query-languages/dax/table-manipulation-functions-dax.md b/query-languages/dax/table-manipulation-functions-dax.md index eec5fd8cb..75c7e4bf9 100644 --- a/query-languages/dax/table-manipulation-functions-dax.md +++ b/query-languages/dax/table-manipulation-functions-dax.md @@ -1,14 +1,6 @@ --- description: "Learn more about: Table manipulation functions" -title: "Table manipulation functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/26/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Table manipulation functions (DAX)" --- # Table manipulation functions @@ -22,15 +14,15 @@ These functions return a table or manipulate existing tables. |[ADDMISSINGITEMS](addmissingitems-function-dax.md) | Adds combinations of items from multiple columns to a table if they do not already exist. | |[CROSSJOIN](crossjoin-function-dax.md) | Returns a table that contains the Cartesian product of all rows from all tables in the arguments. | |[CURRENTGROUP](currentgroup-function-dax.md) | Returns a set of rows from the table argument of a GROUPBY expression. | -|[DATATABLE](datatable-function.md) | Provides a mechanism for declaring an inline set of data values. | +|[DATATABLE](datatable-function-dax.md) | Provides a mechanism for declaring an inline set of data values. | |[DETAILROWS](detailrows-function-dax.md) | Evaluates a Detail Rows Expression defined for a measure and returns the data. | |[DISTINCT column](distinct-function-dax.md) | Returns a one-column table that contains the distinct values from the specified column. | |[DISTINCT table](distinct-table-function-dax.md) | Returns a table by removing duplicate rows from another table or expression. | |[EXCEPT](except-function-dax.md) | Returns the rows of one table which do not appear in another table. | -|[FILTERS](filters-function-dax.md) | Returns a table of values directly applied as filters to *columnName*. | +|[FILTERS](filters-function-dax.md) | Returns a table of values directly applied as filters to `columnName`. | |[GENERATE](generate-function-dax.md) | Returns a table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1*. | |[GENERATEALL](generateall-function-dax.md) | Returns a table with the Cartesian product between each row in *table1* and the table that results from evaluating *table2* in the context of the current row from *table1*. | -|[GENERATESERIES](generateseries-function.md) | Returns a single column table containing the values of an arithmetic series. | +|[GENERATESERIES](generateseries-function-dax.md) | Returns a single column table containing the values of an arithmetic series. | |[GROUPBY](groupby-function-dax.md) | Similar to the SUMMARIZE function, GROUPBY does not do an implicit CALCULATE for any extension columns that it adds. | |[IGNORE](ignore-function-dax.md) | Modifies SUMMARIZECOLUMNS by omitting specific expressions from the BLANK/NULL evaluation. | |[INTERSECT](intersect-function-dax.md) | Returns the row intersection of two tables, retaining duplicates. | @@ -47,6 +39,6 @@ These functions return a table or manipulate existing tables. |[SUMMARIZECOLUMNS](summarizecolumns-function-dax.md) | Returns a summary table over a set of groups. | |[Table Constructor](table-Constructor.md) | Returns a table of one or more columns. | |[TOPN](topn-function-dax.md) | Returns the top N rows of the specified table. | -|[TREATAS](treatas-function.md) | Applies the result of a table expression as filters to columns from an unrelated table. | +|[TREATAS](treatas-function-dax.md) | Applies the result of a table expression as filters to columns from an unrelated table. | |[UNION](union-function-dax.md) | Creates a union (join) table from a pair of tables. | |[VALUES](values-function-dax.md) | Returns a one-column table that contains the distinct values from the specified table or column. | diff --git a/query-languages/dax/tan-function-dax.md b/query-languages/dax/tan-function-dax.md index fce7b7ed2..859b459cd 100644 --- a/query-languages/dax/tan-function-dax.md +++ b/query-languages/dax/tan-function-dax.md @@ -1,44 +1,37 @@ --- description: "Learn more about: TAN" -title: "TAN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TAN function (DAX)" --- # TAN -Returns the tangent of the given angle. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the tangent of the given angle. + +## Syntax + ```dax -TAN(number) +TAN(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Required. The angle in radians for which you want the tangent.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Required. The angle in radians for which you want the tangent.| + ## Return value -Returns the tangent of the given angle. - +Returns the tangent of the given angle. + ## Remarks -If your argument is in degrees, multiply it by PI()/180 or use the RADIANS function to convert it to radians. - -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= TAN(0.785)|Tangent of 0.785 radians (0.99920)|0.99920| -|= TAN(45*PI()/180)|Tangent of 45 degrees (1)|1| -|= TAN(RADIANS(45))|Tangent of 45 degrees (1)|1| +If your argument is in degrees, multiply it by PI()/180 or use the RADIANS function to convert it to radians. + +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= TAN(0.785)`|Tangent of 0.785 radians (0.99920)|0.99920| +|`= TAN(45*PI()/180)`|Tangent of 45 degrees (1)|1| +|`= TAN(RADIANS(45))`|Tangent of 45 degrees (1)|1| diff --git a/query-languages/dax/tanh-function-dax.md b/query-languages/dax/tanh-function-dax.md index 7c4f828cd..07c69cb30 100644 --- a/query-languages/dax/tanh-function-dax.md +++ b/query-languages/dax/tanh-function-dax.md @@ -1,48 +1,41 @@ --- description: "Learn more about: TANH" -title: "TANH function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TANH function (DAX)" --- # TANH -Returns the hyperbolic tangent of a number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the hyperbolic tangent of a number. + +## Syntax + ```dax -TANH(number) +TANH(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|Required. Any real number.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|Required. Any real number.| + ## Return value -Returns the hyperbolic tangent of a number. - +Returns the hyperbolic tangent of a number. + ## Remarks -- The formula for the hyperbolic tangent is: +- The formula for the hyperbolic tangent is: $$\text{TANH}(z) = \frac{\text{SINH}(z)}{\text{COSH}(z)}$$ - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] -## Example - -|Formula|Description|Result| -|-----------|---------------|----------| -|= TANH(-2)|Hyperbolic tangent of -2 (-0.96403)|-0.964028| -|= TANH(0)|Hyperbolic tangent of 0 (0)|0| -|= TANH(0.5)|Hyperbolic tangent of 0.5 (0.462117)|0.462117| +## Example + +|Formula|Description|Result| +|-----------|---------------|----------| +|`= TANH(-2)`|Hyperbolic tangent of -2 (-0.96403)|-0.964028| +|`= TANH(0)`|Hyperbolic tangent of 0 (0)|0| +|`= TANH(0.5)`|Hyperbolic tangent of 0.5 (0.462117)|0.462117| diff --git a/query-languages/dax/tbilleq-function-dax.md b/query-languages/dax/tbilleq-function-dax.md index b2edad967..261445649 100644 --- a/query-languages/dax/tbilleq-function-dax.md +++ b/query-languages/dax/tbilleq-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: TBILLEQ" -title: "TBILLEQ function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "TBILLEQ function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # TBILLEQ +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the bond-equivalent yield for a Treasury bill. ## Syntax @@ -24,11 +18,11 @@ TBILLEQ(, , ) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The Treasury bill's settlement date. The security settlement date is the date after the issue date when the Treasury bill is traded to the buyer.| -|maturity|The Treasury bill's maturity date. The maturity date is the date when the Treasury bill expires.| -|discount|The Treasury bill's discount rate.| +|Term|Definition| +|--------|--------------| +|`settlement`|The Treasury bill's settlement date. The security settlement date is the date after the issue date when the Treasury bill is traded to the buyer.| +|`maturity`|The Treasury bill's maturity date. The maturity date is the date when the Treasury bill expires.| +|`discount`|The Treasury bill's discount rate.| ## Return Value diff --git a/query-languages/dax/tbillprice-function-dax.md b/query-languages/dax/tbillprice-function-dax.md index b52ed03e0..bd6c40759 100644 --- a/query-languages/dax/tbillprice-function-dax.md +++ b/query-languages/dax/tbillprice-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: TBILLPRICE" -title: "TBILLPRICE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "TBILLPRICE function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # TBILLPRICE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the price per \\$100 face value for a Treasury bill. ## Syntax @@ -24,11 +18,11 @@ TBILLPRICE(, , ) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The Treasury bill's settlement date. The security settlement date is the date after the issue date when the Treasury bill is traded to the buyer.| -|maturity|The Treasury bill's maturity date. The maturity date is the date when the Treasury bill expires.| -|discount|The Treasury bill's discount rate.| +|Term|Definition| +|--------|--------------| +|`settlement`|The Treasury bill's settlement date. The security settlement date is the date after the issue date when the Treasury bill is traded to the buyer.| +|`maturity`|The Treasury bill's maturity date. The maturity date is the date when the Treasury bill expires.| +|`discount`|The Treasury bill's discount rate.| ## Return Value diff --git a/query-languages/dax/tbillyield-function-dax.md b/query-languages/dax/tbillyield-function-dax.md index be85d3af4..33db934f3 100644 --- a/query-languages/dax/tbillyield-function-dax.md +++ b/query-languages/dax/tbillyield-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: TBILLYIELD" -title: "TBILLYIELD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "TBILLYIELD function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # TBILLYIELD +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the yield for a Treasury bill. ## Syntax @@ -24,11 +18,11 @@ TBILLYIELD(, , ) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The Treasury bill's settlement date. The security settlement date is the date after the issue date when the Treasury bill is traded to the buyer.| -|maturity|The Treasury bill's maturity date. The maturity date is the date when the Treasury bill expires.| -|pr|The Treasury bill's price per \\$100 face value.| +|Term|Definition| +|--------|--------------| +|`settlement`|The Treasury bill's settlement date. The security settlement date is the date after the issue date when the Treasury bill is traded to the buyer.| +|`maturity`|The Treasury bill's maturity date. The maturity date is the date when the Treasury bill expires.| +|`pr`|The Treasury bill's price per \\$100 face value.| ## Return Value diff --git a/query-languages/dax/text-functions-dax.md b/query-languages/dax/text-functions-dax.md index 72c639626..27b5214cc 100644 --- a/query-languages/dax/text-functions-dax.md +++ b/query-languages/dax/text-functions-dax.md @@ -1,19 +1,11 @@ --- description: "Learn more about: Text functions" -title: "Text functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Text functions (DAX)" --- # Text functions -Data Analysis Expressions (DAX) includes a set of text functions based on the library of string functions in Excel, but which have been modified to work with tables and columns in tabular models. This section describes text functions available in the DAX language. - +Data Analysis Expressions (DAX) includes a set of text functions based on the library of string functions in Excel, but which have been modified to work with tables and columns in tabular models. This section describes text functions available in the DAX language. + ## In this category |Function |Description | @@ -21,7 +13,7 @@ Data Analysis Expressions (DAX) includes a set of text functions based on the li |[COMBINEVALUES](combinevalues-function-dax.md) | Joins two or more text strings into one text string. | |[CONCATENATE](concatenate-function-dax.md) | Joins two text strings into one text string. | |[CONCATENATEX](concatenatex-function-dax.md) | Concatenates the result of an expression evaluated for each row in a table. | -|[EXACT](exact-function-dax.md) | Compares two text strings and returns TRUE if they are exactly the same, FALSE otherwise. | +|[EXACT](exact-function-dax.md) | Compares two text strings and returns ``TRUE`` if they are exactly the same, `FALSE` otherwise. | |[FIND](find-function-dax.md) | Returns the starting position of one text string within another text string. | |[FIXED](fixed-function-dax.md) | Rounds a number to the specified number of decimals and returns the result as text. | |[FORMAT](format-function-dax.md) | Converts a value to text according to the specified format. | diff --git a/query-languages/dax/time-function-dax.md b/query-languages/dax/time-function-dax.md index 8a127e371..1571d1258 100644 --- a/query-languages/dax/time-function-dax.md +++ b/query-languages/dax/time-function-dax.md @@ -1,83 +1,76 @@ --- description: "Learn more about: TIME" -title: "TIME function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TIME function (DAX)" --- # TIME -Converts hours, minutes, and seconds given as numbers to a time in **datetime** format. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Converts hours, minutes, and seconds given as numbers to a time in `datetime` format. + +## Syntax + ```dax -TIME(hour, minute, second) +TIME(hour, minute, second) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|hour|**Import mode:** A number from 0 to 32767 representing the hour.
Any value greater than 23 will be divided by 24 and the remainder will be treated as the hour value, represented as a fraction of a day.
For example, TIME(27,0,0) = TIME(3,0,0) = 3:00:00 AM

**DirectQuery mode:** A number from 0 to 23 representing the hour.| -|minute|**Import mode:** A number from 0 to 32767 representing the minute.
Any value greater than 59 minutes will be converted to hours and minutes.
Any value greater than 1440 (24 hours) does not alter the date portion - instead, it will be divided by 1440 and the remainder will be treated as the minute value, represented as a fraction of a day.
For example, TIME(0,2190,0) = TIME(0,750,0) = TIME(12,30,0) = 12:30:00 PM

**DirectQuery mode:** A number from 0 to 59 representing the minute.| -|second|**Import mode:** A number from 0 to 32767 representing the second.
Any value greater than 59 will be converted to hours, minutes, and seconds.
For example, TIME(0,0,2000) = TIME(0,33,20) = 12:33:20 AM

**DirectQuery mode:** A number from 0 to 59 representing the second.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`hour`|**Import mode:** A number from 0 to 32767 representing the hour.
Any value greater than 23 will be divided by 24 and the remainder will be treated as the hour value, represented as a fraction of a day.
For example, TIME(27,0,0) = TIME(3,0,0) = 3:00:00 AM

**DirectQuery mode:** A number from 0 to 23 representing the hour.| +|`minute`|**Import mode:** A number from 0 to 32767 representing the minute.
Any value greater than 59 minutes will be converted to hours and minutes.
Any value greater than 1440 (24 hours) does not alter the date portion - instead, it will be divided by 1440 and the remainder will be treated as the minute value, represented as a fraction of a day.
For example, TIME(0,2190,0) = TIME(0,750,0) = TIME(12,30,0) = 12:30:00 PM

**DirectQuery mode:** A number from 0 to 59 representing the minute.| +|`second`|**Import mode:** A number from 0 to 32767 representing the second.
Any value greater than 59 will be converted to hours, minutes, and seconds.
For example, TIME(0,0,2000) = TIME(0,33,20) = 12:33:20 AM

**DirectQuery mode:** A number from 0 to 59 representing the second.| + ## Return value -A time (**datetime**) ranging from 00:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 PM). - +A time (`datetime`) ranging from 00:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 PM). + ## Remarks -- In contrast to Microsoft Excel, which stores dates and times as serial numbers, DAX works with date and time values in a **datetime** format. Numbers in other formats are implicitly converted when you use a date/time value in a DAX function. If you need to use serial numbers, you can use formatting to change the way that the numbers are displayed. - -- Time values are a portion of a date value, and in the serial number system are represented by a decimal number. Therefore, the **datetime** value 12:00 PM is equivalent to 0.5, because it is half of a day. - +- In contrast to Microsoft Excel, which stores dates and times as serial numbers, DAX works with date and time values in a `datetime` format. Numbers in other formats are implicitly converted when you use a date/time value in a DAX function. If you need to use serial numbers, you can use formatting to change the way that the numbers are displayed. + +- Time values are a portion of a date value, and in the serial number system are represented by a decimal number. Therefore, the `datetime` value 12:00 PM is equivalent to 0.5, because it is half of a day. + - You can supply the arguments to the TIME function as values that you type directly, as the result of another expression, or by a reference to a column that contains a numeric value. - Date and datetime can also be specified as a literal in the format `dt"YYYY-MM-DD"`, `dt"YYYY-MM-DDThh:mm:ss"`, or `dt"YYYY-MM-DD hh:mm:ss"`. When specified as a literal, using the TIME function in the expression is not necessary. To learn more, see [DAX Syntax | Date and time](dax-syntax-reference.md#date-and-time). - + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example 1 -The following examples both return the time, 3:00 AM: - +The following examples both return the time, 3:00 AM: + ```dax = TIME(27,0,0) ``` ```dax -= TIME(3,0,0) += TIME(3,0,0) ``` - + ## Example 2 -The following examples both return the time, 12:30 PM: - +The following examples both return the time, 12:30 PM: + ```dax = TIME(0,750,0) ``` ```dax -= TIME(12,30,0) += TIME(12,30,0) ``` - + ## Example 3 -The following example creates a time based on the values in the columns, `intHours`, `intMinutes`, `intSeconds`: - +The following example creates a time based on the values in the columns, `intHours`, `intMinutes`, `intSeconds`: + ```dax -= TIME([intHours],[intMinutes],[intSeconds]) += TIME([intHours],[intMinutes],[intSeconds]) ``` - -## See also -[DATE](date-function-dax.md) -[Date and time functions](date-and-time-functions-dax.md) +## Related content + +[DATE](date-function-dax.md) +[Date and time functions](date-and-time-functions-dax.md) diff --git a/query-languages/dax/time-intelligence-functions-dax.md b/query-languages/dax/time-intelligence-functions-dax.md index 3a3eb7100..e1114458b 100644 --- a/query-languages/dax/time-intelligence-functions-dax.md +++ b/query-languages/dax/time-intelligence-functions-dax.md @@ -1,19 +1,11 @@ --- description: "Learn more about: Time intelligence functions" -title: "Time intelligence functions (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/06/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "Time intelligence functions (DAX)" --- # Time intelligence functions -Data Analysis Expressions (DAX) includes time-intelligence functions that enable you to manipulate data using time periods, including days, months, quarters, and years, and then build and compare calculations over those periods. - +Data Analysis Expressions (DAX) includes time-intelligence functions that enable you to manipulate data using time periods, including days, months, quarters, and years, and then build and compare calculations over those periods. Before using any time-intelligence functions, make sure to mark one of the tables containing date column as Date Table. + ## In this category |Function |Description | @@ -31,9 +23,7 @@ Data Analysis Expressions (DAX) includes time-intelligence functions that enable |[ENDOFQUARTER](endofquarter-function-dax.md) | Returns the last date of the quarter in the current context for the specified column of dates. | |[ENDOFYEAR](endofyear-function-dax.md) | Returns the last date of the year in the current context for the specified column of dates. | |[FIRSTDATE](firstdate-function-dax.md) | Returns the first date in the current context for the specified column of dates. | -|[FIRSTNONBLANK](firstnonblank-function-dax.md) | Returns the first value in the column, column, filtered by the current context, where the expression is not blank | |[LASTDATE](lastdate-function-dax.md) | Returns the last date in the current context for the specified column of dates. | -|[LASTNONBLANK](lastnonblank-function-dax.md) | Returns the last value in the column, column, filtered by the current context, where the expression is not blank. | |[NEXTDAY](nextday-function-dax.md) | Returns a table that contains a column of all dates from the next day, based on the first date specified in the dates column in the current context. | |[NEXTMONTH](nextmonth-function-dax.md) | Returns a table that contains a column of all dates from the next month, based on the first date in the dates column in the current context. | |[NEXTQUARTER](nextquarter-function-dax.md) | Returns a table that contains a column of all dates in the next quarter, based on the first date specified in the dates column, in the current context. | diff --git a/query-languages/dax/timevalue-function-dax.md b/query-languages/dax/timevalue-function-dax.md index d31bee921..9972a25f9 100644 --- a/query-languages/dax/timevalue-function-dax.md +++ b/query-languages/dax/timevalue-function-dax.md @@ -1,50 +1,43 @@ --- description: "Learn more about: TIMEVALUE" -title: "TIMEVALUE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TIMEVALUE function (DAX)" --- # TIMEVALUE -Converts a time in text format to a time in datetime format. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Converts a time in text format to a time in datetime format. + +## Syntax + ```dax -TIMEVALUE(time_text) +TIMEVALUE(time_text) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|time_text|A text string that that represents a certain time of the day. Any date information included in the **time_text** argument is ignored.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`time_text`|A text string that that represents a certain time of the day. Any date information included in the `time_text` argument is ignored.| + ## Return value -A date (**datetime**). - +A date (`datetime`). + ## Remarks -- Time values are a portion of a date value and represented by a decimal number. For example, 12:00 PM is represented as 0.5 because it is half of a day. - -- When the **time_text** argument is a text representation of the date and time, the function uses the locale and date/time settings of the model to understand the text value in order to perform the conversion. Most locales use the colon (:) as the time separator, and any input text using colons as time separators will parse correctly. Review your locale settings to understand your results. +- Time values are a portion of a date value and represented by a decimal number. For example, 12:00 PM is represented as 0.5 because it is half of a day. + +- When the `time_text` argument is a text representation of the date and time, the function uses the locale and date/time settings of the model to understand the text value in order to perform the conversion. Most locales use the colon (:) as the time separator, and any input text using colons as time separators will parse correctly. Review your locale settings to understand your results. - Date and datetime can also be specified as a literal in the format `dt"YYYY-MM-DD"`, `dt"YYYY-MM-DDThh:mm:ss"`, or `dt"YYYY-MM-DD hh:mm:ss"`. When specified as a literal, using the TIMEVALUE function in the expression is not necessary. To learn more, see [DAX Syntax | Date and time](dax-syntax-reference.md#date-and-time). - -## Example - + +## Example + ```dax -= TIMEVALUE("20:45:30") += TIMEVALUE("20:45:30") ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) diff --git a/query-languages/dax/toc.yml b/query-languages/dax/toc.yml index 84fbc07ac..71c40cacc 100644 --- a/query-languages/dax/toc.yml +++ b/query-languages/dax/toc.yml @@ -1,3 +1,4 @@ +items: - name: Data Analysis Expressions (DAX) Reference href: index.yml expanded: true @@ -9,11 +10,15 @@ - name: Videos href: dax-learn-videos.md - name: Use DAX in Power BI Desktop Learn path - href: http://aka.ms/learndax + href: https://aka.ms/learndax + - name: Write DAX queries with Copilot + href: dax-copilot.md - name: "Sample model" href: dax-sample-model.md - name: Best practices items: + - name: "Understanding ORDERBY, PARTITIONBY, and MATCHBY functions" + href: best-practices/dax-understand-orderby.md - name: "Appropriate use of error functions" href: best-practices/dax-error-functions.md - name: "Avoid converting BLANKs to values" @@ -112,7 +117,7 @@ - name: MONTH href: month-function-dax.md - name: NETWORKDAYS - href: networkdays-dax.md + href: networkdays-function-dax.md - name: NOW href: now-function-dax.md - name: QUARTER @@ -161,14 +166,48 @@ href: earliest-function-dax.md - name: FILTER href: filter-function-dax.md + - name: FIRSTNONBLANK + href: firstnonblank-function-dax.md + - name: FIRSTNONBLANKVALUE + href: firstnonblankvalue-function-dax.md + - name: INDEX + href: index-function-dax.md - name: KEEPFILTERS href: keepfilters-function-dax.md + - name: LASTNONBLANK + href: lastnonblank-function-dax.md + - name: LASTNONBLANKVALUE + href: lastnonblankvalue-function-dax.md + - name: LOOKUP + href: lookup-function-dax.md - name: LOOKUPVALUE href: lookupvalue-function-dax.md + - name: LOOKUPWITHTOTALS + href: lookupwithtotals-function-dax.md + - name: MATCHBY + href: matchby-function-dax.md + - name: MOVINGAVERAGE + href: movingaverage-function-dax.md + - name: OFFSET + href: offset-function-dax.md + - name: ORDERBY + href: orderby-function-dax.md + - name: PARTITIONBY + href: partitionby-function-dax.md + - name: RANGE + href: range-function-dax.md + - name: RANK + href: rank-function-dax.md - name: REMOVEFILTERS href: removefilters-function-dax.md + - name: ROWNUMBER + href: rownumber-function-dax.md + - name: RUNNINGSUM + href: runningsum-function-dax.md - name: SELECTEDVALUE - href: selectedvalue-function.md + href: selectedvalue-function-dax.md + - name: WINDOW + href: window-function-dax.md - name: Financial functions items: - name: Financial functions overview @@ -275,10 +314,28 @@ href: yielddisc-function-dax.md - name: YIELDMAT href: yieldmat-function-dax.md + - name: INFO functions + items: + - name: INFO functions overview + href: info-functions-dax.md + - name: INFO.VIEW.COLUMNS + href: info-view-columns-function-dax.md + - name: INFO.VIEW.MEASURES + href: info-view-measures-function-dax.md + - name: INFO.VIEW.RELATIONSHIPS + href: info-view-relationships-function-dax.md + - name: INFO.VIEW.TABLES + href: info-view-tables-function-dax.md + - name: INFO.ANNOTATIONS + href: info-annotations-function-dax.md + - name: INFO.CALCDEPENDENCY + href: info-calcdependency-function-dax.md - name: Information functions items: - name: Information functions overview href: information-functions-dax.md + - name: COLUMNSTATISTICS + href: columnstatistics-function-dax.md - name: CONTAINS href: contains-function-dax.md - name: CONTAINSROW @@ -333,6 +390,8 @@ href: selectedmeasureformatstring-function-dax.md - name: SELECTEDMEASURENAME href: selectedmeasurename-function-dax.md + - name: USERCULTURE + href: userculture-function-dax.md - name: USERNAME href: username-function-dax.md - name: USEROBJECTID @@ -482,7 +541,13 @@ - name: BLANK href: blank-function-dax.md - name: ERROR - href: error-function.md + href: error-function-dax.md + - name: EVALUATEANDLOG + href: evaluateandlog-function-dax.md + - name: TOCSV + href: tocsv-function-dax.md + - name: TOJSON + href: tojson-function-dax.md - name: Parent and child functions items: - name: Parent and child functions overview @@ -504,7 +569,7 @@ - name: Relationship functions href: relationship-functions-dax.md - name: CROSSFILTER - href: crossfilter-function.md + href: crossfilter-function-dax.md - name: RELATED href: related-function-dax.md - name: RELATEDTABLE @@ -541,18 +606,22 @@ href: geomean-function-dax.md - name: GEOMEANX href: geomeanx-function-dax.md + - name: LINEST + href: linest-function-dax.md + - name: LINESTX + href: linestx-function-dax.md - name: MEDIAN href: median-function-dax.md - name: MEDIANX href: medianx-function-dax.md - name: NORM.DIST - href: norm-dist-dax.md + href: norm-dist-function-dax.md - name: NORM.INV - href: norm-inv-dax.md + href: norm-inv-function-dax.md - name: NORM.S.DIST - href: norm-s-dist-dax.md + href: norm-s-dist-function-dax.md - name: NORM.S.INV - href: norm-s-inv-dax.md + href: norm-s-inv-function-dax.md - name: PERCENTILE.EXC href: percentile-exc-function-dax.md - name: PERCENTILE.INC @@ -571,6 +640,8 @@ href: rankx-function-dax.md - name: SAMPLE href: sample-function-dax.md + - name: SAMPLECARTESIANPOINTSBYCOVER + href: samplecartesianpointsbycover-function-dax.md - name: STDEV.S href: stdev-s-function-dax.md - name: STDEV.P @@ -580,15 +651,15 @@ - name: STDEVX.P href: stdevx-p-function-dax.md - name: T.DIST - href: t-dist-dax.md + href: t-dist-function-dax.md - name: T.DIST.2T - href: t-dist-2t-dax.md + href: t-dist-2t-function-dax.md - name: T.DIST.RT - href: t-dist-rt-dax.md + href: t-dist-rt-function-dax.md - name: T.INV - href: t-inv-dax.md + href: t-inv-function-dax.md - name: T.INV.2T - href: t-inv-2t-dax.md + href: t-inv-2t-function-dax.md - name: VAR.S href: var-s-function-dax.md - name: VAR.P @@ -610,7 +681,7 @@ - name: CURRENTGROUP href: currentgroup-function-dax.md - name: DATATABLE - href: datatable-function.md + href: datatable-function-dax.md - name: DETAILROWS href: detailrows-function-dax.md - name: DISTINCT (column) @@ -626,7 +697,7 @@ - name: GENERATEALL href: generateall-function-dax.md - name: GENERATESERIES - href: generateseries-function.md + href: generateseries-function-dax.md - name: GROUPBY href: groupby-function-dax.md - name: IGNORE @@ -639,11 +710,11 @@ href: naturalleftouterjoin-function-dax.md - name: ROLLUP href: rollup-function-dax.md - - name: ROLLUPADDISUBTOTAL + - name: ROLLUPADDISSUBTOTAL href: rollupaddissubtotal-function-dax.md - name: ROLLUPGROUP href: rollupgroup-function-dax.md - - name: ROLLUPISUBTOTAL + - name: ROLLUPISSUBTOTAL href: rollupissubtotal-function-dax.md - name: ROW href: row-function-dax.md @@ -660,7 +731,7 @@ - name: TOPN href: topn-function-dax.md - name: TREATAS - href: treatas-function.md + href: treatas-function-dax.md - name: UNION href: union-function-dax.md - name: VALUES @@ -741,16 +812,8 @@ href: endofyear-function-dax.md - name: FIRSTDATE href: firstdate-function-dax.md - - name: FIRSTNONBLANK - href: firstnonblank-function-dax.md - - name: FIRSTNONBLANKVALUE - href: firstnonblankvalue-function-dax.md - name: LASTDATE href: lastdate-function-dax.md - - name: LASTNONBLANK - href: lastnonblank-function-dax.md - - name: LASTNONBLANKVALUE - href: lastnonblankvalue-function-dax.md - name: NEXTDAY href: nextday-function-dax.md - name: NEXTMONTH @@ -797,8 +860,12 @@ href: define-statement-dax.md - name: EVALUATE href: evaluate-statement-dax.md + - name: MEASURE + href: measure-statement-dax.md - name: ORDER BY href: orderby-statement-dax.md + - name: START AT + href: startat-statement-dax.md - name: VAR href: var-dax.md - name: DAX glossary diff --git a/query-languages/dax/tocsv-function-dax.md b/query-languages/dax/tocsv-function-dax.md new file mode 100644 index 000000000..88e08fb67 --- /dev/null +++ b/query-languages/dax/tocsv-function-dax.md @@ -0,0 +1,59 @@ +--- +description: "Learn more about: TOCSV" +title: "TOCSV function (DAX)" +--- +# TOCSV + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table as a string in CSV format. + +## Syntax + +```dax +TOCSV(
, [MaxRows], [Delimiter], [IncludeHeaders]) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Table`|The table to be converted to CSV.| +|`MaxRows`| (Optional) The maximum number fo rows to convert. Default is 10 rows.| +|`Delimiter`|(Optional) A column delimiter. Default is comma ",".| +|`IncludeHeaders`|(Optional) Specifies a header with column name as the first row. Default is True.| + +## Return value + +A string with CSV representation of the table. + +## Example + +The following DAX query: + +```dax +EVALUATE +{TOCSV(DimSalesTerritory)} + +``` + +Returns: + +``` +'DimSalesTerritory'[SalesTerritoryKey],'DimSalesTerritory'[SalesTerritoryAlternateKey],'DimSalesTerritory'[SalesTerritoryRegion],'DimSalesTerritory'[SalesTerritoryCountry],'DimSalesTerritory'[SalesTerritoryGroup] +1,1,Northwest,United States,North America +2,2,Northeast,United States,North America +3,3,Central,United States,North America +4,4,Southwest,United States,North America +5,5,Southeast,United States,North America +6,6,Canada,Canada,North America +7,7,France,France,Europe +8,8,Germany,Germany,Europe +9,9,Australia,Australia,Pacific +10,10,United Kingdom,United Kingdom,Europe +``` + +## Related content + +[TOJSON](tojson-function-dax.md) +[EVALUATEANDLOG](evaluateandlog-function-dax.md) diff --git a/query-languages/dax/today-function-dax.md b/query-languages/dax/today-function-dax.md index ae7dcc021..04a402474 100644 --- a/query-languages/dax/today-function-dax.md +++ b/query-languages/dax/today-function-dax.md @@ -1,49 +1,42 @@ --- description: "Learn more about: TODAY" -title: "TODAY function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TODAY function (DAX)" --- # TODAY -Returns the current date. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the current date. + +## Syntax + ```dax -TODAY() +TODAY() ``` ## Return value -A date (**datetime**). - +A date (`datetime`). + ## Remarks -- The TODAY function is useful when you need to have the current date displayed on a worksheet, regardless of when you open the workbook. It is also useful for calculating intervals. - -- If the TODAY function does not update the date when you expect it to, you might need to change the settings that control when the column or workbook is refreshed.. - -- The NOW function is similar but returns the exact time, whereas TODAY returns the time value 12:00:00 PM for all dates. - +- The TODAY function is useful when you need to have the current date displayed on a worksheet, regardless of when you open the workbook. It is also useful for calculating intervals. + +- If the TODAY function does not update the date when you expect it to, you might need to change the settings that control when the column or workbook is refreshed.. + +- The NOW function is similar but returns the exact time, whereas TODAY returns the time value 12:00:00 PM for all dates. + ## Example -If you know that someone was born in 1963, you might use the following formula to find that person's age as of this year's birthday: - +If you know that someone was born in 1963, you might use the following formula to find that person's age as of this year's birthday: + ```dax -= YEAR(TODAY())-1963 += YEAR(TODAY())-1963 ``` -This formula uses the TODAY function as an argument for the YEAR function to obtain the current year, and then subtracts 1963, returning the person's age. - -## See also +This formula uses the TODAY function as an argument for the YEAR function to obtain the current year, and then subtracts 1963, returning the person's age. + +## Related content -[Date and time functions](date-and-time-functions-dax.md) -[NOW](now-function-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[NOW](now-function-dax.md) diff --git a/query-languages/dax/tojson-function-dax.md b/query-languages/dax/tojson-function-dax.md new file mode 100644 index 000000000..ff54b4826 --- /dev/null +++ b/query-languages/dax/tojson-function-dax.md @@ -0,0 +1,61 @@ +--- +description: "Learn more about: TOJSON" +title: "TOJSON function (DAX)" +--- +# TOJSON + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a table as a string using JSON format. + +## Syntax + +```dax +TOJSON(
, [MaxRows]) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Table`|The table to be converted to JSON.| +|`MaxRows`|(Optional) The maximum number fo rows to convert. Default is 10 rows.| + +## Return value + +A string with JSON representation of the table. The representation contains column names as "header", count-of-rows as "rowCount", and values as "data". + +## Example + +The following DAX query: + +```dax +EVALUATE +{TOJSON(DimSalesTerritory)} +``` + +Returns: + +```json +{ +"header": ["'DimSalesTerritory'[SalesTerritoryKey]", "'DimSalesTerritory'[SalesTerritoryAlternateKey]", "'DimSalesTerritory'[SalesTerritoryRegion]", "'DimSalesTerritory'[SalesTerritoryCountry]", "'DimSalesTerritory'[SalesTerritoryGroup]"],
+"rowCount": 11, +"data": [ +[1, 1, "Northwest", "United States", "North America"], +[2, 2, "Northeast", "United States", "North America"], +[3, 3, "Central", "United States", "North America"], +[4, 4, "Southwest", "United States", "North America"], +[5, 5, "Southeast", "United States", "North America"], +[6, 6, "Canada", "Canada", "North America"], +[7, 7, "France", "France", "Europe"], +[8, 8, "Germany", "Germany", "Europe"], +[9, 9, "Australia", "Australia", "Pacific"], +[10, 10, "United Kingdom", "United Kingdom", "Europe"] +] +} +``` + +## Related content + +[TOCSV](tocsv-function-dax.md) +[EVALUATEANDLOG](evaluateandlog-function-dax.md) diff --git a/query-languages/dax/topn-function-dax.md b/query-languages/dax/topn-function-dax.md index 87945261a..4b0ffcda8 100644 --- a/query-languages/dax/topn-function-dax.md +++ b/query-languages/dax/topn-function-dax.md @@ -1,61 +1,58 @@ --- description: "Learn more about: TOPN" -title: "TOPN function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/08/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TOPN function (DAX)" --- # TOPN -Returns the top N rows of the specified table. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the top N rows of the specified table. + +## Syntax + ```dax -TOPN(,
, , [[, , []]…]) +TOPN(,
, , [[, , []]…]) ``` - + ### Parameters -|Parameter|Definition| -|-------------|--------------| -|N_Value|The number of rows to return. Any DAX expression that returns a scalar value, where the expression is to be evaluated multiple times (for each row/context). See Remarks to better understand when the number of rows returned could be larger than *n_value*. | -|Table|Any DAX expression that returns a table of data from where to extract the top 'n' rows. See Remarks to better understand when an empty table is returned. | -|OrderBy_Expression|Any DAX expression where the result value is used to sort the table and evaluated for each row of *table*. | -|Order|(Optional) A value that specifies how to sort *OrderBy_Expression* values:

- **0** (zero) or **FALSE**. Sorts in descending order of values of *Order*. Default when *Order* parameter is omitted.

- **1** or **TRUE**. Ranks in ascending order of *OrderBy*.| - +|Parameter|Definition| +|-------------|--------------| +|`N_Value`|The number of rows to return. Any DAX expression that returns a scalar value, where the expression is to be evaluated multiple times (for each row/context). See Remarks to better understand when the number of rows returned could be larger than `n_value`. | +|`Table`|Any DAX expression that returns a table of data from where to extract the top 'n' rows. See Remarks to better understand when an empty table is returned. | +|`OrderBy_Expression`|(Optional) Any DAX expression where the result value is used to sort the table and evaluated for each row of `table`. | +|`Order`|(Optional) A value that specifies how to sort `OrderBy_Expression` values:

- `0` (zero) or `FALSE`. Sorts in descending order of values of `Order`. Default when `Order` parameter is omitted.

- `1` or `TRUE`. Ranks in ascending order of `OrderBy`.| + ## Return value -A table with the top N rows of *Table* or an empty table if *N_Value* is 0 (zero) or less. Rows are not sorted in any particular order. - -## Remarks - -- If there is a tie, in *Order_By* values, at the N-th row of the table, then all tied rows are returned. Then, when there are ties at the N-th row the function might return more than n rows. - -- If N_Value is 0 (zero) or less, TOPN returns an empty table. - -- TOPN does not guarantee any sort order for the results. +A table with the top N rows of `Table` or an empty table if `N_Value` is 0 (zero) or less. Rows are not sorted in any particular order. + +## Remarks + +- If there is a tie, in `Order_By` values, at the N-th row of the table, then all tied rows are returned. Then, when there are ties at the N-th row the function might return more than n rows. + +- If N_Value is 0 (zero) or less, TOPN returns an empty table. + +- TOPN does not guarantee any sort order for the results. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following measure formula returns the top 10 sold products by sales amount. - +The following measure formula returns the top 10 sold products by sales amount. + ```dax = SUMX( - TOPN(10, - SUMMARIZE(Product, [ProductKey], "TotalSales", - SUMX(RELATED(InternetSales_USD[SalesAmount_USD]), - InternetSales_USD[SalesAmount_USD]) + SUMX(RELATED(ResellerSales_USD[SalesAmount_USD]), - ResellerSales_USD[SalesAmount_USD]) - ) - ) - ) + TOPN( + 10, + SUMMARIZE( + InternetSales, + InternetSales[ProductKey], + "TotalSales", SUM(InternetSales[SalesAmount]) + ), + [TotalSales], DESC + ), + [TotalSales] +) + ``` diff --git a/query-languages/dax/topnskip-function-dax.md b/query-languages/dax/topnskip-function-dax.md new file mode 100644 index 000000000..9ef660dd2 --- /dev/null +++ b/query-languages/dax/topnskip-function-dax.md @@ -0,0 +1,70 @@ +--- +description: "Learn more about: TOPNSKIP" +title: "TOPNSKIP function (DAX) | Microsoft Docs" +--- +# TOPNSKIP + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the top N rows of the specified table, skipping a number of rows. + +## Syntax + +```dax +TOPNSKIP(, ,
, , [[, , []]…]) +``` + +### Parameters + +|Parameter|Definition| +|-------------|--------------| +|N_Value|The number of rows to return. Any DAX expression that returns a scalar value, where the expression is to be evaluated multiple times (for each row/context). See Remarks to better understand when the number of rows returned could be larger than *n_value*. | +|Skip_Rows_Value|The numner of rows to skip. Any DAX expression that returns a scalar value, where the expression is to be evaluated multiple times (for each row/context)| +|Table|Any DAX expression that returns a table of data from where to extract the top 'n' rows. See Remarks to better understand when an empty table is returned. | +|OrderBy_Expression|(Optional) Any DAX expression where the result value is used to sort the table and evaluated for each row of *table*. | +|Order|(Optional) A value that specifies how to sort *OrderBy_Expression* values:

- **0** (zero) or **FALSE**. Sorts in descending order of values of *Order*. Default when *Order* parameter is omitted.

- **1** or **TRUE**. Ranks in ascending order of *OrderBy*.| + +## Return value + +A table with the top N rows of *Table* or an empty table if *N_Value* is 0 (zero) or less. Rows are not sorted in any particular order. + +## Remarks + +- If there is a tie, in *Order_By* values, at the N-th row of the table, then all tied rows are returned. Then, when there are ties at the N-th row the function might return more than n rows. + +- If N_Value is 0 (zero) or less, TOPNSKIP returns an empty table. + +- The Table parameter can only be DAX expressions that can be fully pushed down to the Vertipaq Engine. + +- TOPNSKIP does not guarantee any sort order for the results. + +- This function is not supported for use in DirectQuery mode, except to semantic models. + +- The parameters for TOPNSKIP cannot depend on columns from an external evaluation context, for example referring to outside columns is not allowed. The following example will return an error: + +```dax +DEFINE +VAR NValues = SELECTCOLUMNS({10, 15, 20}, "N", [Value]) +EVALUATE GENERATE(NValues, TOPNSKIP([N], 5, DimProduct, [Size])) +``` + +## Example + +The following measure formula returns the top 10 sold products by sales amount, skipping one row. + +```dax += SUMX( + TOPNSKIP( + 10, + 1, + SUMMARIZE( + InternetSales, + InternetSales[ProductKey], + "TotalSales", SUM(InternetSales[SalesAmount]) + ), + [TotalSales], DESC + ), + [TotalSales] +) + +``` diff --git a/query-languages/dax/totalmtd-function-dax.md b/query-languages/dax/totalmtd-function-dax.md index 3077ec9e0..1eb0531dd 100644 --- a/query-languages/dax/totalmtd-function-dax.md +++ b/query-languages/dax/totalmtd-function-dax.md @@ -1,62 +1,55 @@ --- description: "Learn more about: TOTALMTD" -title: "TOTALMTD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TOTALMTD function (DAX)" --- # TOTALMTD -Evaluates the value of the **expression** for the month to date, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Evaluates the value of the `expression` for the month to date, in the current context. + +## Syntax + ```dax -TOTALMTD(,[,]) +TOTALMTD(,[,]) ``` - -### Parameters - -|Parameter|Definition| -|-------------|--------------| -|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.| - + +### Parameters + +|Parameter|Definition| +|-------------|--------------| +|`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 for the dates in the current month-to-date, given the dates in **dates**. - +A scalar value that represents the `expression` evaluated for the dates in the current month-to-date, given the dates in `dates`. + ## 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. +- 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](calculate-function-dax.md). + +- The `filter` expression has restrictions described in the topic, [CALCULATE](calculate-function-dax.md). -- Constraints on Boolean expressions are described in the topic, [CALCULATE](calculate-function-dax.md). - -- The **filter** expression has restrictions described in the topic, [CALCULATE](calculate-function-dax.md). - - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example The following sample formula creates a measure that calculates the 'month running total' or 'month running sum' for Internet sales. ```dax -= TOTALMTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey]) += TOTALMTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey]) ``` - -## See also -[ALL](all-function-dax.md) -[CALCULATE](calculate-function-dax.md) -[TOTALYTD](totalytd-function-dax.md) -[TOTALQTD](totalqtd-function-dax.md) +## Related content + +[ALL](all-function-dax.md) +[CALCULATE](calculate-function-dax.md) +[TOTALYTD](totalytd-function-dax.md) +[TOTALQTD](totalqtd-function-dax.md) diff --git a/query-languages/dax/totalqtd-function-dax.md b/query-languages/dax/totalqtd-function-dax.md index 6e0ccb1fe..345be3208 100644 --- a/query-languages/dax/totalqtd-function-dax.md +++ b/query-languages/dax/totalqtd-function-dax.md @@ -1,62 +1,55 @@ --- description: "Learn more about: TOTALQTD" -title: "TOTALQTD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TOTALQTD function (DAX)" --- # TOTALQTD -Evaluates the value of the **expression** for the dates in the quarter to date, in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Evaluates the value of the `expression` for the dates in the quarter to date, in the current context. + +## Syntax + ```dax -TOTALQTD(,[,]) +TOTALQTD(,[,]) ``` - -### Parameters - -|Parameter|Definition| -|-------------|--------------| -|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.| - + +### Parameters + +|Parameter|Definition| +|-------------|--------------| +|`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 for all dates in the current quarter to date, given the dates in **dates**. - +A scalar value that represents the `expression` evaluated for all dates in the current quarter to date, given the dates in `dates`. + ## 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](calculate-function-dax.md). - -- The **filter** expression has restrictions described in the topic, [CALCULATE](calculate-function-dax.md). +- 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](calculate-function-dax.md). + +- The `filter` expression has restrictions described in the topic, [CALCULATE](calculate-function-dax.md). - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'quarter running total' or 'quarter running sum' for Internet sales. - +The following sample formula creates a measure that calculates the 'quarter running total' or 'quarter running sum' for Internet sales. + ```dax -= TOTALQTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey]) += TOTALQTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey]) ``` - -## See also -[ALL](all-function-dax.md) -[CALCULATE](calculate-function-dax.md) -[TOTALYTD](totalytd-function-dax.md) -[TOTALMTD](totalmtd-function-dax.md) +## Related content + +[ALL](all-function-dax.md) +[CALCULATE](calculate-function-dax.md) +[TOTALYTD](totalytd-function-dax.md) +[TOTALMTD](totalmtd-function-dax.md) diff --git a/query-languages/dax/totalytd-function-dax.md b/query-languages/dax/totalytd-function-dax.md index a6022b6ca..86065a1f9 100644 --- a/query-languages/dax/totalytd-function-dax.md +++ b/query-languages/dax/totalytd-function-dax.md @@ -1,72 +1,65 @@ --- description: "Learn more about: TOTALYTD" -title: "TOTALYTD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TOTALYTD function (DAX)" --- # TOTALYTD -Evaluates the year-to-date value of the **expression** in the current context. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations-discouraged](includes/applies-to-measures-columns-tables-visual-calculations-discouraged.md)] + +Evaluates the year-to-date value of the `expression` in the current context. + +## Syntax + ```dax -TOTALYTD(,[,][,]) +TOTALYTD(,[,][,]) ``` - -### Parameters - -|Parameter|Definition| -|-------------|--------------| -|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.| -|year_end_date|(optional) A literal string with a date that defines the year-end date. The default is December 31.| - + +### Parameters + +|Parameter|Definition| +|-------------|--------------| +|`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.| +|`year_end_date`|(optional) A literal string with a date that defines the year-end date. The default is December 31.| + ## Return value -A scalar value that represents the **expression** evaluated for the current year-to-date **dates**. - +A scalar value that represents the `expression` evaluated for the current year-to-date `dates`. + ## Remarks -- The **dates** argument can be any of the following: - - A reference to a date/time column. +- 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](calculate-function-dax.md). - -- The **filter** expression has restrictions described in the topic, [CALCULATE](calculate-function-dax.md). - -- The **year_end_date** parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is not required and is ignored. For example, the following formula specifies a (fiscal) year_end_date of 6/30 in an EN-US locale workbook. - + - A Boolean expression that defines a single-column table of date/time values. + +- Constraints on Boolean expressions are described in the topic, [CALCULATE](calculate-function-dax.md). + +- The `filter` expression has restrictions described in the topic, [CALCULATE](calculate-function-dax.md). + +- The `year_end_date` parameter is a string literal of a date, in the same locale as the locale of the client where the workbook was created. The year portion of the date is not required and is ignored. For example, the following formula specifies a (fiscal) year_end_date of 6/30 in an EN-US locale workbook. + ```dax - = TOTALYTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey], ALL('DateTime'), "6/30") + = TOTALYTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey], ALL('DateTime'), "6/30") ``` - In this example, year_end_date can be specified as "6/30", "Jun 30", "30 June", or any string that resolves to a month/day. However, it is recommended you specify year_end_date using "month/day" (as shown) to ensure the string resolves to a date. - + In this example, year_end_date can be specified as "6/30", "Jun 30", "30 June", or any string that resolves to a month/day. However, it is recommended you specify year_end_date using "month/day" (as shown) to ensure the string resolves to a date. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following sample formula creates a measure that calculates the 'year running total' or 'year running sum' for Internet sales. - +The following sample formula creates a measure that calculates the 'year running total' or 'year running sum' for Internet sales. + ```dax -= TOTALYTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey]) += TOTALYTD(SUM(InternetSales_USD[SalesAmount_USD]),DateTime[DateKey]) ``` - -## See also - -[ALL](all-function-dax.md) -[CALCULATE](calculate-function-dax.md) -[DATESYTD](datesytd-function-dax.md) -[TOTALMTD](totalmtd-function-dax.md) -[TOTALQTD](totalqtd-function-dax.md) + +## Related content + +[ALL](all-function-dax.md) +[CALCULATE](calculate-function-dax.md) +[DATESYTD](datesytd-function-dax.md) +[TOTALMTD](totalmtd-function-dax.md) +[TOTALQTD](totalqtd-function-dax.md) diff --git a/query-languages/dax/treatas-function.md b/query-languages/dax/treatas-function-dax.md similarity index 65% rename from query-languages/dax/treatas-function.md rename to query-languages/dax/treatas-function-dax.md index 9174bf6eb..fc3ced051 100644 --- a/query-languages/dax/treatas-function.md +++ b/query-languages/dax/treatas-function-dax.md @@ -1,42 +1,35 @@ --- description: "Learn more about: TREATAS" -title: "TREATAS function | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TREATAS function" --- # TREATAS +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Applies the result of a table expression as filters to columns from an unrelated table. - -## Syntax - + +## Syntax + ```dax -TREATAS(table_expression, [, [, [,…]]]} ) +TREATAS(table_expression, [, [, [,…]]]} ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table_expression|An expression that results in a table.| -|column|One or more existing columns. It cannot be an expression. | -## Return value +### Parameters + +|Term|Definition| +|--------|--------------| +|`table_expression`|An expression that results in a table.| +|`column`|One or more existing columns. It cannot be an expression. | + +## Return value A table that contains all the rows in column(s) that are also in table_expression. - + ## Remarks - The number of columns specified must match the number of columns in the table expression and be in the same order. -- If a value returned in the table expression does not exist in the column, it is ignored. For example, TREATAS({"Red", "Green", "Yellow"}, DimProduct[Color]) sets a filter on column DimProduct[Color] with three values "Red", "Green", and "Yellow". If "Yellow" does not exist in DimProduct[Color], the effective filter values would are "Red" and "Green". +- If a value returned in the table expression does not exist in the column, it is ignored. For example, TREATAS({"Red", "Green", "Yellow"}, DimProduct[Color]) sets a filter on column DimProduct[Color] with three values "Red", "Green", and "Yellow". If "Yellow" does not exist in DimProduct[Color], the effective filter values would be "Red" and "Green". - Best for use when a relationship does not exist between the tables. If you have multiple relationships between the tables involved, consider using [USERELATIONSHIP](userelationship-function-dax.md) instead. @@ -48,13 +41,16 @@ In the following example, the model contains two unrelated product tables. If a ```dax CALCULATE( -SUM(Sales[Amount]), -TREATAS(VALUES(DimProduct1[ProductCategory]), DimProduct2[ProductCategory]) + SUM(Sales[Amount]), + TREATAS( + VALUES(DimProduct1[ProductCategory]), + DimProduct2[ProductCategory] + ) ) ``` -## See also +## Related content -[INTERSECT](intersect-function-dax.md) -[FILTER](filter-function-dax.md) -[USERELATIONSHIP](userelationship-function-dax.md) +[INTERSECT](intersect-function-dax.md) +[FILTER](filter-function-dax.md) +[USERELATIONSHIP](userelationship-function-dax.md) diff --git a/query-languages/dax/trim-function-dax.md b/query-languages/dax/trim-function-dax.md index 47a30d0ec..bfb0ad347 100644 --- a/query-languages/dax/trim-function-dax.md +++ b/query-languages/dax/trim-function-dax.md @@ -1,58 +1,51 @@ --- description: "Learn more about: TRIM" -title: "TRIM function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/10/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TRIM function (DAX)" --- # TRIM -Removes all spaces from text except for single spaces between words. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Removes all spaces from text except for single spaces between words. + +## Syntax + ```dax -TRIM() +TRIM() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|**text**|The text from which you want spaces removed, or a column that contains text.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text from which you want spaces removed, or a column that contains text.| + ## Return value -The string with spaces removed. - +The string with spaces removed. + ## Remarks -- Use TRIM on text that you have received from another application that may have irregular spacing. - -- The TRIM function was originally designed to trim the 7-bit ASCII space character (value 32) from text. In the Unicode character set, there is an additional space character called the nonbreaking space character that has a decimal value of 160. This character is commonly used in Web pages as the HTML entity, &nbsp;. By itself, the TRIM function does not remove this nonbreaking space character. For an example of how to trim both space characters from text, see Remove spaces and nonprinting characters from text. - +- Use TRIM on text that you have received from another application that may have irregular spacing. + +- The TRIM function was originally designed to trim the 7-bit ASCII space character (value 32) from text. In the Unicode character set, there is an additional space character called the nonbreaking space character that has a decimal value of 160. This character is commonly used in Web pages as the HTML entity, &nbsp;. By itself, the TRIM function does not remove this nonbreaking space character. For an example of how to trim both space characters from text, see Remove spaces and nonprinting characters from text. + ## Example -The following formula creates a new string that does not have trailing white space. - +The following formula creates a new string that does not have trailing white space. + ```dax -= TRIM("A column with trailing spaces. ") += TRIM("A column with trailing spaces. ") ``` -When you create the formula, the formula is propagated through the row just as you typed it, so that you see the original string in each formula and the results are not apparent. However, when the formula is evaluated the string is trimmed. - -You can verify that the formula produces the correct result by checking the length of the calculated column created by the previous formula, as follows: - +When you create the formula, the formula is propagated through the row just as you typed it, so that you see the original string in each formula and the results are not apparent. However, when the formula is evaluated the string is trimmed. + +You can verify that the formula produces the correct result by checking the length of the calculated column created by the previous formula, as follows: + ```dax -= LEN([Calculated Column 1]) += LEN([Calculated Column 1]) ``` - -## See also -[Text functions](text-functions-dax.md) +## Related content + +[Text functions](text-functions-dax.md) diff --git a/query-languages/dax/true-function-dax.md b/query-languages/dax/true-function-dax.md index 9710c7920..2670425e4 100644 --- a/query-languages/dax/true-function-dax.md +++ b/query-languages/dax/true-function-dax.md @@ -1,55 +1,48 @@ --- description: "Learn more about: TRUE" -title: "TRUE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 05/03/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TRUE function (DAX)" --- # TRUE -Returns the logical value TRUE. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the logical value `TRUE`. + +## Syntax + ```dax -TRUE() +TRUE() ``` - + ## Return value -Always TRUE. - +Always `TRUE`. + ## Remarks -The word TRUE is also interpreted as the logical value TRUE. - +The word `TRUE` is also interpreted as the logical value `TRUE`. + ## Example -The formula returns the logical value TRUE when the value in the column, 'InternetSales_USD'[SalesAmount_USD], is greater than 200000. - +The formula returns the logical value `TRUE` when the value in the column, 'InternetSales_USD'[SalesAmount_USD], is greater than 200000. + ```dax -= IF(SUM('InternetSales_USD'[SalesAmount_USD]) >200000, TRUE(), false()) += IF(SUM('InternetSales_USD'[SalesAmount_USD]) >200000, TRUE(), false()) ``` -The following table shows the results when the example formula is used in a report with 'ProductCategory'[ProductCategoryName] in Row Labels and 'DateTime'[CalendarYear] in Column Labels. - +The following table shows the results when the example formula is used in a report with 'ProductCategory'[ProductCategoryName] in Row Labels and 'DateTime'[CalendarYear] in Column Labels. + |Row Labels|2005|2006|2007|2008|-|Grand Total| -|---------------|-----------------|----|----|----|----|----| -|Accessories|FALSE|FALSE|TRUE|TRUE|FALSE|TRUE| -|Bikes|TRUE|TRUE|TRUE|TRUE|FALSE|TRUE| -|Clothing|FALSE|FALSE|FALSE|FALSE|FALSE|TRUE| -|Components|FALSE|FALSE|FALSE|FALSE|FALSE|FALSE| -||FALSE|FALSE|FALSE|FALSE|FALSE|FALSE| -|Grand Total|TRUE|TRUE|TRUE|TRUE|FALSE|TRUE| - -## See also - -[FALSE](false-function-dax.md) -[NOT](not-function-dax.md) -[IF](if-function-dax.md) +|---------------|-----------------|----|----|----|----|----| +|Accessories|`FALSE`|`FALSE`|`TRUE`|`TRUE`|`FALSE`|`TRUE`| +|Bikes|`TRUE`|`TRUE`|`TRUE`|`TRUE`|`FALSE`|`TRUE`| +|Clothing|`FALSE`|`FALSE`|`FALSE`|`FALSE`|`FALSE`|`TRUE`| +|Components|`FALSE`|`FALSE`|`FALSE`|`FALSE`|`FALSE`|`FALSE`| +||`FALSE`|`FALSE`|`FALSE`|`FALSE`|`FALSE`|`FALSE`| +|Grand Total|`TRUE`|`TRUE`|`TRUE`|`TRUE`|`FALSE`|`TRUE`| + +## Related content + +[FALSE](false-function-dax.md) +[NOT](not-function-dax.md) +[IF](if-function-dax.md) diff --git a/query-languages/dax/trunc-function-dax.md b/query-languages/dax/trunc-function-dax.md index 6349473c2..973fed7d9 100644 --- a/query-languages/dax/trunc-function-dax.md +++ b/query-languages/dax/trunc-function-dax.md @@ -1,62 +1,55 @@ --- description: "Learn more about: TRUNC" -title: "TRUNC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "TRUNC function (DAX)" --- # TRUNC -Truncates a number to an integer by removing the decimal, or fractional, part of the number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Truncates a number to an integer by removing the decimal, or fractional, part of the number. + +## Syntax + ```dax -TRUNC(,) +TRUNC(,) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The number you want to truncate.| -|num_digits|A number specifying the precision of the truncation; if omitted, 0 (zero)| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The number you want to truncate.| +|`num_digits`|A number specifying the precision of the truncation; if omitted, 0 (zero)| + ## Return value -A whole number. - +A whole number. + ## Remarks -TRUNC and INT are similar in that both return integers. TRUNC removes the fractional part of the number. INT rounds numbers down to the nearest integer based on the value of the fractional part of the number. INT and TRUNC are different only when using negative numbers: `TRUNC(-4.3)` returns -4, but `INT(-4.3)` returns -5 because -5 is the smaller number. - +TRUNC and INT are similar in that both return integers. TRUNC removes the fractional part of the number. INT rounds numbers down to the nearest integer based on the value of the fractional part of the number. INT and TRUNC are different only when using negative numbers: `TRUNC(-4.3)` returns -4, but `INT(-4.3)` returns -5 because -5 is the smaller number. + ## Example 1 -The following formula returns 3, the integer part of pi. - +The following formula returns 3, the integer part of pi. + ```dax -= TRUNC(PI()) += TRUNC(PI()) ``` - + ## Example 2 -The following formula returns -8, the integer part of -8.9. - +The following formula returns -8, the integer part of -8.9. + ```dax -= TRUNC(-8.9) += TRUNC(-8.9) ``` - -## See also - -[Math and Trig functions](math-and-trig-functions-dax.md) -[ROUND](round-function-dax.md) -[ROUNDUP](roundup-function-dax.md) -[ROUNDDOWN](rounddown-function-dax.md) -[MROUND](mround-function-dax.md) -[INT](int-function-dax.md) + +## Related content + +[Math and Trig functions](math-and-trig-functions-dax.md) +[ROUND](round-function-dax.md) +[ROUNDUP](roundup-function-dax.md) +[ROUNDDOWN](rounddown-function-dax.md) +[MROUND](mround-function-dax.md) +[INT](int-function-dax.md) diff --git a/query-languages/dax/understanding-functions-for-parent-child-hierarchies-in-dax.md b/query-languages/dax/understanding-functions-for-parent-child-hierarchies-in-dax.md index 888cc8075..774a55cc3 100644 --- a/query-languages/dax/understanding-functions-for-parent-child-hierarchies-in-dax.md +++ b/query-languages/dax/understanding-functions-for-parent-child-hierarchies-in-dax.md @@ -1,105 +1,96 @@ --- description: "Learn more about: Understanding functions for parent-child hierarchies in DAX" -title: "Understanding functions for parent-child hierarchies in DAX | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/04/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "Understanding functions for parent-child hierarchies in DAX" --- # Understanding functions for parent-child hierarchies in DAX -DAX provides five functions to help users manage data that is presented as a parent-child hierarchy in their models. With this functions a user can obtain the entire lineage of parents a row has, how many levels has the lineage to the top parent, who is the parent n-levels above the current row, who is the n-descendant from the top of the current row hierarchy and is certain parent a parent in the current row hierarchy? - +DAX provides five functions to help users manage data that is presented as a parent-child hierarchy in their models. With these functions a user can obtain the entire lineage of parents a row has, how many levels has the lineage to the top parent, who is the parent n-levels above the current row, who is the n-descendant from the top of the current row hierarchy and is certain parent a parent in the current row hierarchy? + ## Parent-child functions in DAX -The following table contains a Parent-Child hierarchy on the columns: **EmployeeKey** and **ParentEmployeeKey** that is used in all the functions examples. - -|EmployeeKey|ParentEmployeeKey| -|---------------|---------------------| -|112|| -|14|112| -|3|14| -|11|3| -|13|3| -|162|3| -|117|162| -|221|162| -|81|162| - -In the above table you can see that employee 112 has no parent defined, employee 14 has employee 112 as manager (ParentEmployeeKey), employee 3 has employee 14 as manager and employees 11, 13, and 162 have employee 3 as manager. The above helps to understand that employee 112 has no manager above her/him and she/he is the top manager for all employees shown here; also, employee 3 reports to employee 14 and employees 11, 13, 162 report to 3. - -The following table presents the available functions, a brief description of the function and an example of the function over the same data shown above. - -[PATH function](path-function-dax.md) - Returns a delimited text with the identifiers of all the parents to the current row, starting with the oldest or top most until current. - -|EmployeeKey|ParentEmployeeKey|Path| -|---------------|---------------------|--------| -|112||112| -|14|112|112|14| -|3|14|112|14|3| -|11|3|112|14|3|11| -|13|3|112|14|3|13| -|162|3|112|14|3|162| -|117|162|112|14|3|162|117| -|221|162|112|14|3|162|221| -|81|162|112|14|3|162|81| - -[PATHLENGTH function](pathlength-function-dax.md) - Returns the number of levels in a given PATH(), starting at current level until the oldest or top most parent level. In the following example column PathLength is defined as '`= PATHLENGTH([Path])`'; the example includes all data from the Path() example to help understand how this function works. - -|EmployeeKey|ParentEmployeeKey|Path|PathLength| -|---------------|---------------------|--------|--------------| -|112||112|1| -|14|112|112|14|2| -|3|14|112|14|3|3| -|11|3|112|14|3|11|4| -|13|3|112|14|3|13|4| -|162|3|112|14|3|162|4| -|117|162|112|14|3|162|117|5| -|221|162|112|14|3|162|221|5| -|81|162|112|14|3|162|81|5| - -[PATHITEM function](pathitem-function-dax.md) - Returns the item at the specified position from a PATH() like result, counting from left to right. In the following example column PathItem - 4th from left is defined as '`= PATHITEM([Path], 4)`'; this example returns the EmployeKey at fourth position in the Path string from the left, using the same sample data from the Path() example. - -|EmployeeKey|ParentEmployeeKey|Path|PathItem - 4th from left| -|---------------|---------------------|--------|-----------------------------| -|112||112|| -|14|112|112|14|| -|3|14|112|14|3|| -|11|3|112|14|3|11|11| -|13|3|112|14|3|13|13| -|162|3|112|14|3|162|162| -|117|162|112|14|3|162|117|162| -|221|162|112|14|3|162|221|162| -|81|162|112|14|3|162|81|162| - -[PATHITEMREVERSE function](pathitemreverse-function-dax.md) - Returns the item at *position* from a PATH() like function result, counting backwards from right to left. - In the following example column PathItemReverse - 3rd from right is defined as '`= PATHITEMREVERSE([Path], 3)`'; this example returns the EmployeKey at third position in the Path string from the right, using the same sample data from the Path() example. - -|EmployeeKey|ParentEmployeeKey|Path|PathItemReverse - 3rd from right| -|---------------|---------------------|--------|-------------------------------------| -|112||112|| -|14|112|112|14|| -|3|14|112|14|3|112| -|11|3|112|14|3|11|14| -|13|3|112|14|3|13|14| -|162|3|112|14|3|162|14| -|117|162|112|14|3|162|117|3| -|221|162|112|14|3|162|221|3| -|81|162|112|14|3|162|81|3| - -[PATHCONTAINS function](pathcontains-function-dax.md) - Returns **TRUE** if the specified *item* exists within the specified *path*. In the following example column PathContains - employee 162 is defined as '`= PATHCONTAINS([Path], "162")`'; this example returns **TRUE** if the given path contains employee 162. This example uses the results from the Path() example above. - -|EmployeeKey|ParentEmployeeKey|Path|PathContains - employee 162| -|---------------|---------------------|--------|-------------------------------------| -|112||112|FALSE| -|14|112|112|14|FALSE| -|3|14|112|14|3|FALSE| -|11|3|112|14|3|11|FALSE| -|13|3|112|14|3|13|FALSE| -|162|3|112|14|3|162|TRUE| -|117|162|112|14|3|162|117|TRUE| +The following table contains a Parent-Child hierarchy on the columns: **EmployeeKey** and **ParentEmployeeKey** that is used in all the functions examples. + +|EmployeeKey|ParentEmployeeKey| +|---------------|---------------------| +|112|| +|14|112| +|3|14| +|11|3| +|13|3| +|162|3| +|117|162| +|221|162| +|81|162| + +In the above table you can see that employee 112 has no parent defined, employee 14 has employee 112 as manager (ParentEmployeeKey), employee 3 has employee 14 as manager and employees 11, 13, and 162 have employee 3 as manager. The above helps to understand that employee 112 has no manager above her/him and she/he is the top manager for all employees shown here; also, employee 3 reports to employee 14 and employees 11, 13, 162 report to 3. + +The following table presents the available functions, a brief description of the function and an example of the function over the same data shown above. + +[PATH function](path-function-dax.md) - Returns a delimited text with the identifiers of all the parents to the current row, starting with the oldest or top most until current. + +|EmployeeKey|ParentEmployeeKey|Path| +|---------------|---------------------|--------| +|112||112| +|14|112|112|14| +|3|14|112|14|3| +|11|3|112|14|3|11| +|13|3|112|14|3|13| +|162|3|112|14|3|162| +|117|162|112|14|3|162|117| +|221|162|112|14|3|162|221| +|81|162|112|14|3|162|81| + +[PATHLENGTH function](pathlength-function-dax.md) - Returns the number of levels in a given PATH(), starting at current level until the oldest or top most parent level. In the following example column PathLength is defined as '`= PATHLENGTH([Path])`'; the example includes all data from the Path() example to help understand how this function works. + +|EmployeeKey|ParentEmployeeKey|Path|PathLength| +|---------------|---------------------|--------|--------------| +|112||112|1| +|14|112|112|14|2| +|3|14|112|14|3|3| +|11|3|112|14|3|11|4| +|13|3|112|14|3|13|4| +|162|3|112|14|3|162|4| +|117|162|112|14|3|162|117|5| +|221|162|112|14|3|162|221|5| +|81|162|112|14|3|162|81|5| + +[PATHITEM function](pathitem-function-dax.md) - Returns the item at the specified position from a PATH() like result, counting from left to right. In the following example column PathItem - 4th from left is defined as '`= PATHITEM([Path], 4)`'; this example returns the EmployeKey at fourth position in the Path string from the left, using the same sample data from the Path() example. + +|EmployeeKey|ParentEmployeeKey|Path|PathItem - 4th from left| +|---------------|---------------------|--------|-----------------------------| +|112||112|| +|14|112|112|14|| +|3|14|112|14|3|| +|11|3|112|14|3|11|11| +|13|3|112|14|3|13|13| +|162|3|112|14|3|162|162| +|117|162|112|14|3|162|117|162| +|221|162|112|14|3|162|221|162| +|81|162|112|14|3|162|81|162| + +[PATHITEMREVERSE function](pathitemreverse-function-dax.md) - Returns the item at `position` from a PATH() like function result, counting backwards from right to left. + In the following example column PathItemReverse - 3rd from right is defined as '`= PATHITEMREVERSE([Path], 3)`'; this example returns the EmployeKey at third position in the Path string from the right, using the same sample data from the Path() example. + +|EmployeeKey|ParentEmployeeKey|Path|PathItemReverse - 3rd from right| +|---------------|---------------------|--------|-------------------------------------| +|112||112|| +|14|112|112|14|| +|3|14|112|14|3|112| +|11|3|112|14|3|11|14| +|13|3|112|14|3|13|14| +|162|3|112|14|3|162|14| +|117|162|112|14|3|162|117|3| +|221|162|112|14|3|162|221|3| +|81|162|112|14|3|162|81|3| + +[PATHCONTAINS function](pathcontains-function-dax.md) - Returns `TRUE` if the specified `item` exists within the specified `path`. In the following example column PathContains - employee 162 is defined as '`= PATHCONTAINS([Path], "162")`'; this example returns `TRUE` if the given path contains employee 162. This example uses the results from the Path() example above. + +|EmployeeKey|ParentEmployeeKey|Path|PathContains - employee 162| +|---------------|---------------------|--------|-------------------------------------| +|112||112|`FALSE`| +|14|112|112|14|`FALSE`| +|3|14|112|14|3|`FALSE`| +|11|3|112|14|3|11|`FALSE`| +|13|3|112|14|3|13|`FALSE`| +|162|3|112|14|3|162|`TRUE`| +|117|162|112|14|3|162|117|`TRUE`| diff --git a/query-languages/dax/unichar-function-dax.md b/query-languages/dax/unichar-function-dax.md index b2422a2a6..06dd22cbf 100644 --- a/query-languages/dax/unichar-function-dax.md +++ b/query-languages/dax/unichar-function-dax.md @@ -1,37 +1,30 @@ --- description: "Learn more about: UNICHAR" -title: "UNICHAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "UNICHAR function (DAX)" --- # UNICHAR +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the Unicode character referenced by the numeric value. - -## Syntax - + +## Syntax + ```dax -UNICHAR(number) +UNICHAR(number) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|number|The Unicode number that represents the character.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`number`|The Unicode number that represents the character.| + ## Return value A character represented by the Unicode number. - -## Remarks + +## Remarks - If XML characters are not invalid, UNICHAR returns an error. @@ -42,10 +35,10 @@ A character represented by the Unicode number. - If number is zero (0), UNICHAR returns an error. - The Unicode character returned can be a string of characters, for example in UTF-8 or UTF-16 codes. - -## Example -The following example returns the character represented by the Unicode number 66 (uppercase A). +## Example + +The following example returns the character represented by the Unicode number 66 (uppercase A). ```dax = UNICHAR(65) diff --git a/query-languages/dax/unicode-function-dax.md b/query-languages/dax/unicode-function-dax.md index 3dd8f00ba..0e374287a 100644 --- a/query-languages/dax/unicode-function-dax.md +++ b/query-languages/dax/unicode-function-dax.md @@ -1,32 +1,25 @@ --- description: "Learn more about: UNICODE" -title: "UNICODE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "UNICODE function (DAX)" --- # UNICODE +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the number (code point) corresponding to the first character of the text. - -## Syntax - + +## Syntax + ```dax -UNICODE( ) +UNICODE( ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|Text|Text is the character for which you want the Unicode value.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`Text`|Text is the character for which you want the Unicode value.| + ## Return value A numeric code for the first character in a text string. diff --git a/query-languages/dax/union-function-dax.md b/query-languages/dax/union-function-dax.md index 344f03f05..c2765d46b 100644 --- a/query-languages/dax/union-function-dax.md +++ b/query-languages/dax/union-function-dax.md @@ -1,83 +1,76 @@ --- description: "Learn more about: UNION" -title: "UNION function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "UNION function (DAX)" --- # UNION - -Creates a union (join) table from a pair of tables. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Creates a union (join) table from a pair of tables. + +## Syntax + ```dax -UNION(, [,]…) +UNION(, [,]…) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table_expression|Any DAX expression that returns a table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table_expression`|Any DAX expression that returns a table.| + ## Return value -A table that contains all the rows from each of the two table expressions. - +A table that contains all the rows from each of the two table expressions. + ## Remarks -- The two tables must have the same number of columns. - -- Columns are combined by position in their respective tables. - -- The column names in the return table will match the column names in table_expression1. - -- Duplicate rows are retained. - -- The returned table has lineage where possible. For example, if the first column of each table_expression has lineage to the same base column C1 in the model, the first column in the UNION result will have lineage to C1. However, if combined columns have lineage to different base columns, or if there is an extension column, the resulting column in UNION will have no lineage. - -- When data types differ, the resulting data type is determined based on the rules for data type coercion. - -- The returned table will not contain columns from related tables. +- The two tables must have the same number of columns. + +- Columns are combined by position in their respective tables. + +- The column names in the return table will match the column names in table_expression1. + +- Duplicate rows are retained. + +- The returned table has lineage where possible. For example, if the first column of each table_expression has lineage to the same base column C1 in the model, the first column in the UNION result will have lineage to C1. However, if combined columns have lineage to different base columns, or if there is an extension column, the resulting column in UNION will have no lineage. + +- When data types differ, the resulting data type is determined based on the rules for data type coercion. + +- The returned table will not contain columns from related tables. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following expression creates a union by combining the USAInventory table and the INDInventory table into a single table: +The following expression creates a union by combining the USAInventory table and the INDInventory table into a single table: ```dax UNION(UsaInventory, IndInventory) ``` **USAInventory** - -|Country|State|Count|Total| -|-----------|---------|---------|---------| -|USA|CA|5|500| -|USA|WA|10|900| - + +|Country/Region|State|Count|Total| +|-----------|---------|---------|---------| +|USA|CA|5|500| +|USA|WA|10|900| + **INDInventory** - -|Country|State|Count|Total| -|-----------|---------|---------|---------| -|IND|JK|20|800| -|IND|MH|25|1000| -|IND|WB|10|900| - -Return table, - -|Country|State|Count|Total| -|-----------|---------|---------|---------| -|USA|CA|5|500| -|USA|WA|10|900| -|IND|JK|20|800| -|IND|MH|25|1000| -|IND|WB|10|900| + +|Country/Region|State|Count|Total| +|-----------|---------|---------|---------| +|IND|JK|20|800| +|IND|MH|25|1000| +|IND|WB|10|900| + +Return table, + +|Country/Region|State|Count|Total| +|-----------|---------|---------|---------| +|USA|CA|5|500| +|USA|WA|10|900| +|IND|JK|20|800| +|IND|MH|25|1000| +|IND|WB|10|900| diff --git a/query-languages/dax/upper-function-dax.md b/query-languages/dax/upper-function-dax.md index 29026d2e2..aa07074fd 100644 --- a/query-languages/dax/upper-function-dax.md +++ b/query-languages/dax/upper-function-dax.md @@ -1,45 +1,38 @@ --- description: "Learn more about: UPPER" -title: "UPPER function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "UPPER function (DAX)" --- # UPPER -Converts a text string to all uppercase letters. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Converts a text string to all uppercase letters. + +## Syntax + ```dax -UPPER () +UPPER () ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|The text you want converted to uppercase, or a reference to a column that contains text.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text you want converted to uppercase, or a reference to a column that contains text.| + ## Return value -Same text, in uppercase. - +Same text, in uppercase. + ## Example -The following formula converts the string in the column, [ProductCode], to all uppercase. Non-alphabetic characters are not affected. - +The following formula converts the string in the column, [ProductCode], to all uppercase. Non-alphabetic characters are not affected. + ```dax -= UPPER(['New Products'[Product Code]) += UPPER(['New Products'[Product Code]) ``` - -## See also -[Text functions](text-functions-dax.md) -[LOWER function](lower-function-dax.md) +## Related content + +[Text functions](text-functions-dax.md) +[LOWER function](lower-function-dax.md) diff --git a/query-languages/dax/userculture-function-dax.md b/query-languages/dax/userculture-function-dax.md new file mode 100644 index 000000000..873a6b80e --- /dev/null +++ b/query-languages/dax/userculture-function-dax.md @@ -0,0 +1,65 @@ +--- +description: "Learn more about: USERCULTURE" +title: "USERCULTURE function (DAX)" +--- +# USERCULTURE + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the locale \(language code-country code) for the current user, determined by the operating system, browser settings, or Power BI service. + +## Syntax + +```dax +USERCULTURE() +``` + +### Parameters + +This expression has no parameters. + +## Return value + +Locale as a string. + +## Remarks + +- In the Power BI service, locale is determined by **Settings** > **Language** > **Language Settings**. The default is determined by the user's browser language setting. + +- When used in calculated table and calculated column expressions, the result may differ depending on whether the table is in DirectQuery or Import mode. When in DirectQuery mode, the result is determined by the language (locale) specified in Language Settings in the Power BI service. The default in Language Settings specifies locale is determined by the user's browser language setting, which means the same calculated table or column can return different results depending on the browser language settings for each user. When in Import mode, the result is statically determined during refresh and will not vary at query time. For managed refreshes, such as scheduled or interactive, locale is not based on the user’s browser language setting but instead uses an invariant locale. The invariant locale, however, can be overridden by using the XMLA endpoint to specify a custom locale. + +- When combined with the Field parameters feature in Power BI, USERCULTURE can be used to reliably translate dynamic visualization titles and captions when used in measure and row-level security (RLS) object expressions within the same model. However, expressions containing USERCULTURE called from outside the model, such as queries and live-connect report measures, should not be relied upon for correctly translated titles and captions. + +- USERCULTURE returns the correct user locale when used in object expressions called from within the model such as measures, row-level security (RLS), and calculation items. However, it may not return the correct user locale when used in expressions from outside the model, such as queries and live-connect report measures. + +- In Live-connect reports, USERCULTURE may not return the correct user locale when called from a report measure expression. + +## Example + +For the following expression, + +```dax +FORMAT(TODAY(), "dddd", USERCULTURE()) +``` + +Depending on the language setting for the current user, :::no-loc text="USERCULTURE"::: returns the current day, for example: + +|Locale | Formatted weekday | +|---------|---------| +|de-DE | :::no-loc text="Dienstag":::| +|en-US | :::no-loc text="Tuesday":::| +|es-ES_tradnl | :::no-loc text="martes":::| +|eu-ES | :::no-loc text="asteartea":::| +|it-IT | :::no-loc text="martedì":::| +|nl-NL | :::no-loc text="dinsdag":::| +|pl-PL | :::no-loc text="wtorek":::| +|ro-RO | :::no-loc text="marți":::| +|ru-RU | :::no-loc text="вторник":::| +|uk-UA | :::no-loc text="вівторок":::| + +## Related content + +[Expression-based titles in Power BI](/power-bi/create-reports/desktop-conditional-format-visual-titles) +[USERNAME](username-function-dax.md) +[USERPRINCIPALNAME](userprincipalname-function-dax.md) +[USEROBJECTID](userobjectid-function-dax.md) diff --git a/query-languages/dax/userelationship-function-dax.md b/query-languages/dax/userelationship-function-dax.md index 2f757d1e5..65242cf07 100644 --- a/query-languages/dax/userelationship-function-dax.md +++ b/query-languages/dax/userelationship-function-dax.md @@ -1,65 +1,58 @@ --- description: "Learn more about: USERELATIONSHIP" -title: "USERELATIONSHIP function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "USERELATIONSHIP function (DAX)" --- # USERELATIONSHIP -Specifies the relationship to be used in a specific calculation as the one that exists between columnName1 and columnName2. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables](includes/applies-to-measures-columns-tables.md)] + +Specifies the relationship to be used in a specific calculation as the one that exists between columnName1 and columnName2. + +## Syntax + ```dax -USERELATIONSHIP(,) +USERELATIONSHIP(,) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| columnName1 | The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the many side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression. | -| columnName2 | The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the one side or lookup side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression. | +### Parameters + +|Term|Definition| +|--------|--------------| +| `columnName1` | The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the many side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression. | +| `columnName2` | The name of an existing column, using standard DAX syntax and fully qualified, that usually represents the one side or lookup side of the relationship to be used; if the arguments are given in reverse order the function will swap them before using them. This argument cannot be an expression. | ## Return value -The function returns no value; the function only enables the indicated relationship for the duration of the calculation. - -## Remarks - -- USERELATIONSHIP can only be used in functions that take a filter as an argument, for example: CALCULATE, CALCULATETABLE, CLOSINGBALANCEMONTH, CLOSINGBALANCEQUARTER, CLOSINGBALANCEYEAR, OPENINGBALANCEMONTH, OPENINGBALANCEQUARTER, OPENINGBALANCEYEAR, TOTALMTD, TOTALQTD and TOTALYTD functions. +The function returns no value; the function only enables the indicated relationship for the duration of the calculation. + +## Remarks + +- USERELATIONSHIP can only be used in functions that take a filter as an argument, for example: CALCULATE, CALCULATETABLE, CLOSINGBALANCEMONTH, CLOSINGBALANCEQUARTER, CLOSINGBALANCEYEAR, OPENINGBALANCEMONTH, OPENINGBALANCEQUARTER, OPENINGBALANCEYEAR, TOTALMTD, TOTALQTD and TOTALYTD functions. - USERELATIONSHIP cannot be used when row level security is defined for the table in which the measure is included. For example, `CALCULATE(SUM([SalesAmount]), USERELATIONSHIP(FactInternetSales[CustomerKey], DimCustomer[CustomerKey]))` will return an error if row level security is defined for DimCustomer. - -- USERELATIONSHIP uses existing relationships in the model, identifying relationships by their ending point columns. - -- In USERELATIONSHIP, the status of a relationship is not important; that is, whether the relationship is active or not does not affect the usage of the function. Even if the relationship is inactive, it will be used and overrides any other active relationships that might be present in the model but not mentioned in the function arguments. - -- An error is returned if any of the columns named as an argument is not part of a relationship or the arguments belong to different relationships. - -- If multiple relationships are needed to join table A to table B in a calculation, each relationship must be indicated in a different USERELATIONSHIP function. - -- If CALCULATE expressions are nested, and more than one CALCULATE expression contains a USERELATIONSHIP function, then the innermost USERELATIONSHIP is the one that prevails in case of a conflict or ambiguity. - -- Up to 10 USERELATIONSHIP functions can be nested; however, your expression might have a deeper level of nesting, ie. the following sample expression is nested 3 levels deep but only 2 for USEREALTIONSHIP: `=CALCULATE(CALCULATE( CALCULATE( <anyExpression>, USERELATIONSHIP( t1[colA], t2[colB])), t99[colZ]=999), USERELATIONSHIP( t1[colA], t2[colA]))`. + +- USERELATIONSHIP uses existing relationships in the model, identifying relationships by their ending point columns. + +- In USERELATIONSHIP, the status of a relationship is not important; that is, whether the relationship is active or not does not affect the usage of the function. Even if the relationship is inactive, it will be used and overrides any other active relationships that might be present in the model but not mentioned in the function arguments. + +- An error is returned if any of the columns named as an argument is not part of a relationship or the arguments belong to different relationships. + +- If multiple relationships are needed to join table A to table B in a calculation, each relationship must be indicated in a different USERELATIONSHIP function. + +- If CALCULATE expressions are nested, and more than one CALCULATE expression contains a USERELATIONSHIP function, then the innermost USERELATIONSHIP is the one that prevails in case of a conflict or ambiguity. + +- Up to 10 USERELATIONSHIP functions can be nested; however, your expression might have a deeper level of nesting, ie. the following sample expression is nested 3 levels deep but only 2 for USERELATIONSHIP: `=CALCULATE(CALCULATE( CALCULATE( , USERELATIONSHIP( t1[colA], t2[colB])), t99[colZ]=999), USERELATIONSHIP( t1[colA], t2[colA]))`. - For 1-to-1 relationships, USERELATIONSHIP will only activate the relationship in one direction. In particular, filters will only be able to flow from *columnName2*'s table to *columnName1*'s table. If bi-directional cross-filtering is desired, two USERELATIONSHIPs with opposite directionality can be used in the same calculation. For example, `CALCULATE(..., USERELATIONSHIP(T1[K], T2[K]), USERELATIONSHIP(T2[K], T1[K]))`. - + ## Example -The following sample shows how to override the default, active, relationship between InternetSales and DateTime tables. The default relationship exists between the OrderDate column, in the InternetSales table, and the Date column, in the DateTime table. - -To calculate the sum of internet sales and allow slicing by ShippingDate instead of the traditional OrderDate, create measure, [InternetSales by ShippingDate] using the following expression: - +The following sample shows how to override the default, active, relationship between InternetSales and DateTime tables. The default relationship exists between the OrderDate column, in the InternetSales table, and the Date column, in the DateTime table. + +To calculate the sum of internet sales and allow slicing by ShippingDate instead of the traditional OrderDate, create measure, [InternetSales by ShippingDate] using the following expression: + ```dax -= CALCULATE(SUM(InternetSales[SalesAmount]), USERELATIONSHIP(InternetSales[ShippingDate], DateTime[Date])) += CALCULATE(SUM(InternetSales[SalesAmount]), USERELATIONSHIP(InternetSales[ShippingDate], DateTime[Date])) ``` -Relationships between InternetSales[ShipmentDate] and DateTime[Date] must exist and should not be the active relationship; also, the relationship between InternetSales[OrderDate] and DateTime[Date] should exist and should be the active relationship. +Relationships between InternetSales[ShippingDate] and DateTime[Date] must exist and should not be the active relationship; also, the relationship between InternetSales[OrderDate] and DateTime[Date] should exist and should be the active relationship. diff --git a/query-languages/dax/username-function-dax.md b/query-languages/dax/username-function-dax.md index 4ca395ce1..1a9281bfc 100644 --- a/query-languages/dax/username-function-dax.md +++ b/query-languages/dax/username-function-dax.md @@ -1,38 +1,31 @@ --- description: "Learn more about: USERNAME" -title: "USERNAME function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "USERNAME function (DAX)" --- # USERNAME -Returns the domain name and username from the credentials given to the system at connection time. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the domain name and username from the credentials given to the system at connection time. + +## Syntax + ```dax -USERNAME() +USERNAME() ``` - -### Parameters + +### Parameters This expression has no parameters. - + ## Return value -The username from the credentials given to the system at connection time - +The username from the credentials given to the system at connection time + ## Example -The following formula verifies if the user login is part of the UsersTable. - +The following formula verifies if the user login is part of the UsersTable. + ```dax -= IF(CONTAINS(UsersTable,UsersTable[login], USERNAME()), "Allowed", BLANK()) += IF(CONTAINS(UsersTable,UsersTable[login], USERNAME()), "Allowed", BLANK()) ``` diff --git a/query-languages/dax/userobjectid-function-dax.md b/query-languages/dax/userobjectid-function-dax.md index f04f613db..e4664dc00 100644 --- a/query-languages/dax/userobjectid-function-dax.md +++ b/query-languages/dax/userobjectid-function-dax.md @@ -1,30 +1,23 @@ --- description: "Learn more about: USEROBJECTID" -title: "USEROBJECTID function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "USEROBJECTID function (DAX)" --- # USEROBJECTID -Returns the current user's Object ID from Azure AD or security identifier (SID). - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the current user's Object ID from Microsoft Entra ID or security identifier (SID). + +## Syntax + ```dax -USEROBJECTID() +USEROBJECTID() ``` - -### Parameters - + +### Parameters + This expression has no parameters. ## Return value -The current user's Object ID from Azure AD for Power BI or Azure Analysis Services models or SID for SQL Server Analysis Services models. +The current user's Object ID from Microsoft Entra ID for Power BI or Azure Analysis Services models or SID for SQL Server Analysis Services models. diff --git a/query-languages/dax/userprincipalname-function-dax.md b/query-languages/dax/userprincipalname-function-dax.md index f4d9f52a3..159242bf7 100644 --- a/query-languages/dax/userprincipalname-function-dax.md +++ b/query-languages/dax/userprincipalname-function-dax.md @@ -1,30 +1,23 @@ --- description: "Learn more about: USERPRINCIPALNAME" -title: "USERPRINCIPALNAME function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "USERPRINCIPALNAME function (DAX)" --- # USERPRINCIPALNAME +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the user principal name. - -## Syntax - + +## Syntax + ```dax -USERPRINCIPALNAME() +USERPRINCIPALNAME() ``` - -### Parameters + +### Parameters This expression has no parameters. - + ## Return value The userprincipalname at connection time. diff --git a/query-languages/dax/utcnow-function-dax.md b/query-languages/dax/utcnow-function-dax.md index 0fb65b272..e8445ae58 100644 --- a/query-languages/dax/utcnow-function-dax.md +++ b/query-languages/dax/utcnow-function-dax.md @@ -1,49 +1,42 @@ --- description: "Learn more about: UTCNOW" -title: "UTCNOW function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "UTCNOW function (DAX)" --- # UTCNOW +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the current UTC date and time. - -## Syntax - + +## Syntax + ```dax -UTCNOW() +UTCNOW() ``` - + ## Return value -A (**datetime)**. - -## Remarks +A `datetime`. + +## Remarks + +The result of the UTCNOW function changes only when the formula is refreshed. It is not continuously updated. -The result of the UTCNOW function changes only when the formula is refreshed. It is not continuously updated. - ## Example The following: - + ```dax EVALUATE { FORMAT(UTCNOW(), "General Date") } ``` Returns: -|[Value] | +|Value | |---------| |2/2/2018 4:48:08 AM | -## See also +## Related content -[NOW function](now-function-dax.md) -[UTCTODAY function](utctoday-function-dax.md) +[NOW function](now-function-dax.md) +[UTCTODAY function](utctoday-function-dax.md) diff --git a/query-languages/dax/utctoday-function-dax.md b/query-languages/dax/utctoday-function-dax.md index e1dbc5603..a3ebcb9bc 100644 --- a/query-languages/dax/utctoday-function-dax.md +++ b/query-languages/dax/utctoday-function-dax.md @@ -1,40 +1,33 @@ --- description: "Learn more about: UTCTODAY" -title: "UTCTODAY function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/06/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "UTCTODAY function (DAX)" --- # UTCTODAY +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the current UTC date. -## Syntax - +## Syntax + ```dax -UTCTODAY() +UTCTODAY() ``` - + ## Return value -A date. - -## Remarks +A date. + +## Remarks - UTCTODAY returns the time value 12:00:00 PM for all dates. - The UTCNOW function is similar but returns the exact time and date. - + ## Example The following: - + ```dax EVALUATE { FORMAT(UTCTODAY(), "General Date") } ``` @@ -45,7 +38,7 @@ Returns: |---------| |2/2/2018 | -## See also +## Related content -[NOW function](now-function-dax.md) -[UTCNOW function](utcnow-function-dax.md) +[NOW function](now-function-dax.md) +[UTCNOW function](utcnow-function-dax.md) diff --git a/query-languages/dax/value-function-dax.md b/query-languages/dax/value-function-dax.md index 8bab7f491..5d8445260 100644 --- a/query-languages/dax/value-function-dax.md +++ b/query-languages/dax/value-function-dax.md @@ -1,52 +1,45 @@ --- description: "Learn more about: VALUE" -title: "VALUE function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "VALUE function (DAX)" --- # VALUE -Converts a text string that represents a number to a number. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Converts a text string that represents a number to a number. + +## Syntax + ```dax -VALUE() +VALUE() ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|text|The text to be converted.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`text`|The text to be converted.| + ## Return value -The converted number in decimal data type. - +The converted number in decimal data type. + ## Remarks -- The value passed as the **text** parameter can be in any of the constant, number, date, or time formats recognized by the application or services you are using. If **text** is not in one of these formats, an error is returned. - -- You do not generally need to use the VALUE function in a formula because the engine implicitly converts text to numbers as necessary. - -- You can also use column references. For example, if you have a column that contains mixed number types, VALUE can be used to convert all values to a single numeric data type. However, if you use the VALUE function with a column that contains mixed numbers and text, the entire column is flagged with an error, because not all values in all rows can be converted to numbers. - +- The value passed as the `text` parameter can be in any of the constant, number, date, or time formats recognized by the application or services you are using. If `text` is not in one of these formats, an error is returned. + +- You do not generally need to use the VALUE function in a formula because the engine implicitly converts text to numbers as necessary. + +- You can also use column references. For example, if you have a column that contains mixed number types, VALUE can be used to convert all values to a single numeric data type. However, if you use the VALUE function with a column that contains mixed numbers and text, the entire column is flagged with an error, because not all values in all rows can be converted to numbers. + ## Example -The following formula converts the typed string, "3", into the numeric value 3. - +The following formula converts the typed string, "3", into the numeric value 3. + ```dax -= VALUE("3") += VALUE("3") ``` - -## See also -[Text functions](text-functions-dax.md) +## Related content + +[Text functions](text-functions-dax.md) diff --git a/query-languages/dax/values-function-dax.md b/query-languages/dax/values-function-dax.md index e10b0681d..7c79de39c 100644 --- a/query-languages/dax/values-function-dax.md +++ b/query-languages/dax/values-function-dax.md @@ -1,84 +1,78 @@ --- description: "Learn more about: VALUES" -title: "VALUES function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 05/03/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false +title: "VALUES function (DAX)" --- # VALUES -When the input parameter is a column name, returns a one-column table that contains the distinct values from the specified column. Duplicate values are removed and only unique values are returned. A BLANK value can be added. When the input parameter is a table name, returns the rows from the specified table. Duplicate rows are preserved. A BLANK row can be added. - -> [!NOTE] -> This function cannot be used to Return values into a cell or column on a worksheet; rather, you use it as an intermediate function, nested in a formula, to get a list of distinct values that can be counted or used to filter or sum other values. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +When the input parameter is a column name, returns a one-column table that contains the distinct values from the specified column. Duplicate values are removed and only unique values are returned. A BLANK value can be added. When the input parameter is a table name, returns the rows from the specified table. Duplicate rows are preserved. A BLANK row can be added. + +> [!NOTE] +> This function cannot be used to Return values into a cell or column on a worksheet; rather, you use it as an intermediate function, nested in a formula, to get a list of distinct values that can be counted or used to filter or sum other values. + +## Syntax + ```dax -VALUES() +VALUES() ``` - + ### Parameters - -|Term|Definition| -|--------|--------------| -|TableName or ColumnName|A column from which unique values are to be returned, or a table from which rows are to be returned.| - + +|Term|Definition| +|--------|--------------| +|`TableName` or `ColumnName`|A column from which unique values are to be returned, or a table from which rows are to be returned.| + ## Return value When the input parameter is a column name, a single column table. When the input parameter is a table name, a table of the same columns is returned. - + ## Remarks -- When you use the VALUES function in a context that has been filtered, the unique values returned by VALUES are affected by the filter. For example, if you filter by Region, and return a list of the values for City, the list will include only those cities in the regions permitted by the filter. To return all of the cities, regardless of existing filters, you must use the ALL function to remove filters from the table. The second example demonstrates use of ALL with VALUES. - +- When you use the VALUES function in a context that has been filtered, the unique values returned by VALUES are affected by the filter. For example, if you filter by Region, and return a list of the values for City, the list will include only those cities in the regions permitted by the filter. To return all of the cities, regardless of existing filters, you must use the ALL function to remove filters from the table. The second example demonstrates use of ALL with VALUES. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - For best practices when using VALUES, see [Use SELECTEDVALUE instead of VALUES](best-practices/dax-selectedvalue.md). ## Related functions -In most scenarios, when the argument is a column name, the results of the VALUES function are identical to those of the **DISTINCT** function. Both functions remove duplicates and return a list of the possible values in the specified column. However, the VALUES function can also return a blank value. This blank value is useful in cases where you are looking up distinct values from a related table, but a value used in the relationship is missing from one table. In database terminology, this is termed a violation of referential integrity. Such mismatches in data can occur when one table is being updated and the related table is not. +In most scenarios, when the argument is a column name, the results of the VALUES function are identical to those of the `DISTINCT` function. Both functions remove duplicates and return a list of the possible values in the specified column. However, the VALUES function can also return a blank value. This blank value is useful in cases where you are looking up distinct values from a related table, but a value used in the relationship is missing from one table. In database terminology, this is termed a violation of referential integrity. Such mismatches in data can occur when one table is being updated and the related table is not. When the argument is a table name, the result of the VALUES function returns all rows in the specified table plus a blank row, if there is a violation of referential integrity. The DISTINCT function removes duplicate rows and returns unique rows in the specified table. ->[!NOTE] +>[!NOTE] > The DISTINCT function allows a column name or any valid table expression to be its argument but the VALUES function only accepts a column name or a table name as the argument. -The following table summarizes the mismatch between data that can occur in two related tables when referential integrity is not preserved. - -|MyOrders table|MySales table| -|------------------|-----------------| -|June 1|June 1 sales| -|June 2|June 2 sales| -|(no order dates have been entered)|June 3 sales| - -If you use the DISTINCT function to return a list of dates, only two dates would be returned. However, if you use the VALUES function, the function returns the two dates plus an additional blank member. Also, any row from the MySales table that does not have a matching date in the MyOrders table will be "matched" to this unknown member. - +The following table summarizes the mismatch between data that can occur in two related tables when referential integrity is not preserved. + +|MyOrders table|MySales table| +|------------------|-----------------| +|June 1|June 1 sales| +|June 2|June 2 sales| +|(no order dates have been entered)|June 3 sales| + +If you use the DISTINCT function to return a list of dates, only two dates would be returned. However, if you use the VALUES function, the function returns the two dates plus an additional blank member. Also, any row from the MySales table that does not have a matching date in the MyOrders table will be "matched" to this unknown member. + ## Example -The following formula counts the number of unique invoices (sales orders), and produces the following results when used in a report that includes the Product Category Names: +The following formula counts the number of unique invoices (sales orders), and produces the following results when used in a report that includes the Product Category Names: ```dax -= COUNTROWS(VALUES('InternetSales_USD'[SalesOrderNumber])) += COUNTROWS(VALUES('InternetSales_USD'[SalesOrderNumber])) ``` Returns - -|Row Labels|Count Invoices| -|--------------|------------------| -|Accessories|18,208| -|Bikes|15,205| -|Clothing|7,461| -|Grand Total|27,659| - -## See also - -[FILTER function](filter-function-dax.md) -[COUNTROWS function](countrows-function-dax.md) -[Filter functions](filter-functions-dax.md) + +|Row Labels|Count Invoices| +|--------------|------------------| +|Accessories|18,208| +|Bikes|15,205| +|Clothing|7,461| +|Grand Total|27,659| + +## Related content + +[FILTER function](filter-function-dax.md) +[COUNTROWS function](countrows-function-dax.md) +[Filter functions](filter-functions-dax.md) diff --git a/query-languages/dax/var-dax.md b/query-languages/dax/var-dax.md index f85177534..4c96fc5b8 100644 --- a/query-languages/dax/var-dax.md +++ b/query-languages/dax/var-dax.md @@ -1,87 +1,87 @@ --- description: "Learn more about: VAR" -title: "VAR keyword (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 01/24/2022 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "VAR keyword (DAX)" --- # VAR - -Stores the result of an expression as a named variable, which can then be passed as an argument to other measure expressions. Once resultant values have been calculated for a variable expression, those values do not change, even if the variable is referenced in another expression. -## Syntax - +Stores the result of an expression as a named variable, which can then be passed as an argument to other measure expressions. Once resultant values have been calculated for a variable expression, those values do not change, even if the variable is referenced in another expression. + +## Syntax + ```dax -VAR = +VAR = ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|name|The name of the variable (identifier).
Delimiters are not supported. For example, 'varName' or [varName] will result in an error.
Supported character set: a-z, A-Z, 0-9.
0-9 are not valid as first character.
__ (double underscore) is allowed as a prefix to the identifier name.
No other special characters are supported.
Reserved keywords not allowed.
Names of existing tables are not allowed.
Empty spaces are not allowed.| -|expression|A DAX expression which returns a scalar or table value.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`name`|The name of the variable (identifier).
Delimiters are not supported. For example, 'varName' or [varName] will result in an error.
Supported character set: a-z, A-Z, 0-9.
0-9 are not valid as first character.
__ (double underscore) is allowed as a prefix to the identifier name.
No other special characters are supported.
Reserved keywords not allowed.
Names of existing tables are not allowed.
Empty spaces are not allowed.| +|`expression`|A DAX expression which returns a scalar or table value.| + ## Return value -A named variable containing the result of the expression argument. - +A named variable containing the result of the expression argument. + ## Remarks -- An expression passed as an argument to VAR can contain another VAR declaration. - -- When referencing a variable: - - Measures cannot refer to variables defined outside the measure expression, but can refer to functional scope variables defined within the expression. - - Variables can refer to measures. - - Variables can refer to previously defined variables. - - Columns in table variables cannot be referenced via TableName[ColumnName] syntax. +- An expression passed as an argument to VAR can contain another VAR declaration. + +- When referencing a variable: + - Measures cannot refer to variables defined outside the measure expression, but can refer to functional scope variables defined within the expression. + - Variables can refer to measures. + - Variables can refer to previously defined variables. + - Columns in table variables cannot be referenced via TableName[ColumnName] syntax. - For best practices when using VAR, see [Use variables to improve your DAX formulas](best-practices/dax-variables.md). +- To learn more about how VAR is used within a DAX Query, see [DAX queries](dax-queries.md). + ## Example -To calculate a percentage of year-over-year growth without using a variable, you could create three separate measures. This first measure calculates Sum of Sales Amount: - +To calculate a percentage of year-over-year growth without using a variable, you could create three separate measures. This first measure calculates Sum of Sales Amount: + ```dax -Sum of SalesAmount = SUM(SalesTable[SalesAmount]) +Sum of Sales Amount = +SUM ( Sales[Sales Amount] ) ``` -A second measure calculates the sales amount for the previous year: - +A second measure calculates the sales amount for the previous year: + ```dax -SalesAmount PreviousYear = - CALCULATE([Sum of SalesAmount], - SAMEPERIODLASTYEAR(Calendar[Date]) - ) +Sales Amount PreviousYear = +CALCULATE ( [Sum of Sales Amount], SAMEPERIODLASTYEAR ( 'Date'[Date] ) ) ``` -You can then create a third measure that combines the other two measures to calculate a growth percentage. Notice the Sum of SalesAmount measure is used in two places; first to determine if there is a sale, then again to calculate a percentage. - +You can then create a third measure that combines the other two measures to calculate a growth percentage. Notice the Sum of SalesAmount measure is used in two places; first to determine if there is a sale, then again to calculate a percentage. + ```dax -Sum of SalesAmount YoY%: = - IF([Sum of SalesAmount] , - DIVIDE(([Sum of SalesAmount] – [SalesAmount PreviousYear]), [Sum of SalesAmount]) - ) +Sum of SalesAmount YoY%: = +IF ( + [Sum of Sales Amount] && [Sales Amount PreviousYear], + DIVIDE ( + ( [Sum of Sales Amount] - [Sales Amount PreviousYear] ), + [Sales Amount PreviousYear] + ) +) ``` -By using a variable, you can create a single measure that calculates the same result: - -```dax -YoY% = VAR Sales = SUM(SalesTable[SalesAmount]) +By using a variable, you can create a single measure that calculates the same result: +```dax +YoY% = +VAR Sales = + SUM ( Sales[Sales Amount] ) VAR SalesLastYear = - CALCULATE ( SUM ( SalesTable[SalesAmount] ), SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) ) - - return if(Sales, DIVIDE(Sales – SalesLastYear, Sales)) + CALCULATE ( SUM ( Sales[Sales Amount] ), SAMEPERIODLASTYEAR ( 'Date'[Date] ) ) +RETURN + IF ( Sales && SalesLastYear, DIVIDE ( Sales - SalesLastYear, SalesLastYear ) ) ``` By using a variable, you can get the same outcome, but in a more readable way. And because the result of the expression is stored in the variable, the measure's performance can be significantly improved because it doesn't have to be recalculated each time it's used. -## See also +## Related content + [Use variables to improve your DAX formulas](best-practices/dax-variables.md) + +[DAX queries](dax-queries.md) diff --git a/query-languages/dax/var-p-function-dax.md b/query-languages/dax/var-p-function-dax.md index 901baa86b..298a59ea6 100644 --- a/query-languages/dax/var-p-function-dax.md +++ b/query-languages/dax/var-p-function-dax.md @@ -1,58 +1,51 @@ --- description: "Learn more about: VAR.P" -title: "VAR.P function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "VAR.P function (DAX)" --- # VAR.P -Returns the variance of the entire population. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the variance of the entire population. + +## Syntax + ```dax -VAR.P() +VAR.P() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| columnName | The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. | - +### Parameters + +|Term|Definition| +|--------|--------------| +|`columnName` | The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. | + ## Return value -A number with the variance of the entire population. - -## Remarks - -- VAR.P assumes that the column refers the entire population. If your data represents a sample of the population, then compute the variance by using VAR.S. - -- VAR.P uses the following formula: - - ∑(x - x̃)2/n - - where x̃ is the average value of x for the entire population - - and n is the population size - -- Blank rows are filtered out from *columnName* and not considered in the calculations. - -- An error is returned if *columnName* contains less than 2 non-blank rows - +A number with the variance of the entire population. + +## Remarks + +- VAR.P assumes that the column refers the entire population. If your data represents a sample of the population, then compute the variance by using VAR.S. + +- VAR.P uses the following formula: + + ∑(x - x̃)2/n + + where x̃ is the average value of x for the entire population + + and n is the population size + +- Blank rows are filtered out from `columnName` and not considered in the calculations. + +- An error is returned if `columnName` contains less than 2 non-blank rows + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows the formula for a measure that estimates the variance of the SalesAmount_USD column from the InternetSales_USD table, for the entire population. - +The following example shows the formula for a measure that estimates the variance of the SalesAmount_USD column from the InternetSales_USD table, for the entire population. + ```dax -= VAR.P(InternetSales_USD[SalesAmount_USD]) += VAR.P(InternetSales_USD[SalesAmount_USD]) ``` diff --git a/query-languages/dax/var-s-function-dax.md b/query-languages/dax/var-s-function-dax.md index 75c4e9747..864aa8d6d 100644 --- a/query-languages/dax/var-s-function-dax.md +++ b/query-languages/dax/var-s-function-dax.md @@ -1,58 +1,51 @@ --- description: "Learn more about: VAR.S" -title: "VAR.S function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "VAR.S function (DAX)" --- # VAR.S -Returns the variance of a sample population. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the variance of a sample population. + +## Syntax + ```dax -VAR.S() +VAR.S() ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| columnName | The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. | +### Parameters + +|Term|Definition| +|--------|--------------| +|`columnName`| The name of an existing column using standard DAX syntax, usually fully qualified. It cannot be an expression. | ## Return value -A number with the variance of a sample population. - -## Remarks - -- VAR.S assumes that the column refers to a sample of the population. If your data represents the entire population, then compute the variance by using VAR.P. - -- VAR.S uses the following formula: - - ∑(x - x̃)2/(n-1) - - where x̃ is the average value of x for the sample population - - and n is the population size - -- Blank rows are filtered out from *columnName* and not considered in the calculations. - -- An error is returned if *columnName* contains less than 2 non-blank rows. - +A number with the variance of a sample population. + +## Remarks + +- VAR.S assumes that the column refers to a sample of the population. If your data represents the entire population, then compute the variance by using VAR.P. + +- VAR.S uses the following formula: + + ∑(x - x̃)2/(n-1) + + where x̃ is the average value of x for the sample population + + and n is the population size + +- Blank rows are filtered out from `columnName` and not considered in the calculations. + +- An error is returned if `columnName` contains less than 2 non-blank rows. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows the formula for a measure that calculates the variance of the SalesAmount_USD column from the InternetSales_USD for a sample population. - +The following example shows the formula for a measure that calculates the variance of the SalesAmount_USD column from the InternetSales_USD for a sample population. + ```dax -= VAR.S(InternetSales_USD[SalesAmount_USD]) += VAR.S(InternetSales_USD[SalesAmount_USD]) ``` diff --git a/query-languages/dax/varx-p-function-dax.md b/query-languages/dax/varx-p-function-dax.md index d397050ff..702b053f7 100644 --- a/query-languages/dax/varx-p-function-dax.md +++ b/query-languages/dax/varx-p-function-dax.md @@ -1,59 +1,52 @@ --- description: "Learn more about: VARX.P" -title: "VARX.P function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "VARX.P function (DAX)" --- # VARX.P -Returns the variance of the entire population. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the variance of the entire population. + +## Syntax + ```dax -VARX.P(
, ) +VARX.P(
, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -| table| Any DAX expression that returns a table of data. | -| expression | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`| Any DAX expression that returns a table of data. | +|`expression`| Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | + ## Return value -A number with the variance of the entire population. - -## Remarks - -- VARX.P evaluates <expression> for each row of <table> and returns the variance of <expression> assuming that <table> refers to the entire population.. If <table> represents a sample of the population, then compute the variance by using VARX.S. - -- VARX.P uses the following formula: - - ∑(x - x̃)2/n - - where x̃ is the average value of x for the entire population - - and n is the population size - -- Blank rows are filtered out from *columnName* and not considered in the calculations. - -- An error is returned if *columnName* contains less than 2 non-blank rows - +A number with the variance of the entire population. + +## Remarks + +- VARX.P evaluates <expression> for each row of <table> and returns the variance of <expression> assuming that <table> refers to the entire population.. If <table> represents a sample of the population, then compute the variance by using VARX.S. + +- VARX.P uses the following formula: + + ∑(x - x̃)2/n + + where x̃ is the average value of x for the entire population + + and n is the population size + +- Blank rows are filtered out from `columnName` and not considered in the calculations. + +- An error is returned if `columnName` contains less than 2 non-blank rows + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows the formula for a calculated column that calculates the variance of the unit price per product, when the formula is used in the Product table - +The following example shows the formula for a calculated column that calculates the variance of the unit price per product, when the formula is used in the Product table + ```dax -= VARX.P(InternetSales_USD, InternetSales_USD[UnitPrice_USD] –(InternetSales_USD[DiscountAmount_USD]/InternetSales_USD[OrderQuantity])) += VARX.P(InternetSales_USD, InternetSales_USD[UnitPrice_USD] –(InternetSales_USD[DiscountAmount_USD]/InternetSales_USD[OrderQuantity])) ``` diff --git a/query-languages/dax/varx-s-function-dax.md b/query-languages/dax/varx-s-function-dax.md index 7041fb100..bc4c6b86d 100644 --- a/query-languages/dax/varx-s-function-dax.md +++ b/query-languages/dax/varx-s-function-dax.md @@ -1,59 +1,52 @@ --- description: "Learn more about: VARX.S" -title: "VARX.S function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "VARX.S function (DAX)" --- # VARX.S -Returns the variance of a sample population. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the variance of a sample population. + +## Syntax + ```dax -VARX.S(
, ) +VARX.S(
, ) ``` - -### Parameters -|Term|Definition| -|--------|--------------| -| table | Any DAX expression that returns a table of data. | -| expression | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | +### Parameters + +|Term|Definition| +|--------|--------------| +|`table` | Any DAX expression that returns a table of data. | +|`expression` | Any DAX expression that returns a single scalar value, where the expression is to be evaluated multiple times (for each row/context). | ## Return value -A number that represents the variance of a sample population. - -## Remarks - -- VARX.S evaluates *expression* for each row of *table* and returns the variance of *expression*; on the assumption that *table* refers to a sample of the population. If *table* represents the entire population, then you should compute the variance by using VARX.P. - -- VAR.S uses the following formula: - - ∑(x - x̃)2/(n-1) - - where x̃ is the average value of x for the sample population - - and n is the population size - -- Blank rows are filtered out from *columnName* and not considered in the calculations. - -- An error is returned if *columnName* contains less than 2 non-blank rows. - +A number that represents the variance of a sample population. + +## Remarks + +- VARX.S evaluates `expression` for each row of `table` and returns the variance of `expression`; on the assumption that `table` refers to a sample of the population. If `table` represents the entire population, then you should compute the variance by using VARX.P. + +- VAR.S uses the following formula: + + ∑(x - x̃)2/(n-1) + + where x̃ is the average value of x for the sample population + + and n is the population size + +- Blank rows are filtered out from `columnName` and not considered in the calculations. + +- An error is returned if `columnName` contains less than 2 non-blank rows. + - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] - + ## Example -The following example shows the formula for a calculated column that estimates the variance of the unit price per product for a sample population, when the formula is used in the Product table. - +The following example shows the formula for a calculated column that estimates the variance of the unit price per product for a sample population, when the formula is used in the Product table. + ```dax -= VARX.S(InternetSales_USD, InternetSales_USD[UnitPrice_USD] – (InternetSales_USD[DiscountAmount_USD]/InternetSales_USD[OrderQuantity])) += VARX.S(InternetSales_USD, InternetSales_USD[UnitPrice_USD] – (InternetSales_USD[DiscountAmount_USD]/InternetSales_USD[OrderQuantity])) ``` diff --git a/query-languages/dax/vdb-function-dax.md b/query-languages/dax/vdb-function-dax.md index 1fbbab7e6..e9f15b55e 100644 --- a/query-languages/dax/vdb-function-dax.md +++ b/query-languages/dax/vdb-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: VDB" -title: "VDB function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "VDB function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # VDB +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the depreciation of an asset for any period you specify, including partial periods, using the double-declining balance method or some other method you specify. VDB stands for variable declining balance. ## Syntax @@ -24,15 +18,15 @@ VDB(, , , , [, [, - If no_switch evaluates to TRUE, VDB does not switch to straight-line depreciation, even when the depreciation is greater than the declining balance calculation.
- If no_switch evaluates to FALSE or is omitted, VDB switches to straight-line depreciation when depreciation is greater than the declining balance calculation.| +|Term|Definition| +|--------|--------------| +|`cost`|The initial cost of the asset.| +|`salvage`|The value at the end of the depreciation (sometimes called the salvage value of the asset). This value can be 0.| +|`life`|The number of periods over which the asset is being depreciated (sometimes called the useful life of the asset).| +|`start_period`|The starting period for which you want to calculate the depreciation. Start_period must use the same units as life. Must be between 1 and life (inclusive).| +|`end_period`|The ending period for which you want to calculate the depreciation. End_period must use the same units as life. Must be between start_period and life (inclusive).| +|`factor`|(Optional) The rate at which the balance declines. If factor is omitted, it is assumed to be 2 (the double-declining balance method). Change factor if you do not want to use the double-declining balance method. For a description of the double-declining balance method, see DDB.| +|`no_switch`|(Optional) A logical value specifying whether to switch to straight-line depreciation when depreciation is greater than the declining balance calculation. If omitted, it is assumed to be `FALSE`.
- If no_switch evaluates to `TRUE` VDB does not switch to straight-line depreciation, even when the depreciation is greater than the declining balance calculation.
- If no_switch evaluates to `FALSE` or is omitted, VDB switches to straight-line depreciation when depreciation is greater than the declining balance calculation.| ## Return Value @@ -47,7 +41,7 @@ The depreciation over the specified period. - start_period < 1 or start_period > end_period. - end_period < start_period or end_period > life. - factor < 0. - - no_switch does not evaluate to either TRUE or FALSE. + - no_switch does not evaluate to either `TRUE` or `FALSE`. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] diff --git a/query-languages/dax/virtual-column-statement-dax.md b/query-languages/dax/virtual-column-statement-dax.md new file mode 100644 index 000000000..776f5e738 --- /dev/null +++ b/query-languages/dax/virtual-column-statement-dax.md @@ -0,0 +1,47 @@ +--- +description: "Learn more about: Virtual Column" +title: "Virtual Column (DAX) | Microsoft Docs" +--- +# Virtual Column + +Introduces a virtual column definition in a DEFINE statement of a [DAX query](dax-queries.md). + +## Syntax + +```dax +[DEFINE + ( + COLUMN
[] = + ) + +] + +(EVALUATE
) + +``` + +### Parameters + +Scalar expression defines the content of virtual column. The expression is evaluated row by row on the table. The virtual column is only defined in the scope of current query. + +## Return value + +A virtual column is defined + +## Remarks + +- Virtual column is computed on-demand even for import model. This behavior is different from calculated column which is processed during refresh time. + +- For DirectQuery table, the scalar expression is subject to data source capability. The limitation is the same as DirectQuery calculated column. + +- Please carefully evaluate performance impact when defining a virtual column on a table with huge number of rows. + +- When defining virtual column over a virtual table with visual shape, this virtual column is considered a visual calculation, and subject to visual calculation limitations. + +- [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] + +## Related content + +[DEFINE](define-statement-dax.md) +[EVALUATE](evaluate-statement-dax.md) +[VAR](var-dax.md) +[Virtual Table](virtual-table-statement-dax.md) +[DAX queries](dax-queries.md) diff --git a/query-languages/dax/virtual-table-statement-dax.md b/query-languages/dax/virtual-table-statement-dax.md new file mode 100644 index 000000000..9bcc752da --- /dev/null +++ b/query-languages/dax/virtual-table-statement-dax.md @@ -0,0 +1,86 @@ +--- +description: "Learn more about: Virtual Table" +title: "Virtual Table (DAX) | Microsoft Docs" +--- +# Virtual Table + +Introduces a virtual table definition in a DEFINE statement of a [DAX query](dax-queries.md). + +## Syntax + +```dax +[DEFINE + ( + TABLE
=
+ [WITH VISUAL SHAPE + (AXIS + (GROUP [, ] + TOTAL ) + + ORDER BY [, ] + + ) + + [DENSIFY ] + ] + ) + +] + +(EVALUATE
) + +``` + +### Parameters + +Table expression defines the content of the virtual table. The virtual table is only defined in the scope of current query. + +Optionally a visual shape can be defined on the virtual table. Visual shape is used for visual calculation. A visual shape consists of axes with optionally a Boolean DENSIFY column. + +Axis is defined to be a list of rollup groups followed by a list of order by columns to specify how the axis is ordered. A rollup group consists of one or more group by columns and then one Boolean TOTAL column indicating whether each row is subtotal of the current rollup group. FALSE value indicates that current row is detail row (grouping by current rollup group). TRUE value indicates current row is rolled up (not grouping by current rollup group). + +If DENSIFY column is requested, then the visual shape performs a densification. This means in addition to the rows from original table expression, we also add combination of axes values that do not exist in the original table expression. In other words, we do a left outer join from the cross join of axes with the original table expression. A TRUE value in DENSIFY column indicates the current row is not in the original table expression and added by the densification process. Such row should have empty value in all measure columns (columns outside axes definitions). A FALSE value in DENSIFY column indicates the current row is from the original table expression. + +## Return value + +A virtual table is defined + +## Remark + +Unlike variables, virtual table has lineage of its own, and does not carry the lineage from the table expression it's defined from. + +## Example + +Assume a table T has following rows: + +|Year|Product|SalesAmount| +|----------|---------|---------| +|2000|Apple|$ 10.1| +|2000|Banana|$ 10.2| +|2001|Apple|$ 20.3| + +```dax +DEFINE TABLE data = SUMMARIZECOLUMNS(ROLLUPADDISSUBTOTAL(T[Year], "IsYearTotal"), ROLLUPADDISSUBTOTAL(T[Product], "IsProductTotal"), "Meausre", SUM(T[SalesAmount])) + WITH VISUAL SHAPE + AXIS ROWS GROUP [Year] TOTAL [IsYearTotal] ORDER BY [Year] + AXIS COLUMNS GROUP [Product] TOTAL [IsProductTotal] ORDER BY [Product] + DENSIFY "IsDensified" +EVALUATE data +``` + +The returned result is + +|data[Year]|data[Product]|data[IsYearTotal]|data[IsProductTotal]|data[Measure]|data[IsDensified]| +|----------|---------|---------|---------|---------|---------| +|||true|true|$ 40.6|false| +|2000||false|true|$ 20.3|false| +|2001||false|true|$ 20.3|false| +||Apple|true|false|$ 30.4|false| +|2000|Apple|false|false|$ 10.1|false| +|2001|Apple|false|false|$ 20.3|false| +||Banana|true|false|$ 10.2|false| +|2000|Banana|false|false|$ 10.2|false| +|2001|Banana|false|false||true| + + +## Related content + +[DEFINE](define-statement-dax.md) +[EVALUATE](evaluate-statement-dax.md) +[VAR](var-dax.md) +[Virtual Column](virtual-column-statement-dax.md) +[DAX queries](dax-queries.md) diff --git a/query-languages/dax/weekday-function-dax.md b/query-languages/dax/weekday-function-dax.md index 962eccea5..ce7da9185 100644 --- a/query-languages/dax/weekday-function-dax.md +++ b/query-languages/dax/weekday-function-dax.md @@ -1,55 +1,48 @@ --- description: "Learn more about: WEEKDAY" -title: "WEEKDAY function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "WEEKDAY function (DAX)" --- # WEEKDAY -Returns a number from 1 to 7 identifying the day of the week of a date. By default the day ranges from 1 (Sunday) to 7 (Saturday). - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns a number from 1 to 7 identifying the day of the week of a date. By default the day ranges from 1 (Sunday) to 7 (Saturday). + +## Syntax + ```dax -WEEKDAY(, ) +WEEKDAY(, ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|date|A date in **datetime** format.

Dates should be entered by using the DATE function, by using expressions that result in a date, or as the result of other formulas.| -|return_type|A number that determines the Return value:

Return type: **1**, week begins on Sunday (1) and ends on Saturday (7). numbered 1 through 7.

Return type: **2**, week begins on Monday (1) and ends on Sunday (7).

Return type: **3**, week begins on Monday (0) and ends on Sunday (6).numbered 1 through 7.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`date`|A date in `datetime` format.

Dates should be entered by using the DATE function, by using expressions that result in a date, or as the result of other formulas.| +|`return_type`|A number that determines the Return value:

Return type: **1**, week begins on Sunday (1) and ends on Saturday (7). numbered 1 through 7.

Return type: **2**, week begins on Monday (1) and ends on Sunday (7).

Return type: **3**, week begins on Monday (0) and ends on Sunday (6).numbered 0 through 6.| + ## Return value -An integer number from 1 to 7. - +An integer number from 1 to 7. + ## Remarks -- In contrast to Microsoft Excel, which stores dates as serial numbers, DAX works with dates and times in a **datetime** format. If you need to display dates as serial numbers, you can use the formatting options in Excel. - -- You can also type dates in an accepted text representation of a date, but to avoid unexpected results, it is best to convert the text date to a **datetime** format first. - -- When the date argument is a text representation of the date, the function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. If the current date/time settings represent dates in the format of Month/Day/Year, then the string, "1/8/2009", is interpreted as a **datetime** value equivalent to January 8th of 2009. However, if the current date/time settings represent dates in the format of Day/Month/Year, then the same string would be interpreted as a **datetime** value equivalent to August 1st of 2009. - +- In contrast to Microsoft Excel, which stores dates as serial numbers, DAX works with dates and times in a `datetime` format. If you need to display dates as serial numbers, you can use the formatting options in Excel. + +- You can also type dates in an accepted text representation of a date, but to avoid unexpected results, it is best to convert the text date to a `datetime` format first. + +- When the date argument is a text representation of the date, the function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. If the current date/time settings represent dates in the format of Month/Day/Year, then the string, "1/8/2009", is interpreted as a `datetime` value equivalent to January 8th of 2009. However, if the current date/time settings represent dates in the format of Day/Month/Year, then the same string would be interpreted as a `datetime` value equivalent to August 1st of 2009. + ## Example -The following example gets the date from the [HireDate] column, adds 1, and displays the weekday corresponding to that date. Because the **return_type** argument has been omitted, the default format is used, in which 1 is Sunday and 7 is Saturday. If the result is 4, the day would be Wednesday. - +The following example gets the date from the [HireDate] column, adds 1, and displays the weekday corresponding to that date. Because the `return_type` argument has been omitted, the default format is used, in which 1 is Sunday and 7 is Saturday. If the result is 4, the day would be Wednesday. + ```dax -= WEEKDAY([HireDate]+1) += WEEKDAY([HireDate]+1) ``` - -## See also -[Date and time functions](date-and-time-functions-dax.md) -[WEEKNUM function](weeknum-function-dax.md) +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[WEEKNUM function](weeknum-function-dax.md) [YEARFRAC function](yearfrac-function-dax.md) diff --git a/query-languages/dax/weeknum-function-dax.md b/query-languages/dax/weeknum-function-dax.md index 33923b88e..e3d1f3896 100644 --- a/query-languages/dax/weeknum-function-dax.md +++ b/query-languages/dax/weeknum-function-dax.md @@ -1,48 +1,40 @@ --- description: "Learn more about: WEEKNUM" -title: "WEEKNUM function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 06/15/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "WEEKNUM function (DAX)" --- # WEEKNUM -Returns the week number for the given date according to the **return_type** value. The week number indicates where the week falls numerically within a year. +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the week number for the given date according to the `return_type` value. The week number indicates where the week falls numerically within a year. There are two *systems* used for this function: - **System 1** - The week containing January 1 is the first week of the year and is numbered week 1. - **System 2** - The week containing the first Thursday of the year is the first week of the year and is numbered as week 1. This system is the methodology specified in ISO 8601, which is commonly known as the European week numbering system. - -## Syntax - + +## Syntax + ```dax -WEEKNUM([, ]) +WEEKNUM([, ]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|date|The date in **datetime** format.| -|return_type|(Optional) A number that determines on which day the week begins. Default is 1. See Remarks. -| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`date`|The date in `datetime` format.| +|`return_type`|(Optional) A number that determines on which day the week begins. Default is 1. See Remarks. | + ## Return value -An integer number. - +An integer number. + ## Remarks -- By default, the WEEKNUM function uses a calendar convention in which the week containing January 1 is considered to be the first week of the year. However, the ISO 8601 calendar standard, widely used in Europe, defines the first week as the one with the majority of days (four or more) falling in the new year. This means that if **return_type** is any valid value other than 21, for any years in which there are three days or less in the first week of January, the WEEKNUM function returns week numbers that are different from the ISO 8601 definition. +- By default, the WEEKNUM function uses a calendar convention in which the week containing January 1 is considered to be the first week of the year. However, the ISO 8601 calendar standard, widely used in Europe, defines the first week as the one with the majority of days (four or more) falling in the new year. This means that if `return_type` is any valid value other than 21, for any years in which there are three days or less in the first week of January, the WEEKNUM function returns week numbers that are different from the ISO 8601 definition. -- For **return_type**, except for 21, the following valid values may not be supported by some DirectQuery data sources: +- For `return_type`, the following valid values may not be supported by some DirectQuery data sources: |return_type |Week begins on |System | |---------|---------|---------| @@ -73,7 +65,7 @@ The following example returns the week number of the date stored in the column, = WEEKNUM('Employees'[HireDate]) ``` -## See also +## Related content -[YEARFRAC function](yearfrac-function-dax.md) +[YEARFRAC function](yearfrac-function-dax.md) [WEEKDAY function](weekday-function-dax.md) diff --git a/query-languages/dax/window-function-dax.md b/query-languages/dax/window-function-dax.md new file mode 100644 index 000000000..02050e727 --- /dev/null +++ b/query-languages/dax/window-function-dax.md @@ -0,0 +1,186 @@ +--- +description: "Learn more about: WINDOW" +title: "WINDOW function (DAX)" +--- + +# WINDOW + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns multiple rows which are positioned within the given interval. + +## Syntax + +```dax +WINDOW ( from[, from_type], to[, to_type][, or ][, ][, ][, ][, ][, ] ) +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`from`|Indicates where the window starts. It can be any DAX expression that returns a scalar value.
The behavior depends on the `from_type` parameter:
- If `from_type` is REL, the number of rows to go back (negative value) or forward (positive value) from the current row to get the first row in the window.
- If `from_type` is ABS, and `from` is positive, then it’s the position of the start of the window from beginning of the partition. Indexing is 1-based and 0 is interpreted as 1. For example, 0 and 1 mean the window starts from the beginning of the partition. If `from` is negative, then it’s the position of the start of the window from the end of the partition. -1 means the last row in the partition. | +|`from_type` |Modifies behavior of the `from` parameter. Possible values are ABS (absolute) and REL (relative). Default is REL.| +|`to`|Same as `from`, but indicates the end of the window. The last row is included in the window.| +|`to_type`|Same as `from_type`, but modifies the behavior of `to`.| +|`relation`|(Optional) A table expression from which the output rows are returned. If used in visual calculations, this parameter accepts an axis in the visual shape.
If specified, all columns in `partitionBy` must come from it or a related table.
If omitted:
- `orderBy` must be explicitly specified.
- All `orderBy` and `partitionBy` expressions must be fully qualified column names and come from a single table.
- Defaults to ALLSELECTED() of all columns in `orderBy` and `partitionBy`.| +|`orderBy`|(Optional) An ORDERBY() clause containing the expressions that define how each partition is sorted.
If omitted:
- `relation` must be explicitly specified.
- Defaults to ordering by every column in `relation` that is not already specified in `partitionBy`.| +|`blanks`|(Optional) An enumeration that defines how to handle blank values when sorting the `relation` or `axis`.
The supported values are:
  • `DEFAULT` (the default value), where the behavior for numerical values is blank values are ordered between zero and negative values. The behavior for strings is blank values are ordered before all strings, including empty strings.
  • `FIRST`, blanks are always ordered on the beginning, regardless of ascending or descending sorting order.
  • `LAST`, blanks are always ordered on the end, regardless of ascending or descending sorting order.

Note, when the `blanks` parameter and blanks in the [ORDERBY()](orderby-function-dax.md) function on individual expressions are both specified, `blanks` on individual orderBy expression takes priority for the relevant orderBy expression, and orderBy expressions without `blanks` being specified will honor the `blanks` parameter on the parent function.| +|`partitionBy`|(Optional) A [PARTITIONBY()](partitionby-function-dax.md) clause containing the columns that define how `relation` is partitioned. If omitted, `relation` is treated as a single partition.| +|`matchBy`|(Optional) A [MATCHBY()](matchby-function-dax.md) clause containing the columns that define how to match data and identify the current row.| +|`reset`|(Optional) Available in visual calculations only. Indicates if the calculation resets, and at which level of the visual shape's column hierarchy. Accepted values are: a field reference to a column in the current visual shape, `NONE` (default), `LOWESTPARENT`, `HIGHESTPARENT`, or an integer. The behavior depends on the integer sign:
- If zero or omitted, the calculation does not reset. Equivalent to `NONE`.
- If positive, the integer identifies the column starting from the highest, independent of grain. `HIGHESTPARENT` is equivalent to 1.
- If negative, the integer identifies the column starting from the lowest, relative to the current grain. `LOWESTPARENT` is equivalent to -1.| + +## Return value + +All rows from the window. + +## Remarks +Except for columns added by DAX table functions, each column in `relation`, when `matchBy` is not present, or each column in `matchBy` and `partitionBy`, when `matchBy` is present, must have a corresponding outer value to help define the current row on which to operate. If `from_type` and `to_type` both have value ABS, then the following applies only to the `partitionBy` columns: + +- If there is exactly one corresponding outer column, its value is used. +- If there is no corresponding outer column: + - WINDOW will first determine all columns that have no corresponding outer column. + - For every combination of existing values for these columns in WINDOW’s parent context, WINDOW is evaluated, and the corresponding rows is returned. + - WINDOW final output is a union of these rows. +- If there is more than one corresponding outer column, an error is returned. + +If all of `relation`'s columns were added by DAX table functions, an error is returned. + +If `matchBy` is present, WINDOW will try to use `matchBy` and `partitionBy` columns to identify the row. +If `matchBy` is not present and the columns specified within `orderBy` and `partitionBy` cannot uniquely identify every row in `relation`, then: + +- WINDOW will try to find the least number of additional columns required to uniquely identify every row. +- If such columns can be found, WINDOW will automatically append these new columns to `orderBy`, and each partition is sorted using this new set of orderBy columns. +- If such columns cannot be found, an error is returned. + +An empty table is returned if: + +- The corresponding outer value of an `orderBy` or `partitionBy` column does not exist within `relation`. +- The whole window is outside the partition, or the beginning of the window is after its ending. + +If WINDOW is used within a calculated column defined on the same table as `relation`, and `orderBy` is omitted, an error is returned. + +If the beginning of the window turns out be before the first row, then it’s set to the first row. Similarly, if the end of the window is after the last row of the partition, then it's set to the last row. + +`reset` can be used in visual calculations only, and cannot be used in combination with `orderBy` or `partitionBy`. If `reset` is present, `axis` can be specified but `relation` cannot. + +If the value of `reset` is absolute (i.e., a positive integer, `HIGHESTPARENT` or a field reference) and the calculation is evaluated at or above the target level in the hierarchy, the calculation resets for each individual element. That is, the function is evaluated within a partition containing only that specific element. + +## Example 1 - measure + +The following measure: + +```dax +3-day Average Price = +AVERAGEX( + WINDOW( + -2,REL,0,REL, + SUMMARIZE(ALLSELECTED('Sales'), 'Date'[Date], 'Product'[Product]), + ORDERBY('Date'[Date]), + KEEP, + PARTITIONBY('Product'[Product]) + ), + CALCULATE(AVERAGE(Sales[Unit Price])) +) + +``` + +Returns the 3-day average of unit prices for each product. Note the 3-day window consists of three days in which the product has sales, not necessarily three consecutive calendar days. + +## Example 2 - measure + +The following measure: + +```dax +RunningSum = +SUMX ( + WINDOW ( + 1, ABS, 0, REL, + ALLSELECTED ( + 'Date'[Fiscal Year], + 'Date'[Month Number Of Year] + ), + PARTITIONBY ( 'Date'[Fiscal Year] ) + ), + [Total Sales] +) + +``` + +Returns the running sum for Total Sales by Month Number Of Year, restarting for every Fiscal Year: + +| Year | Month Number Of Year | Sales Amount | RunningSum | +|--------|----------------------|--------------|--------------| +| FY2018 | 1 | $1,327,675 | $1,327,675 | +| FY2018 | 2 | $3,936,463 | $5,264,138 | +| FY2018 | 3 | $700,873 | $5,965,011 | +| FY2018 | 4 | $1,519,275 | $7,484,286 | +| FY2018 | 5 | $2,960,378 | $10,444,664 | +| FY2018 | 6 | $1,487,671 | $11,932,336 | +| FY2018 | 7 | $1,423,357 | $13,355,693 | +| FY2018 | 8 | $2,057,902 | $15,413,595 | +| FY2018 | 9 | $2,523,948 | $17,937,543 | +| FY2018 | 10 | $561,681 | $18,499,224 | +| FY2018 | 11 | $4,764,920 | $23,264,145 | +| FY2018 | 12 | $596,747 | $23,860,891 | +| FY2019 | 1 | $1,847,692 | $1,847,692 | +| FY2019 | 2 | $2,829,362 | $4,677,054 | +| FY2019 | 3 | $2,092,434 | $6,769,488 | +| FY2019 | 4 | $2,405,971 | $9,175,459 | +| FY2019 | 5 | $3,459,444 | $12,634,903 | +| FY2019 | 6 | $2,850,649 | $15,485,552 | +| FY2019 | 7 | $2,939,691 | $18,425,243 | +| FY2019 | 8 | $3,964,801 | $22,390,045 | +| FY2019 | 9 | $3,287,606 | $25,677,650 | +| FY2019 | 10 | $2,157,287 | $27,834,938 | +| FY2019 | 11 | $3,611,092 | $31,446,030 | +| FY2019 | 12 | $2,624,078 | $34,070,109 | +| FY2020 | 1 | $3,235,187 | $3,235,187 | +| FY2020 | 2 | $4,070,046 | $7,305,233 | +| FY2020 | 3 | $4,429,833 | $11,735,066 | +| FY2020 | 4 | $4,002,614 | $15,737,680 | +| FY2020 | 5 | $5,265,797 | $21,003,477 | +| FY2020 | 6 | $3,465,241 | $24,468,717 | +| FY2020 | 7 | $3,513,064 | $27,981,781 | +| FY2020 | 8 | $5,247,165 | $33,228,947 | +| FY2020 | 9 | $5,104,088 | $38,333,035 | +| FY2020 | 10 | $3,542,150 | $41,875,184 | +| FY2020 | 11 | $5,151,897 | $47,027,081 | +| FY2020 | 12 | $4,851,194 | $51,878,275 | + +## Example 3 - visual calculation + +The following visual calculation DAX query: + +```dax +TotalSalesRunningSumByYear = SUMX(WINDOW(0, ABS, 0, REL, ROWS, HIGHESTPARENT), [SalesAmount]) +``` + +Returns the cumulative total sales by month, calculated along each year. The value 1 could be used instead of `HIGHESTPARENT`, with the same result. + +The screenshot below shows the visual matrix and the visual calculation expression: + +![DAX visual calculation](media/dax-queries/dax-visualcalc-window.png) + +## Example 4 - visual calculation + +The following visual calculation DAX query: + +```dax +TotalSalesRunningSumByQuarter = SUMX(WINDOW(0, ABS, 0, REL, , -1), [SalesAmount]) +``` + +Returns the cumulative total sales by month, calculated along each quarter. +The value `LOWESTPARENT` could be used instead of -1, with the same result. + +## Related content + +[INDEX](index-function-dax.md) +[MOVINGAVERAGE](movingaverage-function-dax.md) +[OFFSET](offset-function-dax.md) +[ORDERBY](orderby-function-dax.md) +[PARTITIONBY](partitionby-function-dax.md) +[RANGE](range-function-dax.md) +[RANK](rank-function-dax.md) +[ROWNUMBER](rownumber-function-dax.md) +[RUNNINGSUM](runningsum-function-dax.md) diff --git a/query-languages/dax/xirr-function-dax.md b/query-languages/dax/xirr-function-dax.md index b201a3a2b..4d5b5d2fe 100644 --- a/query-languages/dax/xirr-function-dax.md +++ b/query-languages/dax/xirr-function-dax.md @@ -1,45 +1,38 @@ --- description: "Learn more about: XIRR" -title: "XIRR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 12/17/2021 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "XIRR function (DAX)" --- # XIRR - -Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic. + +## Syntax + ```dax -XIRR(
, , , [, [, ]]) +XIRR(
, , , [, [, ]]) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|A table for which the values and dates expressions should be calculated.| -|values|An expression that returns the cash flow value for each row of the table.| -|dates|An expression that returns the cash flow date for each row of the table.| -|guess|(Optional) An initial guess for the internal rate of return. If omitted, the default guess of 0.1 is used.| -|alternateResult | (Optional) A value returned in place of an error when a solution cannot be determined.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|A table for which the values and dates expressions should be calculated.| +|`values`|An expression that returns the cash flow value for each row of the table.| +|`dates`|An expression that returns the cash flow date for each row of the table.| +|`guess`|(Optional) An initial guess for the internal rate of return. If omitted, the default guess of 0.1 is used.| +|`alternateResult` | (Optional) A value returned in place of an error when a solution cannot be determined.| + ## Return value Internal rate of return for the given inputs. If the calculation fails to return a valid result, an error or value specified as alternateResult is returned. - + ## Remarks -- The value is calculated as the rate that satisfies the following function: +- The value is calculated as the rate that satisfies the following function: - $$\sum^{N}\_{j=1} \frac{P\_{j}}{(1 + \text{rate})^{\frac{d\_{j} - d\_{1}}{365}}}$$ + $$0=\sum^{N}\_{j=1} \frac{P\_{j}}{(1 + \text{rate})^{\frac{d\_{j} - d\_{1}}{365}}}$$ Where: @@ -47,28 +40,32 @@ Internal rate of return for the given inputs. If the calculation fails to return - $d\_{j}$ is the $j^{th}$ payment date - $d\_{1}$ is the first payment date -- The series of cash flow values must contain at least one positive number and one negative number. +- The series of cash flow values must contain at least one positive number and one negative number. - Avoid using ISERROR or IFERROR functions to capture an error returned by XIRR. If some inputs to the function may result in a no solution error, providing an alternateResult parameter is the most reliable and highest performing way to handle the error. -- To learn more about using the alternateResult parameter, be to check out this [video](https://www.microsoft.com/videoplayer/embed/RWLzrC). +- To learn more about using the alternateResult parameter, be to check out this [video](https://learn-video.azurefd.net/vod/player?id=f3170134-1c7f-47ff-82d7-f419404e3a0e). + +- When the absolute value of initial payment is small, the calculation likely fails to return a valid result. + +- Avoid including 0 values in payments. They will not impact the final result, and using 0 as initial payment will fail XIRR() calculation always. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following formula calculates the internal rate of return of the CashFlows table: - +The following formula calculates the internal rate of return of the CashFlows table: + ```dax -= XIRR( CashFlows, [Payment], [Date] ) += XIRR( CashFlows, [Payment], [Date] ) ``` - -|Date|Payment| -|--------|-----------| -|1/1/2014|-10000| -|3/1/2014|2750| -|10/30/2014|4250| -|2/15/2015|3250| -|4/1/2015|2750| - -Rate of return = 37.49% + +|Date|Payment| +|--------|-----------| +|1/1/2014|-10000| +|3/1/2014|2750| +|10/30/2014|4250| +|2/15/2015|3250| +|4/1/2015|2750| + +Rate of return = 37.49% diff --git a/query-languages/dax/xnpv-function-dax.md b/query-languages/dax/xnpv-function-dax.md index feff7ef73..551986ffb 100644 --- a/query-languages/dax/xnpv-function-dax.md +++ b/query-languages/dax/xnpv-function-dax.md @@ -1,42 +1,35 @@ --- description: "Learn more about: XNPV" -title: "XNPV function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 08/07/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "XNPV function (DAX)" --- # XNPV - -Returns the present value for a schedule of cash flows that is not necessarily periodic. - -## Syntax - + +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the present value for a schedule of cash flows that is not necessarily periodic. + +## Syntax + ```dax -XNPV(
, , , ) +XNPV(
, , , ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|table|A table for which the values and dates expressions should be calculated.| -|values|An expression that returns the cash flow value for each row of the table.| -|dates|An expression that returns the cash flow date for each row of the table.| -|rate|The discount rate to apply to the cash flow for each row of the table.| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`table`|A table for which the values and dates expressions should be calculated.| +|`values`|An expression that returns the cash flow value for each row of the table.| +|`dates`|An expression that returns the cash flow date for each row of the table.| +|`rate`|The discount rate to apply to the cash flow for each row of the table.| + ## Return value -Net present value. - +Net present value. + ## Remarks -- The value is calculated as the following summation: +- The value is calculated as the following summation: $$\sum^{N}\_{j=1} \frac{P\_{j}}{(1 + \text{rate})^{\frac{d\_{j} - d\_{1}}{365}}}$$ @@ -46,24 +39,24 @@ Net present value. - $d\_{j}$ is the $j^{th}$ payment date - $d\_{1}$ is the first payment date -- The series of cash flow values must contain at least one positive number and one negative number. +- The series of cash flow values must contain at least one positive number and one negative number. - [!INCLUDE [function-not-supported-in-directquery-mode](includes/function-not-supported-in-directquery-mode.md)] ## Example -The following calculates the present value of the CashFlows table: - +The following calculates the present value of the CashFlows table: + ```dax -= XNPV( CashFlows, [Payment], [Date], 0.09 ) += XNPV( CashFlows, [Payment], [Date], 0.09 ) ``` - -|Date|Payment| -|--------|-----------| -|1/1/2014|-10000| -|3/1/2014|2750| -|10/30/2014|4250| -|2/15/2015|3250| -|4/1/2015|2750| - -Present value = 2086.65 + +|`Date`|Payment| +|--------|-----------| +|`1/1/2014`|-10000| +|`3/1/2014`|2750| +|`10/30/2014`|4250| +|`2/15/2015`|3250| +|`4/1/2015`|2750| + +Present value = 2089.50 diff --git a/query-languages/dax/year-function-dax.md b/query-languages/dax/year-function-dax.md index 4948b2383..f540bfa78 100644 --- a/query-languages/dax/year-function-dax.md +++ b/query-languages/dax/year-function-dax.md @@ -1,68 +1,61 @@ --- description: "Learn more about: YEAR" -title: "YEAR function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "YEAR function (DAX)" --- # YEAR -Returns the year of a date as a four digit integer in the range 1900-9999. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Returns the year of a date as a four digit integer in the range 1900-9999. + +## Syntax + ```dax -YEAR() -``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|date|A date in **datetime** or text format, containing the year you want to find.| - +YEAR() +``` + +### Parameters + +|Term|Definition| +|--------|--------------| +|`date`|A date in `datetime` or text format, containing the year you want to find.| + ## Return value -An integer in the range 1900-9999. - +An integer in the range 1900-9999. + ## Remarks -- In contrast to Microsoft Excel, which stores dates as serial numbers, DAX uses a **datetime** data type to work with dates and times. - -- Dates should be entered by using the DATE function, or as results of other formulas or functions. You can also enter dates in accepted text representations of a date, such as March 3, 2007, or Mar-3-2003. - -- Values returned by the YEAR, MONTH, and DAY functions will be Gregorian values regardless of the display format for the supplied date value. For example, if the display format of the supplied date uses the Hijri calendar, the returned values for the YEAR, MONTH, and DAY functions will be values associated with the equivalent Gregorian date. - -- When the date argument is a text representation of the date, the function uses the locale and date time settings of the client computer to understand the text value in order to perform the conversion. Errors may arise if the format of strings is incompatible with the current locale settings. For example, if your locale defines dates to be formatted as month/day/year, and the date is provided as day/month/year, then 25/1/2009 will not be interpreted as January 25th of 2009 but as an invalid date. - +- In contrast to Microsoft Excel, which stores dates as serial numbers, DAX uses a `datetime` data type to work with dates and times. + +- Dates should be entered by using the DATE function, or as results of other formulas or functions. You can also enter dates in accepted text representations of a date, such as March 3, 2007, or Mar-3-2003. + +- Values returned by the YEAR, MONTH, and DAY functions will be Gregorian values regardless of the display format for the supplied date value. For example, if the display format of the supplied date uses the Hijri calendar, the returned values for the YEAR, MONTH, and DAY functions will be values associated with the equivalent Gregorian date. + +- When the date argument is a text representation of the date, the function uses the locale and date time settings of the client computer to understand the text value in order to perform the conversion. Errors may arise if the format of strings is incompatible with the current locale settings. For example, if your locale defines dates to be formatted as month/day/year, and the date is provided as day/month/year, then 25/1/2009 will not be interpreted as January 25th of 2009 but as an invalid date. + ## Example -The following example returns 2007. - +The following example returns 2007. + ```dax -= YEAR("March 2007") -``` - -## Example - Date as result of expression - += YEAR("March 2007") +``` + +## Example - Date as result of expression + ### Description -The following example returns the year for today's date. - +The following example returns the year for today's date. + ```dax -= YEAR(TODAY()) -``` - -## See also - -[Date and time functions](date-and-time-functions-dax.md) -[HOUR function](hour-function-dax.md) -[MINUTE function](minute-function-dax.md) -[YEAR function](year-function-dax.md) -[SECOND function](second-function-dax.md) += YEAR(TODAY()) +``` + +## Related content + +[Date and time functions](date-and-time-functions-dax.md) +[HOUR function](hour-function-dax.md) +[MINUTE function](minute-function-dax.md) +[YEAR function](year-function-dax.md) +[SECOND function](second-function-dax.md) diff --git a/query-languages/dax/yearfrac-function-dax.md b/query-languages/dax/yearfrac-function-dax.md index 8147b45bd..31dceba13 100644 --- a/query-languages/dax/yearfrac-function-dax.md +++ b/query-languages/dax/yearfrac-function-dax.md @@ -1,69 +1,62 @@ --- description: "Learn more about: YEARFRAC" -title: "YEARFRAC function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/13/2020 -ms.reviewer: owend -ms.topic: reference -author: minewiskan -ms.author: owend -recommendations: false - +title: "YEARFRAC function (DAX)" --- # YEARFRAC -Calculates the fraction of the year represented by the number of whole days between two dates. Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or obligations to assign to a specific term. - -## Syntax - +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + +Calculates the fraction of the year represented by the number of whole days between two dates. Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or obligations to assign to a specific term. + +## Syntax + ```dax -YEARFRAC(, , ) +YEARFRAC(, , ) ``` - -### Parameters - -|Term|Definition| -|--------|--------------| -|start_date|The start date in **datetime** format.| -|end_date|The end date in **datetime** format.| -|basis|(Optional) The type of day count basis to use. All arguments are truncated to integers.

Basis - Description

0 - US (NASD) 30/360

1 - Actual/actual

2 - Actual/360

3 - Actual/365

4 - European 30/360| - + +### Parameters + +|Term|Definition| +|--------|--------------| +|`start_date`|The start date in `datetime` format.| +|`end_date`|The end date in `datetime` format.| +|`basis`|(Optional) The type of day count basis to use. All arguments are truncated to integers.

Basis - Description

0 - US (NASD) 30/360 (Default value)

1 - Actual/actual

2 - Actual/360

3 - Actual/365

4 - European 30/360| + ## Return value -A decimal number. The internal data type is a signed IEEE 64-bit (8-byte) double-precision floating-point number. - +A decimal number. The internal data type is a signed IEEE 64-bit (8-byte) double-precision floating-point number. + ## Remarks -- In contrast to Microsoft Excel, which stores dates as serial numbers, DAX uses a **datetime** format to work with dates and times. If you need to view dates as serial numbers, you can use the formatting options in Excel. - -- If **start_date** or **end_date** are not valid dates, YEARFRAC returns an error. - -- If **basis** < 0 or if **basis** > 4, YEARFRAC returns an error. - +- In contrast to Microsoft Excel, which stores dates as serial numbers, DAX uses a `datetime` format to work with dates and times. If you need to view dates as serial numbers, you can use the formatting options in Excel. + +- If `start_date` or `end_date` are not valid dates, YEARFRAC returns an error. + +- If `basis` < 0 or if `basis` > 4, YEARFRAC returns an error. + ## Example 1 -The following example returns the fraction of a year represented by the difference between the dates in the two columns, `TransactionDate` and `ShippingDate`: - +The following example returns the fraction of a year represented by the difference between the dates in the two columns, `TransactionDate` and `ShippingDate`: + ```dax -= YEARFRAC(Orders[TransactionDate],Orders[ShippingDate]) += YEARFRAC(Orders[TransactionDate],Orders[ShippingDate]) ``` - + ## Example 2 -The following example returns the fraction of a year represented by the difference between the dates, January 1 and March 1: - +The following example returns the fraction of a year represented by the difference between the dates, January 1 and March 1: + ```dax -= YEARFRAC("Jan 1 2007","Mar 1 2007") += YEARFRAC("Jan 1 2007","Mar 1 2007") ``` -Use four-digit years whenever possible, to avoid getting unexpected results. When the year is truncated, the current year is assumed. When the date is or omitted, the first date of the month is assumed. - -The second argument, **basis**, has also been omitted. Therefore, the year fraction is calculated according to the US (NASD) 30/360 standard. - -## See also +Use four-digit years whenever possible, to avoid getting unexpected results. When the year is truncated, the current year is assumed. When the date is or omitted, the first date of the month is assumed. + +The second argument, `basis`, has also been omitted. Therefore, the year fraction is calculated according to the US (NASD) 30/360 standard. + +## Related content -[Date and time functions](date-and-time-functions-dax.md) -[WEEKNUM function](weeknum-function-dax.md) -[YEARFRAC function](yearfrac-function-dax.md) -[WEEKDAY function](weekday-function-dax.md) +[Date and time functions](date-and-time-functions-dax.md) +[WEEKNUM function](weeknum-function-dax.md) +[YEARFRAC function](yearfrac-function-dax.md) +[WEEKDAY function](weekday-function-dax.md) diff --git a/query-languages/dax/yield-function-dax.md b/query-languages/dax/yield-function-dax.md index 3c78988a6..f6c08ae0f 100644 --- a/query-languages/dax/yield-function-dax.md +++ b/query-languages/dax/yield-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: YIELD" -title: "YIELD function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "YIELD function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # YIELD +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the yield on a security that pays periodic interest. Use YIELD to calculate bond yield. ## Syntax @@ -24,19 +18,19 @@ YIELD(, , , , , [, , , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|pr|The security's price per \\$100 face value.| -|redemption|The security's redemption value per \\$100 face value.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`pr`|The security's price per \\$100 face value.| +|`redemption`|The security's redemption value per \\$100 face value.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | diff --git a/query-languages/dax/yieldmat-function-dax.md b/query-languages/dax/yieldmat-function-dax.md index 6941be1dc..c863c5414 100644 --- a/query-languages/dax/yieldmat-function-dax.md +++ b/query-languages/dax/yieldmat-function-dax.md @@ -1,19 +1,13 @@ --- description: "Learn more about: YIELDMAT" -title: "YIELDMAT function (DAX) | Microsoft Docs" -ms.service: powerbi -ms.subservice: dax -ms.date: 07/02/2020 -ms.reviewer: owend -ms.topic: reference +title: "YIELDMAT function (DAX)" author: jajin7 -ms.author: owend -recommendations: false - --- # YIELDMAT +[!INCLUDE[applies-to-measures-columns-tables-visual-calculations](includes/applies-to-measures-columns-tables-visual-calculations.md)] + Returns the annual yield of a security that pays interest at maturity. ## Syntax @@ -24,18 +18,18 @@ YIELDMAT(, , , , [, ]) ### Parameters -|Term|Definition| -|--------|--------------| -|settlement|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| -|maturity|The security's maturity date. The maturity date is the date when the security expires.| -|issue|The security's issue date.| -|rate|The security's interest rate at date of issue.| -|pr|The security's price per \\$100 face value.| -|basis|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| +|Term|Definition| +|--------|--------------| +|`settlement`|The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.| +|`maturity`|The security's maturity date. The maturity date is the date when the security expires.| +|`issue`|The security's issue date.| +|`rate`|The security's interest rate at date of issue.| +|`pr`|The security's price per \\$100 face value.| +|`basis`|(Optional) The type of day count basis to use. If basis is omitted, it is assumed to be 0. The accepted values are listed below this table.| -The **basis** parameter accepts the following values: +The `basis` parameter accepts the following values: -| **Basis** | **Day count basis** | +| `Basis` | **Day count basis** | | ------------ | ------------------- | | 0 or omitted | US (NASD) 30/360 | | 1 | Actual/actual | @@ -88,6 +82,6 @@ EVALUATE Returns the yield for a security using the terms specified above. -| **[Value]** | +| Value | | ------------------ | | 0.0609543336915387 | diff --git a/query-languages/m/access-database.md b/query-languages/m/access-database.md index feb528e16..7684b72bf 100644 --- a/query-languages/m/access-database.md +++ b/query-languages/m/access-database.md @@ -1,21 +1,21 @@ --- description: "Learn more about: Access.Database" -title: "Access.Database | Microsoft Docs" -ms.date: 12/12/2018 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Access.Database" +ms.subservice: m-source --- # Access.Database ## Syntax -
  
-Access.Database(database as binary, optional options as nullable record) as table 
-
- -## About -Returns a structural representation of an Access database, `database`. An optional record parameter, `options`, may be specified to control the following options:
  • `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is false).
  • `NavigationPropertyNameGenerator` : A function that is used for the creation of names for navigation properties.
The record parameter is specified as [option1 = value1, option2 = value2...], for example. +
+Access.Database(database as binary, optional options as nullable record) as table
+
+## About + +Returns a structural representation of an Access database, `database`. An optional record parameter, `options`, may be specified to control the following options: + +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is false). +* `NavigationPropertyNameGenerator`: A function that is used for the creation of names for navigation properties. + +The record parameter is specified as [option1 = value1, option2 = value2...], for example. diff --git a/query-languages/m/accesscontrolentry-conditiontoidentities.md b/query-languages/m/accesscontrolentry-conditiontoidentities.md index f687347e5..7c235a8af 100644 --- a/query-languages/m/accesscontrolentry-conditiontoidentities.md +++ b/query-languages/m/accesscontrolentry-conditiontoidentities.md @@ -1,13 +1,9 @@ --- description: "Learn more about: AccessControlEntry.ConditionToIdentities" -title: "AccessControlEntry.ConditionToIdentities | Microsoft Docs" -ms.date: 3/28/2019 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AccessControlEntry.ConditionToIdentities" +ms.subservice: m-source --- + # AccessControlEntry.ConditionToIdentities ## Syntax @@ -15,9 +11,9 @@ ms.author: dougklo
 AccessControlEntry.ConditionToIdentities(identityProvider as function, condition as function) as list
 
- -## About -

Using the specified identityProvider, converts the condition into the list of identities for which condition would return true in all authorization contexts with identityProvider as the identity provider. An error is raised if it is not possible to convert condition into a list of identities, for example if condition consults attributes other than user or group identities to make a decision.

Note that the list of identities represents the identities as they appear in condition and no normalization (such as group expansion) is performed on them.

+## About + +Using the specified `identityProvider`, converts the `condition` into the list of identities for which `condition` would return `true` in all authorization contexts with `identityProvider` as the identity provider. An error is raised if it is not possible to convert `condition` into a list of identities, for example if `condition` consults attributes other than user or group identities to make a decision. - +Note that the list of identities represents the identities as they appear in `condition` and no normalization (such as group expansion) is performed on them. diff --git a/query-languages/m/accesscontrolkind-type.md b/query-languages/m/accesscontrolkind-type.md index 49973dda1..9d24f151f 100644 --- a/query-languages/m/accesscontrolkind-type.md +++ b/query-languages/m/accesscontrolkind-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: AccessControlKind.Type" -title: "AccessControlKind.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "AccessControlKind.Type" +ms.subservice: m-source --- # AccessControlKind.Type @@ -18,8 +11,8 @@ Specifies the kind of access control. ## Allowed values -|Name|Value|Description| -|------------|--|---------------| +|Name|Value|Description| +|------------|--|---------------| |**AccessControlKind.Deny**|0|Access is denied.| |**AccessControlKind.Allow**|1|Access is allowed.| diff --git a/query-languages/m/accessing-data-functions.md b/query-languages/m/accessing-data-functions.md index fe9dc5439..d9b39a7d9 100644 --- a/query-languages/m/accessing-data-functions.md +++ b/query-languages/m/accessing-data-functions.md @@ -1,98 +1,98 @@ --- description: "Learn more about: Accessing data functions" -title: "Accessing data functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Accessing data functions" +ms.date: 7/16/2025 +ms.custom: + - "nonautomated-date" + - sfi-ropc-nochange --- # Accessing data functions -These functions access data and return table values. Most of these functions return a table value called a **navigation table**. Navigation tables are primarily used by the Power Query user interface to provide a navigation experience over the potentially large hierarchical data sets returned. - -|Name|Description| -|------------|---------------| +These functions access data and return table values. Most of these functions return a table value called a **navigation table**. Navigation tables are primarily used by the Power Query user interface to provide a navigation experience over the potentially large hierarchical data sets returned. + +|Name|Description| +|------------|---------------| |[AccessControlEntry.ConditionToIdentities](accesscontrolentry-conditiontoidentities.md)|Returns a list of identities that the condition will accept.| -|[Access.Database](access-database.md)|Returns a structural representation of an Microsoft Access database. | -|[ActiveDirectory.Domains](activedirectory-domains.md)|Returns a list of Active Directory domains in the same forest as the specified domain or of the current machine's domain if none is specified.| -|[AdobeAnalytics.Cubes](adobeanalytics-cubes.md) | Returns the report suites in Adobe Analytics.| +|[Access.Database](access-database.md)|Returns a structural representation of a Microsoft Access database. | +|[ActiveDirectory.Domains](activedirectory-domains.md)|Returns a list of Active Directory domains in the same forest as the specified domain or of the current machine's domain if none is specified.| +|[AdobeAnalytics.Cubes](adobeanalytics-cubes.md) | Returns the report suites in Adobe Analytics.| |[AdoDotNet.DataSource](adodotnet-datasource.md)|Returns the schema collection for an ADO.NET data source.| -|[AdoDotNet.Query](adodotnet-query.md)|Returns the schema collection for an ADO.NET data source.| -|[AnalysisServices.Database](analysisservices-database.md)|Returns a table of multidimensional cubes or tabular models from the Analysis Services database.| +|[AdoDotNet.Query](adodotnet-query.md)|Returns the result of running a native query on an ADO.NET data source.| +|[AnalysisServices.Database](analysisservices-database.md)|Returns a table of multidimensional cubes or tabular models from the Analysis Services database.| |[AnalysisServices.Databases](analysisservices-databases.md)|Returns the Analysis Services databases on a particular host.| -|[AzureStorage.BlobContents](azurestorage-blobcontents.md) | Returns the content of the specified blob from an Azure storage vault. | -|[AzureStorage.Blobs](azurestorage-blobs.md)|Returns a navigational table containing all containers found in the Azure Storage account. Each row has the container name and a link to the container blobs.| +|[AzureStorage.BlobContents](azurestorage-blobcontents.md) |Returns the content of the specified blob from an Azure storage vault. | +|[AzureStorage.Blobs](azurestorage-blobs.md)|Returns a navigational table containing the containers found in the specified account from an Azure storage vault. Each row has the container name and a link to the container blobs.| |[AzureStorage.DataLake](azurestorage-datalake.md)|Returns a navigational table containing the documents found in the specified container and its subfolders from Azure Data Lake Storage.| |[AzureStorage.DataLakeContents](azurestorage-datalakecontents.md)|Returns the content of the specified file from an Azure Data Lake Storage filesystem.| -|[AzureStorage.Tables](azurestorage-tables.md)|Returns a navigational table containing a row for each table found at the account URL from an Azure storage vault. Each row contains a link to the azure table.| +|[AzureStorage.Tables](azurestorage-tables.md)|Returns a navigational table containing the tables found in the specified account from an Azure storage vault. Each row contains a link to the azure table.| |[Cdm.Contents](cdm-contents.md)|This function is unavailable because it requires .NET 4.5.| -|[Csv.Document](csv-document.md)|Returns the contents of a CSV document as a table using the specified encoding.| -|[Cube.AddAndExpandDimensionColumn](cube-addandexpanddimensioncolumn.md)|Merges the specified dimension table, dimensionSelector, into the cube’s, cube, filter context and changes the dimensional granularity by expanding the specified set, attributeNames, of dimension attributes. | -|[Cube.AddMeasureColumn](cube-addmeasurecolumn.md)|Adds a column with the name column to the cube that contains the results of the measure measureSelector applied in the row context of each row. | -|[Cube.ApplyParameter](cube-applyparameter.md)|Returns a cube after applying parameter with arguments to cube.| -|[Cube.AttributeMemberId](cube-attributememberid.md)|Returns the unique member identifier from a member property value.| -|[Cube.AttributeMemberProperty](cube-attributememberproperty.md) | Returns the property `propertyName` of dimension attribute `attribute`.| -|[Cube.CollapseAndRemoveColumns](cube-collapseandremovecolumns.md)|Changes the dimensional granularity of the filter context for the cube by collapsing the attributes mapped to the specified columns columnNames.| -|[Cube.Dimensions](cube-dimensions.md)|Returns a table containing the set of available dimensions within the cube.| +|[Csv.Document](csv-document.md)|Returns the contents of the CSV document as a table using the specified encoding.| +|[Cube.AddAndExpandDimensionColumn](cube-addandexpanddimensioncolumn.md)|Merges the specified dimension table into the cube’s filter context and changes the dimensional granularity of the filter context by expanding the specified set of dimension attributes.| +|[Cube.AddMeasureColumn](cube-addmeasurecolumn.md)|AAdds a column to the cube that contains the results of the measure applied in the row context of each row.| +|[Cube.ApplyParameter](cube-applyparameter.md)|Returns a cube after applying a parameter to it.| +|[Cube.AttributeMemberId](cube-attributememberid.md)|Returns the unique member identifier from members property value.| +|[Cube.AttributeMemberProperty](cube-attributememberproperty.md) | Returns a property of a dimension attribute.| +|[Cube.CollapseAndRemoveColumns](cube-collapseandremovecolumns.md)|Changes the dimensional granularity of the filter context for the cube by collapsing the attributes mapped to the specified columns.| +|[Cube.Dimensions](cube-dimensions.md)|Returns a table containing the set of available dimensions.| |[Cube.DisplayFolders](cube-displayfolders.md)|Returns a nested tree of tables representing the display folder hierarchy of the objects (for example, dimensions and measures).| -|[Cube.MeasureProperties](cube-measureproperties.md)|Returns a table containing the set of available properties for measures that are expanded in the cube.| -|[Cube.MeasureProperty](cube-measureproperty.md)|Returns the property of a measure.| -|[Cube.Measures](cube-measures.md)|Returns a table containing the set of available measures within the cube.| -|[Cube.Parameters](cube-parameters.md)|Returns a table containing the set of parameters that can be applied to cube.| +|[Cube.MeasureProperties](cube-measureproperties.md)|Returns a table containing the set of available measure properties that are expanded in the cube.| +|[Cube.MeasureProperty](cube-measureproperty.md)|Returns a property of a measure (cell property).| +|[Cube.Measures](cube-measures.md)|Returns a table containing the set of available measures.| +|[Cube.Parameters](cube-parameters.md)|Returns a table containing the set of parameters that can be applied to the cube.| |[Cube.Properties](cube-properties.md)|Returns a table containing the set of available properties for dimensions that are expanded in the cube.| -|[Cube.PropertyKey](cube-propertykey.md) | Returns the key of property `property`. | +|[Cube.PropertyKey](cube-propertykey.md) | Returns the key of a property.| |[Cube.ReplaceDimensions](cube-replacedimensions.md)|Replaces the set of dimensions returned by [Cube.Dimensions](/powerquery-m/cube-dimensions).| -|[Cube.Transform](cube-transform.md)|Applies the list cube functions, transforms, on the cube.| -|[DB2.Database](db2-database.md)|Returns a table of SQL tables and views available in a Db2 database.| +|[Cube.Transform](cube-transform.md)|Applies a list of cube functions.| +|[DB2.Database](db2-database.md)|Returns a table of SQL tables and views available in a Db2 database.| +|[DeltaLake.Metadata](deltalake-metadata.md)|Given a Delta Lake table, returns the log entries for that table.| +|[DeltaLake.Table](deltalake-table.md)|Returns the contents of the Delta Lake table.| |[Essbase.Cubes](essbase-cubes.md)|Returns the cubes in an Essbase instance grouped by Essbase server.| -|[Excel.CurrentWorkbook](excel-currentworkbook.md)|Returns the tables in the current Excel Workbook.| -|[Excel.Workbook](excel-workbook.md)|Returns a table representing sheets in the given excel workbook.| +|[Excel.CurrentWorkbook](excel-currentworkbook.md)|Returns the contents of the current Excel workbook.| +|[Excel.Workbook](excel-workbook.md)|Returns the contents of the Excel workbook.| |[Exchange.Contents](exchange-contents.md)|Returns a table of contents from a Microsoft Exchange account.| -|[File.Contents](file-contents.md)|Returns the binary contents of the file located at a path.| -|[Folder.Contents](folder-contents.md)|Returns a table containing the properties and contents of the files and folders found in the specified folder.| -|[Folder.Files](folder-files.md)|Returns a table containing a row for each file found at a folder path, and subfolders. Each row contains properties of the folder or file and a link to its content.| +|[File.Contents](file-contents.md)|Returns the contents of the specified file as binary.| +|[Folder.Contents](folder-contents.md)|Returns a table containing the properties and contents of the files and folders found in the specified folder.| +|[Folder.Files](folder-files.md)|Returns a table containing the properties and contents of the files found in the specified folder and subfolders. Each row contains properties of the folder or file and a link to its content.| |[GoogleAnalytics.Accounts](googleanalytics-accounts.md)|Returns the Google Analytics accounts for the current credential.| -|[Hdfs.Contents](hdfs-contents.md)|Returns a table containing a row for each folder and file found at the folder url, {0}, from a Hadoop file system. Each row contains properties of the folder or file and a link to its content.| -|[Hdfs.Files](hdfs-files.md)|Returns a table containing a row for each file found at the folder url, {0}, and subfolders from a Hadoop file system. Each row contains properties of the file and a link to its content.| -|[HdInsight.Containers](hdinsight-containers.md)|Returns a navigational table containing all containers found in the HDInsight account. Each row has the container name and table containing its files.| -|[HdInsight.Contents](hdinsight-contents.md)|Returns a navigational table containing all containers found in the HDInsight account. Each row has the container name and table containing its files.| -|[HdInsight.Files](hdinsight-files.md)|Returns a table containing a row for each folder and file found at the container URL, and subfolders from an HDInsight account. Each row contains properties of the file/folder and a link to its content.| -|[Html.Table](html-table.md)|Returns a table containing the results of running the specified CSS selectors against the provided html.| +|[Hdfs.Contents](hdfs-contents.md)|Returns a table containing the properties and contents of the files and folders found in the specified folder from a Hadoop file system. Each row contains properties of the folder or file and a link to its content.| +|[Hdfs.Files](hdfs-files.md)|Returns a table containing the properties and contents of the files found in the specified folder and subfolders from a Hadoop file system. Each row contains properties of the file and a link to its content.| +|[HdInsight.Containers](hdinsight-containers.md)|Returns a navigational table containing the containers found in the specified account from an Azure storage vault. Each row has the container name and table containing its files.| +|[HdInsight.Contents](hdinsight-contents.md)|Returns a navigational table containing the containers found in the specified account from an Azure storage vault. Each row has the container name and table containing its files.| +|[HdInsight.Files](hdinsight-files.md)|Returns a table containing the properties and contents of the blobs found in the specified container from an Azure storage vault. Each row contains properties of the file/folder and a link to its content.| +|[Html.Table](html-table.md)|Returns a table containing the results of running the specified CSS selectors against the provided HTML.| |[Identity.From](identity-from.md)|Creates an identity.| |[Identity.IsMemberOf](identity-ismemberof.md)|Determines whether an identity is a member of an identity collection.| |[IdentityProvider.Default](identityprovider-default.md)|The default identity provider for the current host.| -|[Informix.Database](informix-database.md)|Returns a table of SQL tables and views available in an Informix database on server `server` in the database instance named `database`.| -|[Json.Document](json-document.md)|Returns the contents of a JSON document. The contents may be directly passed to the function as text, or it may be the binary value returned by a function like File.Contents.| +|[Informix.Database](informix-database.md)|Returns a table of SQL tables and views available in an Informix database.| +|[Json.Document](json-document.md)|Returns the content of the JSON document. The contents can be directly passed to the function as text, or it can be the binary value returned by a function like [File.Contents](file-contents.md).| |[Json.FromValue](json-fromvalue.md)|Produces a JSON representation of a given value value with a text encoding specified by encoding.| -|[MySQL.Database](mysql-database.md)|Returns a table with data relating to the tables in the specified MySQL Database.| -|[OData.Feed](odata-feed.md)|Returns a table of OData feeds offered by an OData serviceUri.| -|[Odbc.DataSource](odbc-datasource.md)|Returns a table of SQL tables and views from the ODBC data source specified by the connection string `connectionString`. | -|[Odbc.InferOptions](odbc-inferoptions.md)|Returns the result of trying to infer SQL capabilities for an ODBC driver. | -|[Odbc.Query](odbc-query.md)|Connects to a generic provider with the given connection string and returns the result of evaluating the query.| -|[OleDb.DataSource](oledb-datasource.md)|Returns a table of SQL tables and views from the OLE DB data source specified by the connection string.| +|[MySQL.Database](mysql-database.md)|Returns a table of SQL tables, views, and stored scalar functions available in a MySQL database.| +|[OData.Feed](odata-feed.md)|Returns a table of OData feeds offered by an OData service.| +|[Odbc.DataSource](odbc-datasource.md)|Returns a table of SQL tables and views from the ODBC data source.| +|[Odbc.InferOptions](odbc-inferoptions.md)|Returns the result of trying to infer SQL capabilities for an ODBC driver. | +|[Odbc.Query](odbc-query.md)|Returns the result of running a native query on an ODBC data source.| +|[OleDb.DataSource](oledb-datasource.md)|Returns a table of SQL tables and views from the OLE DB data source.| |[OleDb.Query](oledb-query.md)|Returns the result of running a native query on an OLE DB data source.| -|[Oracle.Database](oracle-database.md)|Returns a table with data relating to the tables in the specified Oracle Database.| -|[Pdf.Tables](pdf-tables.md)|Returns any tables found in pdf.| -|[PostgreSQL.Database](postgresql-database.md)|Returns a table with data relating to the tables in the specified PostgreSQL Database.| -|[RData.FromBinary](rdata-frombinary.md)|Returns a record of data frames from the RData file.| -|[Salesforce.Data](salesforce-data.md)|Connects to the Salesforce Objects API and returns the set of available objects (i.e. Accounts).| -|[Salesforce.Reports](salesforce-reports.md)|Connects to the Salesforce Reports API and returns the set of available reports.| +|[Oracle.Database](oracle-database.md)|Returns a table of SQL tables and views from the Oracle database.| +|[Pdf.Tables](pdf-tables.md)|Returns any tables found in a PDF file.| +|[PostgreSQL.Database](postgresql-database.md)|Returns a table of SQL tables and views available in a PostgreSQL database.| +|[RData.FromBinary](rdata-frombinary.md)|Returns a record of data frames from the RData file.| +|[Salesforce.Data](salesforce-data.md)|Returns the objects from the Salesforce account.| +|[Salesforce.Reports](salesforce-reports.md)|Returns the reports from the Salesforce account.| |[SapBusinessWarehouse.Cubes](sapbusinesswarehouse-cubes.md)|Returns the InfoCubes and queries in an SAP Business Warehouse system grouped by InfoArea.| |[SapHana.Database](saphana-database.md)|Returns the packages in an SAP HANA database.| -|[SharePoint.Contents](sharepoint-contents.md)|Returns a table containing a row for each folder and document found at the SharePoint site url. Each row contains properties of the folder or file and a link to its content.| -|[SharePoint.Files](sharepoint-files.md)|Returns a table containing a row for each document found at the SharePoint site url, and subfolders. Each row contains properties of the folder or file and a link to its content.| -|[SharePoint.Tables](sharepoint-tables.md)|Returns a table containing the result of a SharePoint List as an OData feed.| -|[Soda.Feed](soda-feed.md)|Returns the resulting table of a CSV file that can be accessed using the SODA 2.0 API. The URL must point to a valid SODA-compliant source that ends in a .csv extension.| -|[Sql.Database](sql-database.md)|Returns a table containing SQL tables located on a SQL Server instance database.| -|[Sql.Databases](sql-databases.md)|Returns a table with references to databases located on a SQL Server instance. Returns a navigation table.| -|[Sybase.Database](sybase-database.md)|Returns a table with data relating to the tables in the specified Sybase Database.| -|[Teradata.Database](teradata-database.md)|Returns a table with data relating to the tables in the specified Teradata Database.| -|[WebAction.Request](webaction-request.md)|Creates an action that, when executed, will return the results of performing a method request against url using HTTP as a binary value.| -|[Web.BrowserContents](web-browsercontents.md)|Returns the HTML for the specified url, as viewed by a web browser.| -|[Web.Contents](web-contents.md)|Returns the contents downloaded from a web url as a binary value.| -|[Web.Headers](web-headers.md)|Returns the HTTP headers downloaded from the url as a record value.| -|[Web.Page](web-page.md)|Returns the contents of an HTML webpage as a table.| -|[Xml.Document](xml-document.md)|Returns the contents of an XML document as a hierarchical table (list of records).| -|[Xml.Tables](xml-tables.md)|Returns the contents of an XML document as a nested collection of flattened tables.| +|[SharePoint.Contents](sharepoint-contents.md)|Returns a table containing content from a SharePoint site. Each row contains properties of the folder or file and a link to its content.| +|[SharePoint.Files](sharepoint-files.md)|Returns a table containing documents from a SharePoint site. Each row contains properties of the folder or file and a link to its content.| +|[SharePoint.Tables](sharepoint-tables.md)|Returns a table containing content from a SharePoint List.| +|[Soda.Feed](soda-feed.md)|Returns a table from the contents at the specified URL formatted according to the SODA 2.0 API. The URL must point to a valid SODA-compliant source that ends in a .csv extension.| +|[Sql.Database](sql-database.md)|Returns a table of SQL tables, views, and stored functions from the SQL Server database.| +|[Sql.Databases](sql-databases.md)|Returns a table of databases on a SQL Server.| +|[Sybase.Database](sybase-database.md)|Returns a table of SQL tables and views available in a Sybase database.| +|[Teradata.Database](teradata-database.md)|Returns a table of SQL tables and views from the Teradata database.| +|[WebAction.Request](webaction-request.md)|Creates an action that, when executed, will return the results of performing a method request against url using HTTP as a binary value.| +|[Web.BrowserContents](web-browsercontents.md)|Returns the HTML for the specified URL, as viewed by a web browser.| +|[Web.Contents](web-contents.md)|Returns the contents downloaded from the URL as binary.| +|[Web.Headers](web-headers.md)|Returns the HTTP headers downloaded from the URL as a record value.| +|[Web.Page](web-page.md)|Returns the contents of the HTML document broken into its constituent structures, as well as a representation of the full document and its text after removing tags.| +|[Xml.Document](xml-document.md)|Returns the contents of the XML document as a hierarchical table (list of records).| +|[Xml.Tables](xml-tables.md)|Returns the contents of an XML document as a nested collection of flattened tables.| diff --git a/query-languages/m/action-witherrorcontext.md b/query-languages/m/action-witherrorcontext.md new file mode 100644 index 000000000..c86ffc48e --- /dev/null +++ b/query-languages/m/action-witherrorcontext.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Action.WithErrorContext" +title: "Action.WithErrorContext" +ms.subservice: m-source +--- +# Action.WithErrorContext + +## Syntax + +
+Action.WithErrorContext(action as action, context as text) as action
+
+ +## About + +This function is intended for internal use only. diff --git a/query-languages/m/activedirectory-domains.md b/query-languages/m/activedirectory-domains.md index b9b623c01..500996959 100644 --- a/query-languages/m/activedirectory-domains.md +++ b/query-languages/m/activedirectory-domains.md @@ -1,21 +1,16 @@ --- description: "Learn more about: ActiveDirectory.Domains" -title: "ActiveDirectory.Domains | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "ActiveDirectory.Domains" +ms.subservice: m-source --- # ActiveDirectory.Domains ## Syntax -
  
+
 ActiveDirectory.Domains(optional forestRootDomainName as nullable text) as table
 
- + ## About Returns a list of Active Directory domains in the same forest as the specified domain or of the current machine's domain if none is specified. diff --git a/query-languages/m/adobeanalytics-cubes.md b/query-languages/m/adobeanalytics-cubes.md index b19c1fd29..5b11090f9 100644 --- a/query-languages/m/adobeanalytics-cubes.md +++ b/query-languages/m/adobeanalytics-cubes.md @@ -1,18 +1,13 @@ --- description: "Learn more about: AdobeAnalytics.Cubes" -title: "AdobeAnalytics.Cubes | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AdobeAnalytics.Cubes" +ms.subservice: m-source --- # AdobeAnalytics.Cubes ## Syntax -
  
+
 AdobeAnalytics.Cubes(optional options as nullable record) as table
 
diff --git a/query-languages/m/adodotnet-datasource.md b/query-languages/m/adodotnet-datasource.md index fba1faf7d..c2de3c31f 100644 --- a/query-languages/m/adodotnet-datasource.md +++ b/query-languages/m/adodotnet-datasource.md @@ -1,25 +1,25 @@ --- description: "Learn more about: AdoDotNet.DataSource" -title: "AdoDotNet.DataSource | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AdoDotNet.DataSource" +ms.subservice: m-source +ms.custom: sfi-ropc-nochange --- # AdoDotNet.DataSource ## Syntax
-AdoDotNet.DataSource(providerName as text, connectionString as any, optional options as nullable record) as table
+AdoDotNet.DataSource(
+    providerName as text,
+    connectionString as any,
+    optional options as nullable record
+) as table
 
## About -Returns the schema collection for the ADO.NET data source with provider name providerName and connection string connectionString. connectionString can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, options, may be provided to specify additional properties. The record can contain the following fields: -- CommandTimeout : 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 : A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. -- TypeMap +Returns the schema collection for the ADO.NET data source with provider name `providerName` and connection string `connectionString`. `connectionString` can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: +* `CommandTimeout`: 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`: A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. +* `TypeMap` diff --git a/query-languages/m/adodotnet-query.md b/query-languages/m/adodotnet-query.md index a3734b83e..2872f7065 100644 --- a/query-languages/m/adodotnet-query.md +++ b/query-languages/m/adodotnet-query.md @@ -1,25 +1,25 @@ --- description: "Learn more about: AdoDotNet.Query" -title: "AdoDotNet.Query | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AdoDotNet.Query" +ms.subservice: m-source +ms.custom: sfi-ropc-nochange --- # AdoDotNet.Query ## Syntax -
  
-AdoDotNet.Query(providerName as text, connectionString as any, query as text, optional options as nullable record) as table
+
+AdoDotNet.Query(
+    providerName as text,
+    connectionString as any,
+    query as text,
+    optional options as nullable record
+) as table
 
## About -Returns the result of running `query` with the connection string `connectionString` using the ADO.NET provider `providerName`. `connectionString` can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: - -* `CommandTimeout` : 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` : A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. +Returns the result of running `query` with the connection string `connectionString` using the ADO.NET provider `providerName`. `connectionString` can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: +* `CommandTimeout`: 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`: A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. diff --git a/query-languages/m/analysisservices-database.md b/query-languages/m/analysisservices-database.md index 0ff6d6f26..5d029f4b1 100644 --- a/query-languages/m/analysisservices-database.md +++ b/query-languages/m/analysisservices-database.md @@ -1,29 +1,32 @@ --- description: "Learn more about: AnalysisServices.Database" -title: "AnalysisServices.Database | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AnalysisServices.Database" +ms.subservice: m-source --- # AnalysisServices.Database ## Syntax -
  
-AnalysisServices.Database(server as text, database as text, optional options as nullable record) as table
+
+AnalysisServices.Database(
+    server as text,
+    database as text,
+    optional options as nullable record
+) as table
 
## About -Returns a table of multidimensional cubes or tabular models from the Analysis Services database `database` on server `server`. An optional record parameter, `options`, may be specified to control the following options: -* `Query` : A native MDX query used to retrieve data. -* `TypedMeasureColumns` : 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. The default value for this option is false. -* `Culture` : A culture name specifying the culture for the data. This corresponds to the 'Locale Identifier' connection string property. -* `CommandTimeout` : 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` : 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` : 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. (The default value is 2). -* `Implementation` - +Returns a table of multidimensional cubes or tabular models from the Analysis Services database `database` on server `server`. An optional record parameter, `options`, may be specified to control the following options: + +* `Query`: A native MDX query used to retrieve data. +* `TypedMeasureColumns`: 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. The default value for this option is false. +* `Culture`: A culture name specifying the culture for the data. This corresponds to the 'Locale Identifier' connection string property. +* `CommandTimeout`: 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`: 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`: 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. (The default value is 2). +* `Implementation` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/analysisservices-databases.md b/query-languages/m/analysisservices-databases.md index 496afe2e2..e78504509 100644 --- a/query-languages/m/analysisservices-databases.md +++ b/query-languages/m/analysisservices-databases.md @@ -1,28 +1,27 @@ --- description: "Learn more about: AnalysisServices.Databases" -title: "AnalysisServices.Databases | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AnalysisServices.Databases" +ms.subservice: m-source --- # AnalysisServices.Databases ## Syntax -
  
+
 AnalysisServices.Databases(server as text, optional options as nullable record) as table
 
## About -Returns databases on an Analysis Services instance, `server`. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: +Returns databases on an Analysis Services instance, `server`. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: -* `TypedMeasureColumns` : 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. The default value for this option is false. -* `Culture` : A culture name specifying the culture for the data. This corresponds to the 'Locale Identifier' connection string property. -* `CommandTimeout` : 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` : 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` : 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. (The default value is 2). +* `TypedMeasureColumns`: 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. The default value for this option is false. +* `Culture`: A culture name specifying the culture for the data. This corresponds to the 'Locale Identifier' connection string property. +* `CommandTimeout`: 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`: 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`: 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. (The default value is 2). * `Implementation` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/azurestorage-blobcontents.md b/query-languages/m/azurestorage-blobcontents.md index d5d112416..e18362fcd 100644 --- a/query-languages/m/azurestorage-blobcontents.md +++ b/query-languages/m/azurestorage-blobcontents.md @@ -1,24 +1,20 @@ --- description: "Learn more about: AzureStorage.BlobContents" -title: "AzureStorage.BlobContents | Microsoft Docs" -ms.date: 10/10/2019 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AzureStorage.BlobContents" +ms.subservice: m-source --- # AzureStorage.BlobContents ## Syntax -
  
+
 AzureStorage.BlobContents(url as text, optional options as nullable record) as binary
 
-## About +## About -Returns the content of the blob at the URL, url, from an Azure storage vault. options may be specified to control the following options:
  • BlockSize : The number of bytes to read before waiting on the data consumer. The default value is 4 MB.
  • RequestSize : The number of bytes to try to read in a single HTTP request to the server. The default value is 4 MB.
  • ConcurrentRequests : The ConcurrentRequests option supports faster download of data by specifying the number of requests to be made in parallel, at the cost of memory utilization. The memory required is (ConcurrentRequest * RequestSize). The default value is 16.
- - - +Returns the content of the blob at the URL, `url`, from an Azure storage vault. `options` may be specified to control the following options: + +* `BlockSize`: The number of bytes to read before waiting on the data consumer. The default value is 4 MB. +* `RequestSize`: The number of bytes to try to read in a single HTTP request to the server. The default value is 4 MB. +* `ConcurrentRequests`: The ConcurrentRequests option supports faster download of data by specifying the number of requests to be made in parallel, at the cost of memory utilization. The memory required is (ConcurrentRequest * RequestSize). The default value is 16. diff --git a/query-languages/m/azurestorage-blobs.md b/query-languages/m/azurestorage-blobs.md index 06a990605..42713f835 100644 --- a/query-languages/m/azurestorage-blobs.md +++ b/query-languages/m/azurestorage-blobs.md @@ -1,12 +1,7 @@ --- description: "Learn more about: AzureStorage.Blobs" -title: "AzureStorage.Blobs | Microsoft Docs" -ms.date: 10/10/2019 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AzureStorage.Blobs" +ms.subservice: m-source --- # AzureStorage.Blobs @@ -15,8 +10,11 @@ ms.author: dougklo
 AzureStorage.Blobs(account as text, optional options as nullable record) as table
 
- -## About -Returns a navigational table containing a row for each container found at the account URL, account, from an Azure storage vault. Each row contains a link to the container blobs. options may be specified to control the following options:
  • BlockSize : The number of bytes to read before waiting on the data consumer. The default value is 4 MB.
  • RequestSize : The number of bytes to try to read in a single HTTP request to the server. The default value is 4 MB.
  • ConcurrentRequests : The ConcurrentRequests option supports faster download of data by specifying the number of requests to be made in parallel, at the cost of memory utilization. The memory required is (ConcurrentRequest * RequestSize). The default value is 16.
- +## About + +Returns a navigational table containing a row for each container found at the account URL, `account`, from an Azure storage vault. Each row contains a link to the container blobs. `options` may be specified to control the following options: + +* `BlockSize`: The number of bytes to read before waiting on the data consumer. The default value is 4 MB. +* `RequestSize`: The number of bytes to try to read in a single HTTP request to the server. The default value is 4 MB. +* `ConcurrentRequests`: The ConcurrentRequests option supports faster download of data by specifying the number of requests to be made in parallel, at the cost of memory utilization. The memory required is (ConcurrentRequest * RequestSize). The default value is 16. diff --git a/query-languages/m/azurestorage-datalake.md b/query-languages/m/azurestorage-datalake.md index 68ef4a44b..09bef5ba6 100644 --- a/query-languages/m/azurestorage-datalake.md +++ b/query-languages/m/azurestorage-datalake.md @@ -1,24 +1,21 @@ --- description: "Learn more about: AzureStorage.DataLake" -title: "AzureStorage.DataLake | Microsoft Docs" -ms.date: 10/10/2019 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AzureStorage.DataLake" +ms.subservice: m-source --- # AzureStorage.DataLake ## Syntax -
  
+
 AzureStorage.DataLake(endpoint as text, optional options as nullable record) as table
 
-## About +## About -Returns a navigational table containing the documents found in the specified container and its subfolders at the account URL, endpoint, from an Azure Data Lake Storage filesystem. options may be specified to control the following options:
  • BlockSize : The number of bytes to read before waiting on the data consumer. The default value is 4 MB.
  • RequestSize : The number of bytes to try to read in a single HTTP request to the server. The default value is 4 MB.
  • ConcurrentRequests : The ConcurrentRequests option supports faster download of data by specifying the number of requests to be made in parallel, at the cost of memory utilization. The memory required is (ConcurrentRequest * RequestSize). The default value is 16.
  • HierarchicalNavigation : A logical (true/false) that controls whether the files are returned in a tree-like directory view or in a flat list. The default value is false.
- - - +Returns a navigational table containing the documents found in the specified container and its subfolders at the account URL, `endpoint`, from an Azure Data Lake Storage filesystem. `options` may be specified to control the following options: + +* `BlockSize`: The number of bytes to read before waiting on the data consumer. The default value is 4 MB. +* `RequestSize`: The number of bytes to try to read in a single HTTP request to the server. The default value is 4 MB. +* `ConcurrentRequests`: The ConcurrentRequests option supports faster download of data by specifying the number of requests to be made in parallel, at the cost of memory utilization. The memory required is (ConcurrentRequest * RequestSize). The default value is 16. +* `HierarchicalNavigation`: A logical (true/false) that controls whether the files are returned in a tree-like directory view or in a flat list. The default value is false. diff --git a/query-languages/m/azurestorage-datalakecontents.md b/query-languages/m/azurestorage-datalakecontents.md index 6aad0a7a7..6a5dab2c6 100644 --- a/query-languages/m/azurestorage-datalakecontents.md +++ b/query-languages/m/azurestorage-datalakecontents.md @@ -1,24 +1,20 @@ --- description: "Learn more about: AzureStorage.DataLakeContents" -title: "AzureStorage.DataLakeContents | Microsoft Docs" -ms.date: 10/10/2019 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AzureStorage.DataLakeContents" +ms.subservice: m-source --- # AzureStorage.DataLakeContents ## Syntax -
  
+
 AzureStorage.DataLakeContents(url as text, optional options as nullable record) as binary
 
-## About +## About -Returns the content of the file at the URL, url, from an Azure Data Lake Storage filesystem. options may be specified to control the following options:
  • BlockSize : The number of bytes to read before waiting on the data consumer. The default value is 4 MB.
  • RequestSize : The number of bytes to try to read in a single HTTP request to the server. The default value is 4 MB.
  • ConcurrentRequests : The ConcurrentRequests option supports faster download of data by specifying the number of requests to be made in parallel, at the cost of memory utilization. The memory required is (ConcurrentRequest * RequestSize). The default value is 16.
- - - +Returns the content of the file at the URL, `url`, from an Azure Data Lake Storage filesystem. `options` may be specified to control the following options: + +* `BlockSize`: The number of bytes to read before waiting on the data consumer. The default value is 4 MB. +* `RequestSize`: The number of bytes to try to read in a single HTTP request to the server. The default value is 4 MB. +* `ConcurrentRequests`: The ConcurrentRequests option supports faster download of data by specifying the number of requests to be made in parallel, at the cost of memory utilization. The memory required is (ConcurrentRequest * RequestSize). The default value is 16. diff --git a/query-languages/m/azurestorage-tables.md b/query-languages/m/azurestorage-tables.md index 9c01efff1..560ac99bf 100644 --- a/query-languages/m/azurestorage-tables.md +++ b/query-languages/m/azurestorage-tables.md @@ -1,12 +1,7 @@ --- description: "Learn more about: AzureStorage.Tables" -title: "AzureStorage.Tables | Microsoft Docs" -ms.date: 5/25/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "AzureStorage.Tables" +ms.subservice: m-source --- # AzureStorage.Tables diff --git a/query-languages/m/binary-approximatelength.md b/query-languages/m/binary-approximatelength.md index 035f4a943..9b2ceb7ce 100644 --- a/query-languages/m/binary-approximatelength.md +++ b/query-languages/m/binary-approximatelength.md @@ -1,12 +1,7 @@ --- description: "Learn more about: Binary.ApproximateLength" -title: "Binary.ApproximateLength | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Binary.ApproximateLength" +ms.subservice: m-source --- # Binary.ApproximateLength diff --git a/query-languages/m/binary-buffer.md b/query-languages/m/binary-buffer.md index 359e56429..a7bc71345 100644 --- a/query-languages/m/binary-buffer.md +++ b/query-languages/m/binary-buffer.md @@ -1,12 +1,7 @@ --- description: "Learn more about: Binary.Buffer" -title: "Binary.Buffer | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Binary.Buffer" +ms.subservice: m-source --- # Binary.Buffer diff --git a/query-languages/m/binary-combine.md b/query-languages/m/binary-combine.md index 64fe79600..c4f58f05b 100644 --- a/query-languages/m/binary-combine.md +++ b/query-languages/m/binary-combine.md @@ -1,12 +1,7 @@ --- description: "Learn more about: Binary.Combine" -title: "Binary.Combine | Microsoft Docs" -ms.date: 12/12/2018 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Binary.Combine" +ms.subservice: m-source --- # Binary.Combine @@ -19,4 +14,3 @@ Binary.Combine(binaries as list) as binary ## About Combines a list of binaries into a single binary. - diff --git a/query-languages/m/binary-compress.md b/query-languages/m/binary-compress.md index 90c1ad3a4..2d441b753 100644 --- a/query-languages/m/binary-compress.md +++ b/query-languages/m/binary-compress.md @@ -1,12 +1,7 @@ --- description: "Learn more about: Binary.Compress" -title: "Binary.Compress | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Binary.Compress" +ms.subservice: m-source --- # Binary.Compress @@ -20,8 +15,8 @@ Binary.Compress(binary as nullable binary, compressionType as numb Compresses a binary value using the given compression type. The result of this call is a compressed copy of the input. Compression types include: -* [Compression.GZip](/powerquery-m/compression-gzip) -* [Compression.Deflate](/powerquery-m/compression-deflate) +* [Compression.GZip](compression-type.md) +* [Compression.Deflate](compression-type.md) ## Example 1 diff --git a/query-languages/m/binary-decompress.md b/query-languages/m/binary-decompress.md index 41aae69bb..aab17f3f7 100644 --- a/query-languages/m/binary-decompress.md +++ b/query-languages/m/binary-decompress.md @@ -1,18 +1,13 @@ --- description: "Learn more about: Binary.Decompress" -title: "Binary.Decompress | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Binary.Decompress" +ms.subservice: m-source --- # Binary.Decompress ## Syntax -
 
+
 Binary.Decompress(binary as nullable binary, compressionType as number) as nullable binary
 
@@ -20,8 +15,8 @@ Binary.Decompress(binary as nullable binary, compressionType as nu Decompresses a binary value using the given compression type. The result of this call is a decompressed copy of the input. Compression types include: -* [Compression.GZip](/powerquery-m/compression-gzip) -* [Compression.Deflate](/powerquery-m/compression-deflate) +* [Compression.GZip](compression-type.md) +* [Compression.Deflate](compression-type.md) ## Example 1 @@ -36,4 +31,3 @@ Binary.Decompress(#binary({115, 103, 200, 7, 194, 20, 134, 36, 134, 74, 134, 84, **Output** `#binary({71, 0, 111, 0, 111, 0, 100, 0, 98, 0, 121, 0, 101, 0})` - \ No newline at end of file diff --git a/query-languages/m/binary-from.md b/query-languages/m/binary-from.md index ecdce95ff..46780c569 100644 --- a/query-languages/m/binary-from.md +++ b/query-languages/m/binary-from.md @@ -1,16 +1,11 @@ --- description: "Learn more about: Binary.From" -title: "Binary.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Binary.From" +ms.subservice: m-source --- # Binary.From -## Syntax +## Syntax
 Binary.From(value as any, optional encoding as nullable number) as nullable binary
diff --git a/query-languages/m/binary-fromlist.md b/query-languages/m/binary-fromlist.md
index 98bb110ec..1ff4f7cbf 100644
--- a/query-languages/m/binary-fromlist.md
+++ b/query-languages/m/binary-fromlist.md
@@ -1,13 +1,7 @@
 ---
 description: "Learn more about: Binary.FromList"
-title: "Binary.FromList | Microsoft Docs"
-ms.date: 12/12/2018
-ms.service: powerquery
-ms.reviewer: ehvonleh
-ms.topic: reference
-author: dougklopfenstein
-ms.author: dougklo
-
+title: "Binary.FromList"
+ms.subservice: m-source
 ---
 # Binary.FromList
 
diff --git a/query-languages/m/binary-fromtext.md b/query-languages/m/binary-fromtext.md
index 22214393a..bf892a198 100644
--- a/query-languages/m/binary-fromtext.md
+++ b/query-languages/m/binary-fromtext.md
@@ -1,13 +1,7 @@
 ---
 description: "Learn more about: Binary.FromText"
-title: "Binary.FromText | Microsoft Docs"
-ms.date: 3/11/2022
-ms.service: powerquery
-ms.reviewer: ehvonleh
-ms.topic: reference
-author: dougklopfenstein
-ms.author: dougklo
-
+title: "Binary.FromText"
+ms.subservice: m-source
 ---
 # Binary.FromText
 
@@ -22,7 +16,7 @@ Binary.FromText(text as nullable text, optional encoding as nullab
 Returns the result of converting text value `text` to a binary (list of `number`). `encoding` may be specified to indicate the encoding used in the text value. The following `BinaryEncoding` values may be used for `encoding`.
 
 * [BinaryEncoding.Base64](binaryencoding-type.md): Base 64 encoding
-* [BinaryEncoding.Hex](binaryencoding-type.md: Hex encoding
+* [BinaryEncoding.Hex](binaryencoding-type.md): Hex encoding
 
 ## Example 1
 
diff --git a/query-languages/m/binary-functions.md b/query-languages/m/binary-functions.md
index de7161513..f7998796f 100644
--- a/query-languages/m/binary-functions.md
+++ b/query-languages/m/binary-functions.md
@@ -1,46 +1,40 @@
 ---
 description: "Learn more about: Binary functions"
-title: "Binary functions | Microsoft Docs"
-ms.date: 5/19/2022
-ms.service: powerquery
-
-ms.reviewer: ehvonleh
-ms.topic: reference
-author: dougklopfenstein
-ms.author: dougklo
-
+title: "Binary functions"
+ms.date: 2/17/2023
+ms.custom: "nonautomated-date"
 ---
 # Binary functions
 
 These functions create and manipulate binary data.
-  
-## Binary Formats  
-  
-### Reading numbers  
-  
-|Name|Description|  
-|------------|---------------|  
-|[BinaryFormat.7BitEncodedSignedInteger](binaryformat-7bitencodedsignedinteger.md)|A binary format that reads a 64-bit signed integer that was encoded using a 7-bit variable-length encoding.|  
-|[BinaryFormat.7BitEncodedUnsignedInteger](binaryformat-7bitencodedunsignedinteger.md)|A binary format that reads a 64-bit unsigned integer that was encoded using a 7-bit variable-length encoding.|  
-|[BinaryFormat.Binary](binaryformat-binary.md)|Returns a binary format that reads a binary value.|  
-|[BinaryFormat.Byte](binaryformat-byte.md)|A binary format that reads an 8-bit unsigned integer.|  
-|[BinaryFormat.Choice](binaryformat-choice.md)|Returns a binary format that chooses the next binary format based on a value that has already been read.|  
+
+## Binary Formats
+
+### Reading numbers
+
+|Name|Description|
+|------------|---------------|
+|[BinaryFormat.7BitEncodedSignedInteger](binaryformat-7bitencodedsignedinteger.md)|A binary format that reads a 64-bit signed integer that was encoded using a 7-bit variable-length encoding.|
+|[BinaryFormat.7BitEncodedUnsignedInteger](binaryformat-7bitencodedunsignedinteger.md)|A binary format that reads a 64-bit unsigned integer that was encoded using a 7-bit variable-length encoding.|
+|[BinaryFormat.Binary](binaryformat-binary.md)|Returns a binary format that reads a binary value.|
+|[BinaryFormat.Byte](binaryformat-byte.md)|A binary format that reads an 8-bit unsigned integer.|
+|[BinaryFormat.Choice](binaryformat-choice.md)|Returns a binary format that chooses the next binary format based on a value that has already been read.|
 |[BinaryFormat.Decimal](binaryformat-decimal.md)|A binary format that reads a .NET 16-byte decimal value.|
-|[BinaryFormat.Double](binaryformat-double.md)|A binary format that reads an 8-byte IEEE double-precision floating point value.|  
-|[BinaryFormat.Group](binaryformat-group.md)|Returns a binary format that reads a group of items. Each item value is preceded by a unique key value. The result is a list of item values.|  
-|[BinaryFormat.Length](binaryformat-length.md)|Returns a binary format that limits the amount of data that can be read. Both BinaryFormat.List and BinaryFormat.Binary can be used to read until end of the data. BinaryFormat.Length can be used to limit the number of bytes that are read.|  
-|[BinaryFormat.List](binaryformat-list.md)|Returns a binary format that reads a sequence of items and returns a list.|  
-|[BinaryFormat.Null](binaryformat-null.md)|A binary format that reads zero bytes and returns null.|  
-|[BinaryFormat.Record](binaryformat-record.md)|Returns a binary format that reads a record. Each field in the record can have a different binary format.|  
+|[BinaryFormat.Double](binaryformat-double.md)|A binary format that reads an 8-byte IEEE double-precision floating point value.|
+|[BinaryFormat.Group](binaryformat-group.md)|Returns a binary format that reads a group of items. Each item value is preceded by a unique key value. The result is a list of item values.|
+|[BinaryFormat.Length](binaryformat-length.md)|Returns a binary format that limits the amount of data that can be read. Both BinaryFormat.List and BinaryFormat.Binary can be used to read until end of the data. BinaryFormat.Length can be used to limit the number of bytes that are read.|
+|[BinaryFormat.List](binaryformat-list.md)|Returns a binary format that reads a sequence of items and returns a list.|
+|[BinaryFormat.Null](binaryformat-null.md)|A binary format that reads zero bytes and returns null.|
+|[BinaryFormat.Record](binaryformat-record.md)|Returns a binary format that reads a record. Each field in the record can have a different binary format.|
 |[BinaryFormat.SignedInteger16](binaryformat-signedinteger16.md)|A binary format that reads a 16-bit signed integer.|
-|[BinaryFormat.SignedInteger32](binaryformat-signedinteger32.md)|A binary format that reads a 32-bit signed integer.|  
-|[BinaryFormat.SignedInteger64](binaryformat-signedinteger64.md)|A binary format that reads a 64-bit signed integer.|  
-|[BinaryFormat.Single](binaryformat-single.md)|A binary format that reads a 4-byte IEEE single-precision floating point value.|  
-|[BinaryFormat.Text](binaryformat-text.md)|Returns a binary format that reads a text value. The optional encoding value specifies the encoding of the text.|  
-|[BinaryFormat.Transform](binaryformat-transform.md)|Returns a binary format that will transform the values read by another binary format.|  
-|[BinaryFormat.UnsignedInteger16](binaryformat-unsignedinteger16.md)|A binary format that reads a 16-bit unsigned integer.|  
-|[BinaryFormat.UnsignedInteger32](binaryformat-unsignedinteger32.md)|A binary format that reads a 32-bit unsigned integer.|  
-|[BinaryFormat.UnsignedInteger64](binaryformat-unsignedinteger64.md)|A binary format that reads a 64-bit unsigned integer.|  
+|[BinaryFormat.SignedInteger32](binaryformat-signedinteger32.md)|A binary format that reads a 32-bit signed integer.|
+|[BinaryFormat.SignedInteger64](binaryformat-signedinteger64.md)|A binary format that reads a 64-bit signed integer.|
+|[BinaryFormat.Single](binaryformat-single.md)|A binary format that reads a 4-byte IEEE single-precision floating point value.|
+|[BinaryFormat.Text](binaryformat-text.md)|Returns a binary format that reads a text value. The optional encoding value specifies the encoding of the text.|
+|[BinaryFormat.Transform](binaryformat-transform.md)|Returns a binary format that will transform the values read by another binary format.|
+|[BinaryFormat.UnsignedInteger16](binaryformat-unsignedinteger16.md)|A binary format that reads a 16-bit unsigned integer.|
+|[BinaryFormat.UnsignedInteger32](binaryformat-unsignedinteger32.md)|A binary format that reads a 32-bit unsigned integer.|
+|[BinaryFormat.UnsignedInteger64](binaryformat-unsignedinteger64.md)|A binary format that reads a 64-bit unsigned integer.|
 
 ### Controlling byte order
 
@@ -48,22 +42,26 @@ These functions create and manipulate binary data.
 |---------------------- | -----------|
 |[BinaryFormat.ByteOrder](binaryformat-byteorder.md) | Returns a binary format with the byte order specified by a function.|
 |[Table.PartitionValues](table-partitionvalues.md) | Returns information about how a table is partitioned.|
-  
+
 ## Binary data
-  
-|Name|Description|  
+
+|Name|Description|
 |------------|---------------|
 |[Binary.ApproximateLength](binary-approximatelength.md)|Returns the approximate length of the binary.|
-|[Binary.Buffer](binary-buffer.md)|Buffers the binary value in memory. The result of this call is a stable binary value, which means it will have a deterministic length and order of bytes.|  
+|[Binary.Buffer](binary-buffer.md)|Buffers the binary value in memory. The result of this call is a stable binary value, which means it will have a deterministic length and order of bytes.|
 |[Binary.Combine](binary-combine.md)|Combines a list of binaries into a single binary.|
 |[Binary.Compress](binary-compress.md)|Compresses a binary value using the given compression type.|
-|[Binary.Decompress](binary-decompress.md)|Decompresses a binary value using the given compression type.|  
-|[Binary.From](binary-from.md)|Returns a binary value from the given value.|  
-|[Binary.FromList](binary-fromlist.md)|Converts a list of numbers into a binary value|  
-|[Binary.FromText](binary-fromtext.md)|Decodes data from a text form into binary.|  
-|[Binary.InferContentType](binary-infercontenttype.md)|Returns a record with field Content.Type that contains the inferred MIME-type.|  
-|[Binary.Length](binary-length.md)|Returns the length of binary values.|  
+|[Binary.Decompress](binary-decompress.md)|Decompresses a binary value using the given compression type.|
+|[Binary.From](binary-from.md)|Returns a binary value from the given value.|
+|[Binary.FromList](binary-fromlist.md)|Converts a list of numbers into a binary value|
+|[Binary.FromText](binary-fromtext.md)|Decodes data from a text form into binary.|
+|[Binary.InferContentType](binary-infercontenttype.md)|Returns a record with field Content.Type that contains the inferred MIME-type.|
+|[Binary.Length](binary-length.md)|Returns the length of binary values.|
 |[Binary.Range](binary-range.md)|Returns a subset of the binary value beginning at an offset.|
-|[Binary.ToList](binary-tolist.md)|Converts a binary value into a list of numbers|  
-|[Binary.ToText](binary-totext.md)|Encodes binary data into a text form.|  
+|[Binary.Split](binary-split.md)|Splits the specified binary into a list of binaries using the specified page size.|
+|[Binary.ToList](binary-tolist.md)|Converts a binary value into a list of numbers|
+|[Binary.ToText](binary-totext.md)|Encodes binary data into a text form.|
+|[Binary.View](binary-view.md) | Creates or extends a binary with user-defined handlers for query and action operations.|
+|[Binary.ViewError](binary-viewerror.md) | Creates a modified error record which won't trigger a fallback when thrown by a handler defined on a view (via [Binary.View](binary-view.md)).|
+|[Binary.ViewFunction](binary-viewfunction.md) | Creates a function that can be intercepted by a handler defined on a view (via `Binary.View`).|
 |[#binary](sharpbinary.md) | Creates a binary value from numbers or text.|
diff --git a/query-languages/m/binary-infercontenttype.md b/query-languages/m/binary-infercontenttype.md
index 1fe832e39..e43225bcd 100644
--- a/query-languages/m/binary-infercontenttype.md
+++ b/query-languages/m/binary-infercontenttype.md
@@ -1,23 +1,16 @@
 ---
 description: "Learn more about: Binary.InferContentType"
-title: "Binary.InferContentType | Microsoft Docs"
-ms.date: 4/17/2018
-ms.service: powerquery
-
-ms.reviewer: ehvonleh
-ms.topic: reference
-author: dougklopfenstein
-ms.author: dougklo
-
+title: "Binary.InferContentType"
+ms.subservice: m-source
 ---
 # Binary.InferContentType
 
 ## Syntax
 
-
 
+
 Binary.InferContentType(source as binary) as record
 
- -## About - + +## About + Returns a record with field Content.Type that contains the inferred MIME-type. If the inferred content type is text/*, and an encoding code page is detected, then additionally returns field Content.Encoding that contains the encoding of the stream. If the inferred content type is text/csv, and the format is delimited, additionally returns field Csv.PotentialDelimiter containing a table for analysis of potential delimiters. If the inferred content type is text/csv, and the format is fixed-width, additionally returns field Csv.PotentialPositions containing a list for analysis of potential fixed width column positions. diff --git a/query-languages/m/binary-length.md b/query-languages/m/binary-length.md index 27e5c8430..f2fdc6420 100644 --- a/query-languages/m/binary-length.md +++ b/query-languages/m/binary-length.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Binary.Length" -title: "Binary.Length | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Binary.Length" +ms.subservice: m-source --- # Binary.Length @@ -16,7 +9,8 @@ ms.author: dougklo
 Binary.Length(binary as nullable binary) as nullable number
-
- -## About -Returns the number of characters. +
+ +## About + +Returns the number of characters. diff --git a/query-languages/m/binary-range.md b/query-languages/m/binary-range.md index 7f15b1545..40f6227f0 100644 --- a/query-languages/m/binary-range.md +++ b/query-languages/m/binary-range.md @@ -1,19 +1,18 @@ --- description: "Learn more about: Binary.Range" -title: "Binary.Range | Microsoft Docs" -ms.date: 3/7/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Binary.Range" +ms.subservice: m-source --- # Binary.Range ## Syntax
-Binary.Range(binary as binary, offset as number, optional count as nullable number) as binary
+Binary.Range(
+    binary as binary,
+    offset as number,
+    optional count as nullable number
+) as binary
 
## About diff --git a/query-languages/m/binary-split.md b/query-languages/m/binary-split.md new file mode 100644 index 000000000..a3d19374b --- /dev/null +++ b/query-languages/m/binary-split.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Binary.Split" +title: "Binary.Split" +ms.subservice: m-source +--- +# Binary.Split + +## Syntax + +
+Binary.Split(binary as binary, pageSize as number) as list
+
+ +## About + +Splits `binary` into a list of binaries where the first element of the output list is a binary containing the first `pageSize` bytes from the source binary, the next element of the output list is a binary containing the next `pageSize` bytes from the source binary, and so on. diff --git a/query-languages/m/binary-tolist.md b/query-languages/m/binary-tolist.md index 5e152d908..4d85451ce 100644 --- a/query-languages/m/binary-tolist.md +++ b/query-languages/m/binary-tolist.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Binary.ToList" -title: "Binary.ToList | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Binary.ToList" +ms.subservice: m-source --- # Binary.ToList @@ -16,7 +9,8 @@ ms.author: dougklo
 Binary.ToList(binary as binary) as list
-
- -## About +
+ +## About + Converts a binary value into a list of numbers. diff --git a/query-languages/m/binary-totext.md b/query-languages/m/binary-totext.md index 83ba065b1..3130bd36d 100644 --- a/query-languages/m/binary-totext.md +++ b/query-languages/m/binary-totext.md @@ -1,23 +1,19 @@ --- description: "Learn more about: Binary.ToText" -title: "Binary.ToText | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Binary.ToText" +ms.subservice: m-source --- # Binary.ToText ## Syntax
-Binary.ToText(binary as nullable binary, optional encoding as nullable number) as nullable text 
-
- -## About -Returns the result of converting a binary list of numbers `binary` into a text value. Optionally, `encoding` may be specified to indicate the encoding to be used in the text value produced The following `BinaryEncoding` values may be used for `encoding`.
  • BinaryEncoding.Base64: Base 64 encoding
  • BinaryEncoding.Hex: Hex encoding
- +Binary.ToText(binary as nullable binary, optional encoding as nullable number) as nullable text +
+ +## About + +Returns the result of converting a binary list of numbers `binary` into a text value. Optionally, `encoding` may be specified to indicate the encoding to be used in the text value produced The following `BinaryEncoding` values may be used for `encoding`. + +* `BinaryEncoding.Base64`: Base 64 encoding +* `BinaryEncoding.Hex`: Hex encoding diff --git a/query-languages/m/binary-view.md b/query-languages/m/binary-view.md new file mode 100644 index 000000000..adcc3d5d3 --- /dev/null +++ b/query-languages/m/binary-view.md @@ -0,0 +1,48 @@ +--- +description: "Learn more about: Binary.View" +title: "Binary.View" +ms.subservice: m-source +--- +# Binary.View + +## Syntax + +
+Binary.View(binary as nullable binary, handlers as record) as binary
+
+ +## About + +Returns a view of `binary` where the functions specified in `handlers` are used in lieu of the default behavior of an operation when the operation is applied to the view. + +If `binary` is provided, all handler functions are optional. If `binary` isn't provided, the `GetStream` handler function is required. If a handler function isn't specified for an operation, the default behavior of the operation is applied to `binary` instead (except in the case of `GetExpression`). + +Handler functions must return a value that is semantically equivalent to the result of applying the operation against `binary` (or the resulting view in the case of `GetExpression`). + +If a handler function raises an error, the default behavior of the operation is applied to the view. + +**Binary.View** can be used to implement folding to a data source–the translation of M queries into source-specific operations (for example, to download a section of a file). + +Refer to the published Power Query custom connector documentation for a more complete description of **Binary.View**. + +## Example 1 + +Create a basic view that doesn't require accessing the data in order to determine the length. + +**Usage** + +```powerquery-m +Binary.View( + null, + [ + GetLength = () => 12, + GetStream = () => Text.ToBinary("hello world!") + ] +) +``` + +**Output** + +```powerquery-m +Text.ToBinary("hello world!") +``` diff --git a/query-languages/m/binary-viewerror.md b/query-languages/m/binary-viewerror.md new file mode 100644 index 000000000..b764ea6a6 --- /dev/null +++ b/query-languages/m/binary-viewerror.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Binary.ViewError" +title: "Binary.ViewError" +ms.subservice: m-source +--- +# Binary.ViewError + +## Syntax + +
+Binary.ViewError(errorRecord as record) as record
+
+ +## About + +Creates a modified error record from `errorRecord` which won't trigger a fallback when thrown by a handler defined on a view (via [Binary.View](binary-view.md)). diff --git a/query-languages/m/binary-viewfunction.md b/query-languages/m/binary-viewfunction.md new file mode 100644 index 000000000..1fa9d2de7 --- /dev/null +++ b/query-languages/m/binary-viewfunction.md @@ -0,0 +1,22 @@ +--- +description: "Learn more about: Binary.ViewFunction" +title: "Binary.ViewFunction" +ms.subservice: m-source +--- +# Binary.ViewFunction + +## Syntax + +
+Binary.ViewFunction(function as function) as function
+
+ +## About + +Creates a view function based on `function` that can be handled in a view created by [Binary.View](binary-view.md). + +The `OnInvoke` handler of **Binary.View** can be used to define a handler for the view function. + +As with the handlers for built-in operations, if no `OnInvoke` handler is specified, or if it does not handle the view function, or if an error is raised by the handler, `function` is applied on top of the view. + +Refer to the published Power Query custom connector documentation for a more complete description of **Binary.View** and custom view functions. diff --git a/query-languages/m/binaryencoding-type.md b/query-languages/m/binaryencoding-type.md index ba2eb0beb..de5dfab68 100644 --- a/query-languages/m/binaryencoding-type.md +++ b/query-languages/m/binaryencoding-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BinaryEncoding.Type" -title: "BinaryEncoding.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryEncoding.Type" +ms.subservice: m-source --- # BinaryEncoding.Type @@ -18,8 +11,8 @@ Specifies the type of binary encoding. ## Allowed values -|Name|Value|Description| -|------------|--|-------------| +|Name|Value|Description| +|------------|--|-------------| |**BinaryEncoding.Base64**|0|Constant to use as the encoding type when base-64 encoding is required.| |**BinaryEncoding.Hex**|1|Constant to use as the encoding type when hexadecimal encoding is required.| diff --git a/query-languages/m/binaryformat-7bitencodedsignedinteger.md b/query-languages/m/binaryformat-7bitencodedsignedinteger.md index ad81ce3bd..560138d9a 100644 --- a/query-languages/m/binaryformat-7bitencodedsignedinteger.md +++ b/query-languages/m/binaryformat-7bitencodedsignedinteger.md @@ -1,22 +1,16 @@ --- description: "Learn more about: BinaryFormat.7BitEncodedSignedInteger" -title: "BinaryFormat.7BitEncodedSignedInteger | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.7BitEncodedSignedInteger" +ms.subservice: m-source --- # BinaryFormat.7BitEncodedSignedInteger ## Syntax
-BinaryFormat.7BitEncodedSignedInteger(binary as binary) as any 
-
- -## About -A binary format that reads a 64-bit signed integer that was encoded using a 7-bit variable-length encoding. +BinaryFormat.7BitEncodedSignedInteger(binary as binary) as any +
+ +## About + +A binary format that reads a 64-bit signed integer that was encoded using a 7-bit variable-length encoding. diff --git a/query-languages/m/binaryformat-7bitencodedunsignedinteger.md b/query-languages/m/binaryformat-7bitencodedunsignedinteger.md index a4b0333fc..fb9c95dae 100644 --- a/query-languages/m/binaryformat-7bitencodedunsignedinteger.md +++ b/query-languages/m/binaryformat-7bitencodedunsignedinteger.md @@ -1,22 +1,16 @@ --- description: "Learn more about: BinaryFormat.7BitEncodedUnsignedInteger" -title: "BinaryFormat.7BitEncodedUnsignedInteger | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.7BitEncodedUnsignedInteger" +ms.subservice: m-source --- # BinaryFormat.7BitEncodedUnsignedInteger ## Syntax
-BinaryFormat.7BitEncodedUnsignedInteger(binary as binary) as any 
-
- -## About -A binary format that reads a 64-bit unsigned integer that was encoded using a 7-bit variable-length encoding. +BinaryFormat.7BitEncodedUnsignedInteger(binary as binary) as any +
+ +## About + +A binary format that reads a 64-bit unsigned integer that was encoded using a 7-bit variable-length encoding. diff --git a/query-languages/m/binaryformat-binary.md b/query-languages/m/binaryformat-binary.md index 5dd57e60f..0414a6f99 100644 --- a/query-languages/m/binaryformat-binary.md +++ b/query-languages/m/binaryformat-binary.md @@ -1,23 +1,16 @@ --- description: "Learn more about: BinaryFormat.Binary" -title: "BinaryFormat.Binary | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Binary" +ms.subservice: m-source --- # BinaryFormat.Binary ## Syntax
-BinaryFormat.Binary(optional length as any) as function
+BinaryFormat.Binary(optional length as any) as function
 
- -## About -Returns a binary format that reads a binary value. If `length` is specified, the binary value will contain that many bytes. If `length` is not specified, the binary value will contain the remaining bytes. The `length` can be specified either as a number, or as a binary format of the length that preceeds the binary data. - + +## About + +Returns a binary format that reads a binary value. If `length` is specified, the binary value will contain that many bytes. If `length` is not specified, the binary value will contain the remaining bytes. The `length` can be specified either as a number, or as a binary format of the length that precedes the binary data. diff --git a/query-languages/m/binaryformat-byte.md b/query-languages/m/binaryformat-byte.md index 024d3122d..43d19b271 100644 --- a/query-languages/m/binaryformat-byte.md +++ b/query-languages/m/binaryformat-byte.md @@ -1,22 +1,16 @@ --- description: "Learn more about: BinaryFormat.Byte" -title: "BinaryFormat.Byte | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Byte" +ms.subservice: m-source --- # BinaryFormat.Byte ## Syntax
-BinaryFormat.Byte(binary as binary) as any 
-
- -## About +BinaryFormat.Byte(binary as binary) as any +
+ +## About + A binary format that reads an 8-bit unsigned integer. diff --git a/query-languages/m/binaryformat-byteorder.md b/query-languages/m/binaryformat-byteorder.md index 369287a3a..9eb863c13 100644 --- a/query-languages/m/binaryformat-byteorder.md +++ b/query-languages/m/binaryformat-byteorder.md @@ -1,22 +1,16 @@ --- description: "Learn more about: BinaryFormat.ByteOrder" -title: "BinaryFormat.ByteOrder | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.ByteOrder" +ms.subservice: m-source --- # BinaryFormat.ByteOrder ## Syntax
-BinaryFormat.ByteOrder(binaryFormat as function, byteOrder as number) as function 
-
+BinaryFormat.ByteOrder(binaryFormat as function, byteOrder as number) as function +
+ +## About -## About -Returns a binary format with the byte order specified by `binaryFormat`. The default byte order is `ByteOrder.BigEndian`. +Returns a binary format with the byte order specified by `binaryFormat`. The default byte order is `ByteOrder.BigEndian`. diff --git a/query-languages/m/binaryformat-choice.md b/query-languages/m/binaryformat-choice.md index eb824ea1c..7c51bcaff 100644 --- a/query-languages/m/binaryformat-choice.md +++ b/query-languages/m/binaryformat-choice.md @@ -1,21 +1,19 @@ --- description: "Learn more about: BinaryFormat.Choice" -title: "BinaryFormat.Choice | Microsoft Docs" -ms.date: 3/7/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Choice" +ms.subservice: m-source --- # BinaryFormat.Choice ## Syntax
-BinaryFormat.Choice(binaryFormat as function, chooseFunction as function, optional type as nullable type, optional combineFunction as nullable function) as function
+BinaryFormat.Choice(
+    binaryFormat as function,
+    chooseFunction as function,
+    optional type as nullable type,
+    optional combineFunction as nullable function
+) as function
 
## About diff --git a/query-languages/m/binaryformat-decimal.md b/query-languages/m/binaryformat-decimal.md index 8880b2ff9..9bbf584f9 100644 --- a/query-languages/m/binaryformat-decimal.md +++ b/query-languages/m/binaryformat-decimal.md @@ -1,22 +1,16 @@ --- description: "Learn more about: BinaryFormat.Decimal" -title: "BinaryFormat.Decimal | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Decimal" +ms.subservice: m-source --- # BinaryFormat.Decimal ## Syntax
-BinaryFormat.Decimal(binary as binary) as any 
-
- -## About +BinaryFormat.Decimal(binary as binary) as any +
+ +## About + A binary format that reads a .NET 16-byte decimal value. diff --git a/query-languages/m/binaryformat-double.md b/query-languages/m/binaryformat-double.md index ec483aac6..8a6a21414 100644 --- a/query-languages/m/binaryformat-double.md +++ b/query-languages/m/binaryformat-double.md @@ -1,22 +1,16 @@ --- description: "Learn more about: BinaryFormat.Double" -title: "BinaryFormat.Double | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Double" +ms.subservice: m-source --- # BinaryFormat.Double ## Syntax -
  
-BinaryFormat.Double(binary as binary) as any 
+
+BinaryFormat.Double(binary as binary) as any
 
- -## About -A binary format that reads an 8-byte IEEE double-precision floating point value. + +## About + +A binary format that reads an 8-byte IEEE double-precision floating point value. diff --git a/query-languages/m/binaryformat-group.md b/query-languages/m/binaryformat-group.md index 135001b81..0b07ac61b 100644 --- a/query-languages/m/binaryformat-group.md +++ b/query-languages/m/binaryformat-group.md @@ -1,21 +1,19 @@ --- description: "Learn more about: BinaryFormat.Group" -title: "BinaryFormat.Group | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Group" +ms.subservice: m-source --- # BinaryFormat.Group ## Syntax
-BinaryFormat.Group(binaryFormat as function, group as list, optional extra as nullable function, optional lastKey as any) as function
+BinaryFormat.Group(
+    binaryFormat as function,
+    group as list,
+    optional extra as nullable function,
+    optional lastKey as any
+) as function
 
## About diff --git a/query-languages/m/binaryformat-length.md b/query-languages/m/binaryformat-length.md index 748b1a9bf..f2756e2ad 100644 --- a/query-languages/m/binaryformat-length.md +++ b/query-languages/m/binaryformat-length.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BinaryFormat.Length" -title: "BinaryFormat.Length | Microsoft Docs" -ms.date: 3/7/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Length" +ms.subservice: m-source --- # BinaryFormat.Length @@ -17,10 +10,10 @@ ms.author: dougklo
 BinaryFormat.Length(binaryFormat as function, length as any) as function
 
- + ## About -Returns a binary format that limits the amount of data that can be read. Both `BinaryFormat.List` and `BinaryFormat.Binary` can be used to read until end of the data. `BinaryFormat.Length` can be used to limit the number of bytes that are read. The `binaryFormat` parameter specifies the binary format to limit. The `length` parameter specifies the number of bytes to read. The `length` parameter may either be a number value, or a binary format value that specifies the format of the length value that appears that precedes the value being read. +Returns a binary format that limits the amount of data that can be read. Both [BinaryFormat.List](binaryformat-list.md) and [BinaryFormat.Binary](binaryformat-binary.md) can be used to read until end of the data. **BinaryFormat.Length** can be used to limit the number of bytes that are read. The `binaryFormat` parameter specifies the binary format to limit. The `length` parameter specifies the number of bytes to read. The `length` parameter may either be a number value, or a binary format value that specifies the format of the length value that appears that precedes the value being read. ## Example 1 diff --git a/query-languages/m/binaryformat-list.md b/query-languages/m/binaryformat-list.md index 82f8f178d..85a89e079 100644 --- a/query-languages/m/binaryformat-list.md +++ b/query-languages/m/binaryformat-list.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BinaryFormat.List" -title: "BinaryFormat.List | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.List" +ms.subservice: m-source --- # BinaryFormat.List @@ -17,7 +10,7 @@ ms.author: dougklo
 BinaryFormat.List(binaryFormat as function, optional countOrCondition as any) as function
 
- + ## About Returns a binary format that reads a sequence of items and returns a `list`. The `binaryFormat` parameter specifies the binary format of each item. There are three ways to determine the number of items read: diff --git a/query-languages/m/binaryformat-null.md b/query-languages/m/binaryformat-null.md index 693cbe705..e3f2fe297 100644 --- a/query-languages/m/binaryformat-null.md +++ b/query-languages/m/binaryformat-null.md @@ -1,22 +1,16 @@ --- description: "Learn more about: BinaryFormat.Null" -title: "BinaryFormat.Null | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Null" +ms.subservice: m-source --- # BinaryFormat.Null ## Syntax -
   
-BinaryFormat.Null(binary as binary) as any 
-
- -## About -A binary format that reads zero bytes and returns null. +
+BinaryFormat.Null(binary as binary) as any
+
+ +## About + +A binary format that reads zero bytes and returns null. diff --git a/query-languages/m/binaryformat-record.md b/query-languages/m/binaryformat-record.md index 2c24bdeea..0b949ab85 100644 --- a/query-languages/m/binaryformat-record.md +++ b/query-languages/m/binaryformat-record.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BinaryFormat.Record" -title: "BinaryFormat.Record | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Record" +ms.subservice: m-source --- # BinaryFormat.Record @@ -17,7 +10,7 @@ ms.author: dougklo
 BinaryFormat.Record(record as record) as function
 
- + ## About Returns a binary format that reads a record. The `record` parameter specifies the format of the record. Each field in the record can have a different binary format. If a field contains a value that is not a binary format value, then no data is read for that field, and the field value is echoed to the result. diff --git a/query-languages/m/binaryformat-signedinteger16.md b/query-languages/m/binaryformat-signedinteger16.md index 50c05698e..e65ef7bcd 100644 --- a/query-languages/m/binaryformat-signedinteger16.md +++ b/query-languages/m/binaryformat-signedinteger16.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BinaryFormat.SignedInteger16" -title: "BinaryFormat.SignedInteger16 | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.SignedInteger16" +ms.subservice: m-source --- # BinaryFormat.SignedInteger16 @@ -16,8 +9,8 @@ ms.author: dougklo
 BinaryFormat.SignedInteger16(binary as binary) as any
-
- -## About +
+ +## About + A binary format that reads a 16-bit signed integer. - diff --git a/query-languages/m/binaryformat-signedinteger32.md b/query-languages/m/binaryformat-signedinteger32.md index ec384d434..12e1f6041 100644 --- a/query-languages/m/binaryformat-signedinteger32.md +++ b/query-languages/m/binaryformat-signedinteger32.md @@ -1,23 +1,16 @@ --- description: "Learn more about: BinaryFormat.SignedInteger32" -title: "BinaryFormat.SignedInteger32 | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.SignedInteger32" +ms.subservice: m-source --- # BinaryFormat.SignedInteger32 - + ## Syntax
 BinaryFormat.SignedInteger32(binary as binary) as any
 
- -## About -A binary format that reads a 32-bit signed integer. +## About + +A binary format that reads a 32-bit signed integer. diff --git a/query-languages/m/binaryformat-signedinteger64.md b/query-languages/m/binaryformat-signedinteger64.md index 8edff0d2b..b477d3040 100644 --- a/query-languages/m/binaryformat-signedinteger64.md +++ b/query-languages/m/binaryformat-signedinteger64.md @@ -1,23 +1,16 @@ --- description: "Learn more about: BinaryFormat.SignedInteger64" -title: "BinaryFormat.SignedInteger64 | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.SignedInteger64" +ms.subservice: m-source --- # BinaryFormat.SignedInteger64 ## Syntax
-BinaryFormat.SignedInteger64(binary as binary) as any  
+BinaryFormat.SignedInteger64(binary as binary) as any
 
- -## About -A binary format that reads a 64-bit signed integer. - + +## About + +A binary format that reads a 64-bit signed integer. diff --git a/query-languages/m/binaryformat-single.md b/query-languages/m/binaryformat-single.md index 9d1f7e4ae..02e6e7115 100644 --- a/query-languages/m/binaryformat-single.md +++ b/query-languages/m/binaryformat-single.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BinaryFormat.Single" -title: "BinaryFormat.Single | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Single" +ms.subservice: m-source --- # BinaryFormat.Single @@ -16,8 +9,8 @@ ms.author: dougklo
 BinaryFormat.Single(binary as binary) as any
-
- -## About +
+ +## About + A binary format that reads a 4-byte IEEE single-precision floating point value. - diff --git a/query-languages/m/binaryformat-text.md b/query-languages/m/binaryformat-text.md index a05d48d9f..351da76a1 100644 --- a/query-languages/m/binaryformat-text.md +++ b/query-languages/m/binaryformat-text.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BinaryFormat.Text" -title: "BinaryFormat.Text | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Text" +ms.subservice: m-source --- # BinaryFormat.Text @@ -17,7 +10,7 @@ ms.author: dougklo
 BinaryFormat.Text(length as any, optional encoding as nullable number) as function 
 
- + ## About Returns a binary format that reads a text value. The `length` specifies the number of bytes to decode, or the binary format of the length that precedes the text. The optional `encoding` value specifies the encoding of the text. If the `encoding` is not specified, then the encoding is determined from the Unicode byte order marks. If no byte order marks are present, then `TextEncoding.Utf8` is used. diff --git a/query-languages/m/binaryformat-transform.md b/query-languages/m/binaryformat-transform.md index c1d195e02..66be2169c 100644 --- a/query-languages/m/binaryformat-transform.md +++ b/query-languages/m/binaryformat-transform.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BinaryFormat.Transform" -title: "BinaryFormat.Transform | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.Transform" +ms.subservice: m-source --- # BinaryFormat.Transform diff --git a/query-languages/m/binaryformat-unsignedinteger16.md b/query-languages/m/binaryformat-unsignedinteger16.md index 68b8cba71..944243897 100644 --- a/query-languages/m/binaryformat-unsignedinteger16.md +++ b/query-languages/m/binaryformat-unsignedinteger16.md @@ -1,23 +1,16 @@ --- description: "Learn more about: BinaryFormat.UnsignedInteger16" -title: "BinaryFormat.UnsignedInteger16 | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.UnsignedInteger16" +ms.subservice: m-source --- # BinaryFormat.UnsignedInteger16 ## Syntax
-BinaryFormat.UnsignedInteger16(binary as binary) as any 
-
- -## About -A binary format that reads a 16-bit unsigned integer. - +BinaryFormat.UnsignedInteger16(binary as binary) as any +
+ +## About + +A binary format that reads a 16-bit unsigned integer. diff --git a/query-languages/m/binaryformat-unsignedinteger32.md b/query-languages/m/binaryformat-unsignedinteger32.md index 06e22853e..bb208e530 100644 --- a/query-languages/m/binaryformat-unsignedinteger32.md +++ b/query-languages/m/binaryformat-unsignedinteger32.md @@ -1,23 +1,16 @@ --- description: "Learn more about: BinaryFormat.UnsignedInteger32" -title: "BinaryFormat.UnsignedInteger32 | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.UnsignedInteger32" +ms.subservice: m-source --- # BinaryFormat.UnsignedInteger32 - + ## Syntax
 BinaryFormat.UnsignedInteger32(binary as binary) as any
-
+
+ +## About - -## About -A binary format that reads a 32-bit unsigned integer. +A binary format that reads a 32-bit unsigned integer. diff --git a/query-languages/m/binaryformat-unsignedinteger64.md b/query-languages/m/binaryformat-unsignedinteger64.md index fcddb1f19..1a10d4638 100644 --- a/query-languages/m/binaryformat-unsignedinteger64.md +++ b/query-languages/m/binaryformat-unsignedinteger64.md @@ -1,23 +1,16 @@ --- description: "Learn more about: BinaryFormat.UnsignedInteger64" -title: "BinaryFormat.UnsignedInteger64 | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryFormat.UnsignedInteger64" +ms.subservice: m-source --- # BinaryFormat.UnsignedInteger64 ## Syntax
-BinaryFormat.UnsignedInteger64(binary as binary) as any  
-
- -## About -A binary format that reads a 64-bit unsigned integer. +BinaryFormat.UnsignedInteger64(binary as binary) as any + + +## About +A binary format that reads a 64-bit unsigned integer. diff --git a/query-languages/m/binaryoccurrence-type.md b/query-languages/m/binaryoccurrence-type.md index 1b8c6a1af..3f456d3b3 100644 --- a/query-languages/m/binaryoccurrence-type.md +++ b/query-languages/m/binaryoccurrence-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BinaryOccurrence.Type" -title: "BinaryOccurrence.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BinaryOccurrence.Type" +ms.subservice: m-source --- # BinaryOccurrence.Type @@ -18,7 +11,7 @@ Specifies how many times the item is expected to appear in the group. ## Allowed values -|Name|Value|Description| +|Name|Value|Description| |------------|--|-------------| |**BinaryOccurrence.Optional**|0|The item is expected to appear zero or one time in the input.| |**BinaryOccurrence.Required**|1|The item is expected to appear once in the input.| diff --git a/query-languages/m/breadcrumb/toc.yml b/query-languages/m/breadcrumb/toc.yml index 61d8fca61..62b3289a2 100644 --- a/query-languages/m/breadcrumb/toc.yml +++ b/query-languages/m/breadcrumb/toc.yml @@ -1,3 +1,3 @@ -- name: Docs - tocHref: / - topicHref: / \ No newline at end of file +- name: Power Query M + tocHref: /powerquery-m/ + topicHref: /powerquery-m/index diff --git a/query-languages/m/buffermode-type.md b/query-languages/m/buffermode-type.md index fb75f4603..8d921d949 100644 --- a/query-languages/m/buffermode-type.md +++ b/query-languages/m/buffermode-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: BufferMode.Type" -title: "BufferMode.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "BufferMode.Type" +ms.subservice: m-source --- # BufferMode.Type @@ -18,8 +11,8 @@ Describes the type of buffering to be performed. ## Allowed values -|Name|Value|Description| -|------------|--|---------------| +|Name|Value|Description| +|------------|--|---------------| |**BufferMode.Eager**|1|The entire value is immediately buffered in memory before continuing.| |**BufferMode.Delayed**|2|The type of the value is computed immediately but its contents aren't buffered until data is needed, at which point the entire value is immediately buffered.| diff --git a/query-languages/m/byte-from.md b/query-languages/m/byte-from.md index d54974083..c47d903a4 100644 --- a/query-languages/m/byte-from.md +++ b/query-languages/m/byte-from.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Byte.From" -title: "Byte.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Byte.From" +ms.subservice: m-source --- # Byte.From ## Syntax -
  
-Byte.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable number
+
+Byte.From(
+    value as any,
+    optional culture as nullable text,
+    optional roundingMode as nullable number
+) as nullable number
 
- + ## About -Returns an 8-bit integer `number` value from the given `value`. If the given `value` is `null`, **Byte.From** returns `null`. If the given `value` is a `number` within the range of an 8-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](/powerquery-m/roundingmode-toeven). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](/powerquery-m/number-fromtext). Refer to [Number.Round](/powerquery-m/number-round) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). +Returns an 8-bit integer `number` value from the given `value`. If the given `value` is `null`, **Byte.From** returns `null`. If the given `value` is a `number` within the range of an 8-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](roundingmode-type.md). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](number-fromtext.md). Refer to [Number.Round](number-round.md) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). ## Example 1 @@ -38,7 +35,7 @@ Byte.From("4") ## Example 2 -Get the 8-bit integer `number` value of `"4.5"` using [RoundingMode.AwayFromZero](/powerquery-m/roundingmode-awayfromzero). +Get the 8-bit integer `number` value of `"4.5"` using [RoundingMode.AwayFromZero](roundingmode-type.md). **Usage** @@ -49,3 +46,7 @@ Byte.From("4.5", null, RoundingMode.AwayFromZero) **Output** `5` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/byteorder-type.md b/query-languages/m/byteorder-type.md index d90bff544..72158784c 100644 --- a/query-languages/m/byteorder-type.md +++ b/query-languages/m/byteorder-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: ByteOrder.Type" -title: "ByteOrder.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "ByteOrder.Type" +ms.subservice: m-source --- # ByteOrder.Type diff --git a/query-languages/m/cdm-contents.md b/query-languages/m/cdm-contents.md index 3cefeecc8..f0e3f91d4 100644 --- a/query-languages/m/cdm-contents.md +++ b/query-languages/m/cdm-contents.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Cdm.Contents" -title: "Cdm.Contents | Microsoft Docs" -ms.date: 03/18/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cdm.Contents" +ms.subservice: m-source --- # Cdm.Contents ## Syntax
-Cdm.Contents(table as table) as table 
+Cdm.Contents(table as table) as table
 
## About -This function is unavailable because it requires .NET 4.5. +This function is unavailable in the current context. diff --git a/query-languages/m/character-fromnumber.md b/query-languages/m/character-fromnumber.md index 949b5331c..8af4720ee 100644 --- a/query-languages/m/character-fromnumber.md +++ b/query-languages/m/character-fromnumber.md @@ -1,30 +1,25 @@ --- description: "Learn more about: Character.FromNumber" -title: "Character.FromNumber | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Character.FromNumber" +ms.subservice: m-source --- # Character.FromNumber ## Syntax -
  
+
 Character.FromNumber(number as nullable number) as nullable text
 
- + ## About Returns the character equivalent of the number. +The provided `number` should be a 21-bit Unicode code point. + ## Example 1 -Given the number 9, find the character value. +Convert a number to its equivalent character value. **Usage** @@ -35,3 +30,31 @@ Character.FromNumber(9) **Output** `"#(tab)"` + +## Example 2 + +Convert a character to a number and back again. + +**Usage** + +```powerquery-m +Character.FromNumber(Character.ToNumber("A")) +``` + +**Output** + +`"A"` + +## Example 3 + +Convert the hexadecimal code point for the "grinning face" emoticon to its equivalent UTF-16 surrogate pair. + +**Usage** + +```powerquery-m +Character.FromNumber(0x1F600) +``` + +**Output** + +`"#(0001F600)"` diff --git a/query-languages/m/character-tonumber.md b/query-languages/m/character-tonumber.md index 2016572a6..c04afa1af 100644 --- a/query-languages/m/character-tonumber.md +++ b/query-languages/m/character-tonumber.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Character.ToNumber" -title: "Character.ToNumber | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Character.ToNumber" +ms.subservice: m-source --- # Character.ToNumber @@ -17,14 +10,16 @@ ms.author: dougklo
 Character.ToNumber(character as nullable text) as nullable number
 
- + ## About Returns the number equivalent of the character, `character`. +The result will be the 21-bit Unicode code point represented by the provided character or surrogate pair. + ## Example 1 -Given the character "#(tab)" 9, find the number value. +Convert a character to its equivalent number value. **Usage** @@ -35,3 +30,17 @@ Character.ToNumber("#(tab)") **Output** `9` + +## Example 2 + +Convert the UTF-16 surrogate pair for the "grinning face" emoticon to its equivalent hexadecimal code point. + +**Usage** + +```powerquery-m +Number.ToText(Character.ToNumber("#(0001F600)"), "X") +``` + +**Output** + +`"1F600"` diff --git a/query-languages/m/combiner-combinetextbydelimiter.md b/query-languages/m/combiner-combinetextbydelimiter.md index b1fef07b1..f8158b07b 100644 --- a/query-languages/m/combiner-combinetextbydelimiter.md +++ b/query-languages/m/combiner-combinetextbydelimiter.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Combiner.CombineTextByDelimiter" -title: "Combiner.CombineTextByDelimiter | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Combiner.CombineTextByDelimiter" +ms.subservice: m-source --- # Combiner.CombineTextByDelimiter @@ -17,10 +10,10 @@ ms.author: dougklo
 Combiner.CombineTextByDelimiter(delimiter as text, optional quoteStyle as nullable number) as function
 
- + ## About -Returns a function that combines a list of text into a single text using the specified delimiter. +Returns a function that combines a list of text values into a single text value using the specified delimiter. ## Example 1 @@ -35,3 +28,34 @@ Combiner.CombineTextByDelimiter(";")({"a", "b", "c"}) **Output** `"a;b;c"` + +## Example 2 + +Combine the text of two columns using a comma delimiter and CSV-style quoting. + +**Usage** + +```powerquery-m +let + Source = #table( + type table [Column1 = text, Column2 = text], + {{"a", "b"}, {"c", "d,e,f"}} + ), + Merged = Table.CombineColumns( + Source, + {"Column1", "Column2"}, + Combiner.CombineTextByDelimiter(",", QuoteStyle.Csv), + "Merged" + ) +in + Merged +``` + +**Output** + +```powerquery-m +#table( + type table [Merged = text], + {{"a,b"}, {"c,""d,e,f"""}} +) +``` diff --git a/query-languages/m/combiner-combinetextbyeachdelimiter.md b/query-languages/m/combiner-combinetextbyeachdelimiter.md index a3cb9f246..67e974263 100644 --- a/query-languages/m/combiner-combinetextbyeachdelimiter.md +++ b/query-languages/m/combiner-combinetextbyeachdelimiter.md @@ -1,22 +1,30 @@ --- description: "Learn more about: Combiner.CombineTextByEachDelimiter" -title: "Combiner.CombineTextByEachDelimiter | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Combiner.CombineTextByEachDelimiter" +ms.subservice: m-source --- # Combiner.CombineTextByEachDelimiter ## Syntax
-Combiner.CombineTextByEachDelimiter(delimiters as list, optional quoteStyle as nullable number) as function  
-
- -## About -Returns a function that combines a list of text into a single text using each specified delimiter in sequence. +Combiner.CombineTextByEachDelimiter(delimiters as list, optional quoteStyle as nullable number) as function +
+ +## About + +Returns a function that combines a list of text values into a single text value using a sequence of delimiters. + +## Example 1 + +Combine a list of text values using a sequence of delimiters. + +**Usage** + +```powerquery-m +Combiner.CombineTextByEachDelimiter({"=", "+"})({"a", "b", "c"}) +``` + +**Output** + +`"a=b+c"` diff --git a/query-languages/m/combiner-combinetextbylengths.md b/query-languages/m/combiner-combinetextbylengths.md index 05c5e74ac..10025d92a 100644 --- a/query-languages/m/combiner-combinetextbylengths.md +++ b/query-languages/m/combiner-combinetextbylengths.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Combiner.CombineTextByLengths" -title: "Combiner.CombineTextByLengths | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Combiner.CombineTextByLengths" +ms.subservice: m-source --- # Combiner.CombineTextByLengths @@ -16,8 +9,36 @@ ms.author: dougklo
 Combiner.CombineTextByLengths(lengths as list, optional template as nullable text) as function
-
- -## About -Returns a function that combines a list of text into a single text using the specified lengths. +
+ +## About + +Returns a function that combines a list of text values into a single text value using the specified lengths. + +## Example 1 + +Combine a list of text values by extracting the specified numbers of characters from each input value. + +**Usage** + +```powerquery-m +Combiner.CombineTextByLengths({1, 2, 3})({"aaa", "bbb", "ccc"}) +``` + +**Output** + +`"abbccc"` + +## Example 2 + +Combine a list of text values by extracting the specified numbers of characters, after first pre-filling the result with the template text. + +**Usage** + +```powerquery-m +Combiner.CombineTextByLengths({1, 2, 3}, "*********")({"aaa", "bbb", "ccc"}) +``` + +**Output** +`"abbccc***"` diff --git a/query-languages/m/combiner-combinetextbypositions.md b/query-languages/m/combiner-combinetextbypositions.md index 285bc4bdc..b8081e404 100644 --- a/query-languages/m/combiner-combinetextbypositions.md +++ b/query-languages/m/combiner-combinetextbypositions.md @@ -1,23 +1,32 @@ --- description: "Learn more about: Combiner.CombineTextByPositions" -title: "Combiner.CombineTextByPositions | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Combiner.CombineTextByPositions" +ms.subservice: m-source --- # Combiner.CombineTextByPositions ## Syntax
-Combiner.CombineTextByPositions(positions as list, optional template as nullable text) as function 
+Combiner.CombineTextByPositions(positions as list, optional template as nullable text) as function
 
- -## About -Returns a function that combines a list of text into a single text using the specified positions. - + +## About + +Returns a function that combines a list of text values into a single text value using the specified output positions. + +## Example 1 + +Combine a list of text values by placing them in the output at the specified positions. + +**Usage** + +```powerquery-m +Combiner.CombineTextByPositions({0, 5, 10})({"abc", "def", "ghi"}) +``` + +**Output** + +```powerquery-m +"abc def ghi" +``` diff --git a/query-languages/m/combiner-combinetextbyranges.md b/query-languages/m/combiner-combinetextbyranges.md index 71815173c..1b9712439 100644 --- a/query-languages/m/combiner-combinetextbyranges.md +++ b/query-languages/m/combiner-combinetextbyranges.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Combiner.CombineTextByRanges" -title: "Combiner.CombineTextByRanges | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Combiner.CombineTextByRanges" +ms.subservice: m-source --- # Combiner.CombineTextByRanges @@ -17,7 +10,23 @@ ms.author: dougklo
 Combiner.CombineTextByRanges(ranges as list, optional template as nullable text) as function
 
- + ## About -Returns a function that combines a list of text into a single text using the specified positions and lengths. A null length indicates that the entire text value should be included. +Returns a function that combines a list of text values into a single text value using the specified output positions and lengths. A null length indicates that the entire text value should be included. + +## Example 1 + +Combine a list of text values using the specified output positions and lengths. + +**Usage** + +```powerquery-m +Combiner.CombineTextByRanges({{0, 1}, {3, 2}, {6, null}})({"abc", "def", "ghijkl"}) +``` + +**Output** + +```powerquery-m +"a de ghijkl" +``` diff --git a/query-languages/m/combiner-functions.md b/query-languages/m/combiner-functions.md index eef5b0cec..41e4f56c9 100644 --- a/query-languages/m/combiner-functions.md +++ b/query-languages/m/combiner-functions.md @@ -1,23 +1,17 @@ --- description: "Learn more about: Combiner functions" -title: "Combiner functions | Microsoft Docs" -ms.date: 5/16/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Combiner functions" +ms.date: 11/14/2024 +ms.custom: "nonautomated-date" --- # Combiner functions -These functions are used by other library functions that merge values. For example, `Table.ToList` and `Table.CombineColumns` apply a combiner function to each row in a table to produce a single value for each row. +These functions are used by other library functions that merge values. For example, [Table.ToList](table-tolist.md) and [Table.CombineColumns](table-combinecolumns.md) apply a combiner function to each row in a table to produce a single value for each row. |Name|Description| |------------|---------------| -|[Combiner.CombineTextByDelimiter](combiner-combinetextbydelimiter.md)|Returns a function that combines a list of text into a single text using the specified delimiter.| -|[Combiner.CombineTextByEachDelimiter](combiner-combinetextbyeachdelimiter.md)|Returns a function that combines a list of text into a single text using each specified delimiter in sequence.| -|[Combiner.CombineTextByLengths](combiner-combinetextbylengths.md)|Returns a function that combines a list of text into a single text using the specified lengths.| -|[Combiner.CombineTextByPositions](combiner-combinetextbypositions.md)|Returns a function that combines a list of text into a single text using the specified positions.| -|[Combiner.CombineTextByRanges](combiner-combinetextbyranges.md)|Returns a function that combines a list of text into a single text using the specified positions and lengths.| +|[Combiner.CombineTextByDelimiter](combiner-combinetextbydelimiter.md)|Returns a function that combines a list of text using the specified delimiter.| +|[Combiner.CombineTextByEachDelimiter](combiner-combinetextbyeachdelimiter.md)|Returns a function that combines a list of text using a sequence of delimiters.| +|[Combiner.CombineTextByLengths](combiner-combinetextbylengths.md)|Returns a function that combines a list of text using the specified lengths.| +|[Combiner.CombineTextByPositions](combiner-combinetextbypositions.md)|Returns a function that combines a list of text using the specified output positions.| +|[Combiner.CombineTextByRanges](combiner-combinetextbyranges.md)|Returns a function that combines a list of text using the specified positions and lengths.| diff --git a/query-languages/m/comments.md b/query-languages/m/comments.md index 9d89f29c8..6d709d082 100644 --- a/query-languages/m/comments.md +++ b/query-languages/m/comments.md @@ -1,37 +1,36 @@ --- description: "Learn more about: Comments" -title: "Comments | Microsoft Docs" -ms.date: 12/12/2018 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Comments" +ms.topic: conceptual +ms.date: 10/7/2022 +ms.custom: "nonautomated-date" +ms.subservice: m-background --- # Comments -You can add comments to your code with single-line comments `//` or multi-line comments that begin with `/*` and end with `*/`. - -**Example - Single-line comment** - -```powerquery-m -let - //Convert to proper case. - Source = Text.Proper("hello world") -in - Source -``` -**Example - Multi-line comment** - -```powerquery-m -/* Capitalize each word in the Item column in the Orders table. Text.Proper -is evaluated for each Item in each table row. */ -let - Orders = Table.FromRecords({ - [OrderID = 1, CustomerID = 1, Item = "fishing rod", Price = 100.0], - [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0], - [OrderID = 3, CustomerID = 2, Item = "fishing net", Price = 25.0]}), - #"Capitalized Each Word" = Table.TransformColumns(Orders, {"Item", Text.Proper}) -in - #"Capitalized Each Word" -``` + +You can add comments to your code with single-line comments `//` or multi-line comments that begin with `/*` and end with `*/`. + +**Example - Single-line comment** + +```powerquery-m +let + //Convert to proper case. + Source = Text.Proper("hello world") +in + Source +``` + +**Example - Multi-line comment** + +```powerquery-m +/* Capitalize each word in the Item column in the Orders table. Text.Proper +is evaluated for each Item in each table row. */ +let + Orders = Table.FromRecords({ + [OrderID = 1, CustomerID = 1, Item = "fishing rod", Price = 100.0], + [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0], + [OrderID = 3, CustomerID = 2, Item = "fishing net", Price = 25.0]}), + #"Capitalized Each Word" = Table.TransformColumns(Orders, {"Item", Text.Proper}) +in + #"Capitalized Each Word" +``` diff --git a/query-languages/m/comparer-equals.md b/query-languages/m/comparer-equals.md index 1b91a08c4..0e18b399d 100644 --- a/query-languages/m/comparer-equals.md +++ b/query-languages/m/comparer-equals.md @@ -1,34 +1,31 @@ --- description: "Learn more about: Comparer.Equals" -title: "Comparer.Equals | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Comparer.Equals" +ms.subservice: m-source --- # Comparer.Equals ## Syntax
-Comparer.Equals(comparer as function, x as any, y as any) as logical  
+Comparer.Equals(
+    comparer as function,
+    x as any,
+    y as any
+) as logical
 
- + ## About Returns a `logical` value based on the equality check over the two given values, `x` and `y`, using the provided `comparer`. -`comparer` is a `Comparer` which is used to control the comparison. Comparers can be used to provide case-insensitive or culture and locale-aware comparisons. +`comparer` is a `Comparer` which is used to control the comparison. A comparer is a function that accepts two arguments and returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second. Comparers can be used to provide case-insensitive or culture and locale-aware comparisons. The following built-in comparers are available in the formula language: -* `Comparer.Ordinal`: Used to perform an exact ordinal comparison -* `Comparer.OrdinalIgnoreCase`: Used to perform an exact ordinal case-insensitive comparison -* `Comparer.FromCulture`: Used to perform a culture-aware comparison +* [Comparer.Ordinal](comparer-ordinal.md): Used to perform an exact ordinal comparison +* [Comparer.OrdinalIgnoreCase](comparer-ordinalignorecase.md): Used to perform an exact ordinal case-insensitive comparison +* [Comparer.FromCulture](comparer-fromculture.md): Used to perform a culture-aware comparison ## Example 1 @@ -43,3 +40,7 @@ Comparer.Equals(Comparer.FromCulture("en-US"), "1", "A") **Output** `false` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/comparer-fromculture.md b/query-languages/m/comparer-fromculture.md index 18701c24e..6cf1f3a8e 100644 --- a/query-languages/m/comparer-fromculture.md +++ b/query-languages/m/comparer-fromculture.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Comparer.FromCulture" -title: "Comparer.FromCulture | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Comparer.FromCulture" +ms.subservice: m-source --- # Comparer.FromCulture @@ -17,10 +10,14 @@ ms.author: dougklo
 Comparer.FromCulture(culture as text, optional ignoreCase as nullable logical) as function
 
- + ## About -Returns a comparer function given the `culture` and a logical value `ignoreCase` for case sensitivity for the comparison. The default value for `ignoreCase` is false. The value for culture are well known text representations of locales used in the .NET framework. +Returns a comparer function that uses the `culture` and the case-sensitivity specified by `ignoreCase` to perform comparisons. + +A comparer function accepts two arguments and returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second. + +The default value for `ignoreCase` is false. The `culture` should be one of the locales supported by the operating system (for example, "en-US"). ## Example 1 diff --git a/query-languages/m/comparer-functions.md b/query-languages/m/comparer-functions.md index 0e2825317..ac4ed09de 100644 --- a/query-languages/m/comparer-functions.md +++ b/query-languages/m/comparer-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Comparer functions" -title: "Comparer functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Comparer functions" +ms.date: 11/20/2024 +ms.custom: "nonautomated-date" --- # Comparer functions @@ -17,6 +11,6 @@ These functions test equality and determine ordering. |Name|Description| |------------|---------------| |[Comparer.Equals](comparer-equals.md)|Returns a logical value based on the equality check over the two given values.| -|[Comparer.FromCulture](comparer-fromculture.md)|Returns a comparer function given the culture and a logical value for case sensitivity for the comparison. The default value for ignoreCase is false. The value for culture are well known text representations of locales used in the .NET framework.| +|[Comparer.FromCulture](comparer-fromculture.md)|Returns a comparer function based on the specified culture and case-sensitivity.| |[Comparer.Ordinal](comparer-ordinal.md)|Returns a comparer function which uses Ordinal rules to compare values.| -|[Comparer.OrdinalIgnoreCase](comparer-ordinalignorecase.md)|Returns a case-insensitive comparer function which uses Ordinal rules to compare the provided values x and y.| +|[Comparer.OrdinalIgnoreCase](comparer-ordinalignorecase.md)|Returns a case-insensitive comparer function which uses Ordinal rules to compare the provided values.| diff --git a/query-languages/m/comparer-ordinal.md b/query-languages/m/comparer-ordinal.md index a2fcc645c..0526bfcb1 100644 --- a/query-languages/m/comparer-ordinal.md +++ b/query-languages/m/comparer-ordinal.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Comparer.Ordinal" -title: "Comparer.Ordinal | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Comparer.Ordinal" +ms.subservice: m-source --- # Comparer.Ordinal @@ -17,7 +10,7 @@ ms.author: dougklo
 Comparer.Ordinal(x as any, y as any) as number
 
- + ## About Returns a comparer function which uses Ordinal rules to compare the provided values `x` and `y`. @@ -26,6 +19,8 @@ Returns a comparer function which uses Ordinal rules to compare the provided val Using Ordinal rules, compare if "encyclopædia" and "encyclopaedia" are equivalent. Note these are equivalent using `Comparer.FromCulture("en-US")`. +A comparer function accepts two arguments and returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second. + **Usage** ```powerquery-m @@ -35,3 +30,7 @@ Comparer.Equals(Comparer.Ordinal, "encyclopædia", "encyclopaedia") **Output** `false` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/comparer-ordinalignorecase.md b/query-languages/m/comparer-ordinalignorecase.md index 4a6b79b70..b2aee4bb0 100644 --- a/query-languages/m/comparer-ordinalignorecase.md +++ b/query-languages/m/comparer-ordinalignorecase.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Comparer.OrdinalIgnoreCase" -title: "Comparer.OrdinalIgnoreCase | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Comparer.OrdinalIgnoreCase" +ms.subservice: m-source --- # Comparer.OrdinalIgnoreCase @@ -22,6 +15,8 @@ Comparer.OrdinalIgnoreCase(x as any, y as any) as number Returns a case-insensitive comparer function which uses Ordinal rules to compare the provided values `x` and `y`. +A comparer function accepts two arguments and returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second. + ## Example 1 Using case-insensitive Ordinal rules, compare "Abc" with "abc". Note "Abc" is less than "abc" using `Comparer.Ordinal`. diff --git a/query-languages/m/compression-type.md b/query-languages/m/compression-type.md index a6aeffc83..96b498f25 100644 --- a/query-languages/m/compression-type.md +++ b/query-languages/m/compression-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Compression.Type" -title: "Compression.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Compression.Type" +ms.subservice: m-source --- # Compression.Type diff --git a/query-languages/m/constants.md b/query-languages/m/constants.md index 7d533ac60..481393a74 100644 --- a/query-languages/m/constants.md +++ b/query-languages/m/constants.md @@ -1,30 +1,25 @@ --- description: "Learn more about: Constants" -title: "Constants | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Constants" --- # Constants The Power Query M formula language includes these constant values. ## List of constants - -|Name|Description| -|------------|---------------| + +|Name|Description| +|------------|---------------| +|[ItemExpression.Item](itemexpression-item.md)|An abstract syntax tree (AST) node representing the item in an item expression.| |[Number.E](number-e.md)|Returns 2.7182818284590451, the value of e up to 16 decimal digits.| |[Number.Epsilon](number-epsilon.md)|Returns the smallest possible number.| -|[Number.NaN](number-nan.md)|Represents 0/0.| -|[Number.NegativeInfinity](number-negativeinfinity.md)|Represents -1/0.| +|[Number.NaN](number-nan.md)|Represents 0/0.| +|[Number.NegativeInfinity](number-negativeinfinity.md)|Represents -1/0.| |[Number.PI](number-pi.md)|Returns 3.1415926535897931, the value for Pi up to 16 decimal digits.| -|[Number.PositiveInfinity](number-positiveinfinity.md)|Represents 1/0.| +|[Number.PositiveInfinity](number-positiveinfinity.md)|Represents 1/0.| +|[RowExpression.Row](rowexpression-row.md)|An abstract syntax tree (AST) node representing the row in a row expression.| -## See also +## Related content * [Number functions](number-functions.md) +* [Table construction](table-functions.md#table-construction) diff --git a/query-languages/m/csv-document.md b/query-languages/m/csv-document.md index 32054bd30..7077176e8 100644 --- a/query-languages/m/csv-document.md +++ b/query-languages/m/csv-document.md @@ -1,21 +1,20 @@ --- description: "Learn more about: Csv.Document" -title: "Csv.Document | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Csv.Document" +ms.subservice: m-source --- # Csv.Document ## Syntax
 
-Csv.Document(source as any, optional columns as any, optional delimiter as any, optional extraValues as nullable number, optional encoding as nullable number) as table
+Csv.Document(
+    source as any,
+    optional columns as any,
+    optional delimiter as any,
+    optional extraValues as nullable number,
+    optional encoding as nullable number
+) as table
 
## About @@ -23,17 +22,23 @@ Csv.Document(source as any, optional columns as any, optional d Returns the contents of the CSV document as a table. * `columns` can be null, the number of columns, a list of column names, a table type, or an options record. -* `delimiter` can be a single character, or a list of characters. Default: `","`. +* `delimiter` can be a single character, a list of characters, or the value `""`, which indicates rows should be split by consecutive whitespace characters. Default: `","`. * Refer to [ExtraValues.Type](extravalues-type.md) for the supported values of `extraValues`. -* `encoding` specifies the text encoding type. +* `encoding` specifies the [text encoding](textencoding-type.md) type. If a record is specified for `columns` (and `delimiter`, `extraValues`, and `encoding` are null), the following record fields may be provided: -* `Delimiter`: The column delimiter. Default: `","`. +* `Delimiter`: A single character column delimiter. Default: `","`. * `Columns`: Can be null, the number of columns, a list of column names, or a table type. If the number of columns is lower than the number found in the input, the additional columns will be ignored. If the number of columns is higher than the number found in the input, the additional columns will be null. When not specified, the number of columns will be determined by what is found in the input. * `Encoding`: The text encoding of the file. Default: 65001 (UTF-8). -* `CsvStyle`: Specifies how quotes are handled. [CsvStyle.QuoteAfterDelimiter](csvstyle-type.md) (default): Quotes in a field are only significant immediately following the delimiter. [CsvStyle.QuoteAlways](csvstyle-type.md): Quotes in a field are always significant, regardless of where they appear. -* `QuoteStyle`: Specifies how quoted line breaks are handled. [QuoteStyle.None](quotestyle-type.md) (default): All line breaks are treated as the end of the current row, even when they occur inside a quoted value. [QuoteStyle.Csv](quotestyle-type.md): Quoted line breaks are treated as part of the data, not as the end of the current row. +* `CsvStyle`: Specifies how quotes are handled. + * [CsvStyle.QuoteAfterDelimiter](csvstyle-type.md) (default): Quotes in a field are only significant immediately following the delimiter. + * [CsvStyle.QuoteAlways](csvstyle-type.md): Quotes in a field are always significant, regardless of where they appear. +* `QuoteStyle`: Specifies how quoted line breaks are handled. + * [QuoteStyle.Csv](quotestyle-type.md) (default): Quoted line breaks are treated as part of the data, not as the end of the current row. + * [QuoteStyle.None](quotestyle-type.md): All line breaks are treated as the end of the current row, even when they occur inside a quoted value. +* `IncludeByteOrderMark`: A logical value indicating whether to include a Byte Order Mark (BOM) at the beginning of the CSV output. When set to `true`, the BOM is written (for example, UTF-8 BOM: `0xEF 0xBB 0xBF`); when set to `false`, no BOM is included. This option is applicable only in output scenarios. Default is `false`. +* `ExtraValues`: Refer to [ExtraValues.Type](extravalues-type.md) for the supported values of `ExtraValues`. ## Example 1 @@ -54,4 +59,27 @@ in Table.FromRecords({ [OrderID = "1", Item = "Fishing rod"], [OrderID = "2", Item = "1 lb. worms"] +}) +``` + +## Example 2 + +Process CSV text with multiple delimiter characters. In this example, the third parameter specifies the delimiter pattern `#|#` to use instead of the default. + +**Usage** + +```powerquery-m +let + csv = Text.Combine({"OrderID#|#Color", "1#|#Red", "2#|#Blue"}, "#(cr)#(lf)") +in + Table.PromoteHeaders(Csv.Document(csv, null, "#|#")) +``` + +**Output** + +```powerquery-m +Table.FromRecords({ + [OrderID = "1", Color = "Red"], + [OrderID = "2", Color = "Blue"] +}) ``` diff --git a/query-languages/m/csvstyle-type.md b/query-languages/m/csvstyle-type.md index b29f78fca..7b5bcc67a 100644 --- a/query-languages/m/csvstyle-type.md +++ b/query-languages/m/csvstyle-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: CsvStyle.Type" -title: "CsvStyle.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "CsvStyle.Type" +ms.subservice: m-source --- # CsvStyle.Type @@ -18,8 +11,8 @@ Specifies the significance of quotes in CSV documents. ## Allowed values -|Name|Value|Description| -|------------|--|----------------| +|Name|Value|Description| +|------------|--|----------------| |**CsvStyle.QuoteAfterDelimiter**|0|Quotes in a field are only significant immediately following the delimiter.| |**CsvStyle.QuoteAlways**|1|Quotes in a field are always significant regardless of where they appear.| diff --git a/query-languages/m/cube-addandexpanddimensioncolumn.md b/query-languages/m/cube-addandexpanddimensioncolumn.md index 1b1636e85..41c83e9ef 100644 --- a/query-languages/m/cube-addandexpanddimensioncolumn.md +++ b/query-languages/m/cube-addandexpanddimensioncolumn.md @@ -1,21 +1,21 @@ --- description: "Learn more about: Cube.AddAndExpandDimensionColumn" -title: "Cube.AddAndExpandDimensionColumn | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.AddAndExpandDimensionColumn" +ms.subservice: m-source --- # Cube.AddAndExpandDimensionColumn ## Syntax -
Cube.AddAndExpandDimensionColumn(**cube** as table, **dimensionSelector** as any, **attributeNames** as list, optional **newColumnNames** as any) as table
+
+Cube.AddAndExpandDimensionColumn(
+    cube as table,
+    dimensionSelector as any,
+    attributeNames as list,
+    optional newColumnNames as any
+) as table
 
## About -Merges the specified dimension table, `dimensionSelector`, into the cube’s, `cube`, filter context and changes the dimensional granularity by expanding the specified set, `attributeNames`, of dimension attributes. The dimension attributes are added to the tabular view with columns named `newColumnNames`, or `attributeNames` if not specified. + +Merges the specified dimension table, `dimensionSelector`, into the cube's, `cube`, filter context and changes the dimensional granularity by expanding the specified set, `attributeNames`, of dimension attributes. The dimension attributes are added to the tabular view with columns named `newColumnNames`, or `attributeNames` if not specified. diff --git a/query-languages/m/cube-addmeasurecolumn.md b/query-languages/m/cube-addmeasurecolumn.md index 8dfe3ee3b..b6afca03e 100644 --- a/query-languages/m/cube-addmeasurecolumn.md +++ b/query-languages/m/cube-addmeasurecolumn.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Cube.AddMeasureColumn" -title: "Cube.AddMeasureColumn | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.AddMeasureColumn" +ms.subservice: m-source --- # Cube.AddMeasureColumn ## Syntax
-Cube.AddMeasureColumn(**cube** as table, **column** as text, **measureSelector** as any) as table
+Cube.AddMeasureColumn(
+    cube as table,
+    column as text,
+    measureSelector as any
+) as table
 
## About + Adds a column with the name `column` to the `cube` that contains the results of the measure `measureSelector` applied in the row context of each row. Measure application is affected by changes to dimension granularity and slicing. Measure values will be adjusted after certain cube operations are performed. diff --git a/query-languages/m/cube-applyparameter.md b/query-languages/m/cube-applyparameter.md index 5dd5366c1..f1d52dab7 100644 --- a/query-languages/m/cube-applyparameter.md +++ b/query-languages/m/cube-applyparameter.md @@ -1,24 +1,20 @@ --- description: "Learn more about: Cube.ApplyParameter" -title: "Cube.ApplyParameter | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.ApplyParameter" +ms.subservice: m-source --- # Cube.ApplyParameter ## Syntax
-Cube.ApplyParameter(cube as table, parameter as any, optional arguments as nullable list) as table  
+Cube.ApplyParameter(
+    cube as table,
+    parameter as any,
+    optional arguments as nullable list
+) as table
 
- -## About - + +## About + Returns a cube after applying `parameter` with `arguments` to `cube`. - diff --git a/query-languages/m/cube-attributememberid.md b/query-languages/m/cube-attributememberid.md index 881c7c842..23474f86d 100644 --- a/query-languages/m/cube-attributememberid.md +++ b/query-languages/m/cube-attributememberid.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Cube.AttributeMemberId" -title: "Cube.AttributeMemberId | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.AttributeMemberId" +ms.subservice: m-source --- # Cube.AttributeMemberId @@ -18,4 +11,5 @@ ms.author: dougklo
## About + Returns the unique member identifier from a member property value. `attribute`. Returns null for any other values. diff --git a/query-languages/m/cube-attributememberproperty.md b/query-languages/m/cube-attributememberproperty.md index f5470be93..8d123712a 100644 --- a/query-languages/m/cube-attributememberproperty.md +++ b/query-languages/m/cube-attributememberproperty.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Cube.AttributeMemberProperty" -title: "Cube.AttributeMemberProperty | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.AttributeMemberProperty" +ms.subservice: m-source --- # Cube.AttributeMemberProperty @@ -19,5 +12,5 @@ Cube.AttributeMemberProperty(attribute as any, propertyName as tex ## About -Returns the property `propertyName` of dimension attribute `attribute`. +Returns the property `propertyName` of dimension attribute `attribute`. diff --git a/query-languages/m/cube-collapseandremovecolumns.md b/query-languages/m/cube-collapseandremovecolumns.md index 828f2ce10..5180efd7a 100644 --- a/query-languages/m/cube-collapseandremovecolumns.md +++ b/query-languages/m/cube-collapseandremovecolumns.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Cube.CollapseAndRemoveColumns" -title: "Cube.CollapseAndRemoveColumns | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.CollapseAndRemoveColumns" +ms.subservice: m-source --- # Cube.CollapseAndRemoveColumns ## Syntax
-Cube.CollapseAndRemoveColumns(**cube** as table, **columnNames** as list) as table
+Cube.CollapseAndRemoveColumns(cube as table, columnNames as list) as table
 
## About + Changes the dimensional granularity of the filter context for the `cube` by collapsing the attributes mapped to the specified columns `columnNames`. The columns are also removed from the tabular view of the cube. diff --git a/query-languages/m/cube-dimensions.md b/query-languages/m/cube-dimensions.md index 9c8cb6163..819804bca 100644 --- a/query-languages/m/cube-dimensions.md +++ b/query-languages/m/cube-dimensions.md @@ -1,24 +1,16 @@ --- description: "Learn more about: Cube.Dimensions" -title: "Cube.Dimensions | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.Dimensions" +ms.subservice: m-source --- # Cube.Dimensions ## Syntax
-Cube.Dimensions(**cube** as table) as table
+Cube.Dimensions(cube as table) as table
 
## About -Returns a table containing the set of available dimensions within the `cube`. Each dimension is a table containing a set of dimension attributes and each dimension attribute is represented as a column in the dimension table. Dimensions can be expanded in the cube using Cube.AddAndExpandDimensionColumn. - +Returns a table containing the set of available dimensions within the `cube`. Each dimension is a table containing a set of dimension attributes and each dimension attribute is represented as a column in the dimension table. Dimensions can be expanded in the cube using [Cube.AddAndExpandDimensionColumn](cube-addandexpanddimensioncolumn.md). diff --git a/query-languages/m/cube-displayfolders.md b/query-languages/m/cube-displayfolders.md index 90aeba642..db1b708a5 100644 --- a/query-languages/m/cube-displayfolders.md +++ b/query-languages/m/cube-displayfolders.md @@ -1,21 +1,14 @@ --- description: "Learn more about: Cube.DisplayFolders" -title: "Cube.DisplayFolders | Microsoft Docs" -ms.date: 11/17/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.DisplayFolders" +ms.subservice: m-source --- # Cube.DisplayFolders ## Syntax
-Cube.DisplayFolders(**cube** as table) as table
+Cube.DisplayFolders(cube as table) as table
 
## About diff --git a/query-languages/m/cube-measureproperties.md b/query-languages/m/cube-measureproperties.md index d22c5677b..cf75182ef 100644 --- a/query-languages/m/cube-measureproperties.md +++ b/query-languages/m/cube-measureproperties.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Cube.MeasureProperties" -title: "Cube.MeasureProperties | Microsoft Docs" -ms.date: 8/17/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.MeasureProperties" +ms.subservice: m-source --- # Cube.MeasureProperties @@ -17,6 +10,7 @@ ms.author: dougklo
 Cube.MeasureProperties(cube as table) as table
 
- -## About + +## About + Returns a table containing the set of available properties for measures that are expanded in the cube. diff --git a/query-languages/m/cube-measureproperty.md b/query-languages/m/cube-measureproperty.md index e209b75b3..a8cb9fe8f 100644 --- a/query-languages/m/cube-measureproperty.md +++ b/query-languages/m/cube-measureproperty.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Cube.MeasureProperty" -title: "Cube.MeasureProperty| Microsoft Docs" -ms.date: 8/17/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.MeasureProperty" +ms.subservice: m-source --- # Cube.MeasureProperty @@ -17,6 +10,7 @@ ms.author: dougklo
 Cube.MeasureProperty(measure as any, propertyName as text) as any
 
- -## About + +## About + Returns the property `propertyName` of measure `measure`. diff --git a/query-languages/m/cube-measures.md b/query-languages/m/cube-measures.md index 810f80785..f29da4409 100644 --- a/query-languages/m/cube-measures.md +++ b/query-languages/m/cube-measures.md @@ -1,25 +1,16 @@ --- description: "Learn more about: Cube.Measures" -title: "Cube.Measures | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.Measures" +ms.subservice: m-source --- # Cube.Measures ## Syntax
-Cube.Measures(**cube** as any) as table
+Cube.Measures(cube as any) as table
 
## About -Returns a table containing the set of available measures within the `cube`. Each measure is represented as a function. Measures can be applied to the cube using Cube.AddMeasureColumn. - - +Returns a table containing the set of available measures within the `cube`. Each measure is represented as a function. Measures can be applied to the cube using Cube.AddMeasureColumn. diff --git a/query-languages/m/cube-parameters.md b/query-languages/m/cube-parameters.md index afcbc855a..a58538c56 100644 --- a/query-languages/m/cube-parameters.md +++ b/query-languages/m/cube-parameters.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Cube.Parameters" -title: "Cube.Parameters | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.Parameters" +ms.subservice: m-source --- # Cube.Parameters ## Syntax
-Cube.Parameters(cube as table) as table
-
- -## About -Returns a table containing the set of parameters that can be applied to `cube`. Each parameter is a function that can be invoked to get `cube` with the parameter and its arguments applied. - +Cube.Parameters(cube as table) as table + + +## About + +Returns a table containing the set of parameters that can be applied to `cube`. Each parameter is a function that can be invoked to get `cube` with the parameter and its arguments applied. diff --git a/query-languages/m/cube-properties.md b/query-languages/m/cube-properties.md index 518435d94..88c12a538 100644 --- a/query-languages/m/cube-properties.md +++ b/query-languages/m/cube-properties.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Cube.Properties" -title: "Cube.Properties | Microsoft Docs" -ms.date: 4/17/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.Properties" +ms.subservice: m-source --- # Cube.Properties @@ -17,6 +10,7 @@ ms.author: dougklo
 Cube.Properties(cube as table) as table
 
- -## About + +## About + Returns a table containing the set of available properties for dimensions that are expanded in the cube. diff --git a/query-languages/m/cube-propertykey.md b/query-languages/m/cube-propertykey.md index 1c29c0c80..5517ebbb8 100644 --- a/query-languages/m/cube-propertykey.md +++ b/query-languages/m/cube-propertykey.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Cube.PropertyKey" -title: "Cube.PropertyKey | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.PropertyKey" +ms.subservice: m-source --- # Cube.PropertyKey @@ -19,4 +12,5 @@ Cube.PropertyKey(property as any) as any ## About + Returns the key of property `property`. diff --git a/query-languages/m/cube-replacedimensions.md b/query-languages/m/cube-replacedimensions.md index b52bb21ec..73c25129e 100644 --- a/query-languages/m/cube-replacedimensions.md +++ b/query-languages/m/cube-replacedimensions.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Cube.ReplaceDimensions" -title: "Cube.ReplaceDimensions | Microsoft Docs" -ms.date: 1/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.ReplaceDimensions" +ms.subservice: m-source --- # Cube.ReplaceDimensions diff --git a/query-languages/m/cube-transform.md b/query-languages/m/cube-transform.md index fd7efd836..131c9f5d3 100644 --- a/query-languages/m/cube-transform.md +++ b/query-languages/m/cube-transform.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Cube.Transform" -title: "Cube.Transform | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Cube.Transform" +ms.subservice: m-source --- # Cube.Transform @@ -19,5 +12,5 @@ Cube.Transform(cube as table, transforms as list) as table ## About -Applies the list cube functions, `transforms`, on the `cube`. +Applies the list cube functions, `transforms`, on the `cube`. diff --git a/query-languages/m/culture-current.md b/query-languages/m/culture-current.md index e3bcb5c0d..124382daa 100644 --- a/query-languages/m/culture-current.md +++ b/query-languages/m/culture-current.md @@ -1,17 +1,14 @@ --- description: "Learn more about: Culture.Current" -title: "Culture.Current | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Culture.Current" +ms.subservice: m-source --- # Culture.Current - -## About +## About + Returns the name of the current culture for the application. + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/currency-from.md b/query-languages/m/currency-from.md index 3119a3454..38d72a4d4 100644 --- a/query-languages/m/currency-from.md +++ b/query-languages/m/currency-from.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Currency.From" -title: "Currency.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Currency.From" +ms.subservice: m-source --- # Currency.From ## Syntax
 
-Currency.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable number
+Currency.From(
+    value as any,
+    optional culture as nullable text,
+    optional roundingMode as nullable number
+) as nullable number
 
- + ## About -Returns a `currency` value from the given `value`. If the given `value` is `null`, **Currency.From** returns `null`. If the given `value` is `number` within the range of currency, fractional part of the `value` is rounded to 4 decimal digits and returned. If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](/powerquery-m/number-fromtext). Valid range for currency is `-922,337,203,685,477.5808` to `922,337,203,685,477.5807`. Refer to [Number.Round](/powerquery-m/number-round) for the available rounding modes. The default is [RoundingMode.ToEven](/powerquery-m/roundingmode-toeven). An optional `culture` may also be provided (for example, "en-US"). +Returns a `currency` value from the given `value`. If the given `value` is `null`, **Currency.From** returns `null`. If the given `value` is `number` within the range of currency, fractional part of the `value` is rounded to 4 decimal digits and returned. If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](number-fromtext.md). Valid range for currency is `-922,337,203,685,477.5808` to `922,337,203,685,477.5807`. Refer to [Number.Round](number-round.md) for the available rounding modes. The default is [RoundingMode.ToEven](roundingmode-type.md). An optional `culture` may also be provided (for example, "en-US"). ## Example 1 @@ -49,3 +46,7 @@ Currency.From("1.23455", "en-US", RoundingMode.Down) **Output** `1.2345` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/custom-date-and-time-format-strings.md b/query-languages/m/custom-date-and-time-format-strings.md new file mode 100644 index 000000000..3beb9283e --- /dev/null +++ b/query-languages/m/custom-date-and-time-format-strings.md @@ -0,0 +1,1300 @@ +--- +description: "Learn more about: Custom date and time format strings" +title: "Custom date and time format strings" +ms.date: 10/7/2024 +ms.custom: "nonautomated-date" +ms.subservice: m-background +--- + +# Custom date and time format strings + +A date and time format string defines the text representation of a [Date](date-functions.md), [DateTime](datetime-functions.md), [DateTimeZone](datetimezone-functions.md), or [Time](time-functions.md) value that results from a formatting operation. It can also define the representation of a date and time value that is required in a parsing operation in order to successfully convert the string to a date and time. A custom format string consists of one or more custom date and time format specifiers. Any string that isn't a [standard date and time format string](standard-date-and-time-format-strings.md) is interpreted as a custom date and time format string. + +In formatting operations, custom date and time format strings can be used with the `ToText` method of a date and time and timezone instance. The following example illustrates its uses. + +```powerquery-m +let + Source = + { + Text.From("Today is " & Date.ToText(#date(2011, 6, 10), [Format = "MMMM dd yyyy"]) & "."), + Text.Format("The current date and time: #{0}", {DateTimeZone.ToText( + #datetimezone(2011, 6, 10, 15, 24, 16, 0, 0), [Format = "MM/dd/yy H:mm:ss zzz"])} + ) + } +in + Source + +// The example displays the following output: +// Today is June 10, 2011. +// The current date and time: 06/10/11 15:24:16 +00:00 +``` + +In parsing operations, custom date and time format strings can be used with the **Date**, **DateTime**, **Time**, and **DateTimeZone** functions. These functions require that an input string conforms exactly to a particular pattern for the parse operation to succeed. The following example illustrates a call to the [DateTime.FromText](datetime-fromtext.md) function to parse a date that must include a month, a day, and a two-digit year. + +```powerquery-m +let + dateValues = { "30-12-2011", "12-30-2011", "30-12-11", "12-30-11"}, + pattern = "MM-dd-yy", + convertedDates = List.Transform(dateValues, (dateValue) => + try Text.Format("Converted '#{0}' to #{1}.", {dateValue, DateTime.FromText(dateValue, [Format=pattern])}) + otherwise Text.Format("Unable to convert '#{0}' to a date and time.", {dateValue})) +in + convertedDates + +// The example displays the following output: +// Unable to convert '30-12-2011' to a date and time. +// Unable to convert '12-30-2011' to a date and time. +// Unable to convert '30-12-11' to a date and time. +// Converted '12-30-11' to 12/30/2011. +``` + + The following table describes the custom date and time format specifiers and displays a result string produced by each format specifier. By default, result strings reflect the formatting conventions of the en-US culture. If a particular format specifier produces a localized result string, the example also notes the culture to which the result string applies. For more information about using custom date and time format strings, go to the [Notes](#notes) section. + +| Format specifier | Description | Examples | +|--|--|--| +| "d" | The day of the month, from 1 to 31.

More information: [The "d" custom format specifier](#dSpecifier). | 2009-06-01T13:45:30 -> 1

2009-06-15T13:45:30 -> 15 | +| "dd" | The day of the month, from 01 to 31.

More information: [The "dd" custom format specifier](#ddSpecifier). | 2009-06-01T13:45:30 -> 01

2009-06-15T13:45:30 -> 15 | +| "ddd" | The abbreviated name of the day of the week.

More information: [The "ddd" custom format specifier](#dddSpecifier). | 2009-06-15T13:45:30 -> Mon (en-US)

2009-06-15T13:45:30 -> Пн (ru-RU)

2009-06-15T13:45:30 -> lun. (fr-FR) | +| "dddd" | The full name of the day of the week.

More information: [The "dddd" custom format specifier](#ddddSpecifier). | 2009-06-15T13:45:30 -> Monday (en-US)

2009-06-15T13:45:30 -> понедельник (ru-RU)

2009-06-15T13:45:30 -> lundi (fr-FR) | +| "f" | The tenths of a second in a date and time value.

More information: [The "f" custom format specifier](#fSpecifier). | 2009-06-15T13:45:30.6170000 -> 6

2009-06-15T13:45:30.05 -> 0 | +| "ff" | The hundredths of a second in a date and time value.

More information: [The "ff" custom format specifier](#ffSpecifier). | 2009-06-15T13:45:30.6170000 -> 61

2009-06-15T13:45:30.0050000 -> 00 | +| "fff" | The milliseconds in a date and time value.

More information: [The "fff" custom format specifier](#fffSpecifier). | 6/15/2009 13:45:30.617 -> 617

6/15/2009 13:45:30.0005 -> 000 | +| "ffff" | The ten thousandths of a second in a date and time value.

More information: [The "ffff" custom format specifier](#ffffSpecifier). | 2009-06-15T13:45:30.6175000 -> 6175

2009-06-15T13:45:30.0000500 -> 0000 | +| "fffff" | The hundred thousandths of a second in a date and time value.

More information: [The "fffff" custom format specifier](#fffffSpecifier). | 2009-06-15T13:45:30.6175400 -> 61754

6/15/2009 13:45:30.000005 -> 00000 | +| "ffffff" | The millionths of a second in a date and time value.

More information: [The "ffffff" custom format specifier](#ffffffSpecifier). | 2009-06-15T13:45:30.6175420 -> 617542

2009-06-15T13:45:30.0000005 -> 000000 | +| "fffffff" | The ten millionths of a second in a date and time value.

More information: [The "fffffff" custom format specifier](#fffffffSpecifier). | 2009-06-15T13:45:30.6175425 -> 6175425

2009-06-15T13:45:30.0001150 -> 0001150 | +| "F" | If non-zero, the tenths of a second in a date and time value.

More information: [The "F" custom format specifier](#F_Specifier). | 2009-06-15T13:45:30.6170000 -> 6

2009-06-15T13:45:30.0500000 -> (no output) | +| "FF" | If non-zero, the hundredths of a second in a date and time value.

More information: [The "FF" custom format specifier](#FF_Specifier). | 2009-06-15T13:45:30.6170000 -> 61

2009-06-15T13:45:30.0050000 -> (no output) | +| "FFF" | If non-zero, the milliseconds in a date and time value.

More information: [The "FFF" custom format specifier](#FFF_Specifier). | 2009-06-15T13:45:30.6170000 -> 617

2009-06-15T13:45:30.0005000 -> (no output) | +| "FFFF" | If non-zero, the ten thousandths of a second in a date and time value.

More information: [The "FFFF" custom format specifier](#FFFF_Specifier). | 2009-06-15T13:45:30.5275000 -> 5275

2009-06-15T13:45:30.0000500 -> (no output) | +| "FFFFF" | If non-zero, the hundred thousandths of a second in a date and time value.

More information: [The "FFFFF" custom format specifier](#FFFFF_Specifier). | 2009-06-15T13:45:30.6175400 -> 61754

2009-06-15T13:45:30.0000050 -> (no output) | +| "FFFFFF" | If non-zero, the millionths of a second in a date and time value.

More information: [The "FFFFFF" custom format specifier](#FFFFFF_Specifier). | 2009-06-15T13:45:30.6175420 -> 617542

2009-06-15T13:45:30.0000005 -> (no output) | +| "FFFFFFF" | If non-zero, the ten millionths of a second in a date and time value.

More information: [The "FFFFFFF" custom format specifier](#FFFFFFF_Specifier). | 2009-06-15T13:45:30.6175425 -> 6175425

2009-06-15T13:45:30.0001150 -> 000115 | +| "g", "gg" | The period or era.

More information: [The "g" or "gg" custom format specifier](#gSpecifier). | 2009-06-15T13:45:30.6170000 -> A.D. | +| "h" | The hour, using a 12-hour clock from 1 to 12.

More information: [The "h" custom format specifier](#hSpecifier). | 2009-06-15T01:45:30 -> 1

2009-06-15T13:45:30 -> 1 | +| "hh" | The hour, using a 12-hour clock from 01 to 12.

More information: [The "hh" custom format specifier](#hhSpecifier). | 2009-06-15T01:45:30 -> 01

2009-06-15T13:45:30 -> 01 | +| "H" | The hour, using a 24-hour clock from 0 to 23.

More information: [The "H" custom format specifier](#H_Specifier). | 2009-06-15T01:45:30 -> 1

2009-06-15T13:45:30 -> 13 | +| "HH" | The hour, using a 24-hour clock from 00 to 23.

More information: [The "HH" custom format specifier](#HH_Specifier). | 2009-06-15T01:45:30 -> 01

2009-06-15T13:45:30 -> 13 | +| "K" | Time zone information.

More information: [The "K" custom format specifier](#KSpecifier). | 2009-06-15T13:45:30, Unspecified ->

2009-06-15T13:45:30, Utc -> +00:00

2009-06-15T13:45:30, Local -> -07:00 (depends on local or cloud computer settings) | +| "m" | The minute, from 0 to 59.

More information: [The "m" custom format specifier](#mSpecifier). | 2009-06-15T01:09:30 -> 9

2009-06-15T13:29:30 -> 29 | +| "mm" | The minute, from 00 to 59.

More information: [The "mm" custom format specifier](#mmSpecifier). | 2009-06-15T01:09:30 -> 09

2009-06-15T01:45:30 -> 45 | +| "M" | The month, from 1 to 12.

More information: [The "M" custom format specifier](#M_Specifier). | 2009-06-15T13:45:30 -> 6 | +| "MM" | The month, from 01 to 12.

More information: [The "MM" custom format specifier](#MM_Specifier). | 2009-06-15T13:45:30 -> 06 | +| "MMM" | The abbreviated name of the month.

More information: [The "MMM" custom format specifier](#MMM_Specifier). | 2009-06-15T13:45:30 -> Jun (en-US)

2009-06-15T13:45:30 -> juin (fr-FR)

2009-06-15T13:45:30 -> Jun (zu-ZA) | +| "MMMM" | The full name of the month.

More information: [The "MMMM" custom format specifier](#MMMM_Specifier). | 2009-06-15T13:45:30 -> June (en-US)

2009-06-15T13:45:30 -> juni (da-DK)

2009-06-15T13:45:30 -> Juni (zu-ZA) | +| "s" | The second, from 0 to 59.

More information: [The "s" custom format specifier](#sSpecifier). | 2009-06-15T13:45:09 -> 9 | +| "ss" | The second, from 00 to 59.

More information: [The "ss" custom format specifier](#ssSpecifier). | 2009-06-15T13:45:09 -> 09 | +| "t" | The first character of the AM/PM designator.

More information: [The "t" custom format specifier](#tSpecifier). | 2009-06-15T13:45:30 -> P (en-US)

2009-06-15T13:45:30 -> 午 (ja-JP)

2009-06-15T13:45:30 -> (fr-FR) | +| "tt" | The AM/PM designator.

More information: [The "tt" custom format specifier](#ttSpecifier). | 2009-06-15T13:45:30 -> PM (en-US)

2009-06-15T13:45:30 -> 午後 (ja-JP)

2009-06-15T13:45:30 -> (fr-FR) | +| "y" | The year, from 0 to 99.

More information: [The "y" custom format specifier](#ySpecifier). | 0001-01-01T00:00:00 -> 1

0900-01-01T00:00:00 -> 0

1900-01-01T00:00:00 -> 0

2009-06-15T13:45:30 -> 9

2019-06-15T13:45:30 -> 19 | +| "yy" | The year, from 00 to 99.

More information: [The "yy" custom format specifier](#yySpecifier). | 0001-01-01T00:00:00 -> 01

0900-01-01T00:00:00 -> 00

1900-01-01T00:00:00 -> 00

2019-06-15T13:45:30 -> 19 | +| "yyy" | The year, with a minimum of three digits.

More information: [The "yyy" custom format specifier](#yyySpecifier). | 0001-01-01T00:00:00 -> 001

0900-01-01T00:00:00 -> 900

1900-01-01T00:00:00 -> 1900

2009-06-15T13:45:30 -> 2009 | +| "yyyy" | The year as a four-digit number.

More information: [The "yyyy" custom format specifier](#yyyySpecifier). | 0001-01-01T00:00:00 -> 0001

0900-01-01T00:00:00 -> 0900

1900-01-01T00:00:00 -> 1900

2009-06-15T13:45:30 -> 2009 | +| "yyyyy" | The year as a five-digit number.

More information: [The "yyyyy" custom format specifier](#yyyyySpecifier). | 0001-01-01T00:00:00 -> 00001

2009-06-15T13:45:30 -> 02009 | +| "z" | Hours offset from UTC, with no leading zeros.

More information: [The "z" custom format specifier](#zSpecifier). | 2009-06-15T13:45:30-07:00 -> -7 | +| "zz" | Hours offset from UTC, with a leading zero for a single-digit value.

More information: [The "zz" custom format specifier](#zzSpecifier). | 2009-06-15T13:45:30-07:00 -> -07 | +| "zzz" | Hours and minutes offset from UTC.

More information: [The "zzz" custom format specifier](#zzzSpecifier). | 2009-06-15T13:45:30-07:00 -> -07:00 | +| ":" | The time separator.

More information: [The ":" custom format specifier](#timeSeparator). | 2009-06-15T13:45:30 -> : (en-US)

2009-06-15T13:45:30 -> . (it-IT)

2009-06-15T13:45:30 -> : (ja-JP) | +| "/" | The date separator.

More Information: [The "/" custom format specifier](#dateSeparator). | 2009-06-15T13:45:30 -> / (en-US)

2009-06-15T13:45:30 -> - (ar-DZ)

2009-06-15T13:45:30 -> . (tr-TR) | +| "*string*"

'*string*' | Literal string delimiter.

More information: [Character literals](#Literals). | 2009-06-15T13:45:30 (""arr:"" h:m t) -> arr: 1:45 P

2009-06-15T13:45:30 ('arr:' h:m t) -> arr: 1:45 P | +| % | Defines the following character as a custom format specifier.

More information: [Using single custom format specifiers](#using-single-custom-format-specifiers). | 2009-06-15T13:45:30 (%h) -> 1 | +| \, "", ' | The escape sequences.

More information: [Character literals](#Literals) and [Using the escape sequences](#escape). | 2009-06-15T13:45:30 (h \h) -> 1 h

2009-06-15T13:45:30 (h ""h"") -> 1 h

2009-06-15T13:45:30 (h 'h') -> 1 h | +| Any other character | The character is copied to the result string unchanged.

More information: [Character literals](#Literals). | 2009-06-15T01:45:30 (arr hh:mm t) -> arr 01:45 A | + +The following sections provide additional information about each custom date and time format specifier. Unless otherwise noted, each specifier produces an identical string representation regardless of whether it's used with a **Date**, **DateTime**, **DateTimeZone**, or **Time** value. + +## Day "d" format specifier + +### The "d" custom format specifier + +The "d" custom format specifier represents the day of the month as a number from 1 to 31. A single-digit day is formatted without a leading zero. + +If the "d" format specifier is used without other custom format specifiers, it's interpreted as the "d" standard date and time format specifier. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "d" custom format specifier in several format strings. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "d, M", Culture = ""]), + // Displays 29, 8 + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "d, MMMM", Culture = "en-US"]), + // Displays 29, August + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "d, MMMM", Culture = "es-MX"]) + // Displays 29, agosto + } +in + Source +``` + +[Back to table](#table) + +### The "dd" custom format specifier + +The "dd" custom format string represents the day of the month as a number from 01 to 31. A single-digit day is formatted with a leading zero. + +The following example includes the "dd" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 2, 6, 30, 15), [Format = "dd, MM", Culture = ""]) + // Displays 02, 01 + } +in + Source +``` + +[Back to table](#table) + +### The "ddd" custom format specifier + +The "ddd" custom format specifier represents the abbreviated name of the day of the week. The localized abbreviated name of the day of the week is retrieved from the current or specified culture. + +The following example includes the "ddd" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "ddd d MMM", Culture = "en-US"]), + // Displays Thu 29 Aug + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "ddd d MMM", Culture = "fr-FR"]) + // Displays jeu. 29 août + } +in + Source +``` + +[Back to table](#table) + +### The "dddd" custom format specifier + +The "dddd" custom format specifier (plus any number of additional "d" specifiers) represents the full name of the day of the week. The localized name of the day of the week is retrieved from the current or specified culture. + +The following example includes the "dddd" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "dddd dd MMMM", Culture = "en-US"]), + // Displays Thursday 29 August + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "dddd dd MMMM", Culture = "it-IT"]) + // Displays giovedì 29 agosto + } +in + Source +``` + +[Back to table](#table) + +## Lowercase seconds "f" fraction specifier + +### The "f" custom format specifier + +The "f" custom format specifier represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. + +If the "f" format specifier is used without other format specifiers, it's interpreted as the "f" standard date and time format specifier. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +When you use "f" format specifiers as part of a format string supplied to parse the number of fractional seconds, the number of "f" format specifiers indicates the number of most significant digits of the seconds fraction that must be present to successfully parse the string. + +The following example includes the "f" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:f", Culture = ""]), + // Displays 07:27:15:0 + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:F", Culture = ""]) + // Displays 07:27:15: + } +in + Source +``` + +[Back to table](#table) + +### The "ff" custom format specifier + +The "ff" custom format specifier represents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value. + +following example includes the "ff" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:ff", Culture = ""]), + // Displays 07:27:15:01 + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:FF", Culture = ""]) + // Displays 07:27:15:01 + } +in + Source +``` + +[Back to table](#table) + +### The "fff" custom format specifier + +The "fff" custom format specifier represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value. + +The following example includes the "fff" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:fff", Culture = ""]), + // Displays 07:27:15:018 + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:FFF", Culture = ""]) + // Displays 07:27:15:018 + } +in + Source +``` + +[Back to table](#table) + +### The "ffff" custom format specifier + +The "ffff" custom format specifier represents the four most significant digits of the seconds fraction; that is, it represents the ten thousandths of a second in a date and time value. + +Although it's possible to display the ten thousandths of a second component of a time value, that value might not be meaningful. The precision of date and time values depends on the resolution of the system clock. On the Windows Server 2019 and Windows 11 operating systems, the clock's resolution is approximately 1 millisecond. + +[Back to table](#table) + +### The "fffff" custom format specifier + +The "fffff" custom format specifier represents the five most significant digits of the seconds fraction; that is, it represents the hundred thousandths of a second in a date and time value. + +Although it's possible to display the hundred thousandths of a second component of a time value, that value might not be meaningful. The precision of date and time values depends on the resolution of the system clock. On the Windows Server 2019 and Windows 11 operating systems, the clock's resolution is approximately 1 millisecond. + +[Back to table](#table) + +### The "ffffff" custom format specifier + +The "ffffff" custom format specifier represents the six most significant digits of the seconds fraction; that is, it represents the millionths of a second in a date and time value. + +Although it's possible to display the millionths of a second component of a time value, that value might not be meaningful. The precision of date and time values depends on the resolution of the system clock. On the Windows Server 2019 and Windows 11 operating systems, the clock's resolution is approximately 1 millisecond. + +[Back to table](#table) + +### The "fffffff" custom format specifier + +The "fffffff" custom format specifier represents the seven most significant digits of the seconds fraction; that is, it represents the ten millionths of a second in a date and time value. + +Although it's possible to display the ten millionths of a second component of a time value, that value might not be meaningful. The precision of date and time values depends on the resolution of the system clock. On the Windows Server 2019 and Windows 11 operating systems, the clock's resolution is approximately 1 millisecond. + +[Back to table](#table) + +## Uppercase seconds "F" fraction specifier + +### The "F" custom format specifier + +The "F" custom format specifier represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. Nothing is displayed if the digit is zero, and the decimal point that follows the number of seconds is also not displayed. + +If the "F" format specifier is used without other format specifiers, it's interpreted as the "F" standard date and time format specifier. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The number of "F" format specifiers used when parsing indicates the maximum number of most significant digits of the seconds fraction that can be present to successfully parse the string. + +The following example includes the "F" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:f", Culture = ""]), + // Displays 07:27:15:0 + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:F", Culture = ""]) + // Displays 07:27:15: + } +in + Source +``` + +[Back to table](#table) + +### The "FF" custom format specifier + +The "FF" custom format specifier represents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value. Trailing zeros aren't displayed. Nothing is displayed if the two significant digits are zero, and in that case the decimal point that follows the number of seconds is also not displayed. + +The following example includes the "FF" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:ff", Culture = ""]), + // Displays 07:27:15:01 + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:FF", Culture = ""]) + // Displays 07:27:15:01 + } +in + Source +``` + +[Back to table](#table) + +### The "FFF" custom format specifier + +The "FFF" custom format specifier represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value. Trailing zeros aren't displayed. Nothing is displayed if the three significant digits are zero, and in that case the decimal point that follows the number of seconds is also not displayed. + +The following example includes the "FFF" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:fff", Culture = ""]), + // Displays 07:27:15:018 + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15.018), [Format = "hh:mm:ss:FFF", Culture = ""]) + // Displays 07:27:15:018 + } +in + Source +``` + +[Back to table](#table) + +### The "FFFF" custom format specifier + +The "FFFF" custom format specifier represents the four most significant digits of the seconds fraction; that is, it represents the ten thousandths of a second in a date and time value. Trailing zeros aren't displayed. Nothing is displayed if the four significant digits are zero, and in that case the decimal point that follows the number of seconds is also not displayed. + +Although it's possible to display the ten thousandths of a second component of a time value, that value might not be meaningful. The precision of date and time values depends on the resolution of the system clock. On the Windows Server 2019 and Windows 11 operating systems, the clock's resolution is approximately 1 millisecond. + +[Back to table](#table) + +### The "FFFFF" custom format specifier + +The "FFFFF" custom format specifier represents the five most significant digits of the seconds fraction; that is, it represents the hundred thousandths of a second in a date and time value. Trailing zeros aren't displayed. Nothing is displayed if the five significant digits are zero, and in that case the decimal point that follows the number of seconds is also not displayed. + +Although it's possible to display the hundred thousandths of a second component of a time value, that value might not be meaningful. The precision of date and time values depends on the resolution of the system clock. On the Windows Server 2019 and Windows 11 operating systems, the clock's resolution is approximately 1 millisecond. + +[Back to table](#table) + +### The "FFFFFF" custom format specifier + +The "FFFFFF" custom format specifier represents the six most significant digits of the seconds fraction; that is, it represents the millionths of a second in a date and time value. Trailing zeros aren't displayed. Nothing is displayed if the six significant digits are zero, and in that case the decimal point that follows the number of seconds is also not displayed. + +Although it's possible to display the millionths of a second component of a time value, that value might not be meaningful. The precision of date and time values depends on the resolution of the system clock. On the Windows Server 2019 and Windows 11 operating systems, the clock's resolution is approximately 1 millisecond. + +[Back to table](#table) + +### The "FFFFFFF" custom format specifier + +The "FFFFFFF" custom format specifier represents the seven most significant digits of the seconds fraction; that is, it represents the ten millionths of a second in a date and time value. Trailing zeros aren't displayed. Nothing is displayed if the seven significant digits are zero, and in that case the decimal point that follows the number of seconds is also not displayed. + +Although it's possible to display the ten millionths of a second component of a time value, that value might not be meaningful. The precision of date and time values depends on the resolution of the system clock. On the Windows Server 2019 and Windows 11 operating systems, the clock's resolution is approximately 1 millisecond. + +[Back to table](#table) + +## Era "g" format specifier + +### The "g" or "gg" custom format specifier + +The "g" or "gg" custom format specifiers (plus any number of additional "g" specifiers) represents the period or era, such as A.D. The formatting operation ignores this specifier if the date to be formatted doesn't have an associated period or era string. + +If the "g" format specifier is used without other custom format specifiers, it's interpreted as the "g" standard date and time format specifier. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "g" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + Date.ToText(#date(70, 08, 04), [Format = "MM/dd/yyyy g", Culture = ""]), + // Displays 08/04/0070 A.D. + + Date.ToText(#date(70, 08, 04), [Format = "MM/dd/yyyy g", Culture = "fr-FR"]) + // Displays 08/04/0070 ap. J.-C. + } +in + Source +``` + +[Back to table](#table) + +## Lowercase hour "h" format specifier + +### The "h" custom format specifier + +The "h" custom format specifier represents the hour as a number from 1 to 12; that is, the hour is represented by a 12-hour clock that counts the whole hours since midnight or noon. A particular hour after midnight is indistinguishable from the same hour after noon. The hour isn't rounded, and a single-digit hour is formatted without a leading zero. For example, given a time of 5:43 in the morning or afternoon, this custom format specifier displays "5". + +If the "h" format specifier is used without other custom format specifiers, it's interpreted as a standard date and time format specifier and throws an expression error. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "h" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "h:m:s.F t", Culture = ""]), + // Displays 6:9:1 P + + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "h:m:s.F t", Culture = "el-GR"]), + // Displays 6:9:1 μ + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "h:m:s.F t", Culture = ""]), + // Displays 9:18:1.5 A + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "h:m:s.F t", Culture = "el-GR"]) + // Displays 9:18:1.5 π + } +in + Source +``` + +[Back to table](#table) + +### The "hh" custom format specifier + +The "hh" custom format specifier (plus any number of additional "h" specifiers) represents the hour as a number from 01 to 12; that is, the hour is represented by a 12-hour clock that counts the whole hours since midnight or noon. A particular hour after midnight is indistinguishable from the same hour after noon. The hour isn't rounded, and a single-digit hour is formatted with a leading zero. For example, given a time of 5:43 in the morning or afternoon, this format specifier displays "05". + +The following example includes the "hh" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "hh:mm:ss tt", Culture = ""]), + // Displays 06:09:01 PM + + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "hh:mm:ss tt", Culture = "hu-HU"]), + // Displays 06:09:01 du. + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "hh:mm:ss.ff tt", Culture = ""]), + // Displays 09:18:01.50 AM + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "hh:mm:ss.ff tt", Culture = "hu-HU"]) + // Displays 09:18:01.50 de. + } +in + Source +``` + +[Back to table](#table) + +## Uppercase hour "H" format specifier + +### The "H" custom format specifier + +The "H" custom format specifier represents the hour as a number from 0 to 23; that is, the hour is represented by a zero-based 24-hour clock that counts the hours since midnight. A single-digit hour is formatted without a leading zero. + +If the "H" format specifier is used without other custom format specifiers, it's interpreted as a standard date and time format specifier and throws an expression error. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "H" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 6, 9, 1), [Format = "H:mm:ss", Culture = ""]) + // Displays 6:09:01 + } +in + Source +``` + +[Back to table](#table) + +### The "HH" custom format specifier + +The "HH" custom format specifier (plus any number of additional "H" specifiers) represents the hour as a number from 00 to 23; that is, the hour is represented by a zero-based 24-hour clock that counts the hours since midnight. A single-digit hour is formatted with a leading zero. + +The following example includes the "HH" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 6, 9, 1), [Format = "HH:mm:ss", Culture = ""]) + // Displays 06:09:01 + } +in + Source +``` + +[Back to table](#table) + +## Time zone "K" format specifier + +### The "K" custom format specifier + +The "K" custom format specifier represents the time zone information of a date and time value. When this format specifier is used with **DateTimeZone** values, the result string is defined as: + +- For the local time zone, this specifier produces a result string containing the local offset from Coordinated Universal Time (UTC), for example, "-07:00", if your query runs in Power Query Desktop. If your query runs in Power Query Online, the result string produces no offset from UTC time, that is, "+00:00". + +- For a UTC time, the result string produces no offset from UTC time; that is, "+00:00 to represent a UTC date. + +- For a time from an unspecified time zone, the result is empty. + +If the "K" format specifier is used without other custom format specifiers, it's interpreted as a standard date and time format specifier and throws an expression error. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example displays the string that results from using the "K" custom format specifier with various values on a system in the U.S. Pacific Time zone. + +```powerquery-m +let + Source = + { + DateTimeZone.ToText(DateTimeZone.LocalNow(),[Format="%K"]), + // Displays -07:00 (Desktop) or +00:00 (Online) + + DateTimeZone.ToText(DateTimeZone.UtcNow(),[Format="%K"]), + // Displays +00:00 + + Text.Format("'#{0}'", {DateTime.ToText(DateTime.LocalNow(),[Format="%K"])}) + // Displays '' + } +in + Source +``` + +> [!NOTE] +>The value returned by [DateTimeZone.LocalNow](datetimezone-localnow.md) depends on whether you're running Power Query on a local machine or online. For example, in the sample above on a system in the U.S. Pacific Time zone, Power Query Desktop returns `-07:00` because it's reading the time set on your local machine. However, Power Query Online returns `+00:00` because it's reading the time set on the cloud virtual machines, which are set to UTC. + +[Back to table](#table) + +## Minute "m" format specifier + +### The "m" custom format specifier + +The "m" custom format specifier represents the minute as a number from 0 to 59. The minute represents whole minutes that have passed since the last hour. A single-digit minute is formatted without a leading zero. + +If the "m" format specifier is used without other custom format specifiers, it's interpreted as the "m" standard date and time format specifier. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "m" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "h:m:s.F t", Culture = ""]), + // Displays 6:9:1 P + + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "h:m:s.F t", Culture = "el-GR"]), + // Displays 6:9:1 μ + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "h:m:s.F t", Culture = ""]), + // Displays 9:18:1.5 A + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "h:m:s.F t", Culture = "el-GR"]) + // Displays 9:18:1.5 π + } +in + Source +``` + +[Back to table](#table) + +### The "mm" custom format specifier + +The "mm" custom format specifier (plus any number of additional "m" specifiers) represents the minute as a number from 00 to 59. The minute represents whole minutes that have passed since the last hour. A single-digit minute is formatted with a leading zero. + +The following example includes the "mm" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "hh:mm:ss tt", Culture = ""]), + // Displays 06:09:01 PM + + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "hh:mm:ss tt", Culture = "hu-HU"]), + // Displays 06:09:01 du. + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "hh:mm:ss.ff tt", Culture = ""]), + // Displays 09:18:01.50 AM + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "hh:mm:ss.ff tt", Culture = "hu-HU"]) + // Displays 09:18:01.50 de. + } +in + Source +``` + +[Back to table](#table) + +## Month "M" format specifier + +### The "M" custom format specifier + +The "M" custom format specifier represents the month as a number from 1 to 12 (or from 1 to 13 for calendars that have 13 months). A single-digit month is formatted without a leading zero. + +If the "M" format specifier is used without other custom format specifiers, it's interpreted as the "M" standard date and time format specifier. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "M" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + Date.ToText(#date(2024, 8, 18), [Format = "(M) MMM, MMMM", Culture = "en-US"]), + // Displays (8) Aug, August + + Date.ToText(#date(2024, 8, 18), [Format = "(M) MMM, MMMM", Culture = "nl-NL"]), + // Displays (8) aug, augustus + + Date.ToText(#date(2024, 8, 18), [Format = "(M) MMM, MMMM", Culture = "lv-LV"]) + // Displays (8) aug., augusts + } +in + Source +``` + +[Back to table](#table) + +### The "MM" custom format specifier + +The "MM" custom format specifier represents the month as a number from 01 to 12 (or from 1 to 13 for calendars that have 13 months). A single-digit month is formatted with a leading zero. + +The following example includes the "MM" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 2, 6, 30, 15), [Format = "dd, MM", Culture = ""]) + // Displays 02, 01 + } +in + Source +``` + +[Back to table](#table) + +### The "MMM" custom format specifier + +The "MMM" custom format specifier represents the abbreviated name of the month. The localized abbreviated name of the month is retrieved from the abbreviated month names of the current or specified culture. If there is a "d" or "dd" custom format specifier in the custom format string, the month name is retrieved from the abbreviated genitive names instead. + +The following example includes the "MMM" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "ddd d MMM", Culture = "en-US"]), + // Displays Thu 29 Aug + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "ddd d MMM", Culture = "fr-FR"]) + // Displays jeu. 29 août + } +in + Source +``` + +[Back to table](#table) + +### The "MMMM" custom format specifier + +The "MMMM" custom format specifier represents the full name of the month. The localized name of the month is retrieved from the current or specified culture. If there is a "d" or "dd" custom format specifier in the custom format string, the month name is retrieved from the abbreviated genitive names instead. + +The following example includes the "MMMM" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "dddd dd MMMM", Culture = "en-US"]), + // Displays Thursday 29 August + + DateTime.ToText(#datetime(2024, 8, 29, 19, 27, 15), [Format = "dddd dd MMMM", Culture = "it-IT"]) + // Displays giovedì 29 agosto + } +in + Source +``` + +[Back to table](#table) + +## Seconds "s" format specifier + +### The "s" custom format specifier + +The "s" custom format specifier represents the seconds as a number from 0 to 59. The result represents whole seconds that have passed since the last minute. A single-digit second is formatted without a leading zero. + +If the "s" format specifier is used without other custom format specifiers, it's interpreted as the "s" standard date and time format specifier. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "s" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "h:m:s.F t", Culture = ""]), + // Displays 6:9:1 P + + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "h:m:s.F t", Culture = "el-GR"]), + // Displays 6:9:1 μ + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "h:m:s.F t", Culture = ""]), + // Displays 9:18:1.5 A + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "h:m:s.F t", Culture = "el-GR"]) + // Displays 9:18:1.5 π + } +in + Source +``` + +[Back to table](#table) + +### The "ss" custom format specifier + +The "ss" custom format specifier (plus any number of additional "s" specifiers) represents the seconds as a number from 00 to 59. The result represents whole seconds that have passed since the last minute. A single-digit second is formatted with a leading zero. + +The following example includes the "ss" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "hh:mm:ss tt", Culture = ""]), + // Displays 06:09:01 PM + + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "hh:mm:ss tt", Culture = "hu-HU"]), + // Displays 06:09:01 du. + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "hh:mm:ss.ff tt", Culture = ""]), + // Displays 09:18:01.50 AM + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "hh:mm:ss.ff tt", Culture = "hu-HU"]) + // Displays 09:18:01.50 de. + } +in + Source +``` + +[Back to table](#table) + +## Meridiem "t" format specifier + +### The "t" custom format specifier + +The "t" custom format specifier represents the first character of the AM/PM designator. The appropriate localized designator is retrieved from the current or specific culture. The AM designator is used for all times from 0:00:00 (midnight) to 11:59:59.999. The PM designator is used for all times from 12:00:00 (noon) to 23:59:59.999. + +If the "t" format specifier is used without other custom format specifiers, it's interpreted as the "t" standard date and time format specifier. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "t" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "h:m:s.F t", Culture = ""]), + // Displays 6:9:1 P + + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "h:m:s.F t", Culture = "el-GR"]), + // Displays 6:9:1 μ + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "h:m:s.F t", Culture = ""]), + // Displays 9:18:1.5 A + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "h:m:s.F t", Culture = "el-GR"]) + // Displays 9:18:1.5 π + } +in + Source +``` + +[Back to table](#table) + +### The "tt" custom format specifier + +The "tt" custom format specifier (plus any number of additional "t" specifiers) represents the entire AM/PM designator. The appropriate localized designator is retrieved from the current or specific culture. The AM designator is used for all times from 0:00:00 (midnight) to 11:59:59.999. The PM designator is used for all times from 12:00:00 (noon) to 23:59:59.999. + +Make sure to use the "tt" specifier for languages for which it's necessary to maintain the distinction between AM and PM. An example is Japanese, for which the AM and PM designators differ in the second character instead of the first character. + +The following example includes the "tt" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "hh:mm:ss tt", Culture = ""]), + // Displays 06:09:01 PM + + DateTime.ToText(#datetime(2024, 1, 1, 18, 9, 1), [Format = "hh:mm:ss tt", Culture = "hu-HU"]), + // Displays 06:09:01 du. + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "hh:mm:ss.ff tt", Culture = ""]), + // Displays 09:18:01.50 AM + + DateTime.ToText(#datetime(2024, 1, 1, 9, 18, 1.500), [Format = "hh:mm:ss.ff tt", Culture = "hu-HU"]) + // Displays 09:18:01.50 de. + } +in + Source +``` + +[Back to table](#table) + +## Year "y" format specifier + +### The "y" custom format specifier + +The "y" custom format specifier represents the year as a one-digit or two-digit number. If the year has more than two digits, only the two low-order digits appear in the result. If the first digit of a two-digit year begins with a zero (for example, 2008), the number is formatted without a leading zero. + +If the "y" format specifier is used without other custom format specifiers, it's interpreted as the "y" standard date and time format specifier. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "y" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + Date.ToText(#date(1, 12, 1), [Format = "%y"]), + // Displays 1 + + Date.ToText(#date(2024, 1, 1), [Format = "%y"]) + // Displays 24 + } +in + Source +``` + +[Back to table](#table) + +### The "yy" custom format specifier + +The "yy" custom format specifier represents the year as a two-digit number. If the year has more than two digits, only the two low-order digits appear in the result. If the two-digit year has fewer than two significant digits, the number is padded with leading zeros to produce two digits. + +In a parsing operation, a two-digit year that is parsed using the "yy" custom format specifier is interpreted based on the format provider's current calendar. The following example parses the string representation of a date that has a two-digit year by using the default Gregorian calendar of the en-US culture, which, in this case, is the current culture. The values returned for the four-digit date depend on the 100 year range set by the operating system. + +```powerquery-m +let + // Define the date format and value + fmt = "dd-MMM-yy", + + // Convert year 49 to a 4-digit year + firstDate = Text.Format("#{0}", { Date.FromText("24-Jan-49", [Format = fmt]) }), + + // Convert year 50 to a 4-digit year + finalDate = Text.Format("#{0}", { Date.FromText("24-Jan-50", [Format = fmt]) }), + Heading = "Default Two Digit Year Range: 1950 - 2049", + result = {Heading, firstDate, finalDate} +in + result + +// The example displays the following output: +// Default Two Digit Year Range: 1950 - 2049 +// 1/24/2049 +// 1/24/1950 +``` + +The following example includes the "yy" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + Date.ToText(#date(1, 12, 1), [Format = "yy"]), + // Displays 01 + + Date.ToText(#date(2024, 1, 1), [Format = "yy"]) + // Displays 24 + } +in + Source +``` + +[Back to table](#table) + +### The "yyy" custom format specifier + +The "yyy" custom format specifier represents the year with a minimum of three digits. If the year has more than three significant digits, they are included in the result string. If the year has fewer than three digits, the number is padded with leading zeros to produce three digits. + +> [!NOTE] +> For the Thai Buddhist calendar, which can have five-digit years, this format specifier displays all significant digits. + +The following example includes the "yyy" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + Date.ToText(#date(1, 12, 1), [Format = "yyy"]), + // Displays 001 + + Date.ToText(#date(2024, 1, 1), [Format = "yyy"]) + // Displays 2024 + } +in + Source +``` + +[Back to table](#table) + +### The "yyyy" custom format specifier + +The "yyyy" custom format specifier represents the year with a minimum of four digits. If the year has more than four significant digits, they are included in the result string. If the year has fewer than four digits, the number is padded with leading zeros to produce four digits. + +> [!NOTE] +> For the Thai Buddhist calendar, which can have five-digit years, this format specifier displays a minimum of four digits. + +The following example includes the "yyyy" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + Date.ToText(#date(1, 12, 1), [Format = "yyyy"]), + // Displays 0001 + + Date.ToText(#date(2024, 1, 1), [Format = "yyyy"]) + // Displays 2024 + } +in + Source +``` + +[Back to table](#table) + +### The "yyyyy" custom format specifier + +The "yyyyy" custom format specifier (plus any number of additional "y" specifiers) represents the year with a minimum of five digits. If the year has more than five significant digits, they are included in the result string. If the year has fewer than five digits, the number is padded with leading zeros to produce five digits. + +If there are additional "y" specifiers, the number is padded with as many leading zeros as necessary to produce the number of "y" specifiers. + +The following example includes the "yyyyy" custom format specifier in a custom format string. + +```powerquery-m +let + Source = + { + Date.ToText(#date(1, 12, 1), [Format = "yyyyy"]), + // Displays 00001 + + Date.ToText(#date(2024, 1, 1), [Format = "yyyyy"]) + // Displays 02024 + } +in + Source +``` + +[Back to table](#table) + +## Offset "z" format specifier + +### The "z" custom format specifier + +With **DateTimeZone** values, the "z" custom format specifier represents the signed offset of the specified time zone from Coordinated Universal Time (UTC), measured in hours. The offset is always displayed with a leading sign. A plus sign (+) indicates hours ahead of UTC, and a minus sign (-) indicates hours behind UTC. A single-digit offset is formatted *without* a leading zero. + +The following table shows how the offset value changes depending on the **DateTimeZone** function. + +| DateTimeZone value | Offset value | +| --- | --- | +| [DateTimeZone.LocalNow](datetimezone-localnow.md) | On Power Query Desktop, the signed offset of the local operating system's time zone from UTC. On Power Query Online, returns `+00`. | +| [DateTimeZone.UtcNow](datetimezone-utcnow.md) | Returns `+0`. | + +If the "z" format specifier is used without other custom format specifiers, it's interpreted as a standard date and time format specifier and throws an expression error. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +The following example includes the "z" custom format specifier in a custom format string on a system in the U.S. Pacific Time zone. + +```powerquery-m +let + Source = + { + DateTimeZone.ToText(DateTimeZone.LocalNow(), [Format="{0:%z}"]), + // Displays {0:-7} on Power Query Desktop + // Displays {0:+0} on Power Query Online + + DateTimeZone.ToText(DateTimeZone.UtcNow(),[Format="{0:%z}"]), + // Displays {0:+0} + + DateTimeZone.ToText(DateTimeZone.SwitchZone( + #datetimezone(2024, 8, 1, 0, 0, 0, 0, 0), 6), + [Format = "{0:%z}"] + ) + // Displays {0:+6} + } +in + Source +``` + +> [!NOTE] +>The value returned by [DateTimeZone.LocalNow](datetimezone-localnow.md) depends on whether you're running Power Query on a local machine or online. For example, in the sample above on a system in the U.S. Pacific Time zone, Power Query Desktop returns `{0:-7}` because it's reading the time set on your local machine. However, Power Query Online returns `{0:+0}` because it's reading the time set on the cloud virtual machines, which are set to UTC. + +[Back to table](#table) + +### The "zz" custom format specifier + +With **DateTimeZone** values, the "zz" custom format specifier represents the signed offset of the specified time zone from UTC, measured in hours. The offset is always displayed with a leading sign. A plus sign (+) indicates hours ahead of UTC, and a minus sign (-) indicates hours behind UTC. A single-digit offset is formatted *with* a leading zero. + +The following table shows how the offset value changes depending on the **DateTimeZone** function. + +| DateTimeZone value | Offset value | +| --- | --- | +| [DateTimeZone.LocalNow](datetimezone-localnow.md) | On Power Query Desktop, the signed offset of the local operating system's time zone from UTC. On Power Query Online, returns `+00`. | +| [DateTimeZone.UtcNow](datetimezone-utcnow.md) | Returns `+00`. | + +The following example includes the "zz" custom format specifier in a custom format string on a system in the U.S. Pacific Time zone. + +```powerquery-m +let + Source = + { + DateTimeZone.ToText(DateTimeZone.LocalNow(), [Format="{0:zz}"]), + // Displays {0:-07} on Power Query Desktop + // Displays {0:+00} on Power Query Online + + DateTimeZone.ToText(DateTimeZone.UtcNow(),[Format="{0:zz}"]), + // Displays {0:+00} + + DateTimeZone.ToText(DateTimeZone.SwitchZone( + #datetimezone(2024, 8, 1, 0, 0, 0, 0, 0), 6), + [Format = "{0:zz}"] + ) + // Displays {0:+06} + } +in + Source +``` + +> [!NOTE] +>The value returned by [DateTimeZone.LocalNow](datetimezone-localnow.md) depends on whether you're running Power Query on a local machine or online. For example, in the sample above on a system in the U.S. Pacific Time zone, Power Query Desktop returns `{0:-07}` because it's reading the time set on your local machine. However, Power Query Online returns `{0:+00}` because it's reading the time set on the cloud virtual machines, which are set to UTC. + +[Back to table](#table) + +### The "zzz" custom format specifier + +With **DateTimeZone** values, the "zzz" custom format specifier represents the signed offset of the specified time zone from UTC, measured in hours and minutes. The offset is always displayed with a leading sign. A plus sign (+) indicates hours ahead of UTC, and a minus sign (-) indicates hours behind UTC. A single-digit offset is formatted with a leading zero. + +The following table shows how the offset value changes depending on the **DateTimeZone** function. + +| DateTimeZoneValue value | Offset value | +| --- | --- | +| [DateTimeZone.LocalNow](datetimezone-localnow.md) | On Power Query Desktop, the signed offset of the local operating system's time zone from UTC. On Power Query Online, returns `+00`.| +| [DateTimeZone.UtcNow](datetimezone-utcnow.md) | Returns `+00:00`. | + +The following example includes the "zzz" custom format specifier in a custom format string on a system in the U.S. Pacific Time zone. + +```powerquery-m +let + Source = + { + DateTimeZone.ToText(DateTimeZone.LocalNow(), [Format="{0:zzz}"]), + // Displays {0:-07:00} on Power Query Desktop + // Displays {0:+00:00} on Power Query Online + + DateTimeZone.ToText(DateTimeZone.UtcNow(),[Format="{0:zzz}"]), + // Displays {0:+00:00} + + DateTimeZone.ToText(DateTimeZone.SwitchZone( + #datetimezone(2024, 8, 1, 0, 0, 0, 0, 0), 6), + [Format = "{0:zzz}"] + ) + // Displays {0:+06:00} + } +in + Source +``` + +> [!NOTE] +>The value returned by [DateTimeZone.LocalNow](datetimezone-localnow.md) depends on whether you're running Power Query on a local machine or online. For example, in the sample above on a system in the U.S. Pacific Time zone, Power Query Desktop returns `{0:-07:00}` because it's reading the time set on your local machine. However, Power Query Online returns `{0:+00:00}` because it's reading the time set on the cloud virtual machines, which are set to UTC. + +[Back to table](#table) + +## Date and time separator specifiers + +### The ":" custom format specifier + +The ":" custom format specifier represents the time separator, which is used to differentiate hours, minutes, and seconds. The appropriate localized time separator is retrieved from the current or specified culture. + +> [!NOTE] +> To change the time separator for a particular date and time string, specify the separator character within a literal string delimiter. For example, the custom format string `hh_dd_ss` produces a result string in which "_" (an underscore) is always used as the time separator. + +If the ":" format specifier is used without other custom format specifiers, it's interpreted as a standard date and time format specifier and throws an expression error. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +[Back to table](#table) + +### The "/" custom format specifier + +The "/" custom format specifier represents the date separator, which is used to differentiate years, months, and days. The appropriate localized date separator is retrieved from the current or specified culture. + +> [!NOTE] +> To change the date separator for a particular date and time string, specify the separator character within a literal string delimiter. For example, the custom format string `mm/dd/yyyy` produces a result string in which "/" is always used as the date separator. + +If the "/" format specifier is used without other custom format specifiers, it's interpreted as a standard date and time format specifier and throws an expression error. For more information about using a single format specifier, go to [Using Single Custom Format Specifiers](#using-single-custom-format-specifiers) later in this article. + +[Back to table](#table) + +## Character literals + +The following characters in a custom date and time format string are reserved and are always interpreted as formatting characters or, in the case of `"`, `'`, `/`, and `\`, as special characters. + +- `F` +- `H` +- `K` +- `M` +- `d` +- `f` +- `g` +- `h` +- `m` +- `s` +- `t` +- `y` +- `z` +- `%` +- `:` +- `/` +- `"` +- `'` +- `\` + +All other characters are always interpreted as character literals and, in a formatting operation, are included in the result string unchanged. In a parsing operation, they must match the characters in the input string exactly; the comparison is case-sensitive. + +The following example includes the literal characters "PST" (for Pacific Standard Time) and "PDT" (for Pacific Daylight Time) to represent the local time zone in a format string. Note that the string is included in the result string, and that a string that includes the local time zone string also parses successfully. + +```powerquery-m +let + #"Date Formats" = {"dd MMM yyyy hh:mm tt PST", "dd MMM yyyy hh:mm tt PDT"}, + Source = + { + DateTime.ToText(#datetime(2024, 8, 18, 16, 50, 0), [Format = #"Date Formats"{1}]), + try DateTime.ToText(DateTime.FromText( + "25 Dec 2023 12:00 pm PST", [Format = #"Date Formats"{0}])) + otherwise "Unable to parse '" & "25 Dec 2023 12:00 pm PST" & "'" + } +in + Source + +// The example displays the following output text: +// 18 Aug 2024 04:50 PM PDT +// 12/25/2023 12:00:00 PM +``` + +There are two ways to indicate that characters are to be interpreted as literal characters and not as reserve characters, so that they can be included in a result string or successfully parsed in an input string: + +- By escaping each reserved character. For more information, go to [Using the escape sequences](#escape). + + The following example includes the literal characters "pst" (for Pacific Standard time) to represent the local time zone in a format string. Because both "s" and "t" are custom format strings, both characters must be escaped to be interpreted as character literals. + + ```powerquery-m + let + #"Date Format" = "dd MMM yyyy hh:mm tt p's''t'", + Source = + { + DateTime.ToText(#datetime(2024, 8, 18, 16, 50, 0), [Format = #"Date Format"]), + try DateTime.ToText(DateTime.FromText( + "25 Dec 2023 12:00 pm pst", [Format = #"Date Format"])) + otherwise "Unable to parse '" & "25 Dec 2023 12:00 pm pst" & "'" + } + in + Source + + // The example displays the following output text: + // 18 Aug 2024 04:50 PM pst + // 12/25/2016 12:00:00 PM + ``` + +- By enclosing the entire literal string in apostrophes. The following example is like the previous one, except that "pst" is enclosed in apostrophes to indicate that the entire delimited string should be interpreted as character literals. + + ```powerquery-m + let + #"Date Format" = "dd MMM yyyy hh:mm tt 'pst'", + Source = + { + DateTime.ToText(#datetime(2024, 8, 18, 16, 50, 0), [Format = #"Date Format"]), + try DateTime.ToText(DateTime.FromText( + "25 Dec 2023 12:00 pm pst", [Format = #"Date Format"])) + otherwise "Unable to parse '" & "25 Dec 2023 12:00 pm pst" & "'" + } + in + Source + + // The example displays the following output text: + // 18 Aug 2024 04:50 PM pst + // 12/25/2016 12:00:00 PM + ``` + +## Notes + +### Using single custom format specifiers + +A custom date and time format string consists of two or more characters. Date and time formatting methods interpret any single-character string as a standard date and time format string. If they don't recognize the character as a valid format specifier, they throw an expression error. For example, a format string that consists only of the specifier "h" is interpreted as a standard date and time format string. However, in this particular case, an exception is thrown because there is no "h" standard date and time format specifier. + +To use any of the custom date and time format specifiers as the only specifier in a format string (that is, to use the "d", "f", "F", "g", "h", "H", "K", "m", "M", "s", "t", "y", "z", ":", or "/" custom format specifier by itself), include a space before or after the specifier, or include a percent ("%") format specifier before the single custom date and time specifier. + +For example, "`%h`" is interpreted as a custom date and time format string that displays the hour represented by the current date and time value. You can also use the " h" or "h " format string, although this includes a space in the result string along with the hour. The following example illustrates these three format strings. + +```powerquery-m +let + date = #datetime(2024, 6, 15, 13, 45, 0), + Source = + { + Text.Format("'#{0}'", {DateTime.ToText(date, [Format = "%h"])}), + Text.Format("'#{0}'", {DateTime.ToText(date, [Format = " h"])}), + Text.Format("'#{0}'", {DateTime.ToText(date, [Format = "h "])}) + } +in + Source + +// The example displays a list with the following output text, +// with representing a space: +// '1' +// ' 1' +// '1 ' +``` + +#### Using the escape sequences + +The "d", "f", "F", "g", "h", "H", "K", "m", "M", "s", "t", "y", "z", ":", or "/" characters in a format string are interpreted as custom format specifiers rather than as literal characters. + +To prevent a character from being interpreted as a format specifier, you can: + +- Precede it with a backslash. +- Surround it with a single quote. +- Surround it with two double quotes. + +Each of these characters acts as an escape sequence. The escape sequence signifies that the following character or surrounded character is a text literal that should be included in the result string unchanged. + +To include a double quote in a result string, you must escape it with another double quote (`""`). + +The following example uses different escape sequences to prevent the formatting operation from interpreting the "h" and "m" characters as format specifiers. + +```powerquery-m +let + date = #datetime(2024, 6, 15, 13, 45, 30.90), + format1 = "h \h m \m", + format2 = "h ""h"" m ""m""", + format3 = "h 'h' m 'm'", + Source = + { + Text.Format("#{0} (#{1}) -> #{2}", {DateTime.ToText(date), format1, DateTime.ToText(date, format1)}), + Text.Format("#{0} (#{1}) -> #{2}", {DateTime.ToText(date), format2, DateTime.ToText(date, format2)}), + Text.Format("#{0} (#{1}) -> #{2}", {DateTime.ToText(date), format3, DateTime.ToText(date, format3)}) + } +in + Source + +// The example displays the following output text: +// 6/15/2024 1:45:30 PM (h \h m \m) -> 1 h 45 m +// 6/15/2024 1:45:30 PM (h "h" m "m") -> 1 h 45 m +// 6/15/2024 1:45:30 PM (h 'h' m 'm') -> 1 h 45 m +``` + +## Related content + +- [How culture affects text formatting](how-culture-affects-text-formatting.md) +- [Date, Time, DateTime, and DateTimeZone type conversion](type-conversion.md#date-time-datetime-and-datetimezone) +- [Date functions](date-functions.md) +- [DateTime functions](datetime-functions.md) +- [DateTimeZone functions](datetimezone-functions.md) +- [Time functions](time-functions.md) +- [Standard Date and Time format strings](standard-date-and-time-format-strings.md) diff --git a/query-languages/m/custom-numeric-format-strings.md b/query-languages/m/custom-numeric-format-strings.md new file mode 100644 index 000000000..2b66c5d61 --- /dev/null +++ b/query-languages/m/custom-numeric-format-strings.md @@ -0,0 +1,469 @@ +--- +description: "Learn more about: Custom numeric format strings" +title: "Custom numeric format strings" +ms.date: 9/30/2024 +ms.custom: "nonautomated-date" +ms.subservice: m-background +--- +# Custom numeric format strings + +You can create a custom numeric format string, which consists of one or more custom numeric specifiers, to define how to format numeric data. A custom numeric format string is any format string that isn't a [standard numeric format string](standard-numeric-format-strings.md). + + The following table describes the custom numeric format specifiers and displays sample output produced by each format specifier. Go to the [Notes](#NotesCustomFormatting) section for additional information about using custom numeric format strings, and the [Example](#example) section for a comprehensive illustration of their use. + +|Format specifier|Name|Description|Examples| +|----------------------|----------|-----------------|--------------| +|"0"|Zero placeholder|Replaces the zero with the corresponding digit if one is present; otherwise, zero appears in the result string.

More information: [The "0" Custom Specifier](#Specifier0).|1234.5678 ("00000") -> 01235

0.45678 ("0.00", en-US) -> 0.46

0.45678 ("0.00", fr-FR) -> 0,46| +|"#"|Digit placeholder|Replaces the "#" symbol with the corresponding digit if one is present; otherwise, no digit appears in the result string.

No digit appears in the result string if the corresponding digit in the input string is a nonsignificant 0. For example, 0003 ("####") -> 3.

More information: [The "#" Custom Specifier](#SpecifierD).|1234.5678 ("#####") -> 1235

0.45678 ("#.##", en-US) -> .46

0.45678 ("#.##", fr-FR) -> ,46| +|"."|Decimal point|Determines the location of the decimal separator in the result string.

More information: [The "." Custom Specifier](#SpecifierPt).|0.45678 ("0.00", en-US) -> 0.46

0.45678 ("0.00", fr-FR) -> 0,46| +|","|Group separator and number scaling|Serves as both a group separator and a number scaling specifier. As a group separator, it inserts a localized group separator character between each group. As a number scaling specifier, it divides a number by 1000 for each comma specified.

More information: [The "," Custom Specifier](#SpecifierTh).|Group separator specifier:

2147483647 ("##,#", en-US) -> 2,147,483,647

2147483647 ("##,#", es-ES) -> 2.147.483.647

Scaling specifier:

2147483647 ("#,#,,", en-US) -> 2,147

2147483647 ("#,#,,", es-ES) -> 2.147| +|"%"|Percentage placeholder|Multiplies a number by 100 and inserts a localized percentage symbol in the result string.

More information: [The "%" Custom Specifier](#SpecifierPct).|0.3697 ("%#0.00", en-US) -> %36.97

0.3697 ("%#0.00", el-GR) -> %36,97

0.3697 ("##.0 %", en-US) -> 37.0 %

0.3697 ("##.0 %", el-GR) -> 37,0 %| +|"‰"|Per mille placeholder|Multiplies a number by 1000 and inserts a localized per mille symbol in the result string.

More information: [The "‰" Custom Specifier](#SpecifierPerMille).|0.03697 ("#0.00‰", en-US) -> 36.97‰

0.03697 ("#0.00‰", ru-RU) -> 36,97‰| +|"E0"

"E+0"

"E-0"

"e0"

"e+0"

"e-0"|Exponential notation|If followed by at least one 0 (zero), formats the result using exponential notation. The case of "E" or "e" indicates the case of the exponent symbol in the result string. The number of zeros following the "E" or "e" character determines the minimum number of digits in the exponent. A plus sign (+) indicates that a sign character always precedes the exponent. A minus sign (-) indicates that a sign character precedes only negative exponents.

More information: [The "E" and "e" Custom Specifiers](#SpecifierExponent).|987654 ("#0.0e0") -> 98.8e4

1503.92311 ("0.0##e+00") -> 1.504e+03

1.8901385E-16 ("0.0e+00") -> 1.9e-16| +|"\\", "''", """"|Escape characters|Causes the next character or characters to be interpreted as a literal rather than as a custom format specifier.

More information: [Escape characters](#SpecifierEscape).|987654 ("\\###00\\#") -> #987654#

987654 ("'#'##00'#'") -> #987654#

987654 ("""#""##00""#""") -> #987654#| +|'*string*'

"*string*"|Literal string delimiter|Indicates that the enclosed characters should be copied to the result string unchanged.

More information: [Character literals](#character-literals).|68 ("# 'degrees'") -> 68 degrees

68 ("#' degrees'") -> 68 degrees| +|;|Section separator|Defines sections with separate format strings for positive, negative, and zero numbers.

More information: [The ";" Section Separator](#SectionSeparator).|12.345 ("#0.0#;(#0.0#);-\0-") -> 12.35

0 ("#0.0#;(#0.0#);-\0-") -> -0-

-12.345 ("#0.0#;(#0.0#);-\0-") -> (12.35)

12.345 ("#0.0#;(#0.0#)") -> 12.35

0 ("#0.0#;(#0.0#)") -> 0.0

-12.345 ("#0.0#;(#0.0#)") -> (12.35)| +|Other|All other characters|The character is copied to the result string unchanged.

More information: [Character literals](#character-literals).|68 ("# °") -> 68 °| + +The following sections provide detailed information about each of the custom numeric format specifiers. + + + +## The "0" custom specifier + +The "0" custom format specifier serves as a zero-placeholder symbol. If the value that is being formatted has a digit in the position where the zero appears in the format string, that digit is copied to the result string; otherwise, a zero appears in the result string. The position of the leftmost zero before the decimal point and the rightmost zero after the decimal point determines the range of digits that are always present in the result string. + +The "00" specifier causes the value to be rounded to the nearest digit preceding the decimal, where rounding away from zero is always used. For example, formatting 34.5 with "00" would result in the value 35. + +The following example displays several values that are formatted by using custom format strings that include zero placeholders. + +```powerquery-m +let + Source = + { + Number.ToText(123, "00000", ""), + // Displays 00123 + + Number.ToText(1.2, "0.00", ""), + // Displays 1.20 + + Number.ToText(1.2, "00.00", ""), + // Displays 01.20 + + Number.ToText(1.2, "00.00", "da-DK"), + // Displays 01,20 + + Number.ToText(.56, "0.0", ""), + // Displays 0.6 + + Number.ToText(1234567890, "0,0", ""), + // Displays 1,234,567,890 + + Number.ToText(1234567890, "0,0", "el-GR"), + // Displays 1.234.567.890 + + Number.ToText(1234567890.123456, "0,0.0", ""), + // Displays 1,234,567,890.1 + + Number.ToText(1234.567890, "0,0.00", "") + // Displays 1,234.57 + } +in + Source +``` + +> [!NOTE] +> The blank text value ("") in the last parameter of [Number.ToText](number-totext.md) in the previous sample refers to the invariant culture. + +[Back to table](#table) + + + +## The "#" custom specifier + +The "#" custom format specifier serves as a digit-placeholder symbol. If the value that is being formatted has a digit in the position where the "#" symbol appears in the format string, that digit is copied to the result string. Otherwise, nothing is stored in that position in the result string. + +Note that this specifier never displays a zero that isn't a significant digit, even if zero is the only digit in the string. It displays zero only if it's a significant digit in the number that is being displayed. + +The "##" format string causes the value to be rounded to the nearest digit preceding the decimal, where rounding away from zero is always used. For example, formatting 34.5 with "##" would result in the value 35. + +The following example displays several values that are formatted by using custom format strings that include digit placeholders. + +```powerquery-m +let + Source = + { + Number.ToText(1.2, "#.##", ""), + // Displays 1.2 + + Number.ToText(123, "#####"), + // Displays 123 + + Number.ToText(123456, "[##-##-##]"), + // Displays [12-34-56] + + Number.ToText(1234567890, "#"), + // Displays 1234567890 + + Number.ToText(1234567890, "(###) ###-####") + // Displays (123) 456-7890 + } +in + Source +``` + +To return a result string in which absent digits or leading zeroes are replaced by spaces, use the [Text.PadStart](text-padstart.md) and specify a field width, as the following example illustrates. + +```powerquery-m +let + Source = Text.Format("The value is: '#{0}'", {Text.PadStart(Number.ToText(.324, "#.###"), 5)}) +in + Source + +// The example displays the following output if the current culture +// is en-US: +// The value is: ' .324' +``` + +[Back to table](#table) + + + +## The "." custom specifier + +The "." custom format specifier inserts a localized decimal separator into the result string. The first period in the format string determines the location of the decimal separator in the formatted value; any additional periods are ignored. If the format specifier ends with a "." only the significant digits are formatted into the result string. + +The character that is used as the decimal separator in the result string isn't always a period; it's determined by the culture that controls formatting. + +The following example uses the "." format specifier to define the location of the decimal point in several result strings. + +```powerquery-m +let + Source = + { + Number.ToText(1.2, "0.00", ""), + // Displays 1.20 + + Number.ToText(1.2, "00.00", ""), + // Displays 01.20 + + Number.ToText(1.2, "00.00", "da-DK"), + // Displays 01,20 + + Number.ToText(.086, "#0.##%", ""), + // Displays 8.6% + + Number.ToText(Double.From(86000), "0.###E+0", "") + // Displays 8.6E+4 + } +in + Source +``` + +[Back to table](#table) + + + +## The "," custom specifier + +The "," character serves as both a group separator and a number scaling specifier. + +- Group separator: If one or more commas are specified between two digit placeholders (0 or #) that format the integral digits of a number, a group separator character is inserted between each number group in the integral part of the output. + + The culture determines the character used as the number group separator and the size of each number group. For example, if the string "#,#" and the invariant culture are used to format the number 1000, the output is "1,000". + +- Number scaling specifier: If one or more commas are specified immediately to the left of the explicit or implicit decimal point, the number to be formatted is divided by 1000 for each comma. For example, if the string "0,," is used to format the number 100 million, the output is "100". + +You can use group separator and number scaling specifiers in the same format string. For example, if the string "#,0,," and the invariant culture are used to format the number one billion, the output is "1,000". + +The following example illustrates the use of the comma as a group separator. + +```powerquery-m +let + Source = + { + Number.ToText(1234567890, "#,#", ""), + // Displays 1,234,567,890 + + Number.ToText(1234567890, "#,##0,,", "") + // Displays, 1,235 + } +in + Source +``` + +The following example illustrates the use of the comma as a specifier for number scaling. + +```powerquery-m +let + Source = + { + Number.ToText(1234567890, "#,,", ""), + // Displays 1235 + + Number.ToText(1234567890, "#,,,", ""), + // Displays 1 + + Number.ToText(1234567890, "#,##0,,", "") + // Displays 1,235 + } +in + Source +``` + +[Back to table](#table) + + + +## The "%" custom specifier + +A percent sign (%) in a format string causes a number to be multiplied by 100 before it's formatted. The localized percent symbol is inserted in the number at the location where the % appears in the format string. The percent character used is defined by the culture. + +The following example defines a custom format string that includes the "%" custom specifier. + +```powerquery-m +let + Source = Number.ToText(.086, "#0.##%", "") + // Displays 8.6% +in + Source +``` + +[Back to table](#table) + + + +## The "‰" custom specifier + +A per mille character (‰ or \u2030) in a format string causes a number to be multiplied by 1000 before it's formatted. The appropriate per mille symbol is inserted in the returned string at the location where the ‰ symbol appears in the format string. The per mille character used is defined by the culture, which provides culture-specific formatting information. + +The following example defines a custom format string that includes the "‰" custom specifier. + +```powerquery-m +let + Source = Number.ToText(.00354, "#0.##" & Character.FromNumber(0x2030), "") + // Displays 3.54‰ +in + Source +``` + +[Back to table](#table) + + + +## The "E" and "e" custom specifiers + +If any of the strings "E", "E+", "E-", "e", "e+", or "e-" are present in the format string and are followed immediately by at least one zero, the number is formatted by using scientific notation with an "E" or "e" inserted between the number and the exponent. The number of zeros following the scientific notation indicator determines the minimum number of digits to output for the exponent. The "E+" and "e+" formats indicate that a plus sign or minus sign should always precede the exponent. The "E", "E-", "e", or "e-" formats indicate that a sign character should precede only negative exponents. + +The following example formats several numeric values using the specifiers for scientific notation. + +```powerquery-m +let + Source = + { + Number.ToText(86000, "0.###E+0", ""), + // Displays 8.6E+4 + + Number.ToText(86000, "0.###E+000", ""), + // Displays 8.6E+004 + + Number.ToText(86000, "0.###E-000", "") + // Displays 8.6E004 + } +in + Source +``` + +[Back to table](#table) + + + +## Escape characters + +The "#", "0", ".", ",", "%", and "‰" symbols in a format string are interpreted as format specifiers rather than as literal characters. Depending on their position in a custom format string, the uppercase and lowercase "E" as well as the + and - symbols can also be interpreted as format specifiers. + +To prevent a character from being interpreted as a format specifier, you can: + +- Precede it with a backslash. +- Surround it with a single quote. +- Surround it with two double quotes. + +Each of these characters acts as escape characters. The escape character signifies that the following character is a character literal that should be included in the result string unchanged. + +To include a backslash in a result string, you must escape it with another backslash (`\\`). + +To include a single quote in a result string, you must escape it with a backslash (`\'`). If another single quote that isn't escaped precedes the escaped single quote, the backslash is displayed instead (`'\'` displays `\`). + +To include a double quote in a result string, you must escape two of them with a backslash (`\""`). + +The following example uses escape characters to prevent the formatting operation from interpreting the "#", "0", and "\" characters as either escape characters or format specifiers. + +```powerquery-m +let + Source = + { + Number.ToText(123, "\#\#\# ##0 dollars and \0\0 cents \#\#\#"), + // Displays ### 123 dollars and 00 cents ### + + Number.ToText(123, "'###' ##0 dollars and '00' cents '###'"), + // Displays ### 123 dollars and 00 cents ### + + Number.ToText(123, """###"" ##0 dollars and ""00"" cents ""###"""), + // Displays ### 123 dollars and 00 cents ### + + Number.ToText(123, "\\\\\\ ##0 dollars and \0\0 cents \\\\\\"), + // Displays \\\ 123 dollars and 00 cents \\\ + + Number.ToText(123, "'\\\' ##0 dollars and '00' cents '\\\'"), + // Displays \\\ 123 dollars and 00 cents \\\ + + Number.ToText(123, """\\\"" ##0 dollars and ""00"" cents ""\\\""") + // Displays \\\ 123 dollars and 00 cents \\\ + } +in + Source +``` + +[Back to table](#table) + + + +## The ";" section separator + +The semicolon (;) is a conditional format specifier that applies different formatting to a number depending on whether its value is positive, negative, or zero. To produce this behavior, a custom format string can contain up to three sections separated by semicolons. These sections are described in the following table. + +|Number of sections|Description| +|------------------------|-----------------| +|One section|The format string applies to all values.| +|Two sections|The first section applies to positive values and zeros, and the second section applies to negative values.

If the number to be formatted is negative, but becomes zero after rounding according to the format in the second section, the resulting zero is formatted according to the first section.| +|Three sections|The first section applies to positive values, the second section applies to negative values, and the third section applies to zeros.

The second section can be left empty (by having nothing between the semicolons), in which case the first section applies to all nonzero values.

If the number to be formatted is nonzero, but becomes zero after rounding according to the format in the first or second section, the resulting zero is formatted according to the third section.| + +Section separators ignore any preexisting formatting associated with a number when the final value is formatted. For example, negative values are always displayed without a minus sign when section separators are used. If you want the final formatted value to have a minus sign, you should explicitly include the minus sign as part of the custom format specifier. + +The following example uses the ";" format specifier to format positive, negative, and zero numbers differently. + +```powerquery-m +let + Source = + { + Number.ToText(1234, "##;(##)"), + // Displays 1234 + + Number.ToText(-1234, "##;(##)"), + // Displays (1234) + + Number.ToText(0, "##;(##);**Zero**") + // Displays **Zero** + } +in + Source +``` + +[Back to table](#table) + +## Character literals + +Format specifiers that appear in a custom numeric format string are always interpreted as formatting characters and never as literal characters. This includes the following characters: + +- [0](#Specifier0) +- [\#](#SpecifierD) +- [%](#SpecifierPct) +- [‰](#SpecifierPerMille) +- ' +- [\\](#SpecifierEscape) +- [\""](#SpecifierEscape) +- [.](#SpecifierPt) +- [,](#SpecifierTh) +- [E or e](#SpecifierExponent), depending on its position in the format string. + +All other characters are always interpreted as character literals and, in a formatting operation, are included in the result string unchanged. In a parsing operation, they must match the characters in the input string exactly; the comparison is case-sensitive. + +The following example illustrates one common use of literal character units (in this case, thousands): + +```powerquery-m +let + Source = Number.ToText(123.8, "#,##0.0K") + // Displays 123.8K +in + Source +``` + +There are two ways to indicate that characters are to be interpreted as literal characters and not as formatting characters, so that they can be included in a result string or successfully parsed in an input string: + +- By escaping a formatting character. For more information, go to [Escape characters](#SpecifierEscape). + +- By enclosing the entire literal string in quotation apostrophes. + +The following example uses both approaches to include reserved characters in a custom numeric format string. + +```powerquery-m +let + Source = + { + Number.ToText(9.3, "##.0\%"), + // Displays 9.3% + + Number.ToText(9.3, "\'##\'"), + // Displays '9' + + Number.ToText(9.3, "\\##\\"), + // Displays \9\ + + Number.ToText(9.3, "##.0'%'"), + // Displays 9.3% + + Number.ToText(9.3, "'\'##'\'"), + // Displays \9\ + + Number.ToText(9.3, "##.0""%"""), + // Displays 9.3% + + Number.ToText(9.3, "\""##\""") + // Displays "9" + } +in + Source +``` + + + +## Notes + +### Floating-Point infinities and NaN + +Regardless of the format string, if the value of a `Decimal.Type`, `Single.Type` or `Double.Type` floating-point type is positive infinity, negative infinity, or not a number (NaN), the formatted string is the value of the respective [Number.PositiveInfinity](number-positiveinfinity.md), [Number.NegativeInfinity](number-negativeinfinity.md), or [Number.NaN](number-nan.md) constants specified by the currently applicable culture. + +### Rounding and fixed-point format strings + +For fixed-point format strings (that is, format strings that don't contain scientific notation format characters), numbers are rounded to as many decimal places as there are digit placeholders to the right of the decimal point. If the format string doesn't contain a decimal point, the number is rounded to the nearest integer. If the number has more digits than there are digit placeholders to the left of the decimal point, the extra digits are copied to the result string immediately before the first digit placeholder. + +[Back to table](#table) + + + +## Example + +The following example demonstrates two custom numeric format strings. In both cases, the digit placeholder (`#`) displays the numeric data, and all other characters are copied to the result string. + +```powerquery-m +let + Source = + { + Number.ToText(1234567890, "(###) ###-####"), + // Displays (123) 456-7890 + + Number.ToText(42, "My Number = #") + // Displays My number = 42 + } +in + Source +``` + +[Back to table](#table) + +## Related content + +- [How culture affects text formatting](how-culture-affects-text-formatting.md) +- [Number type conversion](type-conversion.md#number) +- [Data Types in Power Query](/power-query/data-types) +- [Standard Numeric Format Strings](standard-numeric-format-strings.md) diff --git a/query-languages/m/date-adddays.md b/query-languages/m/date-adddays.md index c6b803dc5..6cf016f1c 100644 --- a/query-languages/m/date-adddays.md +++ b/query-languages/m/date-adddays.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Date.AddDays" -title: "Date.AddDays | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.AddDays" +ms.subservice: m-source --- # Date.AddDays ## Syntax
-Date.AddDays(dateTime as any, numberOfDays as number) as any  
+Date.AddDays(dateTime as any, numberOfDays as number) as any
 
- + ## About Returns the `date`, `datetime`, or `datetimezone` result from adding `numberOfDays` days to the `datetime` value `dateTime`. @@ -38,3 +31,9 @@ Date.AddDays(#date(2011, 5, 14), 5) **Output** `#date(2011, 5, 19)` + +## Related content + +* [#date](sharpdate.md) +* [#datetime](sharpdatetime.md) +* [#datetimezone](sharpdatetimezone.md) diff --git a/query-languages/m/date-addmonths.md b/query-languages/m/date-addmonths.md index 6e6e735df..190dba0e3 100644 --- a/query-languages/m/date-addmonths.md +++ b/query-languages/m/date-addmonths.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.AddMonths" -title: "Date.AddMonths | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.AddMonths" +ms.subservice: m-source --- # Date.AddMonths @@ -17,7 +10,7 @@ ms.author: dougklo
 Date.AddMonths(dateTime as any, numberOfMonths as number) as any
 
- + ## About Returns the `date`, `datetime`, or `datetimezone` result from adding `numberOfMonths` months to the `datetime` value `dateTime`. @@ -52,3 +45,9 @@ Date.AddMonths(#datetime(2011, 5, 14, 8, 15, 22), 18) **Output** `#datetime(2012, 11, 14, 8, 15, 22)` + +## Related content + +* [#date](sharpdate.md) +* [#datetime](sharpdatetime.md) +* [#datetimezone](sharpdatetimezone.md) diff --git a/query-languages/m/date-addquarters.md b/query-languages/m/date-addquarters.md index 4676189f0..253d004e2 100644 --- a/query-languages/m/date-addquarters.md +++ b/query-languages/m/date-addquarters.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Date.AddQuarters" -title: "Date.AddQuarters | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.AddQuarters" +ms.subservice: m-source --- # Date.AddQuarters ## Syntax
-Date.AddQuarters(dateTime as any, numberOfQuarters as number) as any  
+Date.AddQuarters(dateTime as any, numberOfQuarters as number) as any
 
- + ## About Returns the `date`, `datetime`, or `datetimezone` result from adding `numberOfQuarters` quarters to the `datetime` value `dateTime`. @@ -38,3 +31,9 @@ Date.AddQuarters(#date(2011, 5, 14), 1) **Output** `#date(2011, 8, 14)` + +## Related content + +* [#date](sharpdate.md) +* [#datetime](sharpdatetime.md) +* [#datetimezone](sharpdatetimezone.md) diff --git a/query-languages/m/date-addweeks.md b/query-languages/m/date-addweeks.md index 781e38466..1bb5f5390 100644 --- a/query-languages/m/date-addweeks.md +++ b/query-languages/m/date-addweeks.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.AddWeeks" -title: "Date.AddWeeks | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.AddWeeks" +ms.subservice: m-source --- # Date.AddWeeks @@ -17,7 +10,7 @@ ms.author: dougklo
 Date.AddWeeks(dateTime as any, numberOfWeeks as number) as any
 
- + ## About Returns the `date`, `datetime`, or `datetimezone` result from adding `numberOfWeeks` weeks to the `datetime` value `dateTime`. @@ -38,3 +31,9 @@ Date.AddWeeks(#date(2011, 5, 14), 2) **Output** `#date(2011, 5, 28)` + +## Related content + +* [#date](sharpdate.md) +* [#datetime](sharpdatetime.md) +* [#datetimezone](sharpdatetimezone.md) diff --git a/query-languages/m/date-addyears.md b/query-languages/m/date-addyears.md index 49bbe6369..a5a1eda1d 100644 --- a/query-languages/m/date-addyears.md +++ b/query-languages/m/date-addyears.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.AddYears" -title: "Date.AddYears | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.AddYears" +ms.subservice: m-source --- # Date.AddYears @@ -17,7 +10,7 @@ ms.author: dougklo
 Date.AddYears(dateTime as any, numberOfYears as number) as any
 
- + ## About Returns the `date`, `datetime`, or `datetimezone` result of adding `numberOfYears` to a `datetime` value `dateTime`. @@ -52,3 +45,9 @@ Date.AddYears(#datetime(2011, 5, 14, 8, 15, 22), 10) **Output** `#datetime(2021, 5, 14, 8, 15, 22)` + +## Related content + +* [#date](sharpdate.md) +* [#datetime](sharpdatetime.md) +* [#datetimezone](sharpdatetimezone.md) diff --git a/query-languages/m/date-day.md b/query-languages/m/date-day.md index 6018ef41d..1fef49216 100644 --- a/query-languages/m/date-day.md +++ b/query-languages/m/date-day.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.Day" -title: "Date.Day | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.Day" +ms.subservice: m-source --- # Date.Day @@ -17,7 +10,7 @@ ms.author: dougklo
 Date.Day(dateTime as any) as nullable number
 
- + ## About Returns the day component of a `date`, `datetime`, or `datetimezone` value. diff --git a/query-languages/m/date-dayofweek.md b/query-languages/m/date-dayofweek.md index e4acde934..1f68bae58 100644 --- a/query-languages/m/date-dayofweek.md +++ b/query-languages/m/date-dayofweek.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.DayOfWeek" -title: "Date.DayOfWeek | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.DayOfWeek" +ms.subservice: m-source --- # Date.DayOfWeek @@ -23,7 +16,7 @@ Date.DayOfWeek(dateTime as any, optional firstDayOfWeek as nullabl Returns a number (from 0 to 6) indicating the day of the week of the provided `dateTime`. * `dateTime`: A `date`, `datetime`, or `datetimezone` value. -* `firstDayOfWeek`: A `Day` value indicating which day should be considered the first day of the week. Allowed values are [Day.Sunday](/powerquery-m/day-sunday), [Day.Monday](/powerquery-m/day-monday), [Day.Tuesday](/powerquery-m/day-tuesday), [Day.Wednesday](/powerquery-m/day-wednesday), [Day.Thursday](/powerquery-m/day-Thursday), [Day.Friday](/powerquery-m/day-friday), or [Day.Saturday](/powerquery-m/day-saturday). If unspecified, a culture-dependent default is used. +* `firstDayOfWeek`: A `Day` value indicating which day should be considered the first day of the week. Allowed values are [Day.Sunday](day-type.md), [Day.Monday](day-type.md), [Day.Tuesday](day-type.md), [Day.Wednesday](day-type.md), [Day.Thursday](day-type.md), [Day.Friday](day-type.md), or [Day.Saturday](day-type.md). If unspecified, a culture-dependent default is used. ## Example 1 @@ -32,7 +25,7 @@ Get the day of the week represented by Monday, February 21st, 2011, treating Sun **Usage** ```powerquery-m -Date.DayOfWeek(#date(2011, 02, 21), Day.Sunday)` +Date.DayOfWeek(#date(2011, 02, 21), Day.Sunday) ``` **Output** @@ -52,3 +45,7 @@ Date.DayOfWeek(#date(2011, 02, 21), Day.Monday) **Output** `0` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/date-dayofweekname.md b/query-languages/m/date-dayofweekname.md index bb9f6d8df..ceb3d618c 100644 --- a/query-languages/m/date-dayofweekname.md +++ b/query-languages/m/date-dayofweekname.md @@ -1,21 +1,15 @@ --- description: "Learn more about: Date.DayOfWeekName" -title: "Date.DayOfWeekName | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.DayOfWeekName" +ms.subservice: m-source --- # Date.DayOfWeekName ## Syntax
-Date.DayOfWeekName(date as any, optional culture as nullable text)
+Date.DayOfWeekName(date as any, optional culture as nullable text) as nullable text
+
 
## About @@ -35,3 +29,7 @@ Date.DayOfWeekName(#date(2011, 12, 31), "en-US") **Output** `"Saturday"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/date-dayofyear.md b/query-languages/m/date-dayofyear.md index 72115eb59..a3f8d2774 100644 --- a/query-languages/m/date-dayofyear.md +++ b/query-languages/m/date-dayofyear.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.DayOfYear" -title: "Date.DayOfYear | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.DayOfYear" +ms.subservice: m-source --- # Date.DayOfYear @@ -24,7 +17,7 @@ Returns a number representing the day of the year in the provided `date`, `datet ## Example 1 -The number of the day March 1st, 2011 (`#date(2011, 03, 01)`). +The day of the year for March 1st, 2011. **Usage** diff --git a/query-languages/m/date-daysinmonth.md b/query-languages/m/date-daysinmonth.md index a36b28411..b92b887cf 100644 --- a/query-languages/m/date-daysinmonth.md +++ b/query-languages/m/date-daysinmonth.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.DaysInMonth" -title: "Date.DaysInMonth | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.DaysInMonth" +ms.subservice: m-source --- # Date.DaysInMonth diff --git a/query-languages/m/date-endofday.md b/query-languages/m/date-endofday.md index 6cd7cfe46..a0a36e754 100644 --- a/query-languages/m/date-endofday.md +++ b/query-languages/m/date-endofday.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.EndOfDay" -title: "Date.EndOfDay | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.EndOfDay" +ms.subservice: m-source --- # Date.EndOfDay @@ -18,7 +11,7 @@ Date.EndOfDay(dateTime as any) as any ## About -Returns a `date`, `datetime`, or `datetimezone` value representing the end of the day in `dateTime`. Time zone information is preserved. +Returns the end of the day represented by `dateTime`. Time zone information is preserved. * `dateTime`: A `date`, `datetime`, or `datetimezone` value from from which the end of the day is calculated. diff --git a/query-languages/m/date-endofmonth.md b/query-languages/m/date-endofmonth.md index 60d850558..803438083 100644 --- a/query-languages/m/date-endofmonth.md +++ b/query-languages/m/date-endofmonth.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.EndOfMonth" -title: "Date.EndOfMonth | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.EndOfMonth" +ms.subservice: m-source --- # Date.EndOfMonth @@ -20,9 +13,9 @@ Date.EndOfMonth(dateTime as any) as any ## About -Returns the last day of the month in `dateTime`. +Returns the end of the month that contains `dateTime`. -* `dateTime`: A `date`, `datetime`, or `datetimezone` value from which the end of the month is calculated +* `dateTime`: A `date`, `datetime`, or `datetimezone` value from which the end of the month is calculated. ## Example 1 diff --git a/query-languages/m/date-endofquarter.md b/query-languages/m/date-endofquarter.md index 302a95c6e..801168cab 100644 --- a/query-languages/m/date-endofquarter.md +++ b/query-languages/m/date-endofquarter.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.EndOfQuarter" -title: "Date.EndOfQuarter | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.EndOfQuarter" +ms.subservice: m-source --- # Date.EndOfQuarter @@ -20,13 +13,13 @@ Date.EndOfQuarter(dateTime as any) as any ## About -Returns a `date`, `datetime`, or `datetimezone` value representing the end of the quarter in `dateTime`. Time zone information is preserved. +Returns the end of the quarter that contains `dateTime`. Time zone information is preserved. * `dateTime`: A `date`, `datetime`, or `datetimezone` value from which the end of the quarter is calculated. ## Example 1 -Find the end of the quarter for October 10th, 2011, 8:00AM (`#datetime(2011, 10, 10, 8, 0, 0)`). +Find the end of the quarter for October 10th, 2011, 8:00AM. **Usage** diff --git a/query-languages/m/date-endofweek.md b/query-languages/m/date-endofweek.md index 634c20668..4979a2e4b 100644 --- a/query-languages/m/date-endofweek.md +++ b/query-languages/m/date-endofweek.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.EndOfWeek" -title: "Date.EndOfWeek | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.EndOfWeek" +ms.subservice: m-source --- # Date.EndOfWeek @@ -20,10 +13,10 @@ Date.EndOfWeek(dateTime as any, optional firstDayOfWeek as nullabl ## About -Returns the last day of the week in the provided `date`, `datetime`, or `datetimezone` `dateTime`. This function takes an optional `Day`, `firstDayOfWeek`, to set the first day of the week for this relative calculation. The default value is [Day.Sunday](/powerquery-m/day-sunday). +Returns the end of the week that contains `dateTime`. This function takes an optional `Day`, `firstDayOfWeek`, to set as the first day of the week for this relative calculation. The default value is [Day.Sunday](/powerquery-m/day-type). * `dateTime`: A `date`, `datetime`, or `datetimezone` value from which the last day of the week is calculated -* `firstDayOfWeek`: _[Optional]_ A [Day.Type](day-type.md) value representing the first day of the week. Possible values are `Day.Sunday`, `Day.Monday`, `Day.Tuesday`, `Day.Wednesday`, `Day.Thursday`, `Day.Friday`, and `Day.Saturday`. The default value is `Day.Sunday`. +* `firstDayOfWeek`: _[Optional]_ A [Day.Type](/powerquery-m/day-type) value representing the first day of the week. Possible values are `Day.Sunday`, `Day.Monday`, `Day.Tuesday`, `Day.Wednesday`, `Day.Thursday`, `Day.Friday` and `Day.Saturday`. The default value is `Day.Sunday`. ## Example 1 diff --git a/query-languages/m/date-endofyear.md b/query-languages/m/date-endofyear.md index 70d43d652..594eb4bc7 100644 --- a/query-languages/m/date-endofyear.md +++ b/query-languages/m/date-endofyear.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.EndOfYear" -title: "Date.EndOfYear | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.EndOfYear" +ms.subservice: m-source --- # Date.EndOfYear @@ -20,7 +13,7 @@ Date.EndOfYear(dateTime as any) as any ## About -Returns a value representing the end of the year in `dateTime`, including fractional seconds. Time zone information is preserved. +Returns the end of the year that contains `dateTime`, including fractional seconds. Time zone information is preserved. * `dateTime`: A `date`, `datetime`, or `datetimezone` value from which the end of the year is calculated. diff --git a/query-languages/m/date-from.md b/query-languages/m/date-from.md index 52e62b362..e13e07936 100644 --- a/query-languages/m/date-from.md +++ b/query-languages/m/date-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.From" -title: "Date.From | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.From" +ms.subservice: m-source --- # Date.From @@ -20,39 +13,88 @@ Date.From(value as any, optional culture as nullable text) as null ## About -Returns a `date` value from the given `value`. An optional `culture`> may also be provided (for example, "en-US"). If the given `value` is `null`, **Date.From** returns `null`. If the given `value` is `date`, `value` is returned. Values of the following types can be converted to a `date` value: +Returns a date value from the given value. + +* `value`: The value to covert to a date. If the given value is `null`, this function returns `null`. If the given value is `date`, `value` is returned. Values of the following types can be converted to a `date` value: -* `text`: A `date` value from textual representation. Refer to [Date.FromText](date-fromtext.md) for details. -* `datetime`: The date component of the `value`. -* `datetimezone`: The date component of the local datetime equivalent of `value`. -* `number`: The date component of the datetime equivalent of the OLE Automation Date expressed by `value`. + * `text`: A `date` value from textual representation. Refer to [Date.FromText](date-fromtext.md) for details. + * `datetime`: The date component of the `value`. + * `datetimezone`: The date component of the local datetime equivalent of `value`. + * `number`: The date component of the datetime equivalent of a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25. The base value is midnight, 30 December 1899. The minimum value is midnight, 1 January 0100. The maximum value is the last moment of 31 December 9999. -If `value` is of any other type, an error is returned. + If `value` is of any other type, an error is returned. + +* `culture`: The culture of the given value (for example, "en-US"). ## Example 1 -Convert `43910` to a `date` value. +Convert the specified date and time to a date value. **Usage** ```powerquery-m -Date.From(43910) +Date.From(#datetime(1899, 12, 30, 06, 45, 12)) ``` **Output** -`#date(2020, 3, 20)` +`#date(1899, 12, 30)` ## Example 2 -Convert `#datetime(1899, 12, 30, 06, 45, 12)` to a `date` value. +Convert the specified number to a date value. **Usage** ```powerquery-m -Date.From(#datetime(1899, 12, 30, 06, 45, 12)) +Date.From(43910) ``` **Output** -`#date(1899, 12, 30)` +#date(2020, 3, 20) + +## Example 3 + +Convert the German text dates in the Posted Date column to date values. + +**Usage** + +```powerquery-m +let + Source = #table(type table [Account Code = text, Posted Date = text, Sales = number], + { + {"US-2004", "20 Januar 2023", 580}, + {"CA-8843", "18 Juli, 2023", 280}, + {"PA-1274", "12 Januar, 2022", 90}, + {"PA-4323", "14 April 2023", 187}, + {"US-1200", "14 Dezember, 2022", 350}, + {"PTY-507", "4 Juni, 2023", 110} + }), + #"Filtered rows" = Table.TransformColumns( + Source, + {"Posted Date", each Date.From(_, "de-DE"), type date} + ) +in + #"Filtered rows" +``` + +**Output** + +```powerquery-m +#table(type table [Account Code = text, Posted Date = date, Sales = number], +{ + {"US-2004", #date(2023, 1, 20), 580}, + {"CA-8843", #date(2023, 7, 18), 280}, + {"PA-1274", #date(2022, 1, 12), 90}, + {"PA-4323", #date(2023, 4, 14), 187}, + {"US-1200", #date(2022, 12, 14), 350}, + {"PTY-507", #date(2023, 6, 4), 110} +}) +``` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/date-fromtext.md b/query-languages/m/date-fromtext.md index e6a13a818..0792ac19f 100644 --- a/query-languages/m/date-fromtext.md +++ b/query-languages/m/date-fromtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.FromText" -title: "Date.FromText | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.FromText" +ms.subservice: m-source --- # Date.FromText @@ -20,13 +13,16 @@ Date.FromText(text as nullable text, optional options as any) as n ## About -Creates a `date` value from a textual representation, `text`. An optional `record` parameter, `options`, may be provided to specify additional properties. The `record` can contain the following fields: +Creates a date value from a textual representation. + +* `text`: A text value to covert to a date. -* `Format`: A `text` value indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providing `null` will result in parsing the date using a best effort. +* `options`: An optional `record` that can be provided to specify additional properties. The `record` can contain the following fields: -* `Culture`: When `Format` is not null, `Culture` controls some format specifiers. For example, in `"en-US"` `"MMM"` is `"Jan", "Feb", "Mar", ...`, while in `"ru-RU"` `"MMM"` is `"янв", "фев", "мар", ...`. When `Format` is `null`, `Culture` controls the default format to use. When `Culture` is `null` or omitted, [Culture.Current](culture-current.md) is used. + * `Format`: A `text` value indicating the format to use. For more details, go to [Standard date and time format strings](standard-date-and-time-format-strings.md) and [Custom date and time format strings](custom-date-and-time-format-strings.md). Omitting this field or providing `null` results in parsing the date using a best effort. + * `Culture`: When `Format` isn't null, `Culture` controls some format specifiers. For example, in `"en-US"` `"MMM"` is `"Jan", "Feb", "Mar", ...`, while in `"ru-RU"` `"MMM"` is `"янв", "фев", "мар", ...`. When `Format` is `null`, `Culture` controls the default format to use. When `Culture` is `null` or omitted, [Culture.Current](culture-current.md) is used. -To support legacy workflows, `options` may also be a text value. This has the same behavior as if `options = [Format = null, Culture = options]`. +To support legacy workflows, `options` can also be a text value. This has the same behavior as if `options = [Format = null, Culture = options]`. ## Example 1 @@ -69,3 +65,48 @@ Date.FromText("1400", [Format="yyyy", Culture="ar-SA"]) **Output** `#date(1979, 11, 20)` + +## Example 4 + +Convert the Italian text dates with abbreviated months in the Posted Date column to date values. + +**Usage** + +```powerquery-m +let + Source = #table(type table [Account Code = text, Posted Date = text, Sales = number], + { + {"US-2004", "20 gen. 2023", 580}, + {"CA-8843", "18 lug. 2024", 280}, + {"PA-1274", "12 gen. 2023", 90}, + {"PA-4323", "14 apr. 2023", 187}, + {"US-1200", "14 dic. 2023", 350}, + {"PTY-507", "4 giu. 2024", 110} + }), + #"Converted Date" = Table.TransformColumns( + Source, + {"Posted Date", each Date.FromText(_, [Culture = "it-IT"]), type date} + ) +in + #"Converted Date" +``` + +**Output** + +```powerquery-m +#table(type table [Account Code = text, Posted Date = date, Sales = number], +{ + {"US-2004", #date(2023, 1, 20), 580}, + {"CA-8843", #date(2024, 7, 18), 280}, + {"PA-1274", #date(2023, 1, 12), 90}, + {"PA-4323", #date(2023, 4, 14), 187}, + {"US-1200", #date(2023, 12, 14), 350}, + {"PTY-507", #date(2024, 6, 4), 110} +}) +``` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/date-functions.md b/query-languages/m/date-functions.md index e45671b28..3d28b8935 100644 --- a/query-languages/m/date-functions.md +++ b/query-languages/m/date-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Date functions" -title: "Date functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date functions" +ms.date: 5/28/2025 +ms.custom: "nonautomated-date" --- # Date functions @@ -16,21 +10,21 @@ These functions create and manipulate the date component of date, datetime, and |Name|Description| |------------|---------------| -|[Date.AddDays](date-adddays.md)|Returns a Date/DateTime/DateTimeZone value with the day portion incremented by the number of days provided. It also handles incrementing the month and year potions of the value as appropriate.| +|[Date.AddDays](date-adddays.md)|Returns a Date/DateTime/DateTimeZone value with the day portion incremented by the number of days provided. It also handles incrementing the month and year portions of the value as appropriate.| |[Date.AddMonths](date-addmonths.md)|Returns a DateTime value with the month portion incremented by n months.| -|[Date.AddQuarters](date-addquarters.md)|Returns a Date/DateTime/DateTimeZone value incremented by the number of quarters provided. Each quarter is defined as a duration of three months. It also handles incrementing the year potion of the value as appropriate.| -|[Date.AddWeeks](date-addweeks.md)|Returns a Date/DateTime/DateTimeZone value incremented by the number of weeks provided. Each week is defined as a duration of seven days. It also handles incrementing the month and year potions of the value as appropriate.| +|[Date.AddQuarters](date-addquarters.md)|Returns a Date/DateTime/DateTimeZone value incremented by the number of quarters provided. Each quarter is defined as a duration of three months. It also handles incrementing the year portion of the value as appropriate.| +|[Date.AddWeeks](date-addweeks.md)|Returns a Date/DateTime/DateTimeZone value incremented by the number of weeks provided. Each week is defined as a duration of seven days. It also handles incrementing the month and year portions of the value as appropriate.| |[Date.AddYears](date-addyears.md)|Returns a DateTime value with the year portion incremented by n years.| |[Date.Day](date-day.md)|Returns the day for a DateTime value.| |[Date.DayOfWeek](date-dayofweek.md)|Returns a number (from 0 to 6) indicating the day of the week of the provided value.| |[Date.DayOfWeekName](date-dayofweekname.md)|Returns the day of the week name.| |[Date.DayOfYear](date-dayofyear.md)|Returns a number that represents the day of the year from a DateTime value.| |[Date.DaysInMonth](date-daysinmonth.md)|Returns the number of days in the month from a DateTime value.| -|[Date.EndOfDay](date-endofday.md)|Returns a DateTime value for the end of the day.| -|[Date.EndOfMonth](date-endofmonth.md)|Returns a DateTime value for the end of the month.| -|[Date.EndOfQuarter](date-endofquarter.md)|Returns a Date/DateTime/DateTimeZone value representing the end of the quarter. The date and time portions are reset to their terminating values for the quarter. The timezone information is persisted.| -|[Date.EndOfWeek](date-endofweek.md)|Returns a DateTime value for the end of the week.| -|[Date.EndOfYear](date-endofyear.md)|Returns a DateTime value for the end of the year.| +|[Date.EndOfDay](date-endofday.md)|Returns the end of the day.| +|[Date.EndOfMonth](date-endofmonth.md)|Returns the end of the month.| +|[Date.EndOfQuarter](date-endofquarter.md)|Returns the end of the quarter.| +|[Date.EndOfWeek](date-endofweek.md)|Returns the end of the week.| +|[Date.EndOfYear](date-endofyear.md)|Returns the end of the year.| |[Date.From](date-from.md)|Returns a date value from a value.| |[Date.FromText](date-fromtext.md)|Creates a Date from local, universal, and custom Date formats.| |[Date.IsInCurrentDay](date-isincurrentday.md)|Indicates whether the given datetime value `dateTime` occurs during the current day, as determined by the current date and time on the system.| @@ -63,11 +57,11 @@ These functions create and manipulate the date component of date, datetime, and |[Date.Month](date-month.md)|Returns the month from a DateTime value.| |[Date.MonthName](date-monthname.md)|Returns the name of the month component.| |[Date.QuarterOfYear](date-quarterofyear.md)|Returns a number between 1 and 4 for the quarter of the year from a DateTime value.| -|[Date.StartOfDay](date-startofday.md)|Returns a DateTime value for the start of the day.| -|[Date.StartOfMonth](date-startofmonth.md)|Returns a DateTime value representing the start of the month.| -|[Date.StartOfQuarter](date-startofquarter.md)|Returns a DateTime value representing the start of the quarter.| -|[Date.StartOfWeek](date-startofweek.md)|Returns a DateTime value representing the start of the week.| -|[Date.StartOfYear](date-startofyear.md)|Returns a DateTime value representing the start of the year.| +|[Date.StartOfDay](date-startofday.md)|Returns the start of the day.| +|[Date.StartOfMonth](date-startofmonth.md)|Returns the start of the month.| +|[Date.StartOfQuarter](date-startofquarter.md)|Returns the start of the quarter.| +|[Date.StartOfWeek](date-startofweek.md)|Returns the start of the week.| +|[Date.StartOfYear](date-startofyear.md)|Returns the start of the year.| |[Date.ToRecord](date-torecord.md)|Returns a record containing parts of a Date value.| |[Date.ToText](date-totext.md)|Returns a text value from a Date value.| |[Date.WeekOfMonth](date-weekofmonth.md)|Returns a number for the count of week in the current month.| diff --git a/query-languages/m/date-isincurrentday.md b/query-languages/m/date-isincurrentday.md index 13a2c9b19..95f7ef8bc 100644 --- a/query-languages/m/date-isincurrentday.md +++ b/query-languages/m/date-isincurrentday.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInCurrentDay" -title: "Date.IsInCurrentDay | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInCurrentDay" +ms.subservice: m-source --- # Date.IsInCurrentDay diff --git a/query-languages/m/date-isincurrentmonth.md b/query-languages/m/date-isincurrentmonth.md index cd36d0922..617c6121d 100644 --- a/query-languages/m/date-isincurrentmonth.md +++ b/query-languages/m/date-isincurrentmonth.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInCurrentMonth" -title: "Date.IsInCurrentMonth | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInCurrentMonth" +ms.subservice: m-source --- # Date.IsInCurrentMonth diff --git a/query-languages/m/date-isincurrentquarter.md b/query-languages/m/date-isincurrentquarter.md index 3e00bb603..cb9a5bacd 100644 --- a/query-languages/m/date-isincurrentquarter.md +++ b/query-languages/m/date-isincurrentquarter.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInCurrentQuarter" -title: "Date.IsInCurrentQuarter | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInCurrentQuarter" +ms.subservice: m-source --- # Date.IsInCurrentQuarter diff --git a/query-languages/m/date-isincurrentweek.md b/query-languages/m/date-isincurrentweek.md index cc6a199b3..acbe5bdf9 100644 --- a/query-languages/m/date-isincurrentweek.md +++ b/query-languages/m/date-isincurrentweek.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInCurrentWeek" -title: "Date.IsInCurrentWeek | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInCurrentWeek" +ms.subservice: m-source --- # Date.IsInCurrentWeek diff --git a/query-languages/m/date-isincurrentyear.md b/query-languages/m/date-isincurrentyear.md index 2616523c8..39b3cf6ce 100644 --- a/query-languages/m/date-isincurrentyear.md +++ b/query-languages/m/date-isincurrentyear.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInCurrentYear" -title: "Date.IsInCurrentYear | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInCurrentYear" +ms.subservice: m-source --- # Date.IsInCurrentYear diff --git a/query-languages/m/date-isinnextday.md b/query-languages/m/date-isinnextday.md index 92aacfc81..eba978a34 100644 --- a/query-languages/m/date-isinnextday.md +++ b/query-languages/m/date-isinnextday.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextDay" -title: "Date.IsInNextDay | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextDay" +ms.subservice: m-source --- # Date.IsInNextDay diff --git a/query-languages/m/date-isinnextmonth.md b/query-languages/m/date-isinnextmonth.md index d1673ef42..d2bba61dc 100644 --- a/query-languages/m/date-isinnextmonth.md +++ b/query-languages/m/date-isinnextmonth.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextMonth" -title: "Date.IsInNextMonth | Microsoft Docs" -ms.date: 3/22/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextMonth" +ms.subservice: m-source --- # Date.IsInNextMonth diff --git a/query-languages/m/date-isinnextndays.md b/query-languages/m/date-isinnextndays.md index 91ff98ee8..eb945eb38 100644 --- a/query-languages/m/date-isinnextndays.md +++ b/query-languages/m/date-isinnextndays.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextNDays" -title: "Date.IsInNextNDays | Microsoft Docs" -ms.date: 3/22/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextNDays" +ms.subservice: m-source --- # Date.IsInNextNDays diff --git a/query-languages/m/date-isinnextnmonths.md b/query-languages/m/date-isinnextnmonths.md index b265185fb..07815583a 100644 --- a/query-languages/m/date-isinnextnmonths.md +++ b/query-languages/m/date-isinnextnmonths.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextNMonths" -title: "Date.IsInNextNMonths | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextNMonths" +ms.subservice: m-source --- # Date.IsInNextNMonths diff --git a/query-languages/m/date-isinnextnquarters.md b/query-languages/m/date-isinnextnquarters.md index 81bab5669..0a3f6bd93 100644 --- a/query-languages/m/date-isinnextnquarters.md +++ b/query-languages/m/date-isinnextnquarters.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextNQuarters" -title: "Date.IsInNextNQuarters | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextNQuarters" +ms.subservice: m-source --- # Date.IsInNextNQuarters diff --git a/query-languages/m/date-isinnextnweeks.md b/query-languages/m/date-isinnextnweeks.md index 3a6e34909..6b9262863 100644 --- a/query-languages/m/date-isinnextnweeks.md +++ b/query-languages/m/date-isinnextnweeks.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextNWeeks" -title: "Date.IsInNextNWeeks | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextNWeeks" +ms.subservice: m-source --- # Date.IsInNextNWeeks diff --git a/query-languages/m/date-isinnextnyears.md b/query-languages/m/date-isinnextnyears.md index ca823c264..ccad94129 100644 --- a/query-languages/m/date-isinnextnyears.md +++ b/query-languages/m/date-isinnextnyears.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextNYears" -title: "Date.IsInNextNYears | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextNYears" +ms.subservice: m-source --- # Date.IsInNextNYears diff --git a/query-languages/m/date-isinnextquarter.md b/query-languages/m/date-isinnextquarter.md index 7f88eca69..e41498ee6 100644 --- a/query-languages/m/date-isinnextquarter.md +++ b/query-languages/m/date-isinnextquarter.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextQuarter" -title: "Date.IsInNextQuarter | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextQuarter" +ms.subservice: m-source --- # Date.IsInNextQuarter diff --git a/query-languages/m/date-isinnextweek.md b/query-languages/m/date-isinnextweek.md index 061844d30..b169b6fea 100644 --- a/query-languages/m/date-isinnextweek.md +++ b/query-languages/m/date-isinnextweek.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextWeek" -title: "Date.IsInNextWeek | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextWeek" +ms.subservice: m-source --- # Date.IsInNextWeek diff --git a/query-languages/m/date-isinnextyear.md b/query-languages/m/date-isinnextyear.md index 2422c3455..41da43f89 100644 --- a/query-languages/m/date-isinnextyear.md +++ b/query-languages/m/date-isinnextyear.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInNextYear" -title: "Date.IsInNextYear | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInNextYear" +ms.subservice: m-source --- # Date.IsInNextYear @@ -17,8 +10,8 @@ ms.author: dougklo
 Date.IsInNextYear(dateTime as any) as nullable logical
 
- -## About + +## About Indicates whether the given datetime value `dateTime` occurs during the next year, as determined by the current date and time on the system. Note that this function will return false when passed a value that occurs within the current year. diff --git a/query-languages/m/date-isinpreviousday.md b/query-languages/m/date-isinpreviousday.md index 64c1d6a13..8edd1d117 100644 --- a/query-languages/m/date-isinpreviousday.md +++ b/query-languages/m/date-isinpreviousday.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousDay" -title: "Date.IsInPreviousDay | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousDay" +ms.subservice: m-source --- # Date.IsInPreviousDay diff --git a/query-languages/m/date-isinpreviousmonth.md b/query-languages/m/date-isinpreviousmonth.md index b1407f58a..f59ccaf0b 100644 --- a/query-languages/m/date-isinpreviousmonth.md +++ b/query-languages/m/date-isinpreviousmonth.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousMonth" -title: "Date.IsInPreviousMonth | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousMonth" +ms.subservice: m-source --- # Date.IsInPreviousMonth diff --git a/query-languages/m/date-isinpreviousndays.md b/query-languages/m/date-isinpreviousndays.md index ffee3e93c..b747db68d 100644 --- a/query-languages/m/date-isinpreviousndays.md +++ b/query-languages/m/date-isinpreviousndays.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousNDays" -title: "Date.IsInPreviousNDays | Microsoft Docs" -ms.date: 3/22/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousNDays" +ms.subservice: m-source --- # Date.IsInPreviousNDays diff --git a/query-languages/m/date-isinpreviousnmonths.md b/query-languages/m/date-isinpreviousnmonths.md index 27d3228cf..544814e54 100644 --- a/query-languages/m/date-isinpreviousnmonths.md +++ b/query-languages/m/date-isinpreviousnmonths.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousNMonths" -title: "Date.IsInPreviousNMonths | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousNMonths" +ms.subservice: m-source --- # Date.IsInPreviousNMonths diff --git a/query-languages/m/date-isinpreviousnquarters.md b/query-languages/m/date-isinpreviousnquarters.md index 8697b8396..3ddcc1554 100644 --- a/query-languages/m/date-isinpreviousnquarters.md +++ b/query-languages/m/date-isinpreviousnquarters.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousNQuarters" -title: "Date.IsInPreviousNQuarters | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousNQuarters" +ms.subservice: m-source --- # Date.IsInPreviousNQuarters diff --git a/query-languages/m/date-isinpreviousnweeks.md b/query-languages/m/date-isinpreviousnweeks.md index ae6837a4c..115e5fb60 100644 --- a/query-languages/m/date-isinpreviousnweeks.md +++ b/query-languages/m/date-isinpreviousnweeks.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousNWeeks" -title: "Date.IsInPreviousNWeeks | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousNWeeks" +ms.subservice: m-source --- # Date.IsInPreviousNWeeks diff --git a/query-languages/m/date-isinpreviousnyears.md b/query-languages/m/date-isinpreviousnyears.md index ca103d33e..3fd14faa0 100644 --- a/query-languages/m/date-isinpreviousnyears.md +++ b/query-languages/m/date-isinpreviousnyears.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousNYears" -title: "Date.IsInPreviousNYears | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousNYears" +ms.subservice: m-source --- # Date.IsInPreviousNYears diff --git a/query-languages/m/date-isinpreviousquarter.md b/query-languages/m/date-isinpreviousquarter.md index c0d533632..0fc2d2cef 100644 --- a/query-languages/m/date-isinpreviousquarter.md +++ b/query-languages/m/date-isinpreviousquarter.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousQuarter" -title: "Date.IsInPreviousQuarter | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousQuarter" +ms.subservice: m-source --- # Date.IsInPreviousQuarter diff --git a/query-languages/m/date-isinpreviousweek.md b/query-languages/m/date-isinpreviousweek.md index 852ad0266..55d595699 100644 --- a/query-languages/m/date-isinpreviousweek.md +++ b/query-languages/m/date-isinpreviousweek.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousWeek" -title: "Date.IsInPreviousWeek | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousWeek" +ms.subservice: m-source --- # Date.IsInPreviousWeek diff --git a/query-languages/m/date-isinpreviousyear.md b/query-languages/m/date-isinpreviousyear.md index b766e7c06..51c9954f6 100644 --- a/query-languages/m/date-isinpreviousyear.md +++ b/query-languages/m/date-isinpreviousyear.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInPreviousYear" -title: "Date.IsInPreviousYear | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInPreviousYear" +ms.subservice: m-source --- # Date.IsInPreviousYear diff --git a/query-languages/m/date-isinyeartodate.md b/query-languages/m/date-isinyeartodate.md index 860f772b1..fa28b179f 100644 --- a/query-languages/m/date-isinyeartodate.md +++ b/query-languages/m/date-isinyeartodate.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsInYearToDate" -title: "Date.IsInYearToDate | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsInYearToDate" +ms.subservice: m-source --- # Date.IsInYearToDate diff --git a/query-languages/m/date-isleapyear.md b/query-languages/m/date-isleapyear.md index 843db6cfb..8a23c650a 100644 --- a/query-languages/m/date-isleapyear.md +++ b/query-languages/m/date-isleapyear.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.IsLeapYear" -title: "Date.IsLeapYear | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.IsLeapYear" +ms.subservice: m-source --- # Date.IsLeapYear diff --git a/query-languages/m/date-month.md b/query-languages/m/date-month.md index d081db74a..a477f9217 100644 --- a/query-languages/m/date-month.md +++ b/query-languages/m/date-month.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.Month" -title: "Date.Month | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.Month" +ms.subservice: m-source --- # Date.Month diff --git a/query-languages/m/date-monthname.md b/query-languages/m/date-monthname.md index 468ff7959..823269dd3 100644 --- a/query-languages/m/date-monthname.md +++ b/query-languages/m/date-monthname.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.MonthName" -title: "Date.MonthName | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.MonthName" +ms.subservice: m-source --- # Date.MonthName @@ -35,3 +28,7 @@ Date.MonthName(#datetime(2011, 12, 31, 5, 0, 0), "en-US") **Output** `"December"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/date-quarterofyear.md b/query-languages/m/date-quarterofyear.md index f2615aabc..9a38ea6a5 100644 --- a/query-languages/m/date-quarterofyear.md +++ b/query-languages/m/date-quarterofyear.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.QuarterOfYear" -title: "Date.QuarterOfYear | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.QuarterOfYear" +ms.subservice: m-source --- # Date.QuarterOfYear diff --git a/query-languages/m/date-startofday.md b/query-languages/m/date-startofday.md index 911a21eed..eabf40d6a 100644 --- a/query-languages/m/date-startofday.md +++ b/query-languages/m/date-startofday.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.StartOfDay" -title: "Date.StartOfDay | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.StartOfDay" +ms.subservice: m-source --- # Date.StartOfDay @@ -20,11 +13,11 @@ Date.StartOfDay(dateTime as any) as any ## About -Returns the first value of the day `dateTime`. `dateTime` must be a `date`, `datetime`, or `datetimezone` value. +Returns the start of the day represented by `dateTime`. `dateTime` must be a `date`, `datetime`, or `datetimezone` value. ## Example 1 -Find the start of the day for October 10th, 2011, 8:00AM (`#datetime(2011, 10, 10, 8, 0, 0)`). +Find the start of the day for October 10th, 2011, 8:00AM. **Usage** diff --git a/query-languages/m/date-startofmonth.md b/query-languages/m/date-startofmonth.md index d2986f940..7ae7c01c6 100644 --- a/query-languages/m/date-startofmonth.md +++ b/query-languages/m/date-startofmonth.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.StartOfMonth" -title: "Date.StartOfMonth | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.StartOfMonth" +ms.subservice: m-source --- # Date.StartOfMonth @@ -20,11 +13,11 @@ Date.StartOfMonth(dateTime as any) as any ## About -Returns the first value of the month given a `date` or `datetime` type. +Returns the start of the month that contains `dateTime`. `dateTime` must be a `date` or `datetime` value. ## Example 1 -Find the start of the month for October 10th, 2011, 8:10:32AM (`#datetime(2011, 10, 10, 8, 10, 32)`). +Find the start of the month for October 10th, 2011, 8:10:32AM. **Usage** diff --git a/query-languages/m/date-startofquarter.md b/query-languages/m/date-startofquarter.md index e290a6f65..f44804274 100644 --- a/query-languages/m/date-startofquarter.md +++ b/query-languages/m/date-startofquarter.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.StartOfQuarter" -title: "Date.StartOfQuarter | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.StartOfQuarter" +ms.subservice: m-source --- # Date.StartOfQuarter @@ -20,11 +13,11 @@ Date.StartOfQuarter(dateTime as any) as any ## About -Returns the first value of the quarter <`dateTime`. `dateTime` must be a `date`, `datetime`, or `datetimezone` value. +Returns the start of the quarter that contains `dateTime`. `dateTime` must be a `date`, `datetime`, or `datetimezone` value. ## Example 1 -Find the start of the quarter for October 10th, 2011, 8:00AM (`#datetime(2011, 10, 10, 8, 0, 0)`). +Find the start of the quarter for October 10th, 2011, 8:00AM. **Usage** diff --git a/query-languages/m/date-startofweek.md b/query-languages/m/date-startofweek.md index 522a924e3..643c324a8 100644 --- a/query-languages/m/date-startofweek.md +++ b/query-languages/m/date-startofweek.md @@ -1,37 +1,50 @@ --- description: "Learn more about: Date.StartOfWeek" -title: "Date.StartOfWeek | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.StartOfWeek" +ms.subservice: m-source --- # Date.StartOfWeek ## Syntax
-Date.StartOfWeek(dateTime as any, optional firstDayOfWeek as nullable number) as any 
+Date.StartOfWeek(dateTime as any, optional firstDayOfWeek as nullable number) as any
 
## About -Returns the first value of the week given a `date`, `datetime`, or `datetimezone` value. +Returns the start of the week that contains `dateTime`. `dateTime` must be a `date`, `datetime`, or `datetimezone` value. ## Example 1 -Find the start of the week for October 10th, 2011, 8:10:32AM (`#datetime(2011, 10, 10, 8, 10, 32)`). +Find the start of the week for Tuesday, October 11th, 2011. + +**Usage** + +```powerquery-m +Date.StartOfWeek(#datetime(2011, 10, 11, 8, 10, 32)) +``` + +**Output** + +```powerquery-m +// Sunday, October 9th, 2011 +#datetime(2011, 10, 9, 0, 0, 0) +``` + +## Example 2 + +Find the start of the week for Tuesday, October 11th, 2011, using Monday as the start of the week. **Usage** ```powerquery-m -Date.StartOfWeek(#datetime(2011, 10, 10, 8, 10, 32)) +Date.StartOfWeek(#datetime(2011, 10, 11, 8, 10, 32), Day.Monday) ``` **Output** -`#datetime(2011, 10, 9, 0, 0, 0)` +```powerquery-m +// Monday, October 10th, 2011 +#datetime(2011, 10, 10, 0, 0, 0) +``` diff --git a/query-languages/m/date-startofyear.md b/query-languages/m/date-startofyear.md index b950c2604..36f9d5531 100644 --- a/query-languages/m/date-startofyear.md +++ b/query-languages/m/date-startofyear.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.StartOfYear" -title: "Date.StartOfYear | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.StartOfYear" +ms.subservice: m-source --- # Date.StartOfYear @@ -20,11 +13,11 @@ Date.StartOfYear(dateTime as any) as any ## About -Returns the first value of the year given a `date`, `datetime`, or `datetimezone` value. +Returns the start of the year that contains `dateTime`. `dateTime` must be a `date`, `datetime`, or `datetimezone` value. ## Example 1 -Find the start of the year for October 10th, 2011, 8:10:32AM (`#datetime(2011, 10, 10, 8, 10, 32)`). +Find the start of the year for October 10th, 2011, 8:10:32AM. **Usage** diff --git a/query-languages/m/date-torecord.md b/query-languages/m/date-torecord.md index 61b65be53..cd0f4ee39 100644 --- a/query-languages/m/date-torecord.md +++ b/query-languages/m/date-torecord.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.ToRecord" -title: "Date.ToRecord | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.ToRecord" +ms.subservice: m-source --- # Date.ToRecord @@ -17,7 +10,7 @@ ms.author: dougklo
 Date.ToRecord(date as date) as record
 
- + ## About Returns a record containing the parts of the given date value, `date`. diff --git a/query-languages/m/date-totext.md b/query-languages/m/date-totext.md index a159d0552..f1fa80dba 100644 --- a/query-languages/m/date-totext.md +++ b/query-languages/m/date-totext.md @@ -1,28 +1,25 @@ --- description: "Learn more about: Date.ToText" -title: "Date.ToText | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.ToText" +ms.subservice: m-source --- # Date.ToText ## Syntax
-Date.ToText(date as nullable date, optional options as any, optional culture as nullable text) as nullable text
+Date.ToText(
+    date as nullable date,
+    optional options as any,
+    optional culture as nullable text
+) as nullable text
 
## About Returns a textual representation of `date`. An optional `record` parameter, `options`, may be provided to specify additional properties. `culture` is only used for legacy workflows. The `record` can contain the following fields: -* `Format`:A `text` value indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providing `null` will result in formatting the date using the default defined by `Culture`. +* `Format`: A `text` value indicating the format to use. For more details, go to [Standard date and time format strings](standard-date-and-time-format-strings.md) and [Custom date and time format strings](custom-date-and-time-format-strings.md). Omitting this field or providing `null` will result in formatting the date using the default defined by `Culture`. * `Culture`: When `Format` is not null, `Culture` controls some format specifiers. For example, in `"en-US"` `"MMM"` is `"Jan", "Feb", "Mar", ...`, while in `"ru-RU"` `"MMM"` is `"янв", "фев", "мар", ...`. When `Format` is `null`, `Culture` controls the default format to use. When `Culture` is `null` or omitted, [Culture.Current](culture-current.md) is used. @@ -69,3 +66,9 @@ Date.ToText(#date(2000, 1, 1), [Format="yyyy", Culture="ar-SA"]) **Output** `"1420"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/date-weekofmonth.md b/query-languages/m/date-weekofmonth.md index 0381f59e0..ac0d9d206 100644 --- a/query-languages/m/date-weekofmonth.md +++ b/query-languages/m/date-weekofmonth.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.WeekOfMonth" -title: "Date.WeekOfMonth | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.WeekOfMonth" +ms.subservice: m-source --- # Date.WeekOfMonth @@ -26,7 +19,7 @@ Returns a number from 1 to 6 indicating which week of the month the date `dateTi ## Example 1 -Determine which week of March the 15th falls on in 2011 (`#date(2011, 03, 15)`). +Determine which week of March the 15th falls on in 2011. **Usage** diff --git a/query-languages/m/date-weekofyear.md b/query-languages/m/date-weekofyear.md index 416a39867..01ec9805a 100644 --- a/query-languages/m/date-weekofyear.md +++ b/query-languages/m/date-weekofyear.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.WeekOfYear" -title: "Date.WeekOfYear | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.WeekOfYear" +ms.subservice: m-source --- # Date.WeekOfYear @@ -28,7 +21,7 @@ Returns a number from 1 to 54 indicating which week of the year the date, `dateT ## Example 1 -Determine which week of the year March 27th, 2011 falls in (`#date(2011, 03, 27)`). +Determine which week of the year contains March 27th, 2011. **Usage** @@ -42,7 +35,7 @@ Date.WeekOfYear(#date(2011, 03, 27)) ## Example 2 -Determine which week of the year March 27th, 2011 falls in (`#date(2011, 03, 27)`), using Monday as the start of a new week. +Determine which week of the year contains March 27th, 2011, using Monday as the start of the week. **Usage** @@ -53,3 +46,7 @@ Date.WeekOfYear(#date(2011, 03, 27), Day.Monday) **Output** `13` + +## Related content + +- [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/date-year.md b/query-languages/m/date-year.md index 90286b798..caeccd5a7 100644 --- a/query-languages/m/date-year.md +++ b/query-languages/m/date-year.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Date.Year" -title: "Date.Year | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Date.Year" +ms.subservice: m-source --- # Date.Year diff --git a/query-languages/m/datetime-addzone.md b/query-languages/m/datetime-addzone.md index 90fb1a90e..688f4c91c 100644 --- a/query-languages/m/datetime-addzone.md +++ b/query-languages/m/datetime-addzone.md @@ -1,30 +1,27 @@ --- description: "Learn more about: DateTime.AddZone" -title: "DateTime.AddZone | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.AddZone" +ms.subservice: m-source --- # DateTime.AddZone ## Syntax
-DateTime.AddZone(dateTime as nullable datetime, timezoneHours as number, optional timezoneMinutes as nullable number) as nullable datetimezone
+DateTime.AddZone(
+    dateTime as nullable datetime,
+    timezoneHours as number,
+    optional timezoneMinutes as nullable number
+) as nullable datetimezone
 
## About -Sets timezone information to on the datetime value `dateTime`. The timezone information will include `timezoneHours` and optionally `timezoneMinutes`. +Adds timezone information to the `dateTime` value. The timezone information includes `timezoneHours` and optionally `timezoneMinutes`, which specify the desired offset from UTC time. ## Example 1 -Set timezone information for #datetime(2010, 12, 31, 11, 56, 02) to 7 hours, 30 minutes. +Set the timezone to UTC+7:30 (7 hours and 30 minutes past UTC). **Usage** diff --git a/query-languages/m/datetime-date.md b/query-languages/m/datetime-date.md index c03ed6de2..c77fb0a33 100644 --- a/query-languages/m/datetime-date.md +++ b/query-languages/m/datetime-date.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.Date" -title: "DateTime.Date | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.Date" +ms.subservice: m-source --- # DateTime.Date @@ -20,7 +13,7 @@ DateTime.Date(dateTime as any) as nullable date ## About -Returns the date component of `dateTime`, the given `date`, `datetime`, or `datetimezone` value. +Returns the date component of the `dateTime` parameter if the parameter is a `date`, `datetime`, or `datetimezone` value, or `null` if the parameter is `null`. ## Example 1 diff --git a/query-languages/m/datetime-fixedlocalnow.md b/query-languages/m/datetime-fixedlocalnow.md index 268c76489..128a6a0b6 100644 --- a/query-languages/m/datetime-fixedlocalnow.md +++ b/query-languages/m/datetime-fixedlocalnow.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.FixedLocalNow" -title: "DateTime.FixedLocalNow | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.FixedLocalNow" +ms.subservice: m-source --- # DateTime.FixedLocalNow @@ -18,6 +11,10 @@ ms.author: dougklo DateTime.FixedLocalNow() as datetime -## About -Returns a `datetime` value set to the current date and time on the system. This value is fixed and will not change with successive calls, unlike DateTime.LocalNow, which may return different values over the course of execution of an expression. +## About + +Returns a `datetime` value set to the current date and time on the system. This value is fixed and will not change with successive calls, unlike [DateTime.LocalNow](datetime-localnow.md), which may return different values over the course of execution of an expression. + +## Related content +[Local, fixed, and UTC variants of current time functions](m-local-fixed-utc-variants.md) diff --git a/query-languages/m/datetime-from.md b/query-languages/m/datetime-from.md index fd82f1c10..27792df7a 100644 --- a/query-languages/m/datetime-from.md +++ b/query-languages/m/datetime-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.From" -title: "DateTime.From | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.From" +ms.subservice: m-source --- # DateTime.From @@ -57,3 +50,9 @@ DateTime.From(#date(1975, 4, 4)) **Output** `#datetime(1975, 4, 4, 0, 0, 0)` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/datetime-fromfiletime.md b/query-languages/m/datetime-fromfiletime.md index d6b36171f..31ec36964 100644 --- a/query-languages/m/datetime-fromfiletime.md +++ b/query-languages/m/datetime-fromfiletime.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.FromFileTime" -title: "DateTime.FromFileTime | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.FromFileTime" +ms.subservice: m-source --- # DateTime.FromFileTime diff --git a/query-languages/m/datetime-fromtext.md b/query-languages/m/datetime-fromtext.md index 1d94e6c60..f4492e4c8 100644 --- a/query-languages/m/datetime-fromtext.md +++ b/query-languages/m/datetime-fromtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.FromText" -title: "DateTime.FromText | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.FromText" +ms.subservice: m-source --- # DateTime.FromText @@ -22,7 +15,7 @@ DateTime.FromText(text as nullable text, optional options as any) Creates a `datetime` value from a textual representation, `text`. An optional `record` parameter, `options`, may be provided to specify additional properties. The `record` can contain the following fields: -* `Format`: A `text` value indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providing `null` will result in parsing the date using a best effort. +* `Format`: A `text` value indicating the format to use. For more details, go to [Standard date and time format strings](standard-date-and-time-format-strings.md) and [Custom date and time format strings](custom-date-and-time-format-strings.md). Omitting this field or providing `null` will result in parsing the date using a best effort. * `Culture`: When `Format` is not null, `Culture` controls some format specifiers. For example, in `"en-US"` `"MMM"` is `"Jan", "Feb", "Mar", ...`, while in `"ru-RU"` `"MMM"` is `"янв", "фев", "мар", ...`. When `Format` is `null`, `Culture` controls the default format to use. When `Culture` is `null` or omitted, [Culture.Current](culture-current.md) is used. @@ -83,3 +76,9 @@ DateTime.FromText("20101231T013000", [Format="yyyyMMdd'T'HHmmss", Culture="en-US **Output** `#datetime(2010, 12, 31, 1, 30, 0)` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/datetime-functions.md b/query-languages/m/datetime-functions.md index e96c540c8..a242ee15e 100644 --- a/query-languages/m/datetime-functions.md +++ b/query-languages/m/datetime-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: DateTime functions" -title: "DateTime functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime functions" +ms.date: 11/21/2024 +ms.custom: "nonautomated-date" --- # DateTime functions @@ -16,29 +10,29 @@ These functions create and manipulate datetime and datetimezone values. |Name|Description| |------------|---------------| -|[DateTime.AddZone](datetime-addzone.md)|Adds the timezonehours as an offset to the input datetime value and returns a new datetimezone value.| -|[DateTime.Date](datetime-date.md)|Returns a date part from a DateTime value| -|[DateTime.FixedLocalNow](datetime-fixedlocalnow.md)|Returns a DateTime value set to the current date and time on the system.| -|[DateTime.From](datetime-from.md)|Returns a datetime value from a value.| -|[DateTime.FromFileTime](datetime-fromfiletime.md)|Returns a DateTime value from the supplied number.| +|[DateTime.AddZone](datetime-addzone.md)|Adds timezone information to the datetime value.| +|[DateTime.Date](datetime-date.md)|Returns the date component of the given date, datetime, or datetimezone value.| +|[DateTime.FixedLocalNow](datetime-fixedlocalnow.md)|Returns the current date and time in the local timezone. This value is fixed and doesn't change with successive calls.| +|[DateTime.From](datetime-from.md)|Creates a datetime from the given value.| +|[DateTime.FromFileTime](datetime-fromfiletime.md)|Creates a datetime from a 64-bit long number.| |[DateTime.FromText](datetime-fromtext.md)|Creates a datetime from local and universal datetime formats.| -|[DateTime.IsInCurrentHour](datetime-isincurrenthour.md)|Indicates whether the given datetime value occurs during the current hour, as determined by the current date and time on the system.| -|[DateTime.IsInCurrentMinute](datetime-isincurrentminute.md)|Indicates whether the given datetime value occurs during the current minute, as determined by the current date and time on the system.| -|[DateTime.IsInCurrentSecond](datetime-isincurrentsecond.md)|Indicates whether the given datetime value occurs during the current second, as determined by the current date and time on the system.| -|[DateTime.IsInNextHour](datetime-isinnexthour.md)|Indicates whether the given datetime value occurs during the next hour, as determined by the current date and time on the system.| -|[DateTime.IsInNextMinute](datetime-isinnextminute.md)|Indicates whether the given datetime value occurs during the next minute, as determined by the current date and time on the system.| -|[DateTime.IsInNextNHours](datetime-isinnextnhours.md)|Indicates whether the given datetime value occurs during the next number of hours, as determined by the current date and time on the system.| -|[DateTime.IsInNextNMinutes](datetime-isinnextnminutes.md)|Indicates whether the given datetime value occurs during the next number of minutes, as determined by the current date and time on the system.| -|[DateTime.IsInNextNSeconds](datetime-isinnextnseconds.md)|Indicates whether the given datetime value occurs during the next number of seconds, as determined by the current date and time on the system.| -|[DateTime.IsInNextSecond](datetime-isinnextsecond.md)|Indicates whether the given datetime value occurs during the next second, as determined by the current date and time on the system.| -|[DateTime.IsInPreviousHour](datetime-isinprevioushour.md)|Indicates whether the given datetime value occurs during the previous hour, as determined by the current date and time on the system.| -|[DateTime.IsInPreviousMinute](datetime-isinpreviousminute.md)|Indicates whether the given datetime value occurs during the previous minute, as determined by the current date and time on the system.| -|[DateTime.IsInPreviousNHours](datetime-isinpreviousnhours.md)|Indicates whether the given datetime value occurs during the previous number of hours, as determined by the current date and time on the system.| -|[DateTime.IsInPreviousNMinutes](datetime-isinpreviousnminutes.md)|Indicates whether the given datetime value occurs during the previous number of minutes, as determined by the current date and time on the system.| -|[DateTime.IsInPreviousNSeconds](datetime-isinpreviousnseconds.md)|Indicates whether the given datetime value occurs during the previous number of seconds, as determined by the current date and time on the system.| -|[DateTime.IsInPreviousSecond](datetime-isinprevioussecond.md)|Indicates whether the given datetime value occurs during the previous second, as determined by the current date and time on the system.| -|[DateTime.LocalNow](datetime-localnow.md)|Returns a datetime value set to the current date and time on the system.| -|[DateTime.Time](datetime-time.md)|Returns a time part from a DateTime value.| -|[DateTime.ToRecord](datetime-torecord.md)|Returns a record containing parts of a DateTime value.| -|[DateTime.ToText](datetime-totext.md)|Returns a text value from a DateTime value.| +|[DateTime.IsInCurrentHour](datetime-isincurrenthour.md)|Indicates whether this datetime occurs during the current hour, as determined by the current date and time on the system.| +|[DateTime.IsInCurrentMinute](datetime-isincurrentminute.md)|Indicates whether this datetime occurs during the current minute, as determined by the current date and time on the system.| +|[DateTime.IsInCurrentSecond](datetime-isincurrentsecond.md)|Indicates whether this datetime occurs during the current second, as determined by the current date and time on the system.| +|[DateTime.IsInNextHour](datetime-isinnexthour.md)|Indicates whether this datetime occurs during the next hour, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current hour.| +|[DateTime.IsInNextMinute](datetime-isinnextminute.md)|Indicates whether this datetime occurs during the next minute, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current minute.| +|[DateTime.IsInNextNHours](datetime-isinnextnhours.md)|Indicates whether this datetime occurs during the next number of hours, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current hour.| +|[DateTime.IsInNextNMinutes](datetime-isinnextnminutes.md)|Indicates whether this datetime occurs during the next number of minutes, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current minute.| +|[DateTime.IsInNextNSeconds](datetime-isinnextnseconds.md)|Indicates whether this datetime occurs during the next number of seconds, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current second.| +|[DateTime.IsInNextSecond](datetime-isinnextsecond.md)|Indicates whether this datetime occurs during the next second, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current second.| +|[DateTime.IsInPreviousHour](datetime-isinprevioushour.md)|Indicates whether this datetime occurs during the previous hour, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current hour.| +|[DateTime.IsInPreviousMinute](datetime-isinpreviousminute.md)|Indicates whether this datetime occurs during the previous minute, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current minute.| +|[DateTime.IsInPreviousNHours](datetime-isinpreviousnhours.md)|Indicates whether this datetime occurs during the previous number of hours, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current hour.| +|[DateTime.IsInPreviousNMinutes](datetime-isinpreviousnminutes.md)|Indicates whether this datetime occurs during the previous number of minutes, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current minute.| +|[DateTime.IsInPreviousNSeconds](datetime-isinpreviousnseconds.md)|Indicates whether this datetime occurs during the previous number of seconds, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current second.| +|[DateTime.IsInPreviousSecond](datetime-isinprevioussecond.md)|Indicates whether this datetime occurs during the previous second, as determined by the current date and time on the system. This function returns `false` when passed a value that occurs within the current second.| +|[DateTime.LocalNow](datetime-localnow.md)|Returns the current date and time in the local timezone.| +|[DateTime.Time](datetime-time.md)|Returns the time part of the given datetime value.| +|[DateTime.ToRecord](datetime-torecord.md)|Returns a record containing the datetime value's parts.| +|[DateTime.ToText](datetime-totext.md)|Returns a textual representation of the datetime value.| |[#datetime](sharpdatetime.md)|Creates a datetime value from year, month, day, hour, minute, and second.| diff --git a/query-languages/m/datetime-isincurrenthour.md b/query-languages/m/datetime-isincurrenthour.md index 902bca12c..bde2882f3 100644 --- a/query-languages/m/datetime-isincurrenthour.md +++ b/query-languages/m/datetime-isincurrenthour.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInCurrentHour" -title: "DateTime.IsInCurrentHour | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInCurrentHour" +ms.subservice: m-source --- # DateTime.IsInCurrentHour diff --git a/query-languages/m/datetime-isincurrentminute.md b/query-languages/m/datetime-isincurrentminute.md index d804712cf..a98cf92dc 100644 --- a/query-languages/m/datetime-isincurrentminute.md +++ b/query-languages/m/datetime-isincurrentminute.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInCurrentMinute" -title: "DateTime.IsInCurrentMinute | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInCurrentMinute" +ms.subservice: m-source --- # DateTime.IsInCurrentMinute diff --git a/query-languages/m/datetime-isincurrentsecond.md b/query-languages/m/datetime-isincurrentsecond.md index 6b204a0ae..b6b7daf07 100644 --- a/query-languages/m/datetime-isincurrentsecond.md +++ b/query-languages/m/datetime-isincurrentsecond.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInCurrentSecond" -title: "DateTime.IsInCurrentSecond | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInCurrentSecond" +ms.subservice: m-source --- # DateTime.IsInCurrentSecond diff --git a/query-languages/m/datetime-isinnexthour.md b/query-languages/m/datetime-isinnexthour.md index 05936c7af..ae25110ed 100644 --- a/query-languages/m/datetime-isinnexthour.md +++ b/query-languages/m/datetime-isinnexthour.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInNextHour" -title: "DateTime.IsInNextHour | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInNextHour" +ms.subservice: m-source --- # DateTime.IsInNextHour diff --git a/query-languages/m/datetime-isinnextminute.md b/query-languages/m/datetime-isinnextminute.md index 8b64b6d72..615e0264d 100644 --- a/query-languages/m/datetime-isinnextminute.md +++ b/query-languages/m/datetime-isinnextminute.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInNextMinute" -title: "DateTime.IsInNextMinute | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInNextMinute" +ms.subservice: m-source --- # DateTime.IsInNextMinute diff --git a/query-languages/m/datetime-isinnextnhours.md b/query-languages/m/datetime-isinnextnhours.md index 36437ab03..4f53f83bf 100644 --- a/query-languages/m/datetime-isinnextnhours.md +++ b/query-languages/m/datetime-isinnextnhours.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInNextNHours" -title: "DateTime.IsInNextNHours | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInNextNHours" +ms.subservice: m-source --- # DateTime.IsInNextNHours diff --git a/query-languages/m/datetime-isinnextnminutes.md b/query-languages/m/datetime-isinnextnminutes.md index 2eae66476..225928958 100644 --- a/query-languages/m/datetime-isinnextnminutes.md +++ b/query-languages/m/datetime-isinnextnminutes.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInNextNMinutes" -title: "DateTime.IsInNextNMinutes | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInNextNMinutes" +ms.subservice: m-source --- # DateTime.IsInNextNMinutes diff --git a/query-languages/m/datetime-isinnextnseconds.md b/query-languages/m/datetime-isinnextnseconds.md index 4fe6acf41..e45fe90a8 100644 --- a/query-languages/m/datetime-isinnextnseconds.md +++ b/query-languages/m/datetime-isinnextnseconds.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInNextNSeconds" -title: "DateTime.IsInNextNSeconds | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInNextNSeconds" +ms.subservice: m-source --- # DateTime.IsInNextNSeconds diff --git a/query-languages/m/datetime-isinnextsecond.md b/query-languages/m/datetime-isinnextsecond.md index 89aed7dc6..b76d65b77 100644 --- a/query-languages/m/datetime-isinnextsecond.md +++ b/query-languages/m/datetime-isinnextsecond.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInNextSecond" -title: "DateTime.IsInNextSecond | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInNextSecond" +ms.subservice: m-source --- # DateTime.IsInNextSecond diff --git a/query-languages/m/datetime-isinprevioushour.md b/query-languages/m/datetime-isinprevioushour.md index 46c157455..36e67f543 100644 --- a/query-languages/m/datetime-isinprevioushour.md +++ b/query-languages/m/datetime-isinprevioushour.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInPreviousHour" -title: "DateTime.IsInPreviousHour | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInPreviousHour" +ms.subservice: m-source --- # DateTime.IsInPreviousHour diff --git a/query-languages/m/datetime-isinpreviousminute.md b/query-languages/m/datetime-isinpreviousminute.md index b905ac923..730fa100d 100644 --- a/query-languages/m/datetime-isinpreviousminute.md +++ b/query-languages/m/datetime-isinpreviousminute.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInPreviousMinute" -title: "DateTime.IsInPreviousMinute | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInPreviousMinute" +ms.subservice: m-source --- # DateTime.IsInPreviousMinute diff --git a/query-languages/m/datetime-isinpreviousnhours.md b/query-languages/m/datetime-isinpreviousnhours.md index d65724bc9..490418d41 100644 --- a/query-languages/m/datetime-isinpreviousnhours.md +++ b/query-languages/m/datetime-isinpreviousnhours.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInPreviousNHours" -title: "DateTime.IsInPreviousNHours | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInPreviousNHours" +ms.subservice: m-source --- # DateTime.IsInPreviousNHours diff --git a/query-languages/m/datetime-isinpreviousnminutes.md b/query-languages/m/datetime-isinpreviousnminutes.md index 34df94ef9..e1f387914 100644 --- a/query-languages/m/datetime-isinpreviousnminutes.md +++ b/query-languages/m/datetime-isinpreviousnminutes.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInPreviousNMinutes" -title: "DateTime.IsInPreviousNMinutes | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInPreviousNMinutes" +ms.subservice: m-source --- # DateTime.IsInPreviousNMinutes diff --git a/query-languages/m/datetime-isinpreviousnseconds.md b/query-languages/m/datetime-isinpreviousnseconds.md index bd48e67aa..d9698b14b 100644 --- a/query-languages/m/datetime-isinpreviousnseconds.md +++ b/query-languages/m/datetime-isinpreviousnseconds.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInPreviousNSeconds" -title: "DateTime.IsInPreviousNSeconds | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInPreviousNSeconds" +ms.subservice: m-source --- # DateTime.IsInPreviousNSeconds diff --git a/query-languages/m/datetime-isinprevioussecond.md b/query-languages/m/datetime-isinprevioussecond.md index 9604993ec..9d4c77adb 100644 --- a/query-languages/m/datetime-isinprevioussecond.md +++ b/query-languages/m/datetime-isinprevioussecond.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.IsInPreviousSecond" -title: "DateTime.IsInPreviousSecond | Microsoft Docs" -ms.date: 3/11/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.IsInPreviousSecond" +ms.subservice: m-source --- # DateTime.IsInPreviousSecond diff --git a/query-languages/m/datetime-localnow.md b/query-languages/m/datetime-localnow.md index daf0bd537..fddd3c6ad 100644 --- a/query-languages/m/datetime-localnow.md +++ b/query-languages/m/datetime-localnow.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.LocalNow" -title: "DateTime.LocalNow | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.LocalNow" +ms.subservice: m-source --- # DateTime.LocalNow @@ -18,5 +11,40 @@ ms.author: dougklo DateTime.LocalNow() as datetime -## About +## About + Returns a `datetime` value set to the current date and time on the system. + +The value returned by this function depends on whether you're running your query on a local machine or online. For example, if you run your query on a system located in the U.S. Pacific Time zone, Power Query Desktop returns the date and time set on your local machine. However, if you run your query on the cloud, Power Query Online returns UTC time because it's reading the time set on the cloud virtual machines, which are all set to UTC. + +## Example 1 + +Invoke this function on a local machine running Power Query Desktop. + +**Usage** + +```powerquery-m +DateTime.LocalNow() +``` + +**Output** + +The current local date and time. + +## Example 2 + +Invoke this function on the cloud running Power Query Online. + +**Usage** + +```powerquery-m +DateTime.LocalNow() +``` + +**Output** + +The current online (UTC) date and time. + +## Related content + +[Local, fixed, and UTC variants of current time functions](m-local-fixed-utc-variants.md) diff --git a/query-languages/m/datetime-time.md b/query-languages/m/datetime-time.md index 2bdc8eec5..bcd0e59a4 100644 --- a/query-languages/m/datetime-time.md +++ b/query-languages/m/datetime-time.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.Time" -title: "DateTime.Time | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.Time" +ms.subservice: m-source --- # DateTime.Time diff --git a/query-languages/m/datetime-torecord.md b/query-languages/m/datetime-torecord.md index 514c7ab39..11beb940d 100644 --- a/query-languages/m/datetime-torecord.md +++ b/query-languages/m/datetime-torecord.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTime.ToRecord" -title: "DateTime.ToRecord | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.ToRecord" +ms.subservice: m-source --- # DateTime.ToRecord diff --git a/query-languages/m/datetime-totext.md b/query-languages/m/datetime-totext.md index 935025cfd..829cd46e3 100644 --- a/query-languages/m/datetime-totext.md +++ b/query-languages/m/datetime-totext.md @@ -1,28 +1,25 @@ --- description: "Learn more about: DateTime.ToText" -title: "DateTime.ToText | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTime.ToText" +ms.subservice: m-source --- # DateTime.ToText ## Syntax
-DateTime.ToText(dateTime as nullable datetime, optional options as any, optional culture as nullable text) as nullable text
+DateTime.ToText(
+    dateTime as nullable datetime,
+    optional options as any,
+    optional culture as nullable text
+) as nullable text
 
## About Returns a textual representation of `dateTime`. An optional `record` parameter, `options`, may be provided to specify additional properties. `culture` is only used for legacy workflows. The `record` can contain the following fields: -* `Format`: A `text` value indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providing `null` will result in formatting the date using the default defined by `Culture`. +* `Format`: A `text` value indicating the format to use. For more details, go to [Standard date and time format strings](standard-date-and-time-format-strings.md) and [Custom date and time format strings](custom-date-and-time-format-strings.md). Omitting this field or providing `null` will result in formatting the date using the default defined by `Culture`. * `Culture`: When `Format` is not null, `Culture` controls some format specifiers. For example, in `"en-US"` `"MMM"` is `"Jan", "Feb", "Mar", ...`, while in `"ru-RU"` `"MMM"` is `"янв", "фев", "мар", ...`. When `Format` is `null`, `Culture` controls the default format to use. When `Culture` is `null` or omitted, [Culture.Current](culture-current.md) is used. @@ -69,3 +66,9 @@ DateTime.ToText(#datetime(2000, 2, 8, 3, 45, 12),[Format="yyyy-MM-dd'T'HH:mm:ss' **Output** `"2000-02-08T03:45:12Z"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/datetimezone-fixedlocalnow.md b/query-languages/m/datetimezone-fixedlocalnow.md index e71c6ad50..a1032da7d 100644 --- a/query-languages/m/datetimezone-fixedlocalnow.md +++ b/query-languages/m/datetimezone-fixedlocalnow.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.FixedLocalNow" -title: "DateTimeZone.FixedLocalNow | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.FixedLocalNow" +ms.subservice: m-source --- # DateTimeZone.FixedLocalNow @@ -17,6 +10,11 @@ ms.author: dougklo
 DateTimeZone.FixedLocalNow() as datetimezone
 
- -## About -Returns a `datetime` value set to the current date and time on the system. The returned value contains timezone information representing the local timezone. This value is fixed and will not change with successive calls, unlike DateTimeZone.LocalNow, which may return different values over the course of execution of an expression. + +## About + +Returns a `datetime` value set to the current date and time on the system. The returned value contains timezone information representing the local timezone. This value is fixed and will not change with successive calls, unlike [DateTimeZone.LocalNow](datetimezone-localnow.md), which may return different values over the course of execution of an expression. + +## Related content + +[Local, fixed, and UTC variants of current time functions](m-local-fixed-utc-variants.md) diff --git a/query-languages/m/datetimezone-fixedutcnow.md b/query-languages/m/datetimezone-fixedutcnow.md index 4a1587a62..228937b2e 100644 --- a/query-languages/m/datetimezone-fixedutcnow.md +++ b/query-languages/m/datetimezone-fixedutcnow.md @@ -1,23 +1,20 @@ --- description: "Learn more about: DateTimeZone.FixedUtcNow" -title: "DateTimeZone.FixedUtcNow | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.FixedUtcNow" +ms.subservice: m-source --- # DateTimeZone.FixedUtcNow ## Syntax
-DateTimeZone.FixedUtcNow() as datetimezone  
+DateTimeZone.FixedUtcNow() as datetimezone
 
- -## About -Returns the current date and time in UTC (the GMT timezone). This value is fixed and will not change with successive calls. - + +## About + +Returns the current date and time in UTC (the GMT timezone). This value is fixed and will not change with successive calls. + +## Related content + +[Local, fixed, and UTC variants of current time functions](m-local-fixed-utc-variants.md) diff --git a/query-languages/m/datetimezone-from.md b/query-languages/m/datetimezone-from.md index 77bf16672..96a41bd38 100644 --- a/query-languages/m/datetimezone-from.md +++ b/query-languages/m/datetimezone-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.From" -title: "DateTimeZone.From | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.From" +ms.subservice: m-source --- # DateTimeZone.From @@ -20,19 +13,28 @@ DateTimeZone.From(value as any, optional culture as nullable text) ## About -Returns a `datetimezone` value from the given `value`. An optional `culture` may also be provided (for example, "en-US"). If the given `value` is `null`, **DateTimeZone.From** returns `null`. If the given `value` is `datetimezone`, `value` is returned. Values of the following types can be converted to a `datetimezone` value: +Creates a `datetimezone` from the given value. + +* `value`: The value used to create a `datetimezone`. +* `culture`: (Optional) The culture to use when transforming the value (for example, "en-US"). + +Values of the following types can be converted to a `datetimezone` value: -* `text`: A `datetimezone` value from textual representation. Refer to [DateTimeZone.FromText](datetimezone-fromtext.md) for details. -* `date`: A `datetimezone` with `value` as the date component, `12:00:00 AM` as the time component, and the offset corresponding the local time zone. -* `datetime`: A `datetimezone` with `value` as the datetime and the offset corresponding the local time zone. -* `time`: A `datetimezone` with the date equivalent of the OLE Automation Date of `0` as the date component, `value` as the time component, and the offset corresponding the local time zone. -* `number`: A `datetimezone` with the datetime equivalent to the OLE Automation Date expressed by `value` and the offset corresponding the local time zone. +* `text`: Returns a `datetimezone` value from textual representation. Refer to [DateTimeZone.FromText](datetimezone-fromtext.md) for details. +* `date`: Returns a `datetimezone` with `value` as the date component, `12:00:00 AM` as the time component, and the offset corresponding the local time zone. +* `datetime`: Returns a `datetimezone` with `value` as the datetime and the offset corresponding the local time zone. +* `datetimezone`: Returns `value`. +* `time`: Returns a `datetimezone` with the date equivalent of the OLE Automation Date of `0` as the date component, `value` as the time component, and the offset corresponding the local time zone. The OLE Automation Date consists of a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25. The base value is midnight, 30 December 1899. The minimum value is midnight, 1 January 0100. The maximum value is the last moment of 31 December 9999. +* `number`: Returns a `datetimezone` with the datetime equivalent to the OLE Automation Date expressed by `value` and the offset corresponding the local time zone. +* `null`: Returns `null`. If `value` is of any other type, an error is returned. +The value of the offset corresponding to the local time zone is different when running this function locally as opposed to running it online. When run locally, the local time zone is returned. When run online, the UTC time zone (+00:00) is returned. + ## Example 1 -Convert `"2020-10-30T01:30:00-08:00"` to a `datetimezone` value. +Convert the textual representation of a date, time, and timezone to a `datetimezone` value. **Usage** @@ -43,3 +45,39 @@ DateTimeZone.From("2020-10-30T01:30:00-08:00") **Output** `#datetimezone(2020, 10, 30, 01, 30, 00, -8, 00)` + +## Example 2 + +Convert the textual representation of Brazilian Portuguese date, time, and timezone to a `datetimezone` value. + +**Usage** + +```powerquery-m +DateTimeZone.From("13 de agosto de 2025 15:43:00 -03:00", "pt-BR") +``` + +**Output** + +`#datetimezone(2025, 08, 13, 15, 43, 00, -3, 00)` + +## Example 3 + +Convert a number representing January 1, 2025 at 12 PM to a `datetimezone` value. The timezone in the result depends on whether the example is run locally or online. + +**Usage** + +```powerquery-m +DateTimeZone.From(45658.5) +``` + +**Output** + +`#datetimezone(2025, 01, 01, 12, 00, 00, 0, 00)` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Local, fixed, and UTC variants of current time functions](m-local-fixed-utc-variants.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) +* [Number.From](number-from.md) diff --git a/query-languages/m/datetimezone-fromfiletime.md b/query-languages/m/datetimezone-fromfiletime.md index bc12ced75..2ac0d7112 100644 --- a/query-languages/m/datetimezone-fromfiletime.md +++ b/query-languages/m/datetimezone-fromfiletime.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.FromFileTime" -title: "DateTimeZone.FromFileTime | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.FromFileTime" +ms.subservice: m-source --- # DateTimeZone.FromFileTime diff --git a/query-languages/m/datetimezone-fromtext.md b/query-languages/m/datetimezone-fromtext.md index 0696f92d0..a1a6b003f 100644 --- a/query-languages/m/datetimezone-fromtext.md +++ b/query-languages/m/datetimezone-fromtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.FromText" -title: "DateTimeZone.FromText | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.FromText" +ms.subservice: m-source --- # DateTimeZone.FromText @@ -22,7 +15,7 @@ DateTimeZone.FromText(text as nullable text, optional options as a Creates a `datetimezone` value from a textual representation, `text`. An optional `record` parameter, `options`, may be provided to specify additional properties. The `record` can contain the following fields: -* `Format`: A `text` value indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providing `null` will result in parsing the date using a best effort. +* `Format`: A `text` value indicating the format to use. For more details, go to [Standard date and time format strings](standard-date-and-time-format-strings.md) and [Custom date and time format strings](custom-date-and-time-format-strings.md). Omitting this field or providing `null` will result in parsing the date using a best effort. * `Culture`: When `Format` is not null, `Culture` controls some format specifiers. For example, in `"en-US"` `"MMM"` is `"Jan", "Feb", "Mar", ...`, while in `"ru-RU"` `"MMM"` is `"янв", "фев", "мар", ...`. When `Format` is `null`, `Culture` controls the default format to use. When `Culture` is `null` or omitted, [Culture.Current](culture-current.md) is used. @@ -69,3 +62,9 @@ DateTimeZone.FromText("2009-06-15T13:45:30.0000000-07:00", [Format="O", Culture= **Output** `#datetimezone(2009, 6, 15, 13, 45, 30, -7, 0)` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/datetimezone-functions.md b/query-languages/m/datetimezone-functions.md index ea45a5b34..8c8e0b22d 100644 --- a/query-languages/m/datetimezone-functions.md +++ b/query-languages/m/datetimezone-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: DateTimeZone functions" -title: "DateTimeZone functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone functions" +ms.date: 11/13/2024 +ms.custom: "nonautomated-date" --- # DateTimeZone functions @@ -29,6 +23,6 @@ These functions create and manipulate datetimezone values. |[DateTimeZone.ToText](datetimezone-totext.md)|Returns a text value from a DateTime value.| |[DateTimeZone.ToUtc](datetimezone-toutc.md)|Returns a DateTime value to the Utc time zone.| |[DateTimeZone.UtcNow](datetimezone-utcnow.md)|Returns a DateTime value set to the current system date and time in the Utc timezone.| -|[DateTimeZone.ZoneHours](datetimezone-zonehours.md)|Returns a time zone hour value from a DateTime value.| -|[DateTimeZone.ZoneMinutes](datetimezone-zoneminutes.md)|Returns a time zone minute value from a DateTime value.| +|[DateTimeZone.ZoneHours](datetimezone-zonehours.md)|Gets the timezone hour of the value.| +|[DateTimeZone.ZoneMinutes](datetimezone-zoneminutes.md)|Gets the timezone minute of the value.| |[#datetimezone](sharpdatetimezone.md)|Creates a datetimezone value from year, month, day, hour, minute, second, offset-hours, and offset-minutes.| diff --git a/query-languages/m/datetimezone-localnow.md b/query-languages/m/datetimezone-localnow.md index 868f485ea..97583a351 100644 --- a/query-languages/m/datetimezone-localnow.md +++ b/query-languages/m/datetimezone-localnow.md @@ -1,22 +1,20 @@ --- description: "Learn more about: DateTimeZone.LocalNow" -title: "DateTimeZone.LocalNow | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.LocalNow" +ms.subservice: m-source --- # DateTimeZone.LocalNow ## Syntax
-DateTimeZone.LocalNow() as datetimezone  
+DateTimeZone.LocalNow() as datetimezone
 
- -## About + +## About + Returns a `datetimezone` value set to the current date and time on the system. The returned value contains timezone information representing the local timezone. + +## Related content + +[Local, fixed, and UTC variants of current time functions](m-local-fixed-utc-variants.md) diff --git a/query-languages/m/datetimezone-removezone.md b/query-languages/m/datetimezone-removezone.md index df637afd2..97a3708fd 100644 --- a/query-languages/m/datetimezone-removezone.md +++ b/query-languages/m/datetimezone-removezone.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.RemoveZone" -title: "DateTimeZone.RemoveZone | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.RemoveZone" +ms.subservice: m-source --- # DateTimeZone.RemoveZone diff --git a/query-languages/m/datetimezone-switchzone.md b/query-languages/m/datetimezone-switchzone.md index cdbef9229..0b4816acf 100644 --- a/query-languages/m/datetimezone-switchzone.md +++ b/query-languages/m/datetimezone-switchzone.md @@ -1,21 +1,18 @@ --- description: "Learn more about: DateTimeZone.SwitchZone" -title: "DateTimeZone.SwitchZone | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.SwitchZone" +ms.subservice: m-source --- # DateTimeZone.SwitchZone ## Syntax
-DateTimeZone.SwitchZone(dateTimeZone as nullable datetimezone, timezoneHours as number, optional timezoneMinutes as nullable number) as nullable datetimezone
+DateTimeZone.SwitchZone(
+    dateTimeZone as nullable datetimezone,
+    timezoneHours as number,
+    optional timezoneMinutes as nullable number
+) as nullable datetimezone
 
## About diff --git a/query-languages/m/datetimezone-tolocal.md b/query-languages/m/datetimezone-tolocal.md index c6ba7d7e8..bb690002b 100644 --- a/query-languages/m/datetimezone-tolocal.md +++ b/query-languages/m/datetimezone-tolocal.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.ToLocal" -title: "DateTimeZone.ToLocal | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.ToLocal" +ms.subservice: m-source --- # DateTimeZone.ToLocal diff --git a/query-languages/m/datetimezone-torecord.md b/query-languages/m/datetimezone-torecord.md index 7d66521e0..9f54d3672 100644 --- a/query-languages/m/datetimezone-torecord.md +++ b/query-languages/m/datetimezone-torecord.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.ToRecord" -title: "DateTimeZone.ToRecord | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.ToRecord" +ms.subservice: m-source --- # DateTimeZone.ToRecord diff --git a/query-languages/m/datetimezone-totext.md b/query-languages/m/datetimezone-totext.md index 6be1c868c..fe681a913 100644 --- a/query-languages/m/datetimezone-totext.md +++ b/query-languages/m/datetimezone-totext.md @@ -1,28 +1,25 @@ --- description: "Learn more about: DateTimeZone.ToText" -title: "DateTimeZone.ToText | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.ToText" +ms.subservice: m-source --- # DateTimeZone.ToText ## Syntax
-DateTimeZone.ToText(dateTimeZone as nullable datetimezone, optional options as any, optional culture as nullable text) as nullable text
+DateTimeZone.ToText(
+    dateTimeZone as nullable datetimezone,
+    optional options as any,
+    optional culture as nullable text
+) as nullable text
 
## About Returns a textual representation of `dateTimeZone`. An optional `record` parameter, `options`, may be provided to specify additional properties. `culture` is only used for legacy workflows. The `record` can contain the following fields: -* `Format`: A `text` value indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providing `null` will result in formatting the date using the default defined by `Culture`. +* `Format`: A `text` value indicating the format to use. For more details, go to * [Standard date and time format strings](standard-date-and-time-format-strings.md) and [Custom date and time format strings](custom-date-and-time-format-strings.md). Omitting this field or providing `null` will result in formatting the date using the default defined by `Culture`. * `Culture`: When `Format` is not null, `Culture` controls some format specifiers. For example, in `"en-US"` `"MMM"` is `"Jan", "Feb", "Mar", ...`, while in `"ru-RU"` `"MMM"` is `"янв", "фев", "мар", ...`. When `Format` is `null`, `Culture` controls the default format to use. When `Culture` is `null` or omitted, [Culture.Current](culture-current.md) is used. @@ -69,3 +66,9 @@ DateTimeZone.ToText(#datetimezone(2000, 2, 8, 3, 45, 12, 2, 0),[Format="O", Cult **Output** `"2000-02-08T03:45:12.0000000+02:00"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/datetimezone-toutc.md b/query-languages/m/datetimezone-toutc.md index 1b13d85e1..284fa3028 100644 --- a/query-languages/m/datetimezone-toutc.md +++ b/query-languages/m/datetimezone-toutc.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.ToUtc" -title: "DateTimeZone.ToUtc | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.ToUtc" +ms.subservice: m-source --- # DateTimeZone.ToUtc diff --git a/query-languages/m/datetimezone-utcnow.md b/query-languages/m/datetimezone-utcnow.md index e7485107e..d0cfbed95 100644 --- a/query-languages/m/datetimezone-utcnow.md +++ b/query-languages/m/datetimezone-utcnow.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.UtcNow" -title: "DateTimeZone.UtcNow | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.UtcNow" +ms.subservice: m-source --- # DateTimeZone.UtcNow @@ -17,7 +10,7 @@ ms.author: dougklo
 DateTimeZone.UtcNow() as datetimezone
 
- + ## About Returns the current date and time in UTC (the GMT timezone). @@ -35,3 +28,7 @@ DateTimeZone.UtcNow() **Output** `#datetimezone(2011, 8, 16, 23, 34, 37.745, 0, 0)` + +## Related content + +[Local, fixed, and UTC variants of current time functions](m-local-fixed-utc-variants.md) diff --git a/query-languages/m/datetimezone-zonehours.md b/query-languages/m/datetimezone-zonehours.md index a00c60fcb..9a0122d27 100644 --- a/query-languages/m/datetimezone-zonehours.md +++ b/query-languages/m/datetimezone-zonehours.md @@ -1,22 +1,32 @@ --- description: "Learn more about: DateTimeZone.ZoneHours" -title: "DateTimeZone.ZoneHours | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.ZoneHours" +ms.subservice: m-source --- # DateTimeZone.ZoneHours ## Syntax
-DateTimeZone.ZoneHours(dateTimeZone as nullable datetimezone) as nullable number  
+DateTimeZone.ZoneHours(dateTimeZone as nullable datetimezone) as nullable number
 
- -## About -Changes the timezone of the value. + +## About + +Returns the time zone hour component of a `datetimezone` value. + +* `dateTimeZone`: A `datetimezone` value from which the time zone hour component is extracted. If `dateTimeZone` is `null`, the function returns `null`. + +## Example 1 + +Get the time zone hours component of the specified `datetimezone` value. + +**Usage** + +```powerquery-m +DateTimeZone.ZoneHours(#datetimezone(2024, 4, 28, 13, 24, 22, 7, 30)) +``` + +**Output** + +`7` diff --git a/query-languages/m/datetimezone-zoneminutes.md b/query-languages/m/datetimezone-zoneminutes.md index e61fbbb44..bb3a4e032 100644 --- a/query-languages/m/datetimezone-zoneminutes.md +++ b/query-languages/m/datetimezone-zoneminutes.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DateTimeZone.ZoneMinutes" -title: "DateTimeZone.ZoneMinutes | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DateTimeZone.ZoneMinutes" +ms.subservice: m-source --- # DateTimeZone.ZoneMinutes @@ -19,5 +12,21 @@ DateTimeZone.ZoneMinutes(dateTimeZone as nullable datetimezone) as nullab ## About -Changes the timezone of the value. +Returns the time zone minutes component of a `datetimezone` value. + +* `dateTimeZone`: a `datetimezone` value from which the time zone minutes component is extracted. If `dateTimeZone` is `null`, the function returns `null`. + +## Example 1 + +Get the time zone minutes component of the specified `datetimezone` value. + +**Usage** + +```powerquery-m +DateTimeZone.ZoneMinutes(#datetimezone(2024, 4, 28, 13, 24, 22, 7, 30)) +``` + +**Output** + +`30` diff --git a/query-languages/m/day-type.md b/query-languages/m/day-type.md index df6ffb4a9..6188bfc31 100644 --- a/query-languages/m/day-type.md +++ b/query-languages/m/day-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Day.Type" -title: "Day.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Day.Type" +ms.subservice: m-source --- # Day.Type diff --git a/query-languages/m/db2-database.md b/query-languages/m/db2-database.md index 764ef98fc..ee1eb412e 100644 --- a/query-languages/m/db2-database.md +++ b/query-languages/m/db2-database.md @@ -1,38 +1,33 @@ --- description: "Learn more about: DB2.Database" -title: "DB2.Database | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DB2.Database" +ms.subservice: m-source --- # DB2.Database ## Syntax
-DB2.Database(server as text, database as text, optional options as nullable record) as table
+DB2.Database(
+    server as text,
+    database as text,
+    optional options as nullable record
+) as table
 
## About -Returns a table of SQL tables and views available in a Db2 database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: - -- `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). -- `NavigationPropertyNameGenerator` : A function that is used for the creation of names for navigation properties. -- `Query` : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. -- `CommandTimeout` : A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. -- `ConnectionTimeout` : 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. -- `HierarchicalNavigation` : A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). -- `Implementation` : Specifies the internal database provider implementation to use. Valid values are: "IBM" and "Microsoft". -- `BinaryCodePage` : A number for the CCSID (Coded Character Set Identifier) to decode Db2 FOR BIT binary data into character strings. Applies to Implementation = "Microsoft". Set 0 to disable conversion (default). Set 1 to convert based on database encoding. Set other CCSID number to convert to application encoding. -- `PackageCollection` : Specifies a string value for package collection (default is "NULLID") to enable use of shared packages required to process SQL statements. Applies to Implementation = "Microsoft". -- `UseDb2ConnectGateway` : Specifies whether the connection is being made through a Db2 Connect gateway. Applies to Implementation = "Microsoft". - -The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. - +Returns a table of SQL tables and views available in a Db2 database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: +- `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). +- `NavigationPropertyNameGenerator`: A function that is used for the creation of names for navigation properties. +- `Query`: A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. +- `CommandTimeout`: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. +- `ConnectionTimeout`: 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. +- `HierarchicalNavigation`: A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). +- `Implementation`: Specifies the internal database provider implementation to use. Valid values are: "IBM" and "Microsoft". +- `BinaryCodePage`: A number for the CCSID (Coded Character Set Identifier) to decode Db2 FOR BIT binary data into character strings. Applies to Implementation = "Microsoft". Set 0 to disable conversion (default). Set 1 to convert based on database encoding. Set other CCSID number to convert to application encoding. +- `PackageCollection`: Specifies a string value for package collection (default is "NULLID") to enable use of shared packages required to process SQL statements. Applies to Implementation = "Microsoft". +- `UseDb2ConnectGateway`: Specifies whether the connection is being made through a Db2 Connect gateway. Applies to Implementation = "Microsoft". +The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. diff --git a/query-languages/m/decimal-from.md b/query-languages/m/decimal-from.md index 8a143e542..2a586c392 100644 --- a/query-languages/m/decimal-from.md +++ b/query-languages/m/decimal-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Decimal.From" -title: "Decimal.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Decimal.From" +ms.subservice: m-source --- # Decimal.From @@ -17,10 +10,10 @@ ms.author: dougklo
 Decimal.From(value as any, optional culture as nullable text) as nullable number
 
- + ## About -Returns a Decimal `number` value from the given `value`. If the given `value` is `null`, **Decimal.From** returns `null`. If the given `value` is `number` within the range of Decimal, `value` is returned, otherwise an error is returned. If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](/powerquery-m/number-fromtext). An optional `culture` may also be provided (for example, "en-US"). +Returns a Decimal `number` value from the given `value`. If the given `value` is `null`, **Decimal.From** returns `null`. If the given `value` is `number` within the range of Decimal, `value` is returned, otherwise an error is returned. If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](number-fromtext.md). An optional `culture` may also be provided (for example, "en-US"). ## Example 1 @@ -35,3 +28,7 @@ Decimal.From("4.5") **Output** `4.5` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/deltalake-metadata.md b/query-languages/m/deltalake-metadata.md new file mode 100644 index 000000000..5bdd45e54 --- /dev/null +++ b/query-languages/m/deltalake-metadata.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: DeltaLake.Metadata" +title: "DeltaLake.Metadata" +ms.subservice: m-source +--- +# DeltaLake.Metadata + +## Syntax + +
+DeltaLake.Metadata(table as table) as table
+
+ +## About + +Given a Delta Lake table, returns the log entries for that table. diff --git a/query-languages/m/deltalake-table.md b/query-languages/m/deltalake-table.md new file mode 100644 index 000000000..cf599a2d6 --- /dev/null +++ b/query-languages/m/deltalake-table.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: DeltaLake.Table" +title: "DeltaLake.Table" +ms.subservice: m-source +--- +# DeltaLake.Table + +## Syntax + +
+DeltaLake.Table(directory as table, optional options as nullable record) as any
+
+ +## About + +Returns the contents of the Delta Lake table. diff --git a/query-languages/m/diagnostics-activityid.md b/query-languages/m/diagnostics-activityid.md index 3919fd979..721f2c19a 100644 --- a/query-languages/m/diagnostics-activityid.md +++ b/query-languages/m/diagnostics-activityid.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Diagnostics.ActivityId" -title: "Diagnostics.ActivityId | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Diagnostics.ActivityId" +ms.subservice: m-source --- # Diagnostics.ActivityId @@ -19,5 +12,5 @@ Diagnostics.ActivityId() as nullable text ## About -Returns an opaque identifier for the currently-running evaluation. +Returns an opaque identifier for the currently-running evaluation. diff --git a/query-languages/m/diagnostics-correlationid.md b/query-languages/m/diagnostics-correlationid.md new file mode 100644 index 000000000..d0175f9b0 --- /dev/null +++ b/query-languages/m/diagnostics-correlationid.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Diagnostics.CorrelationId" +title: "Diagnostics.CorrelationId" +ms.subservice: m-source +--- +# Diagnostics.CorrelationId + +## Syntax + +
+Diagnostics.CorrelationId() as nullable text
+
+ +## About + +Returns an opaque identifier to correlate incoming requests with outgoing ones. diff --git a/query-languages/m/diagnostics-trace.md b/query-languages/m/diagnostics-trace.md index a37e5e999..9943704b4 100644 --- a/query-languages/m/diagnostics-trace.md +++ b/query-languages/m/diagnostics-trace.md @@ -1,39 +1,38 @@ --- description: "Learn more about: Diagnostics.Trace" -title: "Diagnostics.Trace | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Diagnostics.Trace" +ms.subservice: m-source --- # Diagnostics.Trace + ## Syntax
-Diagnostics.Trace(traceLevel as number, message as anynonnull, value as any, optional delayed as nullable logical) as any
+Diagnostics.Trace(
+    traceLevel as number,
+    message as anynonnull,
+    value as any,
+    optional delayed as nullable logical
+) as any
 
-## About +## About Writes a trace `message`, if tracing is enabled, and returns `value`. An optional parameter `delayed` specifies whether to delay the evaluation of `value` until the message is traced. `traceLevel` can take one of the following values: -- [TraceLevel.Critical](/powerquery-m/tracelevel-critical) -- [TraceLevel.Error](/powerquery-m/tracelevel-error) -- [TraceLevel.Warning](/powerquery-m/tracelevel-warning) -- [TraceLevel.Information](/powerquery-m/tracelevel-information) -- [TraceLevel.Verbose](/powerquery-m/tracelevel-verbose) - -## Example 1 +- [TraceLevel.Critical](tracelevel-type.md) +- [TraceLevel.Error](tracelevel-type.md) +- [TraceLevel.Warning](tracelevel-type.md) +- [TraceLevel.Information](tracelevel-type.md) +- [TraceLevel.Verbose](tracelevel-type.md) + +## Example 1 Trace the message before invoking Text.From function and return the result. **Usage** -``` +```powerquery-m Diagnostics.Trace(TraceLevel.Information, "TextValueFromNumber", () => Text.From(123), true) ``` diff --git a/query-languages/m/directquerycapabilities-from.md b/query-languages/m/directquerycapabilities-from.md index d9057611f..3233de819 100644 --- a/query-languages/m/directquerycapabilities-from.md +++ b/query-languages/m/directquerycapabilities-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: DirectQueryCapabilities.From" -title: "DirectQueryCapabilities.From | Microsoft Docs" -ms.date: 10/18/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "DirectQueryCapabilities.From" +ms.subservice: m-source --- # DirectQueryCapabilities.From diff --git a/query-languages/m/docfx.json b/query-languages/m/docfx.json index dc6eaa6fb..ff6af0563 100644 --- a/query-languages/m/docfx.json +++ b/query-languages/m/docfx.json @@ -35,11 +35,721 @@ "overwrite": [], "externalReference": [], "globalMetadata": { + "feedback_system": "Standard", + "feedback_product_url": "/power-query/feedback", + "feedback_help_link_url": "https://community.fabric.microsoft.com/t5/Power-Query/bd-p/power-bi-services", + "feedback_help_link_type": "ask-the-community", "breadcrumb_path": "/powerquery-m/breadcrumb/toc.json", - "extendBreadcrumb": true, - "titleSuffix": "PowerQuery M" + "uhfHeaderId": "MSDocsHeader-PowerQueryM", + "titleSuffix": "PowerQuery M", + "ms.service": "powerquery", + "ms.topic": "article", + "ms.reviewer": "ehvonleh", + "author": "dougklopfenstein", + "ms.author": "dougklo", + "searchScope": ["Power Query","M formula language"], + "ms.date": "7/16/2025", + "no-loc": [ + "#binary", + "#date", + "#datetime", + "#datetimezone", + "#duration", + "#table", + "#time", + "Access.Database", + "AccessControlEntry.ConditionToIdentities", + "AccessControlKind.Type", + "Action.WithErrorContext", + "ActiveDirectory.Domains", + "AdobeAnalytics.Cubes", + "AdoDotNet.DataSource", + "AdoDotNet.Query", + "AnalysisServices.Database", + "AnalysisServices.Databases", + "AzureStorage.BlobContents", + "AzureStorage.Blobs", + "AzureStorage.DataLake", + "AzureStorage.DataLakeContents", + "AzureStorage.Tables", + "Binary.ApproximateLength", + "Binary.Buffer", + "Binary.Combine", + "Binary.Compress", + "Binary.Decompress", + "Binary.From", + "Binary.FromList", + "Binary.FromText", + "Binary.InferContentType", + "Binary.Length", + "Binary.Range", + "Binary.Split", + "Binary.ToList", + "Binary.ToText", + "Binary.View", + "Binary.ViewError", + "Binary.ViewFunction", + "BinaryEncoding.Type", + "BinaryFormat.7BitEncodedSignedInteger", + "BinaryFormat.7BitEncodedUnsignedInteger", + "BinaryFormat.Binary", + "BinaryFormat.Byte", + "BinaryFormat.ByteOrder", + "BinaryFormat.Choice", + "BinaryFormat.Decimal", + "BinaryFormat.Double", + "BinaryFormat.Group", + "BinaryFormat.Length", + "BinaryFormat.List", + "BinaryFormat.Null", + "BinaryFormat.Record", + "BinaryFormat.SignedInteger16", + "BinaryFormat.SignedInteger32", + "BinaryFormat.SignedInteger64", + "BinaryFormat.Single", + "BinaryFormat.Text", + "BinaryFormat.Transform", + "BinaryFormat.UnsignedInteger16", + "BinaryFormat.UnsignedInteger32", + "BinaryFormat.UnsignedInteger64", + "BinaryOccurrence.Type", + "BufferMode.Type", + "Byte.From", + "ByteOrder.Type", + "Cdm.Contents", + "Character.FromNumber", + "Character.ToNumber", + "Combiner.CombineTextByDelimiter", + "Combiner.CombineTextByEachDelimiter", + "Combiner.CombineTextByLengths", + "Combiner.CombineTextByPositions", + "Combiner.CombineTextByRanges", + "Comparer.Equals", + "Comparer.FromCulture", + "Comparer.Ordinal", + "Comparer.OrdinalIgnoreCase", + "Compression.Type", + "Csv.Document", + "CsvStyle.Type", + "Cube.AddAndExpandDimensionColumn", + "Cube.AddMeasureColumn", + "Cube.ApplyParameter", + "Cube.AttributeMemberId", + "Cube.AttributeMemberProperty", + "Cube.CollapseAndRemoveColumns", + "Cube.Dimensions", + "Cube.DisplayFolders", + "Cube.MeasureProperties", + "Cube.MeasureProperty", + "Cube.Measures", + "Cube.Parameters", + "Cube.Properties", + "Cube.PropertyKey", + "Cube.ReplaceDimensions", + "Cube.Transform", + "Culture.Current", + "Currency.From", + "Date.AddDays", + "Date.AddMonths", + "Date.AddQuarters", + "Date.AddWeeks", + "Date.AddYears", + "Date.Day", + "Date.DayOfWeek", + "Date.DayOfWeekName", + "Date.DayOfYear", + "Date.DaysInMonth", + "Date.EndOfDay", + "Date.EndOfMonth", + "Date.EndOfQuarter", + "Date.EndOfWeek", + "Date.EndOfYear", + "Date.From", + "Date.FromText", + "Date.IsInCurrentDay", + "Date.IsInCurrentMonth", + "Date.IsInCurrentQuarter", + "Date.IsInCurrentWeek", + "Date.IsInCurrentYear", + "Date.IsInNextDay", + "Date.IsInNextMonth", + "Date.IsInNextNDays", + "Date.IsInNextNMonths", + "Date.IsInNextNQuarters", + "Date.IsInNextNWeeks", + "Date.IsInNextNYears", + "Date.IsInNextQuarter", + "Date.IsInNextWeek", + "Date.IsInNextYear", + "Date.IsInPreviousDay", + "Date.IsInPreviousMonth", + "Date.IsInPreviousNDays", + "Date.IsInPreviousNMonths", + "Date.IsInPreviousNQuarters", + "Date.IsInPreviousNWeeks", + "Date.IsInPreviousNYears", + "Date.IsInPreviousQuarter", + "Date.IsInPreviousWeek", + "Date.IsInPreviousYear", + "Date.IsInYearToDate", + "Date.IsLeapYear", + "Date.Month", + "Date.MonthName", + "Date.QuarterOfYear", + "Date.StartOfDay", + "Date.StartOfMonth", + "Date.StartOfQuarter", + "Date.StartOfWeek", + "Date.StartOfYear", + "Date.ToRecord", + "Date.ToText", + "Date.WeekOfMonth", + "Date.WeekOfYear", + "Date.Year", + "DateTime.AddZone", + "DateTime.Date", + "DateTime.FixedLocalNow", + "DateTime.From", + "DateTime.FromFileTime", + "DateTime.FromText", + "DateTime.IsInCurrentHour", + "DateTime.IsInCurrentMinute", + "DateTime.IsInCurrentSecond", + "DateTime.IsInNextHour", + "DateTime.IsInNextMinute", + "DateTime.IsInNextNHours", + "DateTime.IsInNextNMinutes", + "DateTime.IsInNextNSeconds", + "DateTime.IsInNextSecond", + "DateTime.IsInPreviousHour", + "DateTime.IsInPreviousMinute", + "DateTime.IsInPreviousNHours", + "DateTime.IsInPreviousNMinutes", + "DateTime.IsInPreviousNSeconds", + "DateTime.IsInPreviousSecond", + "DateTime.LocalNow", + "DateTime.Time", + "DateTime.ToRecord", + "DateTime.ToText", + "DateTimeZone.FixedLocalNow", + "DateTimeZone.FixedUtcNow", + "DateTimeZone.From", + "DateTimeZone.FromFileTime", + "DateTimeZone.FromText", + "DateTimeZone.LocalNow", + "DateTimeZone.RemoveZone", + "DateTimeZone.SwitchZone", + "DateTimeZone.ToLocal", + "DateTimeZone.ToRecord", + "DateTimeZone.ToText", + "DateTimeZone.ToUtc", + "DateTimeZone.UtcNow", + "DateTimeZone.ZoneHours", + "DateTimeZone.ZoneMinutes", + "Day.Type", + "DB2.Database", + "Decimal.From", + "DeltaLake.Metadata", + "DeltaLake.Table", + "Diagnostics.ActivityId", + "Diagnostics.CorrelationId", + "Diagnostics.Trace", + "DirectQueryCapabilities.From", + "Double.From", + "Duration.Days", + "Duration.From", + "Duration.FromText", + "Duration.Hours", + "Duration.Minutes", + "Duration.Seconds", + "Duration.ToRecord", + "Duration.TotalDays", + "Duration.TotalHours", + "Duration.TotalMinutes", + "Duration.TotalSeconds", + "Duration.ToText", + "Embedded.Value", + "Error.Record", + "Essbase.Cubes", + "Excel.CurrentWorkbook", + "Excel.ShapeTable", + "Excel.Workbook", + "Exchange.Contents", + "Exchange.Contents ", + "Expression.Constant", + "Expression.Evaluate", + "Expression.Identifier", + "ExtraValues.Type", + "File.Contents", + "Folder.Contents", + "Folder.Files", + "Function.From", + "Function.Invoke", + "Function.InvokeAfter", + "Function.InvokeWithErrorContext", + "Function.IsDataSource", + "Function.ScalarVector", + "Geography.FromWellKnownText", + "Geography.ToWellKnownText", + "GeographyPoint.From", + "Geometry.FromWellKnownText", + "Geometry.ToWellKnownText", + "GeometryPoint.From", + "GoogleAnalytics.Accounts", + "Graph.Nodes", + "GroupKind.Type", + "Guid.From", + "Hdfs.Contents", + "Hdfs.Files", + "HdInsight.Containers", + "HdInsight.Contents", + "HdInsight.Files", + "Html.Table", + "Identity.From", + "Identity.IsMemberOf", + "IdentityProvider.Default", + "Informix.Database", + "Int16.From", + "Int32.From", + "Int64.From", + "Int8.From", + "ItemExpression.From", + "ItemExpression.Item", + "JoinAlgorithm.Type", + "JoinKind.Type", + "JoinSide.Type", + "Json.Document", + "Json.FromValue", + "LimitClauseKind.Type", + "Lines.FromBinary", + "Lines.FromText", + "Lines.ToBinary", + "Lines.ToText", + "List.Accumulate", + "List.AllTrue", + "List.Alternate", + "List.AnyTrue", + "List.Average", + "List.Buffer", + "List.Combine", + "List.ConformToPageReader", + "List.Contains", + "List.ContainsAll", + "List.ContainsAny", + "List.Count", + "List.Covariance", + "List.Dates", + "List.DateTimes", + "List.DateTimeZones", + "List.Difference", + "List.Distinct", + "List.Durations", + "List.FindText", + "List.First", + "List.FirstN", + "List.Generate", + "List.InsertRange", + "List.Intersect", + "List.IsDistinct", + "List.IsEmpty", + "List.Last", + "List.LastN", + "List.MatchesAll", + "List.MatchesAny", + "List.Max", + "List.MaxN", + "List.Median", + "List.Min", + "List.MinN", + "List.Mode", + "List.Modes", + "List.NonNullCount", + "List.Numbers", + "List.Percentile", + "List.PositionOf", + "List.PositionOfAny", + "List.Positions", + "List.Product", + "List.Random", + "List.Range", + "List.RemoveFirstN", + "List.RemoveItems", + "List.RemoveLastN", + "List.RemoveMatchingItems", + "List.RemoveNulls", + "List.RemoveRange", + "List.Repeat", + "List.ReplaceMatchingItems", + "List.ReplaceRange", + "List.ReplaceValue", + "List.Reverse", + "List.Select", + "List.Single", + "List.SingleOrDefault", + "List.Skip", + "List.Sort", + "List.Split", + "List.StandardDeviation", + "List.Sum", + "List.Times", + "List.Transform", + "List.TransformMany", + "List.Union", + "List.Zip", + "Logical.From", + "Logical.FromText", + "Logical.ToText", + "MissingField.Type", + "Module.Versions", + "MySQL.Database", + "Number.Abs", + "Number.Acos", + "Number.Asin", + "Number.Atan", + "Number.Atan2", + "Number.BitwiseAnd", + "Number.BitwiseNot", + "Number.BitwiseOr", + "Number.BitwiseShiftLeft", + "Number.BitwiseShiftRight", + "Number.BitwiseXor", + "Number.Combinations", + "Number.Cos", + "Number.Cosh", + "Number.E", + "Number.Epsilon", + "Number.Exp", + "Number.Factorial", + "Number.From", + "Number.FromText", + "Number.IntegerDivide", + "Number.IsEven", + "Number.IsNaN", + "Number.IsOdd", + "Number.Ln", + "Number.Log", + "Number.Log10", + "Number.Mod", + "Number.NaN", + "Number.NegativeInfinity", + "Number.Permutations", + "Number.PI", + "Number.PositiveInfinity", + "Number.Power", + "Number.Random", + "Number.RandomBetween", + "Number.Round", + "Number.RoundAwayFromZero", + "Number.RoundDown", + "Number.RoundTowardZero", + "Number.RoundUp", + "Number.Sign", + "Number.Sin", + "Number.Sinh", + "Number.Sqrt", + "Number.Tan", + "Number.Tanh", + "Number.ToText", + "Occurrence.Type", + "OData.Feed", + "ODataOmitValues.Type", + "Odbc.DataSource", + "Odbc.InferOptions", + "Odbc.Query", + "OleDb.DataSource", + "OleDb.Query", + "Oracle.Database", + "Order.Type", + "Pdf.Tables", + "Percentage.From", + "PercentileMode.Type", + "PostgreSQL.Database", + "Precision.Type", + "Progress.DataSourceProgress", + "QuoteStyle.Type", + "RankKind.Type", + "RData.FromBinary", + "Record.AddField", + "Record.Combine", + "Record.Field", + "Record.FieldCount", + "Record.FieldNames", + "Record.FieldOrDefault", + "Record.FieldValues", + "Record.FromList", + "Record.FromTable", + "Record.HasFields", + "Record.RemoveFields", + "Record.RenameFields", + "Record.ReorderFields", + "Record.SelectFields", + "Record.ToList", + "Record.ToTable", + "Record.TransformFields", + "RelativePosition.Type", + "Replacer.ReplaceText", + "Replacer.ReplaceValue", + "RoundingMode.Type", + "RowExpression.Column", + "RowExpression.From", + "RowExpression.Row", + "Salesforce.Data", + "Salesforce.Reports", + "SapBusinessWarehouse.Cubes", + "SapBusinessWarehouseExecutionMode.Type", + "SapHana.Database", + "SapHanaDistribution.Type", + "SapHanaRangeOperator.Type", + "SharePoint.Contents", + "SharePoint.Files", + "SharePoint.Tables", + "Single.From", + "Soda.Feed", + "Splitter.SplitByNothing", + "Splitter.SplitTextByAnyDelimiter", + "Splitter.SplitTextByCharacterTransition", + "Splitter.SplitTextByDelimiter", + "Splitter.SplitTextByEachDelimiter", + "Splitter.SplitTextByLengths", + "Splitter.SplitTextByPositions", + "Splitter.SplitTextByRanges", + "Splitter.SplitTextByRepeatedLengths", + "Splitter.SplitTextByWhitespace", + "Sql.Database", + "Sql.Databases", + "SqlExpression.SchemaFrom", + "SqlExpression.ToExpression", + "Sybase.Database", + "Table.AddColumn", + "Table.AddFuzzyClusterColumn", + "Table.AddIndexColumn", + "Table.AddJoinColumn", + "Table.AddKey", + "Table.AddRankColumn", + "Table.AggregateTableColumn", + "Table.AlternateRows", + "Table.ApproximateRowCount", + "Table.Buffer", + "Table.Column", + "Table.ColumnCount", + "Table.ColumnNames", + "Table.ColumnsOfType", + "Table.Combine", + "Table.CombineColumns", + "Table.CombineColumnsToRecord", + "Table.ConformToPageReader", + "Table.Contains", + "Table.ContainsAll", + "Table.ContainsAny", + "Table.DemoteHeaders", + "Table.Distinct", + "Table.DuplicateColumn", + "Table.ExpandListColumn", + "Table.ExpandRecordColumn", + "Table.ExpandTableColumn", + "Table.FillDown", + "Table.FillUp", + "Table.FilterWithDataTable", + "Table.FindText", + "Table.First", + "Table.FirstN", + "Table.FirstValue", + "Table.FromColumns", + "Table.FromList", + "Table.FromPartitions", + "Table.FromRecords", + "Table.FromRows", + "Table.FromValue", + "Table.FuzzyGroup", + "Table.FuzzyJoin", + "Table.FuzzyNestedJoin", + "Table.Group", + "Table.HasColumns", + "Table.InsertRows", + "Table.IsDistinct", + "Table.IsEmpty", + "Table.Join", + "Table.Keys", + "Table.Last", + "Table.LastN", + "Table.MatchesAllRows", + "Table.MatchesAnyRows", + "Table.Max", + "Table.MaxN", + "Table.Min", + "Table.MinN", + "Table.NestedJoin", + "Table.Partition", + "Table.PartitionValues", + "Table.Pivot", + "Table.PositionOf", + "Table.PositionOfAny", + "Table.PrefixColumns", + "Table.Profile", + "Table.PromoteHeaders", + "Table.Range", + "Table.RemoveColumns", + "Table.RemoveFirstN", + "Table.RemoveLastN", + "Table.RemoveMatchingRows", + "Table.RemoveRows", + "Table.RemoveRowsWithErrors", + "Table.RenameColumns", + "Table.ReorderColumns", + "Table.Repeat", + "Table.ReplaceErrorValues", + "Table.ReplaceKeys", + "Table.ReplaceMatchingRows", + "Table.ReplaceRelationshipIdentity", + "Table.ReplaceRows", + "Table.ReplaceValue", + "Table.ReverseRows", + "Table.RowCount", + "Table.Schema", + "Table.SelectColumns", + "Table.SelectRows", + "Table.SelectRowsWithErrors", + "Table.SingleRow", + "Table.Skip", + "Table.Sort", + "Table.Split", + "Table.SplitAt", + "Table.SplitColumn", + "Table.StopFolding", + "Table.ToColumns", + "Table.ToList", + "Table.ToRecords", + "Table.ToRows", + "Table.TransformColumnNames", + "Table.TransformColumns", + "Table.TransformColumnTypes", + "Table.TransformRows", + "Table.Transpose", + "Table.Unpivot", + "Table.UnpivotOtherColumns", + "Table.View", + "Table.ViewError", + "Table.ViewFunction", + "Table.WithErrorContext", + "Tables.GetRelationships", + "Teradata.Database", + "Text.AfterDelimiter", + "Text.At", + "Text.BeforeDelimiter", + "Text.BetweenDelimiters", + "Text.Clean", + "Text.Combine", + "Text.Contains", + "Text.End", + "Text.EndsWith", + "Text.Format", + "Text.From", + "Text.FromBinary", + "Text.InferNumberType", + "Text.Insert", + "Text.Length", + "Text.Lower", + "Text.Middle", + "Text.NewGuid", + "Text.PadEnd", + "Text.PadStart", + "Text.PositionOf", + "Text.PositionOfAny", + "Text.Proper", + "Text.Range", + "Text.Remove", + "Text.RemoveRange", + "Text.Repeat", + "Text.Replace", + "Text.ReplaceRange", + "Text.Reverse", + "Text.Select", + "Text.Split", + "Text.SplitAny", + "Text.Start", + "Text.StartsWith", + "Text.ToBinary", + "Text.ToList", + "Text.Trim", + "Text.TrimEnd", + "Text.TrimStart", + "Text.Upper", + "TextEncoding.Type", + "Time.EndOfHour", + "Time.From", + "Time.FromText", + "Time.Hour", + "Time.Minute", + "Time.Second", + "Time.StartOfHour", + "Time.ToRecord", + "Time.ToText", + "TimeZone.Current", + "TraceLevel.Type", + "Type.AddTableKey", + "Type.ClosedRecord", + "Type.Facets", + "Type.ForFunction", + "Type.ForRecord", + "Type.FunctionParameters", + "Type.FunctionRequiredParameters", + "Type.FunctionReturn", + "Type.Is", + "Type.IsNullable", + "Type.IsOpenRecord", + "Type.ListItem", + "Type.NonNullable", + "Type.OpenRecord", + "Type.RecordFields", + "Type.ReplaceFacets", + "Type.ReplaceTableKeys", + "Type.TableColumn", + "Type.TableKeys", + "Type.TableRow", + "Type.TableSchema", + "Type.Union", + "Uri.BuildQueryString", + "Uri.Combine", + "Uri.EscapeDataString", + "Uri.Parts", + "Value.Add", + "Value.Alternates", + "Value.As", + "Value.Compare", + "Value.Divide", + "Value.Equals", + "Value.Expression", + "Value.Firewall", + "Value.FromText", + "Value.Is", + "Value.Lineage", + "Value.Metadata", + "Value.Multiply", + "Value.NativeQuery", + "Value.NullableEquals", + "Value.Optimize", + "Value.RemoveMetadata", + "Value.ReplaceMetadata", + "Value.ReplaceType", + "Value.Subtract", + "Value.Traits", + "Value.Type", + "Value.VersionIdentity", + "Value.Versions", + "Value.ViewError", + "Value.ViewFunction", + "Variable.Value", + "Web.BrowserContents", + "Web.Contents", + "Web.Headers", + "Web.Page", + "WebAction.Request", + "WebMethod.Type", + "Xml.Document", + "Xml.Tables" + ] }, - "fileMetadata": {}, + "fileMetadata": { }, "template": [], "dest": "m-language" } diff --git a/query-languages/m/double-from.md b/query-languages/m/double-from.md index 63132b31f..31c836f6e 100644 --- a/query-languages/m/double-from.md +++ b/query-languages/m/double-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Double.From" -title: "Double.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Double.From" +ms.subservice: m-source --- # Double.From @@ -17,10 +10,10 @@ ms.author: dougklo
 Double.From(value as any, optional culture as nullable text) as nullable number
 
- + ## About -Returns a Double `number` value from the given `value`. If the given `value` is `null`, **Double.From** returns `null`. If the given `value` is `number` within the range of Double, `value` is returned, otherwise an error is returned. If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](/powerquery-m/number-fromtext). An optional `culture` may also be provided (for example, "en-US"). +Returns a Double `number` value from the given `value`. If the given `value` is `null`, **Double.From** returns `null`. If the given `value` is `number` within the range of Double, `value` is returned, otherwise an error is returned. If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](number-fromtext.md). An optional `culture` may also be provided (for example, "en-US"). ## Example 1 @@ -35,3 +28,7 @@ Double.From("4.5") **Output** `4.5` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/duration-days.md b/query-languages/m/duration-days.md index 52a74f39e..8629578b0 100644 --- a/query-languages/m/duration-days.md +++ b/query-languages/m/duration-days.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.Days" -title: "Duration.Days | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.Days" +ms.subservice: m-source --- # Duration.Days @@ -17,21 +10,21 @@ ms.author: dougklo
 Duration.Days(duration as nullable duration) as nullable number
 
- + ## About -Returns the day component of the provided `duration` value, `duration`. +Returns the days portion of `duration`. ## Example 1 -Find the day in #duration(5, 4, 3, 2). +Extract the number of days between two dates. **Usage** ```powerquery-m -Duration.Days(#duration(5, 4, 3, 2)) +Duration.Days(#date(2022, 3, 4) - #date(2022, 2, 25)) ``` **Output** -`5` +`7` diff --git a/query-languages/m/duration-from.md b/query-languages/m/duration-from.md index 7aca5a526..e77fc68ad 100644 --- a/query-languages/m/duration-from.md +++ b/query-languages/m/duration-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.From" -title: "Duration.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.From" +ms.subservice: m-source --- # Duration.From @@ -20,10 +13,11 @@ Duration.From(value as any) as nullable duration ## About -Returns a `duration` value from the given `value`. If the given `value` is `null`, **Duration.From** returns `null`. If the given `value` is `duration`, `value` is returned. Values of the following types can be converted to a `duration` value: +Returns the duration value from the given value. -* `text`: A `duration` value from textual elapsed time forms (d.h:m:s). Refer to [Duration.FromText](duration-fromtext.md) for details. -* `number`: A `duration` equivalent to the number of whole and fractional days expressed by `value`. +* `value`: The value from which the duration is derived. If the given `value` is `null`, this function returns `null`. If the given `value` is a `duration`, `value` is returned. Values of the following types can be converted to a `duration` value: + * `text`: A `duration` value from textual elapsed time forms (d.h:m:s). Refer to [Duration.FromText](duration-fromtext.md) for details. + * `number`: A `duration` equivalent to the number of whole and fractional days expressed by `value`. If `value` is of any other type, an error is returned. @@ -40,3 +34,17 @@ Duration.From(2.525) **Output** `#duration(2, 12, 36, 0)` + +## Example 2 + +Convert the text value `"2.05:55:20.34567"` into a `duration` value. + +**Usage** + +```powerquery-m +Duration.From("2.05:55:20.34567") +``` + +**Output** + +`#duration(2, 5, 55, 20.3456700)` diff --git a/query-languages/m/duration-fromtext.md b/query-languages/m/duration-fromtext.md index 32e09e63d..f9f4760ea 100644 --- a/query-languages/m/duration-fromtext.md +++ b/query-languages/m/duration-fromtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.FromText" -title: "Duration.FromText | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.FromText" +ms.subservice: m-source --- # Duration.FromText diff --git a/query-languages/m/duration-functions.md b/query-languages/m/duration-functions.md index 061d9e58b..0d4ca9869 100644 --- a/query-languages/m/duration-functions.md +++ b/query-languages/m/duration-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Duration functions" -title: "Duration functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration functions" +ms.date: 1/28/2025 +ms.custom: "nonautomated-date" --- # Duration functions @@ -16,16 +10,16 @@ These functions create and manipulate duration values. |Name|Description| |------------|---------------| -|[Duration.Days](duration-days.md)|Returns the day component of a Duration value.| -|[Duration.From](duration-from.md)|Returns a duration value from a value.| -|[Duration.FromText](duration-fromtext.md)|Returns a Duration value from a text value.| -|[Duration.Hours](duration-hours.md)|Returns an hour component of a Duration value.| -|[Duration.Minutes](duration-minutes.md)|Returns a minute component of a Duration value.| -|[Duration.Seconds](duration-seconds.md)|Returns a second component of a Duration value.| -|[Duration.ToRecord](duration-torecord.md)|Returns a record with parts of a Duration value.| -|[Duration.TotalDays](duration-totaldays.md)|Returns the total magnitude of days from a Duration value.| -|[Duration.TotalHours](duration-totalhours.md)|Returns the total magnitude of hours from a Duration value.| -|[Duration.TotalMinutes](duration-totalminutes.md)|Returns the total magnitude of minutes from a Duration value.| -|[Duration.TotalSeconds](duration-totalseconds.md)|Returns the total magnitude of seconds from a duration value.| -|[Duration.ToText](duration-totext.md)|Returns a text value from a Duration value.| +|[Duration.Days](duration-days.md)|Returns the days portion of a duration.| +|[Duration.From](duration-from.md)|Creates a duration from the given value.| +|[Duration.FromText](duration-fromtext.md)|Returns a duration value from a text value.| +|[Duration.Hours](duration-hours.md)|Returns the hours portion of a duration.| +|[Duration.Minutes](duration-minutes.md)|Returns the minutes portion of a duration.| +|[Duration.Seconds](duration-seconds.md)|Returns the seconds portion of a duration.| +|[Duration.ToRecord](duration-torecord.md)|Returns a record containing the parts of the duration.| +|[Duration.TotalDays](duration-totaldays.md)|Returns the total days this duration spans.| +|[Duration.TotalHours](duration-totalhours.md)|Returns the total hours this duration spans.| +|[Duration.TotalMinutes](duration-totalminutes.md)|Returns the total minutes this duration spans.| +|[Duration.TotalSeconds](duration-totalseconds.md)|Returns the total seconds this duration spans.| +|[Duration.ToText](duration-totext.md)|Returns the text of the form "d.h:m:s".| |[#duration](sharpduration.md)|Creates a duration value from days, hours, minutes, and seconds.| diff --git a/query-languages/m/duration-hours.md b/query-languages/m/duration-hours.md index f5ce2bd7b..e3929c830 100644 --- a/query-languages/m/duration-hours.md +++ b/query-languages/m/duration-hours.md @@ -1,30 +1,23 @@ --- description: "Learn more about: Duration.Hours" -title: "Duration.Hours | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.Hours" +ms.subservice: m-source --- # Duration.Hours ## Syntax
-Duration.Hours(duration as nullable duration) as nullable number 
+Duration.Hours(duration as nullable duration) as nullable number
 
## About -Returns the hour component of the provided `duration` value, `duration`. +Returns the hours portion of `duration`. ## Example 1 -Find the hours in #duration(5, 4, 3, 2). +Extract the hours from a duration value. **Usage** diff --git a/query-languages/m/duration-minutes.md b/query-languages/m/duration-minutes.md index dedbb8cef..0fdb0eb74 100644 --- a/query-languages/m/duration-minutes.md +++ b/query-languages/m/duration-minutes.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.Minutes" -title: "Duration.Minutes | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.Minutes" +ms.subservice: m-source --- # Duration.Minutes @@ -20,11 +13,11 @@ Duration.Minutes(duration as nullable duration) as nullable number ## About -Returns the minutes component of the provided `duration` value, `duration`. +Returns the minutes portion of `duration`. ## Example 1 -Find the minutes in #duration(5, 4, 3, 2). +Extract the minutes from a duration value. **Usage** diff --git a/query-languages/m/duration-seconds.md b/query-languages/m/duration-seconds.md index 1759a7f23..05ce0e4a9 100644 --- a/query-languages/m/duration-seconds.md +++ b/query-languages/m/duration-seconds.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.Seconds" -title: "Duration.Seconds | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.Seconds" +ms.subservice: m-source --- # Duration.Seconds @@ -20,11 +13,11 @@ Duration.Seconds(duration as nullable duration) as nullable number ## About -Returns the seconds component of the provided `duration` value, `duration`. +Returns the seconds portion of `duration`. ## Example 1 -Find the seconds in #duration(5, 4, 3, 2). +Extract the seconds from a duration value. **Usage** diff --git a/query-languages/m/duration-torecord.md b/query-languages/m/duration-torecord.md index 676274d3b..fab05a75f 100644 --- a/query-languages/m/duration-torecord.md +++ b/query-languages/m/duration-torecord.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.ToRecord" -title: "Duration.ToRecord | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.ToRecord" +ms.subservice: m-source --- # Duration.ToRecord @@ -17,7 +10,7 @@ ms.author: dougklo
 Duration.ToRecord(duration as duration) as record
 
- + ## About Returns a record containing the parts the duration value, `duration`. diff --git a/query-languages/m/duration-totaldays.md b/query-languages/m/duration-totaldays.md index a1e6b63dc..50585a8b6 100644 --- a/query-languages/m/duration-totaldays.md +++ b/query-languages/m/duration-totaldays.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.TotalDays" -title: "Duration.TotalDays | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.TotalDays" +ms.subservice: m-source --- # Duration.TotalDays @@ -17,14 +10,14 @@ ms.author: dougklo
 Duration.TotalDays(duration as nullable duration) as nullable number
 
- + ## About -Returns the total days spanned by the provided `duration` value, `duration`. +Returns the total days spanned by `duration`. ## Example 1 -Find the total days spanned in #duration(5, 4, 3, 2). +Find the total days spanned by a duration value. **Usage** diff --git a/query-languages/m/duration-totalhours.md b/query-languages/m/duration-totalhours.md index 54a880b8d..4b6a679b3 100644 --- a/query-languages/m/duration-totalhours.md +++ b/query-languages/m/duration-totalhours.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.TotalHours" -title: "Duration.TotalHours | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.TotalHours" +ms.subservice: m-source --- # Duration.TotalHours @@ -20,11 +13,11 @@ Duration.TotalHours(duration as nullable duration) as nullable number ## About -Returns the total hours spanned by the provided `duration` value, `duration`. +Returns the total hours spanned by `duration`. ## Example 1 -Find the total hours spanned in #duration(5, 4, 3, 2). +Find the total hours spanned by a duration value. **Usage** diff --git a/query-languages/m/duration-totalminutes.md b/query-languages/m/duration-totalminutes.md index ff327cd13..41ee1afb9 100644 --- a/query-languages/m/duration-totalminutes.md +++ b/query-languages/m/duration-totalminutes.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.TotalMinutes" -title: "Duration.TotalMinutes | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.TotalMinutes" +ms.subservice: m-source --- # Duration.TotalMinutes @@ -20,11 +13,11 @@ Duration.TotalMinutes(duration as nullable duration) as nullable number ## About -Returns the total minutes spanned by the provided `duration` value, `duration`. +Returns the total minutes spanned by `duration`. ## Example 1 -Find the total minutes spanned in #duration(5, 4, 3, 2). +Find the total minutes spanned by a duration value. **Usage** diff --git a/query-languages/m/duration-totalseconds.md b/query-languages/m/duration-totalseconds.md index dd310831e..5b492aa44 100644 --- a/query-languages/m/duration-totalseconds.md +++ b/query-languages/m/duration-totalseconds.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.TotalSeconds" -title: "Duration.TotalSeconds | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.TotalSeconds" +ms.subservice: m-source --- # Duration.TotalSeconds @@ -20,11 +13,11 @@ Duration.TotalSeconds(duration as nullable duration) as nullable number ## About -Returns the total seconds spanned by the provided `duration` value, `duration`. +Returns the total seconds spanned by `duration`. ## Example 1 -Find the total seconds spanned in #duration(5, 4, 3, 2). +Find the total seconds spanned by a duration value. **Usage** diff --git a/query-languages/m/duration-totext.md b/query-languages/m/duration-totext.md index f9caf3e8a..9aba19a32 100644 --- a/query-languages/m/duration-totext.md +++ b/query-languages/m/duration-totext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Duration.ToText" -title: "Duration.ToText | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Duration.ToText" +ms.subservice: m-source --- # Duration.ToText diff --git a/query-languages/m/durations.md b/query-languages/m/durations.md new file mode 100644 index 000000000..2810ff6ee --- /dev/null +++ b/query-languages/m/durations.md @@ -0,0 +1,266 @@ +--- +description: "Learn more about: Durations in Power Query M" +title: "Durations in Power Query M" +ms.date: 8/6/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-background +--- + +# Duration support in Power Query M + +A duration in Power Query M represents the difference between two points in time, expressed in days, hours, minutes, and seconds. Whether you're calculating the time between customer interactions, filtering records based on elapsed time, or building dynamic time-based logic, durations are essential for creating robust and intelligent data models. + +This article explores the structure, creation, and manipulation of durations in Power Query M. It includes practical examples and shares tips to help you use durations effectively in your own data workflows. + +## Create a duration + +A duration is defined by the `#duration(, , , )` function. For example, `#duration(2, 3, 0, 0)` represents a duration of 2 days and 3 hours. Power Query M provides several ways to create a duration, depending on the context and the level of precision required. + +### Use the #duration function + +The most direct way to create a duration is with the `#duration(, , , )` syntax. Each argument must be a number, and the result is a duration value. + +`#duration(2, 5, 30, 0) // 2 days, 5 hours, 30 minutes` + +This function supports fractional seconds as well: + +`#duration(0, 0, 0, 1.75) // 1.75 seconds` + +### Create durations from date and time values + +Durations can also be created by subtracting one date and time value from another. The result is a duration representing the time span between the two. + +```powerquery-m +let + Source = + { + #date(2025, 7, 24) - #date(2025, 7, 23), + // Result: #duration(1, 0, 0, 0) + #time(12, 0, 0) - #time(11, 30, 30), + // Result: #duration(0, 0, 29, 30) + #datetime(2025, 7, 24, 12, 0, 0) - #datetime(2025, 7, 23, 12, 0, 0), + // Result: #duration(1, 0, 0, 0) + #datetimezone(2025, 7, 24, 12, 0, 0, 7, 0) - #datetimezone(2025, 7, 23, 10, 30, 0, 4, 0), + // Result: #duration(0, 22, 30, 0) + #datetime(2025, 7, 24, 12, 0, 0) - DateTime.From(#date(2025, 7, 23)) + // Result: #duration(1, 12, 0, 0) + } +in + Source +``` + +> [!NOTE] +> Subtracting one date and time type from a different date and time type (for example, subtracting a `date` value from a `datetime` value) results in an error. If you must use different date and time types to determine a duration, use the [Date.From](date-from.md), [DateTime.From](datetime-from.md), [DateTimeZone.From](datetimezone-from.md), or [Time.From](time-from.md) functions to explicitly change one of the date and time types. + +### Convert from compatible values + +The [Duration.From](duration-from.md) function can convert compatible values into durations. For more information, go to [Duration.From(value)](#durationfromvalue). + +## Work with durations + +Once a duration is created in Power Query M, it can be manipulated using various operations and functions. These capabilities make durations highly versatile for time-based logic and calculations. + +### Arithmetic operations + +Durations support standard arithmetic operations: + +* Addition and subtraction: Add or subtract durations to or from each other or from date and time values. + + ```powerquery-m + let + Source = { + #duration(1, 2, 0, 0) + #duration(0, 3, 30, 0), + // Result: #duration(1, 5, 30, 0) + #duration(1, 2, 0, 0) - #duration(0, 3, 30, 0), + // Result: #duration(0, 22, 30, 0) + #datetime(2025, 7, 24, 12, 0, 0) + #duration(0, 2, 0, 0), + // Result: #datetime(2025, 7, 24, 14, 0, 0) + #datetime(2025, 7, 24, 12, 0, 0) - #duration(0, 2, 0, 0), + // Result: #datetime(2025, 7, 24, 10, 0, 0) + #time(12, 0, 0) - #duration(0, 3, 30, 0) + // Result: #time(8, 30, 0) + } + in + Source + ``` + +* Negation: A duration can be negated to reverse its direction. + + ```powerquery-m + let + Source = { + #datetime(2025, 7, 24, 12, 0, 0) + -#duration(0, 2, 0, 0), + // Result (subtracts two hours): #datetime(2025, 7, 24, 10, 0, 0) + #datetime(2025, 7, 23, 12, 0, 0) - #datetime(2025, 7, 24, 12, 0, 0) + // Result: -#duration(1, 0, 0, 0) + } + in + Source + ``` + +### Multiplication and division + +Durations can be multiplied or divided by numeric values: + +```powerquery-m +let + Source = { + #duration(0, 2, 0, 0) * 2, + // Result (4 hours): #duration(0, 4, 0, 0) + #duration(1, 0, 0, 0) / 2 + // Result (12 hours): #duration(0, 12, 0, 0) + } +in + Source +``` + +This calculation is useful for scaling durations or averaging time intervals. + +### Comparisons + +Durations can be compared using standard comparison operators: + +```powerquery-m +let + Source = #duration(1, 0, 0, 0) > #duration(0, 23, 59, 59) + // Result: true +in + Source +``` + +This calculation allows durations to be used in conditional logic, such as filtering rows based on elapsed time. + +### Type compatibility + +Durations are compatible with date and time values in arithmetic expressions but not interchangeable with them. For example, subtracting two date and time values yields a `duration`, but adding two date and time values is invalid. + +```powerquery-m +let + Source = + { + #datetime(2025, 7, 24, 12, 0, 0) - #datetime(2025, 7, 23, 12, 0, 0), + // Result: #duration(1, 0, 0, 0) + #datetime(2025, 7, 24, 12, 0, 0) + #datetime(2025, 7, 23, 12, 0, 0) + // Result: Error + } +in + Source +``` + +## Duration functions in M + +Power Query M includes a set of built-in functions for working with durations. These functions allow for conversion, extraction of components, and aggregation of duration values, making them essential tools for time-based transformations. + +### Duration.From(value) + +The [Duration.From](duration-from.md) function converts a compatible value into a duration. Compatible values consist of either a number that's interpreted as a fraction of a day or a textual representation of a duration. Go to [Duration.FromText](duration-fromtext.md) for information about the textual representation formats. + +```powerquery-m +let + Source = + { + Duration.From(1.5), + // Result: 1.5 days = #duration(1, 12, 0, 0) + Duration.From("2.05:55:20.242") + // Result: #duration(2, 5, 55, 20.242) + } +in + Source +``` + +### Component accessors + +These functions extract specific parts of a duration: + +* `Duration.Days()` + + Returns the number of whole days in the duration. + +* `Duration.Hours()` + + Returns the number of hours beyond the whole days. + +* `Duration.Minutes()` + + Returns the number of minutes beyond the whole hours. + +* `Duration.Seconds()` + + Returns the number of seconds beyond the whole minutes. + +```powerquery-m +let + Source = #duration(2, 5, 30, 45), + TextFormat = Text.Format( + "Duration = #{0} days, #{1} hours, #{2} minutes, and #{3} seconds.", + { + Duration.Days(Source), + Duration.Hours(Source), + Duration.Minutes(Source), + Duration.Seconds(Source) + } + ) + // Results: "Duration = 2 days, 5 hours, 30 minutes, and 45 seconds." +in + TextFormat +``` + +### Total value functions + +These functions return the total value of a duration in a single unit, including fractional parts: + +* `Duration.TotalDays()` +* `Duration.TotalHours()` +* `Duration.TotalMinutes()` +* `Duration.TotalSeconds()` + +```powerquery-m +let + Source = + { + Duration.TotalDays(#duration(1, 12, 0, 0)), // 1.5 days + Duration.TotalHours(#duration(1, 12, 0, 0)), // 36 hours + Duration.TotalMinutes(#duration(1, 12, 0, 0)), // 2160 minutes + Duration.TotalSeconds(#duration(1, 12, 0, 0)) // 129600 seconds + } +in + Source +``` + +## Duration normalization + +In most cases, duration is composed of days, hours (maximum 23 hours), minutes (maximum 59 minutes), and seconds (maximum 59.9999999 seconds). However, in some cases you might exceed the maximum values in the duration parameters. In this case, Power Query M automatically normalizes these values: + +* Seconds overflow into minutes +* Minutes overflow into hours +* Hours overflow into days + +For example, suppose you have a column that provides the start date and time for a running process. In addition, you have a column that shows how long it took for the process to complete, in seconds. You want to create a third column that shows the date and time that the process completes. + +```powerquery-m +let + Source = #table(type table[StartTime = datetime, Seconds = Int64.Type], + { + {#datetime(2025, 7, 25, 8, 0, 0), 5400}, + {#datetime(2025, 7, 25, 13, 15, 0), 86400}, + {#datetime(2025, 7, 24, 22, 30, 0), 172800} + }), + AddSeconds = Table.AddColumn( + Source, + "EndTime", + each [StartTime] + #duration(0, 0, 0, [Seconds]), + type datetime + ) +in + AddSeconds +``` + +The following table is the result of these calculations. + +:::image type="content" source="media/durations/add-seconds-for-duration.png" alt-text="Screenshot of the table containing the end date and time column derived from the start time and duration in seconds."::: + +So, even though you only had the number of seconds that a process took place, Power Query M rolls that duration value up into minutes, hours, and days when the result is evaluated. + +## Represent weeks, months, and years + +Since durations are based on fixed units (days, hours, minutes, seconds), there's no native concept of weeks, months, or years, which vary in length. A `duration` type in Power Query M is a fixed structure that doesn’t account for calendar rules. For accurate duration spans over months or years, subtract one date and time from another instead of using fixed durations. This approach correctly handles leap years, varying month lengths, and daylight savings time (DST). However, also note that some date and time behavior might differ depending on whether the query runs locally (on Power Query Desktop) or online (on Power Query Online). For details, go to [Local, fixed, and UTC variants of current date and time](m-local-fixed-utc-variants.md). In general, avoid relying on fixed durations for long-term calculations. diff --git a/query-languages/m/dynamic-values.md b/query-languages/m/dynamic-values.md index 51743b45c..3aa33908a 100644 --- a/query-languages/m/dynamic-values.md +++ b/query-languages/m/dynamic-values.md @@ -1,23 +1,15 @@ --- description: "Learn more about: Dynamic values" -title: "Dynamic values | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Dynamic values" --- # Dynamic values The Power Query M formula language includes these dynamic values. ## List of dynamic values - -|Name|Description| -|------------|---------------| + +|Name|Description| +|------------|---------------| |[Culture.Current](culture-current.md)|Returns the name of the current culture for the application.| |[TimeZone.Current](timezone-current.md)|Returns the name of the current time zone for the application.| diff --git a/query-languages/m/embedded-value.md b/query-languages/m/embedded-value.md index d8a1df407..61a0b11d9 100644 --- a/query-languages/m/embedded-value.md +++ b/query-languages/m/embedded-value.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Embedded.Value" -title: "Embedded.Value | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Embedded.Value" +ms.subservice: m-source --- # Embedded.Value @@ -19,4 +12,5 @@ Embedded.Value(value as any, path as text) as any ## About + Accesses a value by name in an embedded mashup. diff --git a/query-languages/m/enumerations.md b/query-languages/m/enumerations.md index 8860e180c..a361f3c06 100644 --- a/query-languages/m/enumerations.md +++ b/query-languages/m/enumerations.md @@ -1,21 +1,15 @@ --- description: "Learn more about: Enumerations" -title: "Accessing data enumerations | Microsoft Docs" -ms.date: 6/27/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Accessing data enumerations" --- # Enumerations The Power Query M formula language includes these enumerations. ## List of enumerations - -|Name|Description| -|------------|---------------| + +|Name|Description| +|------------|---------------| |[AccessControlKind.Type](accesscontrolkind-type.md)|Specifies the kind of access control.| |[BinaryEncoding.Type](binaryencoding-type.md)|Specifies the type of binary encoding.| |[BinaryOccurrence.Type](binaryoccurrence-type.md)|Specifies how many times the item is expected to appear in the group.| @@ -44,5 +38,5 @@ The Power Query M formula language includes these enumerations. |[SapHanaDistribution.Type](saphanadistribution-type.md)|Specifies valid options for SAP HANA distribution option.| |[SapHanaRangeOperator.Type](saphanarangeoperator-type.md)|Specifies a range operator for SAP HANA range input parameters.| |[TextEncoding.Type](textencoding-type.md) | Specifies the text encoding type.| -|[TraceLevel.Type](tracelevel-type.md)|Specifies the trace level.| +|[TraceLevel.Type](tracelevel-type.md)|Specifies the trace level.| |[WebMethod.Type](webmethod-type.md) |Specifies an HTTP method.| diff --git a/query-languages/m/error-handling.md b/query-languages/m/error-handling.md index 188e9d497..f89ee7ee4 100644 --- a/query-languages/m/error-handling.md +++ b/query-languages/m/error-handling.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Error handling functions" -title: "Error handling functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Error handling functions" +ms.date: 7/15/2024 +ms.custom: "nonautomated-date" --- # Error handling functions @@ -17,5 +11,6 @@ These functions can be used to trace or construct errors. |Name|Description| |------------|---------------| |[Diagnostics.ActivityId](diagnostics-activityid.md)|Returns an opaque identifier for the currently-running evaluation.| +|[Diagnostics.CorrelationId](diagnostics-correlationid.md)|Returns an opaque identifier to correlate incoming requests with outgoing ones.| |[Diagnostics.Trace](diagnostics-trace.md)|Writes a trace message, if tracing is enabled, and returns value.| -|[Error.Record](error-record.md)|Returns a record containing fields **Reason**, **Message**, and **Detail** set to the provided values. The record can be used to raise or throw an error.| +|[Error.Record](error-record.md)|Returns an error record from the provided text values for reason, message, detail, and error code.| diff --git a/query-languages/m/error-record.md b/query-languages/m/error-record.md index 736ba5219..eeab88566 100644 --- a/query-languages/m/error-record.md +++ b/query-languages/m/error-record.md @@ -1,23 +1,22 @@ --- description: "Learn more about: Error.Record" -title: "Error.Record | Microsoft Docs" -ms.date: 1/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Error.Record" +ms.subservice: m-source --- # Error.Record ## Syntax
-Error.Record(reason as text, optional message as nullable text, optional detail as any, optional parameters as nullable list) as record
+Error.Record(
+    reason as text,
+    optional message as nullable text,
+    optional detail as any,
+    optional parameters as nullable list,
+    optional errorCode as nullable text
+) as record
 
- + ## About -Returns an error record from the provided text values for reason, message and detail. +Returns an error record from the provided text values for reason, message, detail, and error code. diff --git a/query-languages/m/errors.md b/query-languages/m/errors.md index f28c82c04..4de066bda 100644 --- a/query-languages/m/errors.md +++ b/query-languages/m/errors.md @@ -1,74 +1,77 @@ --- description: "Learn more about: Errors" -title: "Errors | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Errors" +ms.topic: conceptual +ms.date: 10/7/2022 +ms.custom: "nonautomated-date" +ms.subservice: m-background --- + # Errors -An **error** in Power Query M formula language is an indication that the process of evaluating an expression could not produce a value. Errors are raised by operators and functions encountering **error** conditions or by using the **error** expression. Errors are handled using the **try** expression. When an error is raised, a value is specified that can be used to indicate why the error occurred. - -## Try expression -A try expression converts values and errors into a record value that indicates whether the try expression handled an error, or not, and either the proper value or the error record it extracted when handling the error. For example, consider the following expression that raises an error and then handles it right away: - -```powerquery-m -try error "negative unit count" -``` -This expression evaluates to the following nested record value, explaining the `[HasError], [Error]`, and `[Message]` field lookups in the unit-price example before. - -## Error record - + +An *error* in Power Query M formula language is an indication that the process of evaluating an expression could not produce a value. Errors are raised by operators and functions encountering **error** conditions or by using the **error** expression. Errors are handled using the **try** expression. When an error is raised, a value is specified that can be used to indicate why the error occurred. + +## Try expression + +A try expression converts values and errors into a record value that indicates whether the try expression handled an error, or not, and either the proper value or the error record it extracted when handling the error. For example, consider the following expression that raises an error and then handles it right away: + +```powerquery-m +try error "negative unit count" +``` + +This expression evaluates to the following nested record value, explaining the `[HasError], [Error]`, and `[Message]` field lookups in the unit-price example before. + +## Error record + ```powerquery-m -[ - HasError = true, - Error = +[ + HasError = true, + Error = [ - Reason = "Expression.Error", - Message = "negative unit count", - Detail = null - ] -] -``` -A common case is to replace errors with default values. The try expression can be used with an optional otherwise clause to achieve just that in a compact form: - + Reason = "Expression.Error", + Message = "negative unit count", + Detail = null + ] +] +``` + +A common case is to replace errors with default values. The try expression can be used with an optional otherwise clause to achieve just that in a compact form: + ```powerquery-m -try error "negative unit count" otherwise 42 -// equals 42 -``` - -## Error example - +try error "negative unit count" otherwise 42 +// equals 42 +``` + +## Error example + ```powerquery-m -let Sales = - [ - ProductName = "Fishing rod", - Revenue = 2000, - Units = 1000, - UnitPrice = if Units = 0 then error "No Units" - else Revenue / Units - ], - - //Get UnitPrice from Sales record - textUnitPrice = try Number.ToText(Sales[UnitPrice]), - Label = "Unit Price: " & - (if textUnitPrice[HasError] then textUnitPrice[Error][Message] - //Continue expression flow - else textUnitPrice[Value]) -in - Label -``` -The above example accesses the `Sales[UnitPrice]` field and formats the value producing the result: - +let Sales = + [ + ProductName = "Fishing rod", + Revenue = 2000, + Units = 1000, + UnitPrice = if Units = 0 then error "No Units" + else Revenue / Units + ], + + //Get UnitPrice from Sales record + textUnitPrice = try Number.ToText(Sales[UnitPrice]), + Label = "Unit Price: " & + (if textUnitPrice[HasError] then textUnitPrice[Error][Message] + //Continue expression flow + else textUnitPrice[Value]) +in + Label +``` + +The previous example accesses the `Sales[UnitPrice]` field and formats the value producing the result: + ```powerquery-m -"Unit Price: 2" -``` -If the Units field had been zero, then the `UnitPrice` field would have raised an error which would have been handled by the try. The resulting value would then have been: - +"Unit Price: 2" +``` + +If the Units field had been zero, then the `UnitPrice` field would have raised an error which would have been handled by the try. The resulting value would then have been: + ```powerquery-m -"No Units" -``` +"No Units" +``` diff --git a/query-languages/m/essbase-cubes.md b/query-languages/m/essbase-cubes.md index d87a04fc8..f1e14d9d3 100644 --- a/query-languages/m/essbase-cubes.md +++ b/query-languages/m/essbase-cubes.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Essbase.Cubes" -title: "Essbase.Cubes | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Essbase.Cubes" +ms.subservice: m-source --- # Essbase.Cubes @@ -17,9 +11,8 @@ ms.author: dougklo Essbase.Cubes(url as text, optional options as nullable record) as table -## About - -Returns a table of cubes grouped by Essbase server from an Essbase instance at APS server `url`. An optional record parameter, `options`, may be specified to control the following options: -- `CommandTimeout` : A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. +## About +Returns a table of cubes grouped by Essbase server from an Essbase instance at APS server `url`. An optional record parameter, `options`, may be specified to control the following options: +* `CommandTimeout`: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. diff --git a/query-languages/m/evaluation-model.md b/query-languages/m/evaluation-model.md index e90a9e815..ae2b5e086 100644 --- a/query-languages/m/evaluation-model.md +++ b/query-languages/m/evaluation-model.md @@ -1,82 +1,84 @@ --- description: "Learn more about: Evaluation model" -title: "Evaluation model | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Evaluation model" +ms.topic: conceptual +ms.date: 10/7/2022 +ms.custom: "nonautomated-date" +ms.subservice: m-background --- # Evaluation model -The evaluation model of the Power Query M formula language is modeled after the evaluation model commonly found in spreadsheets, where the order of calculations can be determined based on dependencies between the formulas in the cells. -If you have written formulas in a spreadsheet such as Excel, you may recognize the formulas on the left will result in the values on the right when calculated: - -![Evaluation Model 1](media/evaluation-model-1.png "Evaluation Model 1") - -![Evaluation Model 2](media/evaluation-model-2.png "Evaluation Model 2") - -In M, an expression can reference previous expressions by name, and the evaluation process will automatically determine the order in which referenced expressions are calculated. - -Let’s use a record to produce an expression which is equivalent to the above spreadsheet example. When initializing the value of a field, you refer to other fields within the record by the name of the field, as follows: - + +The evaluation model of the Power Query M formula language is modeled after the evaluation model commonly found in spreadsheets, where the order of calculations can be determined based on dependencies between the formulas in the cells. + +If you have written formulas in a spreadsheet such as Excel, you may recognize the formulas on the left will result in the values on the right when calculated: + +![Evaluation Model 1](media/evaluation-model-1.png "Evaluation Model 1") + +![Evaluation Model 2](media/evaluation-model-2.png "Evaluation Model 2") + +In M, an expression can reference previous expressions by name, and the evaluation process will automatically determine the order in which referenced expressions are calculated. + +Let's use a record to produce an expression which is equivalent to the above spreadsheet example. When initializing the value of a field, you refer to other fields within the record by the name of the field, as follows: + ```powerquery-m -[ - A1 = A2 * 2, - A2 = A3 + 1, - A3 = 1 -] -``` -The above expression evaluates to the following record: - +[ + A1 = A2 * 2, + A2 = A3 + 1, + A3 = 1 +] +``` + +The above expression evaluates to the following record: + ```powerquery-m -[ - A1 = 4, - A2 = 2, - A3 = 1 -] -``` -Records can be contained within, or **nested**, within other records. You can use the **lookup operator** ([ ]) to access the fields of a record by name. For example, the following record has a field named Sales containing a record, and a field named Total that accesses the FirstHalf and SecondHalf fields of the Sales record: - +[ + A1 = 4, + A2 = 2, + A3 = 1 +] +``` + +Records can be contained within, or **nested**, within other records. You can use the **lookup operator** ([ ]) to access the fields of a record by name. For example, the following record has a field named Sales containing a record, and a field named Total that accesses the FirstHalf and SecondHalf fields of the Sales record: + ```powerquery-m -[ - Sales = [ FirstHalf = 1000, SecondHalf = 1100 ], - Total = Sales[FirstHalf] + Sales[SecondHalf] -] -``` -The above expression evaluates to the following record: - +[ + Sales = [ FirstHalf = 1000, SecondHalf = 1100 ], + Total = Sales[FirstHalf] + Sales[SecondHalf] +] +``` + +The above expression evaluates to the following record: + ```powerquery-m -[ - Sales = [ FirstHalf = 1000, SecondHalf = 1100 ], - Total = 2100 -] -``` -You use the **positional index operator** ({ }) to access an item in a list by its numeric index. The values within a list are referred to using a zero-based index from the beginning of the list. For example, the indexes 0 and 1 are used to reference the first and second items in the list below: - +[ + Sales = [ FirstHalf = 1000, SecondHalf = 1100 ], + Total = 2100 +] +``` + +You use the **positional index operator** ({ }) to access an item in a list by its numeric index. The values within a list are referred to using a zero-based index from the beginning of the list. For example, the indexes 0 and 1 are used to reference the first and second items in the list below: + ```powerquery-m -[ - Sales = - { - [ - Year = 2007, - FirstHalf = 1000, - SecondHalf = 1100, - Total = FirstHalf + SecondHalf // equals 2100 - ], - [ - Year = 2008, - FirstHalf = 1200, - SecondHalf = 1300, - Total = FirstHalf + SecondHalf // equals 2500 - ] - }, - #"Total Sales" = Sales{0}[Total] + Sales{1}[Total] // equals 4600 -] -``` - -## Lazy and eager evaluation -**List**, **Record**, and **Table** member expressions, as well as **let** expressions (See [Expressions, values, and let expression](expressions-values-and-let-expression.md)), are evaluated using **lazy evaluation**: they are evaluated when needed. All other expressions are evaluated using **eager evaluation**: they are evaluated immediately, when encountered during the evaluation process. A good way to think about this is to remember that evaluating a list or record expression will return a list or record value that knows how its list items or record fields need to computed, when requested (by lookup or index operators). - +[ + Sales = + { + [ + Year = 2007, + FirstHalf = 1000, + SecondHalf = 1100, + Total = FirstHalf + SecondHalf // equals 2100 + ], + [ + Year = 2008, + FirstHalf = 1200, + SecondHalf = 1300, + Total = FirstHalf + SecondHalf // equals 2500 + ] + }, + #"Total Sales" = Sales{0}[Total] + Sales{1}[Total] // equals 4600 +] +``` + +## Lazy and eager evaluation + +**List**, **Record**, and **Table** member expressions, as well as **let** expressions (Go to [Expressions, values, and let expression](expressions-values-and-let-expression.md)), are evaluated using **lazy evaluation**. That is, they are evaluated when needed. All other expressions are evaluated using **eager evaluation**. That is, they are evaluated immediately when encountered during the evaluation process. A good way to think about this is to remember that evaluating a list or record expression will return a list or record value that knows how its list items or record fields need to computed, when requested (by lookup or index operators). diff --git a/query-languages/m/excel-currentworkbook.md b/query-languages/m/excel-currentworkbook.md index 2e5535077..7b1529967 100644 --- a/query-languages/m/excel-currentworkbook.md +++ b/query-languages/m/excel-currentworkbook.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Excel.CurrentWorkbook" -title: "Excel.CurrentWorkbook | Microsoft Docs" -ms.date: 7/16/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Excel.CurrentWorkbook" +ms.subservice: m-source --- # Excel.CurrentWorkbook ## Syntax
-Excel.CurrentWorkbook() as table  
+Excel.CurrentWorkbook() as table
 
- -## About -Returns the contents of the current Excel workbook. +## About + +Returns the contents of the current Excel workbook. It returns tables, named ranges, and dynamic arrays. Unlike [Excel.Workbook](excel-workbook.md), it does not return sheets. diff --git a/query-languages/m/excel-shapetable.md b/query-languages/m/excel-shapetable.md index 5ba8eed8a..f33522be4 100644 --- a/query-languages/m/excel-shapetable.md +++ b/query-languages/m/excel-shapetable.md @@ -1,17 +1,10 @@ --- description: "Learn more about: Excel.ShapeTable" -title: "Excel.ShapeTable | Microsoft Docs" -ms.date: 1/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Excel.ShapeTable" +ms.subservice: m-source --- # Excel.ShapeTable - + ## Syntax
diff --git a/query-languages/m/excel-workbook.md b/query-languages/m/excel-workbook.md
index b8172b301..73fbd9234 100644
--- a/query-languages/m/excel-workbook.md
+++ b/query-languages/m/excel-workbook.md
@@ -1,26 +1,23 @@
 ---
 description: "Learn more about: Excel.Workbook"
-title: "Excel.Workbook | Microsoft Docs"
-ms.date: 4/13/2022
-ms.service: powerquery
-
-ms.reviewer: ehvonleh
-ms.topic: reference
-author: dougklopfenstein
-ms.author: dougklo
-
+title: "Excel.Workbook"
+ms.subservice: m-source
 ---
 # Excel.Workbook
-  
+
 ## Syntax
 
 
-Excel.Workbook(workbook as binary, optional useHeaders as any, optional delayTypes as nullable logical) as table
+Excel.Workbook(
+    workbook as binary,
+    optional useHeaders as any,
+    optional delayTypes as nullable logical
+) as table
 
## About -Returns the contents of the Excel workbook. +Returns the contents of the Excel workbook. * `useHeaders` can be null, a logical (true/false) value indicating whether the first row of each returned table should be treated as a header, or an options record. Default: false. * `delayTypes` can be null or a logical (true/false) value indicating whether the columns of each returned table should be left untyped. Default: false. @@ -31,6 +28,9 @@ If a record is specified for `useHeaders` (and `delayTypes` is null), the follow * `DelayTypes`: Can be null or a logical (true/false) value indicating whether the columns of each returned table should be left untyped. Default: false. * `InferSheetDimensions`: Can be null or a logical (true/false) value indicating whether the area of a worksheet that contains data should be inferred by reading the worksheet itself, rather than by reading the dimensions metadata from the file. This can be useful in cases where the dimensions metadata is incorrect. Note that this option is only supported for Open XML Excel files, not for legacy Excel files. Default: false. +> [!NOTE] +> The `useHeaders` parameter or the `UseHeaders` record field converts numbers and dates to text using the current culture, and thus behaves differently when run in environments with different operating system cultures set. We recommend using [Table.PromoteHeaders](table-promoteheaders.md) instead. For example, instead of using `Excel.Workbook(File.Contents("C:\myfile.xlsx", true, true))` or `Excel.Workbook(File.Contents("C:\myfile.xlsx", [UseHeaders = true], null))`, use `Table.PromoteHeaders(Excel.Workbook(File.Contents("C:\myfile.xlsx", null, true), [PromoteAllScalars = true]))` instead. + ## Example 1 Return the contents of Sheet1 from an Excel workbook. diff --git a/query-languages/m/exchange-contents.md b/query-languages/m/exchange-contents.md index 13911d1d1..2e8a0193a 100644 --- a/query-languages/m/exchange-contents.md +++ b/query-languages/m/exchange-contents.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Exchange.Contents" -title: "Exchange.Contents | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Exchange.Contents" +ms.subservice: m-source --- # Exchange.Contents ## Syntax
-Exchange.Contents (optional mailboxAddress as nullable text) as table  
+Exchange.Contents (optional mailboxAddress as nullable text) as table
 
- -## About + +## About + Returns a table of contents from the Microsoft Exchange account `mailboxAddress`. If `mailboxAddress` is not specified, the default account for the credential will be used. - diff --git a/query-languages/m/expression-constant.md b/query-languages/m/expression-constant.md index 3fed95907..89419a6f7 100644 --- a/query-languages/m/expression-constant.md +++ b/query-languages/m/expression-constant.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Expression.Constant" -title: "Expression.Constant | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Expression.Constant" +ms.subservice: m-source --- # Expression.Constant - ## Syntax
-Expression.Constant(value as any) as text  
+Expression.Constant(value as any) as text
 
- + ## About Returns the M source code representation of a constant value. diff --git a/query-languages/m/expression-evaluate.md b/query-languages/m/expression-evaluate.md index 075af386b..06d603759 100644 --- a/query-languages/m/expression-evaluate.md +++ b/query-languages/m/expression-evaluate.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Expression.Evaluate" -title: "Expression.Evaluate | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Expression.Evaluate" +ms.subservice: m-source --- # Expression.Evaluate @@ -16,7 +10,7 @@ ms.author: dougklo
 Expression.Evaluate(document as text, optional environment as nullable record) as any
 
- + ## About Returns the result of evaluating an M expression `document`, with the available identifiers that can be referenced defined by `environment`. diff --git a/query-languages/m/expression-functions.md b/query-languages/m/expression-functions.md index c7cf3ea0c..93cd5ac37 100644 --- a/query-languages/m/expression-functions.md +++ b/query-languages/m/expression-functions.md @@ -1,13 +1,8 @@ --- description: "Learn more about: Expression functions" -title: "Expression functions | Microsoft Docs" -ms.date: 5/16/2020 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Expression functions" +ms.date: 8/11/2025 +ms.custom: "nonautomated-date" --- # Expression functions diff --git a/query-languages/m/expression-identifier.md b/query-languages/m/expression-identifier.md index 999d904a1..06c442707 100644 --- a/query-languages/m/expression-identifier.md +++ b/query-languages/m/expression-identifier.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Expression.Identifier" -title: "Expression.Identifier | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Expression.Identifier" +ms.subservice: m-source --- # Expression.Identifier @@ -16,7 +10,7 @@ ms.author: dougklo
 Expression.Identifier(name as text) as text
 
- + ## About Returns the M source code representation of an identifier `name`. diff --git a/query-languages/m/expressions-values-and-let-expression.md b/query-languages/m/expressions-values-and-let-expression.md index adf82193d..e8ac59078 100644 --- a/query-languages/m/expressions-values-and-let-expression.md +++ b/query-languages/m/expressions-values-and-let-expression.md @@ -1,238 +1,259 @@ --- description: "Learn more about: Expressions, values, and let expression" -title: "Expressions, values, and let expression | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Expressions, values, and let expression" +ms.topic: conceptual +ms.date: 8/11/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-background --- # Expressions, values, and let expression -A Power Query M formula language query is composed of formula **expression** steps that create a mashup query. A formula expression can be evaluated (computed), yielding a value. The **let** expression encapsulates a set of values to be computed, assigned names, and then used in a subsequent expression that follows the **in** statement. For example, a let expression could contain a **Source** variable that equals the value of **Text.Proper()** and yields a text value in proper case. - -## Let expression - + +A Power Query M formula language query is composed of formula **expression** steps that create a mashup query. A formula expression can be evaluated (computed), yielding a value. The **let** expression encapsulates a set of values to be computed, assigned names, and then used in a subsequent expression that follows the **in** statement. For example, a let expression could contain a **Source** variable that equals the value of [Text.Proper](text-proper.md) and yields a text value in proper case. + +## Let expression + +```powerquery-m +let + Source = Text.Proper("hello world") +in + Source +``` + +In this example, `Text.Proper("hello world")` is evaluated to `"Hello World"`. + +The next sections describe value types in the language. + +## Primitive value + +A *primitive* value is single-part value, such as a `number`, `logical`, `text`, or `null`. A `null` value can be used to indicate the absence of any data. + +|Type|Example value| +|--------|-----------------| +|Binary|00 00 00 02 // number of points (2)| +|Date|5/23/2015| +|DateTime|5/23/2015 12:00:00 AM| +|DateTimeZone|5/23/2015 12:00:00 AM -08:00| +|Duration|15:35:00| +|Logical|true and false| +|Null|null| +|Number|0, 1, -1, 1.5, and 2.3e-5| +|Text|"abc"| +|Time|12:34:12 PM| + +## Function value + +A *Function* is a value that, when invoked with arguments, produces a new value. Functions are written by listing the function's *parameters* in parentheses, followed by the goes-to symbol =>, followed by the expression defining the function. For example, to create a function called **MyFunction** that has two parameters and performs a calculation on parameter1 and parameter2: + ```powerquery-m -let - Source = Text.Proper("hello world") -in - Source -``` -In the example above, Text.Proper("hello world") is evaluated to "Hello World". - -The next sections describe value types in the language. - -## Primitive value -A **primitive** value is single-part value, such as a number, logical, text, or null. A null value can be used to indicate the absence of any data. - -|Type|Example value| -|--------|-----------------| -|Binary|00 00 00 02 // number of points (2)| -|Date|5/23/2015| -|DateTime|5/23/2015 12:00:00 AM| -|DateTimeZone|5/23/2015 12:00:00 AM -08:00| -|Duration|15:35:00| -|Logical|true and false| -|Null|null| -|Number|0, 1, -1, 1.5, and 2.3e-5| -|Text|"abc"| -|Time|12:34:12 PM| - -## Function value -A **Function** is a value which, when invoked with arguments, produces a new value. Functions are written by listing the function’s **parameters** in parentheses, followed by the goes-to symbol =>, followed by the expression defining the function. For example, to create a function called “MyFunction” that has two parameters and performs a calculation on parameter1 and parameter2: - +let + MyFunction = (parameter1, parameter2) => (parameter1 + parameter2) / 2 +in + MyFunction +``` + +Calling **MyFunction** returns the result: + ```powerquery-m -let - MyFunction = (parameter1, parameter2) => (parameter1 + parameter2) / 2 -in - MyFunction - -Calling the MyFunction() returns the result: - -let - Source = MyFunction(2, 4) -in - Source -``` -This code produces the value of 3. - -## Structured data values -The M language supports the following structured data values: - -- [List](#list) - -- [Record](#record) - -- [Table](#table) - -- [Additional structured data examples](#additional) - -> [!NOTE] -> Structured data can contain any M value. To see a couple of examples, see [Additional structured data examples](#additional). - -### List -A List is a zero-based ordered sequence of values enclosed in curly brace characters { }. The curly brace characters { } are also used to retrieve an item from a List by index position. See \[List value](#_List_value). - -> [!NOTE] -> Power Query M supports an infinite list size, but if a list is written as a literal, the list has a fixed length. For example, {1, 2, 3} has a fixed length of 3. - -The following are some **List** examples. - -|Value|Type| -|---------|--------| -|{123, true, "A"}|List containing a number, a logical, and text.| -|{1, 2, 3}|List of numbers| -|{
{1, 2, 3},
{4, 5, 6}
}|List of List of numbers| -|{
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
}|List of Records| -|{123, true, "A"}{0}|Get the value of the first item in a List. This expression returns the value 123.| -|{
{1, 2, 3},
{4, 5, 6}
}{0}{1}|Get the value of the second item from the first List element. This expression returns the value 2.| - -### Record -A **Record** is a set of fields. A **field** is a name/value pair where the name is a text value that is unique within the field’s record. The syntax for record values allows the names to be written without quotes, a form also referred to as **identifiers**. An identifier can take the following two forms: - -- identifier_name such as OrderID. - -- \#"identifier name" such as #"Today's data is: ". - -The following is a record containing fields named "OrderID", "CustomerID", "Item", and "Price" with values 1, 1, "Fishing rod", and 100.00. Square brace characters [ ] denote the beginning and end of a record expression, and are used to get a field value from a record. The follow examples show a record and how to get the Item field value. - -Here's an example record: - +let + Source = MyFunction(2, 4) +in + Source +``` + +This code produces the value of 3. + +## Structured data values + +The M language supports the following structured data values: + +- [List](#list) + +- [Record](#record) + +- [Table](#table) + +- [Additional structured data examples](#additional-structured-data-examples) + +> [!NOTE] +> Structured data can contain any M value. To see a couple of examples, go to [Additional structured data examples](#additional-structured-data-examples). + +### List + +A *List* is a zero-based ordered sequence of values enclosed in curly brace characters { }. The curly brace characters { } are also used to retrieve an item from a List by index position. For more information, go to [List values](m-spec-values.md#list). + +> [!NOTE] +> Power Query M supports an infinite list size, but if a list is written as a literal, the list has a fixed length. For example, {1, 2, 3} has a fixed length of 3. + +The following are some List examples. + +|Value|Type| +|---------|--------| +|{123, true, "A"}|List containing a number, a logical, and text.| +|{1, 2, 3}|List of numbers| +|{
    {1, 2, 3},
    {4, 5, 6}
}|List of List of numbers| +|{
    [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
    [CustomerID = 2, Name = "Jim", Phone = "987-6543"]
}|List of Records| +|{123, true, "A"}{0}|Get the value of the first item in a List. This expression returns the value 123.| +|{
    {1, 2, 3},
    {4, 5, 6}
}{0}{1}|Get the value of the second item from the first List element. This expression returns the value 2.| + +### Record + +A *Record* is a set of fields. A *field* is a name/value pair where the name is a text value that's unique within the field's record. The syntax for record values allows the names to be written without quotes, a form also referred to as *identifiers*. An identifier can take the following two forms: + +- identifier_name such as OrderID. + +- \#"identifier name" such as #"Today's data is: ". + +The following is a record containing fields named "OrderID", "CustomerID", "Item", and "Price" with values 1, 1, "Fishing rod", and 100.00. Square brace characters [ ] denote the beginning and end of a record expression, and are used to get a field value from a record. The following examples show a record and how to get the Item field value. + +Here's an example record: + ```powerquery-m -let Source = - [ - OrderID = 1, - CustomerID = 1, - Item = "Fishing rod", - Price = 100.00 - ] -in Source -``` -To get the value of an Item, you use square brackets as Source[Item]: - +let + Source = + [ + OrderID = 1, + CustomerID = 1, + Item = "Fishing rod", + Price = 100.00 + ] +in + Source +``` + +To get the value of an Item, you use square brackets as `Source[Item]`: + ```powerquery-m -let Source = - [ - OrderID = 1, - CustomerID = 1, - Item = "Fishing rod", - Price = 100.00 - ] -in Source[Item] //equals "Fishing rod" -``` - -### Table -A **Table** is a set of values organized into named columns and rows. The column type can be implicit or explicit. You can use #table to create a list of column names and list of rows. A **Table** of values is a List in a **List**. The curly brace characters { } are also used to retrieve a row from a **Table** by index position (see [Example 3 – Get a row from a table by index position](#tableIndex)). - -#### Example 1 - Create a table with implicit column types - +let Source = + [ + OrderID = 1, + CustomerID = 1, + Item = "Fishing rod", + Price = 100.00 + ], + GetItem = Source[Item] //equals "Fishing rod" +in + GetItem +``` + +### Table + +A *Table* is a set of values organized into named columns and rows. The column type can be implicit or explicit. You can use [#table](sharptable.md) to create a list of column names and list of rows. A Table of values is a List in a [List](#list). The curly brace characters { } are also used to retrieve a row from a Table by index position (go to [Example 3 - Get a row from a table by index position](#example-3---get-a-row-from-a-table-by-index-position)). + +#### Example 1 - Create a table with implicit column types + ```powerquery-m -let - Source = #table( - {"OrderID", "CustomerID", "Item", "Price"}, - { - {1, 1, "Fishing rod", 100.00}, - {2, 1, "1 lb. worms", 5.00} - }) -in - Source -``` - -#### Example 2 – Create a table with explicit column types - +let + Source = #table( + {"OrderID", "CustomerID", "Item", "Price"}, + { + {1, 1, "Fishing rod", 100.00}, + {2, 1, "1 lb. worms", 5.00} + } + ) +in + Source +``` + +#### Example 2 - Create a table with explicit column types + ```powerquery-m -let - Source = #table( - type table [OrderID = number, CustomerID = number, Item = text, Price = number], - { - {1, 1, "Fishing rod", 100.00}, - {2, 1, "1 lb. worms", 5.00} - } - ) -in - Source -``` -Both of the examples above creates a table with the following shape: - -|OrderID|CustomerID|Item|Price| -|-----------|--------------|--------|---------| -|1|1|Fishing rod|100.00| -|2|1|1 lb. worms|5.00| - -#### Example 3 – Get a row from a table by index position - +let + Source = #table( + type table [OrderID = number, CustomerID = number, Item = text, Price = number], + { + {1, 1, "Fishing rod", 100.00}, + {2, 1, "1 lb. worms", 5.00} + } + ) +in + Source +``` + +Both of the previous examples creates a table with the following shape: + +|OrderID|CustomerID|Item|Price| +|-----------|--------------|--------|---------| +|1|1|Fishing rod|100.00| +|2|1|1 lb. worms|5.00| + +#### Example 3 - Get a row from a table by index position + ```powerquery-m -let - Source = #table( - type table [OrderID = number, CustomerID = number, Item = text, Price = number], - { - {1, 1, "Fishing rod", 100.00}, - {2, 1, "1 lb. worms", 5.00} - } - ) -in - Source{1} -``` -This expression returns the follow record: - -|Field|Value| -|-|-| -|**OrderID**|2| -|**CustomerID**|1| -|**Item**|1 lb. worms| -|**Price**|5| - -### Additional structured data examples -Structured data can contain any M value. Here are some examples: - -#### Example 1 - List with \[Primitive](#_Primitive_value_1) values, \[Function](#_Function_value), and \[Record](#_Record_value) - +let + Source = #table( + type table [OrderID = number, CustomerID = number, Item = text, Price = number], + { + {1, 1, "Fishing rod", 100.00}, + {2, 1, "1 lb. worms", 5.00} + } + ) +in + Source{1} +``` + +This expression returns the follow record: + +|Field|Value| +|-|-| +|**OrderID**|2| +|**CustomerID**|1| +|**Item**|1 lb. worms| +|**Price**|5| + +### Additional structured data examples + +Structured data can contain any M value. Here are some examples: + +#### Example 1 - List with \[Primitive](#_Primitive_value_1) values, \[Function](#_Function_value), and \[Record](#_Record_value) + ```powerquery-m -let - Source = -{ - 1, - "Bob", - DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd"), - [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0] -} -in - Source -``` -Evaluating this expression can be visualized as: - -![List Example 1](media/list-example-1.png "List Example 1") - -### Example 2 - Record containing Primitive values and nested Records - +let + Source = + { + 1, + "Bob", + DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd"), + [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0] + } +in + Source +``` + +Evaluating this expression can be visualized as: + +:::image type="content" source="media/list-example-1.png" alt-text="Diagram of a table that visualizes the expression with a primitive value, a function, and a record."::: + +### Example 2 - Record containing primitive values and nested records + ```powerquery-m -let - Source = [CustomerID = 1, Name = "Bob", Phone = "123-4567", Orders = - { - [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0], - [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0] - }] -in - Source -``` -Evaluating this expression can be visualized as: - -![List Example 2](media/list-example-2.png "List Example 2") - -> [!NOTE] -> Although many values can be written literally as an expression, a value is not an expression. For example, the expression 1 evaluates to the value 1; the expression 1+1 evaluates to the value 2. This distinction is subtle, but important. Expressions are recipes for evaluation; values are the results of evaluation. - -### If expression -The **if** expression selects between two expressions based on a logical condition. For example: - +let + Source = [CustomerID = 1, Name = "Bob", Phone = "123-4567", Orders = + { + [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0], + [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0] + } + ] +in + Source +``` + +Evaluating this expression can be visualized as: + +:::image type="content" source="media/list-example-2.png" alt-text="Diagram of a table that visualizes the expression with several primitive values and nested records."::: + +> [!NOTE] +> Although many values can be written literally as an expression, a value isn't an expression. For example, the expression 1 evaluates to the value 1; the expression 1+1 evaluates to the value 2. This distinction is subtle, but important. Expressions are recipes for evaluation; values are the results of evaluation. + +### If expression + +The **if** expression selects between two expressions based on a logical condition. For example: + ```powerquery-m -if 2 > 1 then - 2 + 2 -else - 1 + 1 -``` -The first expression (2 + 2) is selected if the logical expression (2 > 1) is true, and the second expression (1 + 1) is selected if it is false. The selected expression (in this case 2 + 2) is evaluated and becomes the result of the **if** expression (4). - +if 2 > 1 then + 2 + 2 +else + 1 + 1 +``` + +The first expression (2 + 2) is selected if the logical expression (2 > 1) is true, and the second expression (1 + 1) is selected if it's false. The selected expression (in this case 2 + 2) is evaluated and becomes the result of the **if** expression (4). diff --git a/query-languages/m/extravalues-type.md b/query-languages/m/extravalues-type.md index e3e2cae24..216f00250 100644 --- a/query-languages/m/extravalues-type.md +++ b/query-languages/m/extravalues-type.md @@ -1,13 +1,7 @@ --- description: "Learn more about: ExtraValues.Type" -title: "ExtraValues.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "ExtraValues.Type" +ms.subservice: m-source --- # ExtraValues.Type diff --git a/query-languages/m/file-contents.md b/query-languages/m/file-contents.md index 24852fe12..6978fce6d 100644 --- a/query-languages/m/file-contents.md +++ b/query-languages/m/file-contents.md @@ -1,12 +1,7 @@ --- description: "Learn more about: File.Contents" -title: "File.Contents | Microsoft Docs" -ms.date: 9/13/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "File.Contents" +ms.subservice: m-source --- # File.Contents @@ -15,7 +10,7 @@ ms.author: dougklo
 File.Contents(path as text, optional options as nullable record) as binary
 
- -## About + +## About Returns the contents of the file, `path`, as binary. The `options` parameter is currently intended for internal use only. diff --git a/query-languages/m/folder-contents.md b/query-languages/m/folder-contents.md index d5f080570..708c5ab26 100644 --- a/query-languages/m/folder-contents.md +++ b/query-languages/m/folder-contents.md @@ -1,12 +1,7 @@ --- description: "Learn more about: Folder.Contents" -title: "Folder.Contents | Microsoft Docs" -ms.date: 9/13/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Folder.Contents" +ms.subservice: m-source --- # Folder.Contents @@ -15,7 +10,7 @@ ms.author: dougklo
 Folder.Contents(path as text, optional options as nullable record) as table
 
- + ## About Returns a table containing a row for each folder and file found in the folder `path`. Each row contains properties of the folder or file and a link to its content. The `options` parameter is currently intended for internal use only. diff --git a/query-languages/m/folder-files.md b/query-languages/m/folder-files.md index 30b26270f..b57a386c2 100644 --- a/query-languages/m/folder-files.md +++ b/query-languages/m/folder-files.md @@ -1,21 +1,35 @@ --- description: "Learn more about: Folder.Files" -title: "Folder.Files | Microsoft Docs" -ms.date: 9/13/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Folder.Files" +ms.subservice: m-source --- # Folder.Files - + ## Syntax
 Folder.Files(path as text, optional options as nullable record) as table
 
- + ## About -Returns a table containing a row for each file found in the folder `path` and all its subfolders. Each row contains properties of the file and a link to its content. The `options` parameter is currently intended for internal use only. +Returns a table containing a row for each file found in the specified folder and all its subfolders. + +* `path`: The path to the folder you want to retrieve the files from. The supplied folder path must be a valid absolute path. +* `options`: This parameter is currently intended for internal use only. + +Each row of the returned table contains properties of the file and a link to its content. + +## Example 1 + +Return a table containing all of the files found in C:\test-examples\example-folder and all of its subfolders. + +**Usage** + +```powerquery-m +Folder.Files("C:\test-examples\example-folder") +``` + +**Output** + +A table containing the files, their properties, and a link to their content. diff --git a/query-languages/m/function-from.md b/query-languages/m/function-from.md index cdf0fa688..01307dd91 100644 --- a/query-languages/m/function-from.md +++ b/query-languages/m/function-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Function.From" -title: "Function.From | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Function.From" +ms.subservice: m-source --- # Function.From diff --git a/query-languages/m/function-invoke.md b/query-languages/m/function-invoke.md index e18111267..599dbe1ad 100644 --- a/query-languages/m/function-invoke.md +++ b/query-languages/m/function-invoke.md @@ -1,35 +1,28 @@ --- description: "Learn more about: Function.Invoke" -title: "Function.Invoke | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Function.Invoke" +ms.subservice: m-source --- # Function.Invoke ## Syntax
-Function.Invoke(function as function, args as list) as any 
+Function.Invoke(function as function, args as list) as any
 
- + ## About Invokes the given function using the specified list of arguments and returns the result. ## Example 1 -Invokes [Record.FieldNames](/powerquery-m/record-fieldnames) with one argument [A=1,B=2] +Invokes [Record.FieldNames](record-fieldnames.md) with one argument [A=1,B=2] **Usage** ```powerquery-m -Function.Invoke(Record.FieldNames, {[A = 1, B = 2]} +Function.Invoke(Record.FieldNames, {[A = 1, B = 2]}) ``` **Output** diff --git a/query-languages/m/function-invokeafter.md b/query-languages/m/function-invokeafter.md index d0e697aee..71671b800 100644 --- a/query-languages/m/function-invokeafter.md +++ b/query-languages/m/function-invokeafter.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Function.InvokeAfter" -title: "Function.InvokeAfter | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Function.InvokeAfter" +ms.subservice: m-source --- # Function.InvokeAfter ## Syntax
-Function.InvokeAfter(function as function, delay as duration) as any 
+Function.InvokeAfter(function as function, delay as duration) as any
 
- -## About + +## About + Returns the result of invoking `function` after duration `delay` has passed. - diff --git a/query-languages/m/function-invokewitherrorcontext.md b/query-languages/m/function-invokewitherrorcontext.md new file mode 100644 index 000000000..8c9f5cb6c --- /dev/null +++ b/query-languages/m/function-invokewitherrorcontext.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Function.InvokeWithErrorContext" +title: "Function.InvokeWithErrorContext" +ms.subservice: m-source +--- +# Function.InvokeWithErrorContext + +## Syntax + +
+Function.InvokeWithErrorContext(function as function, context as text) as any
+
+ +## About + +This function is intended for internal use only. diff --git a/query-languages/m/function-isdatasource.md b/query-languages/m/function-isdatasource.md index be8414946..f5ab32415 100644 --- a/query-languages/m/function-isdatasource.md +++ b/query-languages/m/function-isdatasource.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Function.IsDataSource" -title: "Function.IsDataSource | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Function.IsDataSource" +ms.subservice: m-source --- # Function.IsDataSource @@ -16,8 +9,8 @@ ms.author: dougklo
 Function.IsDataSource(function as function) as logical
-
- -## About +
+ +## About + Returns whether or not `function` is considered a data source. - diff --git a/query-languages/m/function-scalarvector.md b/query-languages/m/function-scalarvector.md index 00a7ed677..d91575038 100644 --- a/query-languages/m/function-scalarvector.md +++ b/query-languages/m/function-scalarvector.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Function.ScalarVector" -title: "Function.ScalarVector | Microsoft Docs" -ms.date: 09/13/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Function.ScalarVector" +ms.subservice: m-source --- # Function.ScalarVector @@ -16,9 +9,9 @@ ms.author: dougklo
 Function.ScalarVector(scalarFunctionType as type, vectorFunction as function) as function
-
- -## About + + +## About Returns a scalar function of type `scalarFunctionType` that invokes `vectorFunction` with a single row of arguments and returns its single output. Additionally, when the scalar function is repeatedly applied for each row of a table of inputs, such as in Table.AddColumn, instead `vectorFunction` will be applied once for all inputs. diff --git a/query-languages/m/function-values.md b/query-languages/m/function-values.md index d44ff6222..b37be3fcb 100644 --- a/query-languages/m/function-values.md +++ b/query-languages/m/function-values.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Function values" -title: "Function values | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Function values" +ms.date: 10/24/2023 +ms.custom: "nonautomated-date" --- # Function values @@ -19,5 +13,6 @@ These functions create and invoke other M functions. |[Function.From](function-from.md)|Takes a unary function `function` and creates a new function with the type `functionType` that constructs a list out of its arguments and passes it to `function`.| |[Function.Invoke](function-invoke.md)|Invokes the given function using the specified and returns the result.| |[Function.InvokeAfter](function-invokeafter.md)|Returns the result of invoking function after duration delay has passed.| +|[Function.InvokeWithErrorContext](function-invokewitherrorcontext.md) | This function is intended for internal use only.| |[Function.IsDataSource](function-isdatasource.md)|Returns whether or not function is considered a data source.| |[Function.ScalarVector](function-scalarvector.md)|Returns a scalar function of type scalarFunctionType that invokes vectorFunction with a single row of arguments and returns its single output. | diff --git a/query-languages/m/geography-fromwellknowntext.md b/query-languages/m/geography-fromwellknowntext.md index 10e7424a8..54011aafb 100644 --- a/query-languages/m/geography-fromwellknowntext.md +++ b/query-languages/m/geography-fromwellknowntext.md @@ -1,16 +1,10 @@ --- description: "Learn more about: Geography.FromWellKnownText" -title: "Geography.FromWellKnownText | Microsoft Docs" -ms.date: 7/16/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Geography.FromWellKnownText" +ms.subservice: m-source --- # Geography.FromWellKnownText + ## Syntax
@@ -18,5 +12,5 @@ Geography.FromWellKnownText(input as nullable text) as nullable record
 
## About -Translates text representing a geographic value in Well-Known Text (WKT) format into a structured record. WKT is a standard format defined by the Open Geospatial Consortium (OGC) and is the typical serialization format used by databases including SQL Server. +Translates text representing a geographic value in Well-Known Text (WKT) format into a structured record. WKT is a standard format defined by the Open Geospatial Consortium (OGC) and is the typical serialization format used by databases including SQL Server. diff --git a/query-languages/m/geography-towellknowntext.md b/query-languages/m/geography-towellknowntext.md index f79d3bb04..4e5ea9f36 100644 --- a/query-languages/m/geography-towellknowntext.md +++ b/query-languages/m/geography-towellknowntext.md @@ -1,16 +1,10 @@ --- description: "Learn more about: Geography.ToWellKnownText" -title: "Geography.ToWellKnownText | Microsoft Docs" -ms.date: 7/16/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Geography.ToWellKnownText" +ms.subservice: m-source --- # Geography.ToWellKnownText + ## Syntax
@@ -18,5 +12,5 @@ Geography.ToWellKnownText(input as nullable record, optional omitSRID<
 
## About -Translates a structured geographic point value into its Well-Known Text (WKT) representation as defined by the Open Geospatial Consortium (OGC), also the serialization format used by many databases including SQL Server. +Translates a structured geographic point value into its Well-Known Text (WKT) representation as defined by the Open Geospatial Consortium (OGC), also the serialization format used by many databases including SQL Server. diff --git a/query-languages/m/geographypoint-from.md b/query-languages/m/geographypoint-from.md index ae41e214f..67d4f31e8 100644 --- a/query-languages/m/geographypoint-from.md +++ b/query-languages/m/geographypoint-from.md @@ -1,22 +1,22 @@ --- description: "Learn more about: GeographyPoint.From" -title: "GeographyPoint.From | Microsoft Docs" -ms.date: 7/16/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "GeographyPoint.From" +ms.subservice: m-source --- # GeographyPoint.From + ## Syntax
-GeographyPoint.From(longitude as number, latitude as number, optional z as nullable number, optional m as nullable number, optional srid as nullable number) as record
+GeographyPoint.From(
+    longitude as number,
+    latitude as number,
+    optional z as nullable number,
+    optional m as nullable number,
+    optional srid as nullable number
+) as record
 
## About -Creates a record representing a geographic point from its constituent parts, such as longitude, latitude, and if present, elevation (Z) and measure (M). An optional spatial reference identifier (SRID) can be given if different from the default value (4326). +Creates a record representing a geographic point from its constituent parts, such as longitude, latitude, and if present, elevation (Z) and measure (M). An optional spatial reference identifier (SRID) can be given if different from the default value (4326). diff --git a/query-languages/m/geometry-fromwellknowntext.md b/query-languages/m/geometry-fromwellknowntext.md index 2e5a9b6ec..7b77c5002 100644 --- a/query-languages/m/geometry-fromwellknowntext.md +++ b/query-languages/m/geometry-fromwellknowntext.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Geometry.FromWellKnownText" -title: "Geometry.FromWellKnownText | Microsoft Docs" -ms.date: 7/16/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Geometry.FromWellKnownText" +ms.subservice: m-source --- # Geometry.FromWellKnownText + ## Syntax
-Geometry.FromWellKnownText(input as nullable text) as nullable record
+Geometry.FromWellKnownText(input as nullable text) as nullable record
 
## About -Translates text representing a geometric value in Well-Known Text (WKT) format into a structured record. WKT is a standard format defined by the Open Geospatial Consortium (OGC) and is the typical serialization format used by databases including SQL Server. +Translates text representing a geometric value in Well-Known Text (WKT) format into a structured record. WKT is a standard format defined by the Open Geospatial Consortium (OGC) and is the typical serialization format used by databases including SQL Server. diff --git a/query-languages/m/geometry-towellknowntext.md b/query-languages/m/geometry-towellknowntext.md index 8c0b822c8..4d2d1baf9 100644 --- a/query-languages/m/geometry-towellknowntext.md +++ b/query-languages/m/geometry-towellknowntext.md @@ -1,16 +1,10 @@ --- description: "Learn more about: Geometry.ToWellKnownText" -title: "Geometry.ToWellKnownText | Microsoft Docs" -ms.date: 7/16/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Geometry.ToWellKnownText" +ms.subservice: m-source --- # Geometry.ToWellKnownText + ## Syntax
@@ -18,5 +12,5 @@ Geometry.ToWellKnownText(input as nullable record, optional omitSRID
 
 ## About
-Translates a structured geometric point value into its Well-Known Text (WKT) representation as defined by the Open Geospatial Consortium (OGC), also the serialization format used by many databases including SQL Server.
 
+Translates a structured geometric point value into its Well-Known Text (WKT) representation as defined by the Open Geospatial Consortium (OGC), also the serialization format used by many databases including SQL Server.
diff --git a/query-languages/m/geometrypoint-from.md b/query-languages/m/geometrypoint-from.md
index a4c6c8dc9..e2a3556aa 100644
--- a/query-languages/m/geometrypoint-from.md
+++ b/query-languages/m/geometrypoint-from.md
@@ -1,21 +1,22 @@
 ---
 description: "Learn more about: GeometryPoint.From"
-title: "GeometryPoint.From | Microsoft Docs"
-ms.date: 7/16/2020
-ms.service: powerquery
-
-ms.reviewer: ehvonleh
-ms.topic: reference
-author: dougklopfenstein
-ms.author: dougklo
-
+title: "GeometryPoint.From"
+ms.subservice: m-source
 ---
 # GeometryPoint.From
+
 ## Syntax
 
 
-GeometryPoint.From(x as number, y as number, optional z as nullable number, optional m as nullable number, optional srid as nullable number) as record
+GeometryPoint.From(
+    x as number,
+    y as number,
+    optional z as nullable number,
+    optional m as nullable number,
+    optional srid as nullable number
+) as record
 
## About + Creates a record representing a geometric point from its constituent parts, such as X coordinate, Y coordinate, and if present, Z coordinate and measure (M). An optional spatial reference identifier (SRID) can be given if different from the default value (0). diff --git a/query-languages/m/googleanalytics-accounts.md b/query-languages/m/googleanalytics-accounts.md index 0a8a1dbb7..96621c364 100644 --- a/query-languages/m/googleanalytics-accounts.md +++ b/query-languages/m/googleanalytics-accounts.md @@ -1,22 +1,16 @@ --- description: "Learn more about: GoogleAnalytics.Accounts" -title: "GoogleAnalytics.Accounts | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "GoogleAnalytics.Accounts" +ms.subservice: m-source --- # GoogleAnalytics.Accounts ## Syntax
-GoogleAnalytics.Accounts() as table
+GoogleAnalytics.Accounts(optional options as nullable record) as table
 
## About + Returns Google Analytics accounts that are accessible from the current credential. diff --git a/query-languages/m/graph-nodes.md b/query-languages/m/graph-nodes.md index 91a0827e0..8b6f51d59 100644 --- a/query-languages/m/graph-nodes.md +++ b/query-languages/m/graph-nodes.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Graph.Nodes" -title: "Graph.Nodes | Microsoft Docs" -ms.date: 9/22/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Graph.Nodes" +ms.subservice: m-source --- # Graph.Nodes ## Syntax -
 
+
 Graph.Nodes(graph as record) as list
 
## About + This function is intended for internal use only. diff --git a/query-languages/m/groupkind-type.md b/query-languages/m/groupkind-type.md index 875a344a7..38e301538 100644 --- a/query-languages/m/groupkind-type.md +++ b/query-languages/m/groupkind-type.md @@ -1,13 +1,7 @@ --- description: "Learn more about: GroupKind.Type" -title: "GroupKind.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "GroupKind.Type" +ms.subservice: m-source --- # GroupKind.Type diff --git a/query-languages/m/guid-from.md b/query-languages/m/guid-from.md index 69cf64f8e..5cf49cc3c 100644 --- a/query-languages/m/guid-from.md +++ b/query-languages/m/guid-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Guid.From" -title: "Guid.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Guid.From" +ms.subservice: m-source --- # Guid.From diff --git a/query-languages/m/hdfs-contents.md b/query-languages/m/hdfs-contents.md index 181b98262..5f5752aa3 100644 --- a/query-languages/m/hdfs-contents.md +++ b/query-languages/m/hdfs-contents.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Hdfs.Contents" -title: "Hdfs.Contents | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Hdfs.Contents" +ms.subservice: m-source --- # Hdfs.Contents - + ## Syntax
 Hdfs.Contents(url as text) as table
-
+
+ +## About -## About Returns a table containing a row for each folder and file found at the folder URL, `url`, from a Hadoop file system. Each row contains properties of the folder or file and a link to its content. diff --git a/query-languages/m/hdfs-files.md b/query-languages/m/hdfs-files.md index 6ab9bb009..c9896e78e 100644 --- a/query-languages/m/hdfs-files.md +++ b/query-languages/m/hdfs-files.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Hdfs.Files" -title: "Hdfs.Files | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Hdfs.Files" +ms.subservice: m-source --- # Hdfs.Files @@ -17,6 +10,7 @@ ms.author: dougklo
 Hdfs.Files(url as text) as table
 
- -## About + +## About + Returns a table containing a row for each file found at the folder URL, `url`, and subfolders from a Hadoop file system. Each row contains properties of the file and a link to its content. diff --git a/query-languages/m/hdinsight-containers.md b/query-languages/m/hdinsight-containers.md index 0b89de797..f1d377f56 100644 --- a/query-languages/m/hdinsight-containers.md +++ b/query-languages/m/hdinsight-containers.md @@ -1,14 +1,7 @@ --- description: "Learn more about: HdInsight.Containers" -title: "HdInsight.Containers | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "HdInsight.Containers" +ms.subservice: m-source --- # HdInsight.Containers @@ -17,6 +10,7 @@ ms.author: dougklo
 HdInsight.Containers(account as text) as table
 
- -## About + +## About + Returns a navigational table containing a row for each container found at the account URL, `account`, from an Azure storage vault. Each row contains a link to the container blobs. diff --git a/query-languages/m/hdinsight-contents.md b/query-languages/m/hdinsight-contents.md index d25444594..65c7cb9fa 100644 --- a/query-languages/m/hdinsight-contents.md +++ b/query-languages/m/hdinsight-contents.md @@ -1,14 +1,7 @@ --- description: "Learn more about: HdInsight.Contents" -title: "HdInsight.Contents | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "HdInsight.Contents" +ms.subservice: m-source --- # HdInsight.Contents @@ -17,6 +10,7 @@ ms.author: dougklo
 HdInsight.Contents(account as text) as table
 
- -## About + +## About + Returns a navigational table containing a row for each container found at the account URL, `account`, from an Azure storage vault. Each row contains a link to the container blobs. diff --git a/query-languages/m/hdinsight-files.md b/query-languages/m/hdinsight-files.md index 729fac9e7..72f39f0a3 100644 --- a/query-languages/m/hdinsight-files.md +++ b/query-languages/m/hdinsight-files.md @@ -1,14 +1,7 @@ --- description: "Learn more about: HdInsight.Files" -title: "HdInsight.Files | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "HdInsight.Files" +ms.subservice: m-source --- # HdInsight.Files @@ -18,5 +11,6 @@ ms.author: dougklo HdInsight.Files(account as text, containerName as text) as table
-## About +## About + Returns a table containing a row for each blob file found at the container URL, `account`, from an Azure storage vault. Each row contains properties of the file and a link to its content. diff --git a/query-languages/m/how-culture-affects-text-formatting.md b/query-languages/m/how-culture-affects-text-formatting.md new file mode 100644 index 000000000..9cc9f6f5f --- /dev/null +++ b/query-languages/m/how-culture-affects-text-formatting.md @@ -0,0 +1,41 @@ +--- +description: "Learn more about: How culture affects text formatting" +title: How culture affects text formatting +ms.date: 10/7/2024 +ms.custom: "nonautomated-date" +ms.subservice: m-background + +--- + +# How culture affects text formatting + +Different countries and language groups have different conventions for formatting different kinds of text, such as numbers, dates, and time. In Power Query, *culture* refers to the locale whose conventions are used to format this type of text in Power Query M. This locale is generally composed of the language and the country where the language is spoken, for example "en-US" for the English language spoken in the United States of America. + +## Default culture + +The default culture is set to the system locale (Windows, MacOS) of a particular document where your queries are first authored. For example, if you author your queries in Power Query Desktop, the default culture is defined by the locale set on your local computer. However, if you author your queries in the Power Query Online, the default culture is defined by the locale set on the online service. No matter where you author your query, if you move your query to a different location that uses a different default culture, your query still uses the culture of the original location. + +To use the current default culture, no culture setting is required in your Power Query M code. + +However, you can change the default culture in the Power Query settings dialog where you create the query. For example, if you are running Power Query from Excel: + +1. In Power Query, select **File** > **Options and settings** > **Query options**. +1. Under **Current Workbook**, select **Regional Settings**. +1. Select the locale you want to use. + +Other versions of Power Query work similarly. In general, within Power Query you select **Options**, which opens the **Options** dialog. Then select **Regional Settings** and select the locale you want to use. + +## Invariant culture + +The invariant culture is culture-insensitive; it's associated with the English language but not with any country or region. You specify the invariant culture by name by using an empty string ("") in functions that include the culture parameter. + +Unlike culture-sensitive data, which is subject to change by user customization or by updates to the operating system, invariant culture data is stable over time and across installed cultures and can't be customized by users. This makes the invariant culture particularly useful for operations that require culture-independent results, such as formatting and parsing operations that persist formatted data, or sorting and ordering operations that require that data be displayed in a fixed order regardless of culture. + +To use the invariant culture in Power Query M, use the blank text value (`""`) in the numeric functions that support culture, or (`Culture = ""`) in date and time functions that support culture. + +## Related content + +- [Standard date and time format strings](standard-date-and-time-format-strings.md) +- [Custom date and time format strings](custom-date-and-time-format-strings.md) +- [Standard numeric format strings](standard-numeric-format-strings.md) +- [Custom numeric format strings](custom-numeric-format-strings.md) diff --git a/query-languages/m/html-table.md b/query-languages/m/html-table.md index 7f3c1ff69..fcb2028d2 100644 --- a/query-languages/m/html-table.md +++ b/query-languages/m/html-table.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Html.Table" -title: "Html.Table | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Html.Table" +ms.subservice: m-source --- # Html.Table ## Syntax
-Html.Table(html as any, columnNameSelectorPairs as list, optional options as nullable record) as table
+Html.Table(
+    html as any,
+    columnNameSelectorPairs as list,
+    optional options as nullable record
+) as table
 
- + ## About Returns a table containing the results of running the specified CSS selectors against the provided `html`. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: diff --git a/query-languages/m/identity-from.md b/query-languages/m/identity-from.md index 786131cbc..98e20e38d 100644 --- a/query-languages/m/identity-from.md +++ b/query-languages/m/identity-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Identity.From" -title: "Identity.From | Microsoft Docs" -ms.date: 3/28/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Identity.From" +ms.subservice: m-source --- # Identity.From @@ -18,6 +11,6 @@ ms.author: dougklo Identity.From(identityProvider as function, value as any) as record -## About +## About Creates an identity. diff --git a/query-languages/m/identity-ismemberof.md b/query-languages/m/identity-ismemberof.md index 48f9d0577..9b4cebf1e 100644 --- a/query-languages/m/identity-ismemberof.md +++ b/query-languages/m/identity-ismemberof.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Identity.IsMemberOf" -title: "Identity.IsMemberOf | Microsoft Docs" -ms.date: 3/28/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Identity.IsMemberOf" +ms.subservice: m-source --- # Identity.IsMemberOf @@ -18,6 +11,6 @@ ms.author: dougklo Identity.IsMemberOf(identity as record, collection as record) as logical -## About +## About Determines whether an identity is a member of an identity collection. diff --git a/query-languages/m/identityprovider-default.md b/query-languages/m/identityprovider-default.md index fb90fe0c6..a187680a6 100644 --- a/query-languages/m/identityprovider-default.md +++ b/query-languages/m/identityprovider-default.md @@ -1,14 +1,7 @@ --- description: "Learn more about: IdentityProvider.Default" -title: "IdentityProvider.Default | Microsoft Docs" -ms.date: 3/28/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "IdentityProvider.Default" +ms.subservice: m-source --- # IdentityProvider.Default @@ -18,6 +11,6 @@ ms.author: dougklo IdentityProvider.Default() as any -## About +## About The default identity provider for the current host. diff --git a/query-languages/m/index.yml b/query-languages/m/index.yml index ff9ebaffe..f2c82b70e 100644 --- a/query-languages/m/index.yml +++ b/query-languages/m/index.yml @@ -1,18 +1,14 @@ ### YamlMime:Landing title: Power Query M formula language -summary: Microsoft Power Query provides a powerful data import experience that encompasses many features. Power Query works with Analysis Services, Excel, and Power BI workbooks. A core capability of Power Query is to filter and combine, that is, to mash-up data from one or more of a rich collection of supported data sources. Any such data mashup is expressed using the Power Query M Formula Language. It's a functional, case sensitive language similar to F#. +summary: Microsoft Power Query provides a powerful data import experience that encompasses many features. Power Query works with desktop Analysis Services, Excel, and Power BI workbooks, in addition to many online services, such as Fabric, Power BI service, Power Apps, Microsoft 365 Customer Insights, and more. A core capability of Power Query is to filter and combine, that is, to mash-up data from one or more of a rich collection of supported data sources. Any such data mashup is expressed using the Power Query M formula language. The M language is a functional, case sensitive language similar to F#. metadata: title: Power Query M formula language reference description: Power Query M is used to filter, combine, and mash-up data from one or more supported data sources. - ms.service: power-query ms.topic: landing-page - ms.collection: - author: dougklopfenstein - ms.author: dougklo - manager: mtillman - ms.date: 10/17/2019 + ms.date: 6/9/2025 + ms.custom: nonautomated-date # linkListType: architecture | concept | deploy | download | get-started | how-to-guide | learn | overview | quickstart | reference | tutorial | whats-new @@ -32,20 +28,14 @@ landingContent: url: expressions-values-and-let-expression.md - text: Evaluation model url: evaluation-model.md + - text: Types and type conversion + url: type-conversion.md + - text: How culture affects text formatting + url: how-culture-affects-text-formatting.md - linkListType: learn links: - text: Power Query documentation - url: https://docs.microsoft.com/en-us/power-query - - # Card - - title: Functions - linkLists: - - linkListType: reference - links: - - text: Power Query M function reference - url: power-query-m-function-reference.md - - linkListType: overview - links: + url: /power-query - text: Understanding Power Query M functions url: understanding-power-query-m-functions.md @@ -57,4 +47,19 @@ landingContent: - text: Power Query M language specification url: power-query-m-language-specification.md - text: Power Query M type system - url: power-query-m-type-system.md \ No newline at end of file + url: power-query-m-type-system.md + + # Card + - title: Reference + linkLists: + - linkListType: reference + links: + - text: Power Query M function reference + url: power-query-m-function-reference.md + - text: Power Query M enumeration reference + url: enumerations.md + - text: Power Query M constant reference + url: constants.md + - text: Power Query M dynamic value reference + url: dynamic-values.md + diff --git a/query-languages/m/informix-database.md b/query-languages/m/informix-database.md index 534a487a9..7e2fe214e 100644 --- a/query-languages/m/informix-database.md +++ b/query-languages/m/informix-database.md @@ -1,30 +1,29 @@ --- description: "Learn more about: Informix.Database" -title: "Informix.Database | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Informix.Database" +ms.subservice: m-source --- # Informix.Database ## Syntax
-Informix.Database(server as text, database as text, optional options as nullable record) as table
+Informix.Database(
+    server as text,
+    database as text,
+    optional options as nullable record
+) as table
 
-## About -Returns a table of SQL tables and views available in an Informix database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: +## About + +Returns a table of SQL tables and views available in an Informix database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: -* `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). -* `NavigationPropertyNameGenerator` : A function that is used for the creation of names for navigation properties. -* `Query` : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. -* `CommandTimeout` : A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. -* `ConnectionTimeout` : 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. -* `HierarchicalNavigation` : A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). +* `NavigationPropertyNameGenerator`: A function that is used for the creation of names for navigation properties. +* `Query`: A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. +* `CommandTimeout`: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. +* `ConnectionTimeout`: 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. +* `HierarchicalNavigation`: A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). - The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. +The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. diff --git a/query-languages/m/int16-from.md b/query-languages/m/int16-from.md index 5f0b70588..213d8937c 100644 --- a/query-languages/m/int16-from.md +++ b/query-languages/m/int16-from.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Int16.From" -title: "Int16.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Int16.From" +ms.subservice: m-source --- # Int16.From ## Syntax
-Int16.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable number
+Int16.From(
+    value as any,
+    optional culture as nullable text,
+    optional roundingMode as nullable number
+) as nullable number
 
- + ## About -Returns a 16-bit integer `number` value from the given `value`. If the given `value` is `null`, **Int16.From** returns `null`. If the given `value` is `number` within the range of 16-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](/powerquery-m/roundingmode-toeven). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](/powerquery-m/number-fromtext). Refer to [Number.Round](/powerquery-m/number-round) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). +Returns a 16-bit integer `number` value from the given `value`. If the given `value` is `null`, **Int16.From** returns `null`. If the given `value` is `number` within the range of 16-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](roundingmode-type.md). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](number-fromtext.md). Refer to [Number.Round](number-round.md) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). ## Example 1 @@ -49,3 +46,7 @@ Int16.From("4.5", null, RoundingMode.AwayFromZero) **Output** `5` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/int32-from.md b/query-languages/m/int32-from.md index edb102590..2855b93e1 100644 --- a/query-languages/m/int32-from.md +++ b/query-languages/m/int32-from.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Int32.From" -title: "Int32.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Int32.From" +ms.subservice: m-source --- # Int32.From ## Syntax
-Int32.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable number
+Int32.From(
+    value as any,
+    optional culture as nullable text,
+    optional roundingMode as nullable number
+) as nullable number
 
- + ## About -Returns a 32-bit integer `number` value from the given `value`. If the given `value` is `null`, **Int32.From** returns `null`. If the given `value` is `number` within the range of 32-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](/powerquery-m/roundingmode-toeven). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](/powerquery-m/number-fromtext). Refer to [Number.Round](/powerquery-m/number-round) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). +Returns a 32-bit integer `number` value from the given `value`. If the given `value` is `null`, **Int32.From** returns `null`. If the given `value` is `number` within the range of 32-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](roundingmode-type.md). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](number-fromtext.md). Refer to [Number.Round](number-round.md) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). ## Example 1 @@ -49,3 +46,7 @@ Int32.From("4.5", null, RoundingMode.AwayFromZero) **Output** `5` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/int64-from.md b/query-languages/m/int64-from.md index eb97243af..fbe16be2f 100644 --- a/query-languages/m/int64-from.md +++ b/query-languages/m/int64-from.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Int64.From" -title: "Int64.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Int64.From" +ms.subservice: m-source --- # Int64.From ## Syntax
-Int64.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable number
+Int64.From(
+    value as any,
+    optional culture as nullable text,
+    optional roundingMode as nullable number
+) as nullable number
 
- + ## About -Returns a 64-bit integer `number` value from the given `value`. If the given `value` is `null`, **Int64.From** returns `null`. If the given `value` is `number` within the range of 64-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](/powerquery-m/roundingmode-toeven). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](/powerquery-m/number-fromtext). Refer to [Number.Round](/powerquery-m/number-round) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). +Returns a 64-bit integer `number` value from the given `value`. If the given `value` is `null`, **Int64.From** returns `null`. If the given `value` is `number` within the range of 64-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](roundingmode-type.md). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](number-fromtext.md). Refer to [Number.Round](number-round.md) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). ## Example 1 @@ -49,3 +46,7 @@ Int64.From("4.5", null, RoundingMode.AwayFromZero) **Output** `5` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/int8-from.md b/query-languages/m/int8-from.md index 035c62517..c32e50b1d 100644 --- a/query-languages/m/int8-from.md +++ b/query-languages/m/int8-from.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Int8.From" -title: "Int8.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Int8.From" +ms.subservice: m-source --- # Int8.From ## Syntax
-Int8.From(value as any, optional culture as nullable text, optional roundingMode as nullable number) as nullable number
+Int8.From(
+    value as any,
+    optional culture as nullable text,
+    optional roundingMode as nullable number
+) as nullable number
 
- + ## About -Returns a signed 8-bit integer `number` value from the given `value`. If the given `value` is `null`, **Int8.From** returns `null`. If the given `value` is `number` within the range of signed 8-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](/powerquery-m/roundingmode-toeven). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](/powerquery-m/number-fromtext). Refer to [Number.Round](/powerquery-m/number-round) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). +Returns a signed 8-bit integer `number` value from the given `value`. If the given `value` is `null`, **Int8.From** returns `null`. If the given `value` is `number` within the range of signed 8-bit integer without a fractional part, `value` is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default rounding mode is [RoundingMode.ToEven](roundingmode-type.md). If `value` is of any other type, it will first be converted to a `number` using [Number.FromText](number-fromtext.md). Refer to [Number.Round](number-round.md) for the available rounding modes. An optional `culture` may also be provided (for example, "en-US"). ## Example 1 @@ -38,7 +35,7 @@ Int8.From("4") ## Example 2 -Get the signed 8-bit integer `number` value of `"4.5"` using [RoundingMode.AwayFromZero](/powerquery-m/roundingmode-awayfromzero). +Get the signed 8-bit integer `number` value of `"4.5"` using [RoundingMode.AwayFromZero](roundingmode-type.md). **Usage** @@ -49,3 +46,7 @@ Int8.From("4.5", null, RoundingMode.AwayFromZero) **Output** `5` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/itemexpression-from.md b/query-languages/m/itemexpression-from.md index 2c29b5b45..2bc3b8709 100644 --- a/query-languages/m/itemexpression-from.md +++ b/query-languages/m/itemexpression-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: ItemExpression.From" -title: "ItemExpression.From | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "ItemExpression.From" +ms.subservice: m-source --- # ItemExpression.From @@ -22,22 +15,23 @@ ItemExpression.From(function as function) as record Returns the abstract syntax tree (AST) for the body of `function`, normalized into an *item expression*: -- The function must be a 1-argument lambda. -- All references to the function parameter are replaced with `ItemExpression.Item`. -- The AST will be simplified to contain only nodes of the kinds: - - `Constant` - - `Invocation` - - `Unary` - - `Binary` - - `If` - - `FieldAccess` - - `NotImplemented` +* The function must be a 1-argument lambda. +* All references to the function parameter are replaced with [ItemExpression.Item](itemexpression-item.md). +* The AST will be simplified to contain only nodes of the kinds: + * `Constant` + * `Invocation` + * `Unary` + * `Binary` + * `If` + * `FieldAccess` An error is raised if an item expression AST cannot be returned for the body of `function`. +This function is identical to [`RowExpression.From`](rowexpression-from.md). + ## Example 1 -Returns the AST for the body of the function `each _ <> null` +Returns the AST for the body of the function `each _ <> null`. **Usage** diff --git a/query-languages/m/itemexpression-item.md b/query-languages/m/itemexpression-item.md index 5d79b5811..dfbfb7039 100644 --- a/query-languages/m/itemexpression-item.md +++ b/query-languages/m/itemexpression-item.md @@ -1,17 +1,12 @@ --- description: "Learn more about: ItemExpression.Item" -title: "ItemExpression.Item | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "ItemExpression.Item" +ms.subservice: m-source --- # ItemExpression.Item ## About An abstract syntax tree (AST) node representing the item in an item expression. + +This value is identical to [`RowExpression.Row`](rowexpression-row.md). diff --git a/query-languages/m/joinalgorithm-type.md b/query-languages/m/joinalgorithm-type.md index c80de9921..a969093be 100644 --- a/query-languages/m/joinalgorithm-type.md +++ b/query-languages/m/joinalgorithm-type.md @@ -1,13 +1,7 @@ --- description: "Learn more about: JoinAlgorithm.Type" -title: "JoinAlgorithm.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "JoinAlgorithm.Type" +ms.subservice: m-source --- # JoinAlgorithm.Type diff --git a/query-languages/m/joinkind-type.md b/query-languages/m/joinkind-type.md index 39e179bd1..d425c2883 100644 --- a/query-languages/m/joinkind-type.md +++ b/query-languages/m/joinkind-type.md @@ -1,13 +1,7 @@ --- description: "Learn more about: JoinKind.Type" -title: "JoinKind.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "JoinKind.Type" +ms.subservice: m-source --- # JoinKind.Type @@ -23,8 +17,10 @@ Specifies the kind of join operation. |**JoinKind.LeftOuter**|1| A left outer join ensures that all rows of the first table appear in the result.| |**JoinKind.RightOuter**|2| A right outer join ensures that all rows of the second table appear in the result.| |**JoinKind.FullOuter**|3| A full outer join ensures that all rows of both tables appear in the result. Rows that did not have a match in the other table are joined with a default row containing null values for all of its columns.| -|**JoinKind.LeftAnti**|4| A left anti join returns that all rows from the first table which do not have a match in the second table.| -|**JoinKind.RightAnti**|5| A right anti join returns that all rows from the second table which do not have a match in the first table.| +|**JoinKind.LeftAnti**|4| A left anti join returns all rows from the first table that do not have a match in the second table.| +|**JoinKind.RightAnti**|5| A right anti join returns all rows from the second table that do not have a match in the first table.| +|**JoinKind.LeftSemi**|6| A left semi join returns all rows from the first table that have a match in the second table.| +|**JoinKind.RightSemi**|7| A right semi join returns all rows from the second table that have a match in the first table.| ## Remarks diff --git a/query-languages/m/joinside-type.md b/query-languages/m/joinside-type.md index 31945f4eb..846b7c253 100644 --- a/query-languages/m/joinside-type.md +++ b/query-languages/m/joinside-type.md @@ -1,13 +1,7 @@ --- description: "Learn more about: JoinSide.Type" -title: "JoinSide.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "JoinSide.Type" +ms.subservice: m-source --- # JoinSide.Type diff --git a/query-languages/m/json-document.md b/query-languages/m/json-document.md index 4802e65ae..88496580e 100644 --- a/query-languages/m/json-document.md +++ b/query-languages/m/json-document.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Json.Document" -title: "Json.Document | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Json.Document" +ms.subservice: m-source --- # Json.Document @@ -18,5 +11,83 @@ ms.author: dougklo Json.Document(jsonText as any, optional encoding as nullable number) as any -## About +## About + Returns the content of the JSON document. + +* `jsonText`: The content of the JSON document. The value of this parameter can be text or a binary value returned by a function like [File.Content](file-contents.md). +* `encoding`: A [TextEncoding.Type](textencoding-type.md) that specifies the encoding used in the JSON document. If `encoding` is omitted, UTF8 is used. + +## Example 1 + +Returns the content of the specified JSON text as a record. + +**Usage** + +```powerquery-m +let + Source = "{ + ""project"": ""Contosoware"", + ""description"": ""A comprehensive initiative aimed at enhancing digital presence."", + ""components"": [ + ""Website Development"", + ""CRM Implementation"", + ""Mobile Application"" + ] + }", + jsonDocument = Json.Document(Source) +in + jsonDocument +``` + +**Output** + +```powerquery-m +[ + project = "Contosoware", + description = "A comprehensive initiative aimed at enhancing digital presence." + components = + { + "Website Development", + "CRM Implementation", + "Mobile Application" + } +] +``` + +## Example 2 + +Returns the content of a local JSON file. + +**Usage** + +```powerquery-m +let + Source = (Json.Document( + File.Contents("C:\test-examples\JSON\Contosoware.json") + ) +in + Source +``` + +**Output** + +A record, list, or primitive value representing the JSON data contained in the file + +## Example 3 + +Returns the content of an online UTF16 encoded JSON file. + +**Usage** + +```powerquery-m +let + Source = Json.Document( + Web.Contents("htts://contoso.com/products/Contosoware.json"), + TextEncoding.Utf16) + ) +``` + +**Output** + +A record, list, or primitive value representing the JSON UTF16 data contained in the file diff --git a/query-languages/m/json-fromvalue.md b/query-languages/m/json-fromvalue.md index bd3f1c705..5cfd4e138 100644 --- a/query-languages/m/json-fromvalue.md +++ b/query-languages/m/json-fromvalue.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Json.FromValue" -title: "Json.FromValue | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Json.FromValue" +ms.subservice: m-source --- # Json.FromValue ## Syntax
-Json.FromValue(value as any, optional encoding as nullable number) as binary  
+Json.FromValue(value as any, optional encoding as nullable number) as binary
 
- + ## About Produces a JSON representation of a given value `value` with a text encoding specified by `encoding`. If `encoding` is omitted, UTF8 is used. Values are represented as follows: @@ -25,9 +18,9 @@ Produces a JSON representation of a given value `value` with a text encoding spe * Null, text and logical values are represented as the corresponding JSON types * Numbers are represented as numbers in JSON, except that `#infinity`, `-#infinity` and `#nan` are converted to null * Lists are represented as JSON arrays -* Records are represnted as JSON objects +* Records are represented as JSON objects * Tables are represented as an array of objects -* Dates, times, datetimes, datetimezones and durations are represented as ISO-8601 text +* Dates, times, datetimes, datetimezones, and durations are represented as ISO-8601 text * Binary values are represented as base-64 encoded text * Types and functions produce an error diff --git a/query-languages/m/limitclausekind-type.md b/query-languages/m/limitclausekind-type.md index ca165c5dd..e13e0ce39 100644 --- a/query-languages/m/limitclausekind-type.md +++ b/query-languages/m/limitclausekind-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: LimitClauseKind.Type" -title: "LimitClauseKind.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "LimitClauseKind.Type" +ms.subservice: m-source --- # LimitClauseKind.Type @@ -18,8 +11,8 @@ Describes the type of limit clause supported by the SQL dialect used by this dat ## Allowed values -|Name|Value|Description| -|------------|--|---------------| +|Name|Value|Description| +|------------|--|---------------| |**LimitClauseKind.None**|0|This SQL dialect does not support a limit clause.| |**LimitClauseKind.Top**|1|This SQL dialect supports a TOP specifier to limit the number of rows returned.| |**LimitClauseKind.LimitOffset**|2|This SQL dialect supports LIMIT and OFFSET specifiers to limit the number of rows returned.| diff --git a/query-languages/m/lines-frombinary.md b/query-languages/m/lines-frombinary.md index 881cf784d..2405ca41d 100644 --- a/query-languages/m/lines-frombinary.md +++ b/query-languages/m/lines-frombinary.md @@ -1,22 +1,38 @@ --- description: "Learn more about: Lines.FromBinary" -title: "Lines.FromBinary | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Lines.FromBinary" +ms.subservice: m-source --- # Lines.FromBinary ## Syntax
-Lines.FromBinary(binary as binary, optional quoteStyle as nullable number, optional includeLineSeparators as nullable logical, optional encoding as nullable number) as list
+Lines.FromBinary(
+    binary as binary,
+    optional quoteStyle as any,
+    optional includeLineSeparators as nullable logical,
+    optional encoding as nullable number
+) as list
 
## About -Converts a binary value to a list of text values split at lines breaks. If a quote style is specified, then line breaks may appear within quotes. If includeLineSeparators is true, then the line break characters are included in the text. + +Converts a binary value to a list of text values split at line breaks. + +* `binary`: The binary value to convert to the list. +* `quoteStyle`: Specifies how line breaks are handled. The value of `quoteStyle` can be `null`. The default value is [QuoteStyle.None](quotestyle-type.md). +* `includeLineSeparators`: Specifies whether to include the line break characters in the text. The value of `includeLineSeparators` can be `null`. The default value is `false`. +* `encoding`: Specifies the text encoding of the binary value. The value of `encoding` can be `null`. The default value is `65001` (UTF-8). + +If a record is specified for `quoteStyle` (and `includeLineSeparators` and `encoding` are `null`), the following record fields can be provided: + +* `QuoteStyle`: Specifies how quoted line breaks are handled. + * [QuoteStyle.Csv](quotestyle-type.md): Quoted line breaks are treated as part of the data, not as the end of the current row. + * [QuoteStyle.None](quotestyle-type.md): All line breaks are treated as the end of the current row, even when they occur inside a quoted value. This value is the default if the `CsvStyle` option isn't specified. +* `CsvStyle`: Specifies how quotes are handled. Should not be used with `QuoteStyle.None`. + * [CsvStyle.QuoteAfterDelimiter](csvstyle-type.md): Quotes in a field are only significant immediately following the `Delimiter. + * [CsvStyle.QuoteAlways](csvstyle-type.md): Quotes in a field are always significant, regardless of where they appear. +* `Delimiter`: A single character delimiter. Should be used only with `CsvStyle.QuoteAfterDelimiter`. +* `IncludeLineSeparators`: Specifies whether to include the line break characters in the text. The default value is `false`. +* `Encoding`: The text encoding of the binary value. The default value is `65001` (UTF-8). diff --git a/query-languages/m/lines-fromtext.md b/query-languages/m/lines-fromtext.md index c1f15a709..642fe2e3e 100644 --- a/query-languages/m/lines-fromtext.md +++ b/query-languages/m/lines-fromtext.md @@ -1,22 +1,35 @@ --- description: "Learn more about: Lines.FromText" -title: "Lines.FromText | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Lines.FromText" +ms.subservice: m-source --- # Lines.FromText ## Syntax
-Lines.FromText(text as text, optional quoteStyle as nullable number, optional includeLineSeparators as nullable logical) as list
+Lines.FromText(
+    text as text,
+    optional quoteStyle as any,
+    optional includeLineSeparators as nullable logical
+) as list
 
- -## About -Converts a text value to a list of text values split at lines breaks. If includeLineSeparators is true, then the line break characters are included in the text.
  • QuoteStyle.None: (default) No quoting behavior is needed.
  • QuoteStyle.Csv: Quoting is as per Csv. A double quote character is used to demarcate such regions, and a pair of double quote characters is used to indicate a single double quote character within such a region.
+ +## About + +Converts a text value to a list of text values split at line breaks. + +* `text`: The text value to convert to the list of text values. +* `quoteStyle`: Specifies how line breaks are handled. The value of `quoteStyle` can be `null`. The default value is [QuoteStyle.None](quotestyle-type.md). +* `includeLineSeparators`: Specifies whether to include the line break characters in the text. The value of `includeLineSeparators` can be `null`. The default value is `false`. + +If a record is specified for `quoteStyle` (and `includeLineSeparators` is `null`), the following record fields can be provided: + +* `QuoteStyle`: Specifies how quoted line breaks are handled. + * [QuoteStyle.Csv](quotestyle-type.md): Quoted line breaks are treated as part of the data, not as the end of the current row. + * [QuoteStyle.None](quotestyle-type.md): All line breaks are treated as the end of the current row, even when they occur inside a quoted value. This value is the default if the `CsvStyle` option isn't specified. +* `CsvStyle`: Specifies how quotes are handled. Should not be used with `QuoteStyle.None`. + * [CsvStyle.QuoteAfterDelimiter](csvstyle-type.md): Quotes in a field are only significant immediately following the `Delimiter`. + * [CsvStyle.QuoteAlways](csvstyle-type.md): Quotes in a field are always significant, regardless of where they appear. +* `Delimiter`: A single character delimiter. Should be used only with `CsvStyle.QuoteAfterDelimiter`. +* `IncludeLineSeparators`: Specifies whether to include the line break characters in the text. The default value is `false`. diff --git a/query-languages/m/lines-functions.md b/query-languages/m/lines-functions.md index 4bfae5f2c..f082b0ce7 100644 --- a/query-languages/m/lines-functions.md +++ b/query-languages/m/lines-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Lines functions" -title: "Lines functions | Microsoft Docs" +title: "Lines functions" ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +ms.custom: "nonautomated-date" --- # Lines functions diff --git a/query-languages/m/lines-tobinary.md b/query-languages/m/lines-tobinary.md index f3a4ac08f..3e3821753 100644 --- a/query-languages/m/lines-tobinary.md +++ b/query-languages/m/lines-tobinary.md @@ -1,22 +1,21 @@ --- description: "Learn more about: Lines.ToBinary" -title: "Lines.ToBinary | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Lines.ToBinary" +ms.subservice: m-source --- # Lines.ToBinary ## Syntax
-Lines.ToBinary(lines as list, optional lineSeparator as nullable text, optional encoding as nullable number, optional includeByteOrderMark as nullable logical) as binary
+Lines.ToBinary(
+    lines as list,
+    optional lineSeparator as nullable text,
+    optional encoding as nullable number,
+    optional includeByteOrderMark as nullable logical
+) as binary
 
- -## About + +## About + Converts a list of text into a binary value using the specified encoding and lineSeparator.The specified lineSeparator is appended to each line. If not specified then the carriage return and line feed characters are used. diff --git a/query-languages/m/lines-totext.md b/query-languages/m/lines-totext.md index be71b609d..f616002f3 100644 --- a/query-languages/m/lines-totext.md +++ b/query-languages/m/lines-totext.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Lines.ToText" -title: "Lines.ToText | Microsoft Docs" -ms.date: 7/30/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Lines.ToText" +ms.subservice: m-source --- # Lines.ToText ## Syntax
-Lines.ToText(lines as list, optional lineSeparator as nullable text) as text 
+Lines.ToText(lines as list, optional lineSeparator as nullable text) as text
 
- -## About + +## About + Converts a list of text into a single text. The specified lineSeparator is appended to each line. If not specified then the carriage return and line feed characters are used. diff --git a/query-languages/m/list-accumulate.md b/query-languages/m/list-accumulate.md index 9721bfdf6..2f36cc48d 100644 --- a/query-languages/m/list-accumulate.md +++ b/query-languages/m/list-accumulate.md @@ -1,23 +1,20 @@ --- description: "Learn more about: List.Accumulate" -title: "List.Accumulate | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Accumulate" +ms.subservice: m-source --- # List.Accumulate ## Syntax
-List.Accumulate(list as list, seed as any, accumulator as function) as any
+List.Accumulate(
+    list as list,
+    seed as any,
+    accumulator as function
+) as any
 
- + ## About Accumulates a summary value from the items in the list `list`, using `accumulator`. An optional seed parameter, `seed`, may be set. diff --git a/query-languages/m/list-alltrue.md b/query-languages/m/list-alltrue.md index 1ed020fd0..59b10b136 100644 --- a/query-languages/m/list-alltrue.md +++ b/query-languages/m/list-alltrue.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.AllTrue" -title: "List.AllTrue | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.AllTrue" +ms.subservice: m-source --- # List.AllTrue @@ -17,7 +10,7 @@ ms.author: dougklo
 List.AllTrue(list as list) as logical
 
- + ## About Returns true if all expressions in the list `list` are true. diff --git a/query-languages/m/list-alternate.md b/query-languages/m/list-alternate.md index a2c932e65..889f03c08 100644 --- a/query-languages/m/list-alternate.md +++ b/query-languages/m/list-alternate.md @@ -1,23 +1,21 @@ --- description: "Learn more about: List.Alternate" -title: "List.Alternate | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Alternate" +ms.subservice: m-source --- # List.Alternate ## Syntax
-List.Alternate(list as list, count as number, optional repeatInterval as nullable number, optional offset as nullable number) as list
+List.Alternate(
+    list as list,
+    count as number,
+    optional repeatInterval as nullable number,
+    optional offset as nullable number
+) as list
 
- + ## About Returns a list comprised of all the odd numbered offset elements in a list. Alternates between taking and skipping values from the list `list` depending on the parameters. diff --git a/query-languages/m/list-anytrue.md b/query-languages/m/list-anytrue.md index 1c604cc83..c84f08edd 100644 --- a/query-languages/m/list-anytrue.md +++ b/query-languages/m/list-anytrue.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.AnyTrue" -title: "List.AnyTrue | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.AnyTrue" +ms.subservice: m-source --- # List.AnyTrue @@ -17,7 +10,7 @@ ms.author: dougklo
 List.AnyTrue(list as list) as logical
 
- + ## About Returns true if any expression in the list `list` is true. diff --git a/query-languages/m/list-average.md b/query-languages/m/list-average.md index 939bec636..6d7a68c85 100644 --- a/query-languages/m/list-average.md +++ b/query-languages/m/list-average.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Average" -title: "List.Average | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Average" +ms.subservice: m-source --- # List.Average @@ -17,7 +10,7 @@ ms.author: dougklo
 List.Average(list as list, optional precision as nullable number) as any 
 
- + ## About Returns the average value for the items in the list, `list`. The result is given in the same datatype as the values in the list. Only works with number, date, time, datetime, datetimezone and duration values. If the list is empty null is returned. diff --git a/query-languages/m/list-buffer.md b/query-languages/m/list-buffer.md index a0f1b976c..c89e260e2 100644 --- a/query-languages/m/list-buffer.md +++ b/query-languages/m/list-buffer.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Buffer" -title: "List.Buffer | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Buffer" +ms.subservice: m-source --- # List.Buffer @@ -17,7 +10,7 @@ ms.author: dougklo
 List.Buffer(list as list) as list
 
- + ## About Buffers the list `list` in memory. The result of this call is a stable list. diff --git a/query-languages/m/list-combine.md b/query-languages/m/list-combine.md index 1fbc365c1..bf5289cc8 100644 --- a/query-languages/m/list-combine.md +++ b/query-languages/m/list-combine.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Combine" -title: "List.Combine | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Combine" +ms.subservice: m-source --- # List.Combine diff --git a/query-languages/m/list-conformtopagereader.md b/query-languages/m/list-conformtopagereader.md index c9e6abb54..341bfba88 100644 --- a/query-languages/m/list-conformtopagereader.md +++ b/query-languages/m/list-conformtopagereader.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.ConformToPageReader" -title: "List.ConformToPageReader | Microsoft Docs" -ms.date: 8/21/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.ConformToPageReader" +ms.subservice: m-source --- # List.ConformToPageReader @@ -17,6 +10,7 @@ ms.author: dougklo
 List.ConformToPageReader(list as list, optional options as nullable record) as table
 
- -## About + +## About + This function is intended for internal use only. diff --git a/query-languages/m/list-contains.md b/query-languages/m/list-contains.md index fe04eb718..53e17cb42 100644 --- a/query-languages/m/list-contains.md +++ b/query-languages/m/list-contains.md @@ -1,30 +1,31 @@ --- description: "Learn more about: List.Contains" -title: "List.Contains | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Contains" +ms.subservice: m-source --- # List.Contains ## Syntax
-List.Contains(list as list, value as any, optional equationCriteria as any) as logical 
+List.Contains(
+    list as list,
+    value as any,
+    optional equationCriteria as any
+) as logical
 
- + ## About -Indicates whether the list `list` contains the value `value`. Returns true if value is found in the list, false otherwise. An optional equation criteria value, `equationCriteria`, can be specified to control equality testing. +Indicates whether the list contains the specified value. Returns `true` if the value is found in the list, `false` otherwise. + +* `list`: The list to search. +* `value`: The value to search for in the list. +* `equationCriteria`: (Optional) The comparer used to determine if the two values are equal. ## Example 1 -Find if the list {1, 2, 3, 4, 5} contains 3. +Determine if the list {1, 2, 3, 4, 5} contains 3. **Usage** @@ -38,7 +39,7 @@ List.Contains({1, 2, 3, 4, 5}, 3) ## Example 2 -Find if the list {1, 2, 3, 4, 5} contains 6. +Determine if the list {1, 2, 3, 4, 5} contains 6. **Usage** @@ -49,3 +50,42 @@ List.Contains({1, 2, 3, 4, 5}, 6) **Output** `false` + +## Example 3 + +Ignoring case, determine if the list contains "rhubarb". + +**Usage** + +```powerquery-m +List.Contains({"Pears", "Bananas", "Rhubarb", "Peaches"}, + "rhubarb", + Comparer.OrdinalIgnoreCase +) +``` + +**Output** + +`true` + +## Example 4 + +Determine if the list contains the date April 8, 2022. + +**Usage** + +```powerquery-m +let + Source = {#date(2024, 2, 23), #date(2023, 12, 2), #date(2022, 4, 8), #date(2021, 7, 6)}, + ContainsDate = List.Contains(Source, Date.From("4/8/2022")) +in + ContainsDate +``` + +**Output** + +`true` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-containsall.md b/query-languages/m/list-containsall.md index ec18a0b5c..21c8eae3e 100644 --- a/query-languages/m/list-containsall.md +++ b/query-languages/m/list-containsall.md @@ -1,30 +1,31 @@ --- description: "Learn more about: List.ContainsAll" -title: "List.ContainsAll | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.ContainsAll" +ms.subservice: m-source --- # List.ContainsAll ## Syntax
-List.ContainsAll(list as list, values as list, optional equationCriteria as any) as logical
+List.ContainsAll(
+    list as list,
+    values as list,
+    optional equationCriteria as any
+) as logical
 
- + ## About -Indicates whether the list `list` includes all the values in another list, `values`. Returns true if value is found in the list, false otherwise. An optional equation criteria value, `equationCriteria`, can be specified to control equality testing. +Indicates whether the list includes all the values from another list. Returns `true` if all the values are found in the list, `false` otherwise. + +* `list`: The list to search. +* `values`: The list of values to search for in the first list. +* `equationCriteria`: (Optional) The comparer used to determine if the two values are equal. ## Example 1 -Find out if the list {1, 2, 3, 4, 5} contains 3 and 4. +Determine if the list {1, 2, 3, 4, 5} contains 3 and 4. **Usage** @@ -38,7 +39,7 @@ List.ContainsAll({1, 2, 3, 4, 5}, {3, 4}) ## Example 2 -Find out if the list {1, 2, 3, 4, 5} contains 5 and 6. +Determine if the list {1, 2, 3, 4, 5} contains 5 and 6. **Usage** @@ -49,3 +50,39 @@ List.ContainsAll({1, 2, 3, 4, 5}, {5, 6}) **Output** `false` + +## Example 3 + +Determine if the list contains a dog and a horse, while ignoring case. + +**Usage** + +```powerquery-m +List.ContainsAll({"dog", "cat", "racoon", "horse", "rabbit"}, {"DOG", "Horse"}, Comparer.OrdinalIgnoreCase) +``` + +**Output** + +`true` + +## Example 4 + +Determine if the list contains the dates April 8, 2022 and July 6, 2021. + +**Usage** + +```powerquery-m +let + Source = {#date(2024, 2, 23), #date(2023, 12, 2), #date(2022, 4, 8), #date(2021, 7, 6)}, + ContainsDates = List.ContainsAll(Source, {#date(2022, 4, 8), #date(2021, 7, 6)}) +in + ContainsDates +``` + +**Output** + +`true` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-containsany.md b/query-languages/m/list-containsany.md index 452b41177..3d2f4addc 100644 --- a/query-languages/m/list-containsany.md +++ b/query-languages/m/list-containsany.md @@ -1,30 +1,31 @@ --- description: "Learn more about: List.ContainsAny" -title: "List.ContainsAny | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.ContainsAny" +ms.subservice: m-source --- # List.ContainsAny ## Syntax
-List.ContainsAny(list as list, values as list, optional equationCriteria as any) as logical
+List.ContainsAny(
+    list as list,
+    values as list,
+    optional equationCriteria as any
+) as logical
 
- + ## About -Indicates whether the list `list` includes any of the values in another list, `values`. Returns true if value is found in the list, false otherwise. An optional equation criteria value, `equationCriteria`, can be specified to control equality testing. +Indicates whether the list contains any of the values from another list. Returns `true` if the values are found in the list, `false` otherwise. + +* `list`: The list to search. +* `values`: The list of values to search for in the first list. +* `equationCriteria`: (Optional) The comparer used to determine if the two values are equal. ## Example 1 -Find out if the list {1, 2, 3, 4, 5} contains 3 or 9. +Determine if the list {1, 2, 3, 4, 5} contains 3 or 9. **Usage** @@ -38,7 +39,7 @@ List.ContainsAny({1, 2, 3, 4, 5}, {3, 9}) ## Example 2 -Find out if the list {1, 2, 3, 4, 5} contains 6 or 7. +Determine if the list {1, 2, 3, 4, 5} contains 6 or 7. **Usage** @@ -49,3 +50,39 @@ List.ContainsAny({1, 2, 3, 4, 5}, {6, 7}) **Output** `false` + +## Example 3 + +Determine if the list contains a horse or an owl, while ignoring case. + +**Usage** + +```powerquery-m +List.ContainsAny({"dog", "cat", "racoon", "horse", "rabbit"}, {"Horse", "OWL"}, Comparer.OrdinalIgnoreCase) +``` + +**Output** + +`true` + +## Example 4 + +Determine if the list contains a date of either April 8, 2022 or January 12, 2021. + +**Usage** + +```powerquery-m +let + Source = {#date(2024, 2, 23), #date(2023, 12, 2), #date(2022, 4, 8), #date(2021, 7, 6)}, + ContainsDates = List.ContainsAny(Source, {Date.From("Apr 8, 2022"), Date.From("Jan 11, 2021")}) +in + ContainsDates +``` + +**Output** + +`true` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-count.md b/query-languages/m/list-count.md index 0ff007160..0004f0957 100644 --- a/query-languages/m/list-count.md +++ b/query-languages/m/list-count.md @@ -1,23 +1,16 @@ --- description: "Learn more about: List.Count" -title: "List.Count | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Count" +ms.subservice: m-source --- # List.Count ## Syntax
-List.Count(list as list) as number  
+List.Count(list as list) as number
 
- + ## About Returns the number of items in the list `list`. diff --git a/query-languages/m/list-covariance.md b/query-languages/m/list-covariance.md index b173720e4..1ca4ae1de 100644 --- a/query-languages/m/list-covariance.md +++ b/query-languages/m/list-covariance.md @@ -1,23 +1,16 @@ --- description: "Learn more about: List.Covariance" -title: "List.Covariance | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Covariance" +ms.subservice: m-source --- # List.Covariance ## Syntax
-List.Covariance(numberList1 as list, numberList2 as list) as nullable number 
+List.Covariance(numberList1 as list, numberList2 as list) as nullable number
 
- + ## About Returns the covariance between two lists, `numberList1` and `numberList2`. `numberList1` and `numberList2` must contain the same number of `number` values. diff --git a/query-languages/m/list-dates.md b/query-languages/m/list-dates.md index 9aa29fe55..f356a4117 100644 --- a/query-languages/m/list-dates.md +++ b/query-languages/m/list-dates.md @@ -1,21 +1,18 @@ --- description: "Learn more about: List.Dates" -title: "List.Dates | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Dates" +ms.subservice: m-source --- # List.Dates ## Syntax
-List.Dates(start as date, count as number, step as duration) as list
+List.Dates(
+    start as date,
+    count as number,
+    step as duration
+) as list
 
## About @@ -24,7 +21,7 @@ Returns a list of `date` values of size `count`, starting at `start`. The given ## Example 1 -Create a list of 5 values starting from New Year's Eve (#date(2011, 12, 31)) incrementing by 1 day(#duration(1, 0, 0, 0)). +Create a list of 5 values starting from New Year's Eve (#date(2011, 12, 31)) incrementing by 1 day (#duration(1, 0, 0, 0)). **Usage** @@ -43,3 +40,7 @@ List.Dates(#date(2011, 12, 31), 5, #duration(1, 0, 0, 0)) #date(2012, 1, 4) } ``` + +## Related content + +[#duration](sharpduration.md) diff --git a/query-languages/m/list-datetimes.md b/query-languages/m/list-datetimes.md index 3bb809cd1..883cee13f 100644 --- a/query-languages/m/list-datetimes.md +++ b/query-languages/m/list-datetimes.md @@ -1,21 +1,18 @@ --- description: "Learn more about: List.DateTimes" -title: "List.DateTimes | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.DateTimes" +ms.subservice: m-source --- # List.DateTimes ## Syntax
-List.DateTimes(start as datetime, count as number, step as duration) as list
+List.DateTimes(
+    start as datetime,
+    count as number,
+    step as duration
+) as list
 
## About diff --git a/query-languages/m/list-datetimezones.md b/query-languages/m/list-datetimezones.md index 85fb8f858..f271c3ba6 100644 --- a/query-languages/m/list-datetimezones.md +++ b/query-languages/m/list-datetimezones.md @@ -1,23 +1,20 @@ --- description: "Learn more about: List.DateTimeZones" -title: "List.DateTimeZones | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.DateTimeZones" +ms.subservice: m-source --- # List.DateTimeZones ## Syntax
-List.DateTimeZones(start as datetimezone, count as number, step as duration) as list 
+List.DateTimeZones(
+    start as datetimezone,
+    count as number,
+    step as duration
+) as list
 
- + ## About Returns a list of `datetimezone` values of size `count`, starting at `start`. The given increment, `step`, is a `duration` value that is added to every value. diff --git a/query-languages/m/list-difference.md b/query-languages/m/list-difference.md index d771370be..1841b5895 100644 --- a/query-languages/m/list-difference.md +++ b/query-languages/m/list-difference.md @@ -1,21 +1,18 @@ --- description: "Learn more about: List.Difference" -title: "List.Difference | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Difference" +ms.subservice: m-source --- # List.Difference
-List.Difference(list1 as list, list2 as list, optional equationCriteria as any) as list
+List.Difference(
+    list1 as list,
+    list2 as list,
+    optional equationCriteria as any
+) as list
 
- + ## About Returns the items in list `list1` that do not appear in list `list2`. Duplicate values are supported. An optional equation criteria value, `equationCriteria`, can be specified to control equality testing. @@ -47,3 +44,7 @@ List.Difference({1, 2}, {1, 2, 3}) **Output** `{}` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-distinct.md b/query-languages/m/list-distinct.md index ceb9cf624..eca6963ee 100644 --- a/query-languages/m/list-distinct.md +++ b/query-languages/m/list-distinct.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Distinct" -title: "List.Distinct | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Distinct" +ms.subservice: m-source --- # List.Distinct @@ -17,10 +10,13 @@ ms.author: dougklo
 List.Distinct(list as list, optional equationCriteria as any) as list
 
- + ## About -Returns a list that contains all the values in list `list` with duplicates removed. If the list is empty, the result is an empty list. +Returns a list that contains all the values in the specified list with duplicates removed. If the specified list is empty, the result is an empty list. + +* `list`: The list from which distinct values are extracted. +* `equationCriteria`: (Optional) Specifies how equality is determined when comparing values. This parameter can be a key selector function, a comparer function, or a list containing both a key selector and a comparer. ## Example 1 @@ -35,3 +31,83 @@ List.Distinct({1, 1, 2, 3, 3, 3}) **Output** `{1, 2, 3}` + +## Example 2 + +Starting at the end of the list, select the fruits that have a unique text length. + +**Usage** + +```powerquery-m +let + Source = {"Apple", "Banana", "Cherry", "Date", "Fig"}, + Result = List.Distinct(List.Reverse(Source), each Text.Length(_)) +in + Result +``` + +**Output** + +`{"Fig", "Date", "Cherry", "Apple"}` + +## Example 3 + +Starting at the beginning of the list, select the unique fruits while ignoring case. + +**Usage** + +```powerquery-m +let + Source = {"apple", "Pear", "aPPle", "banana", "ORANGE", "pear", "Banana", "Cherry"}, + Result = List.Distinct(Source, Comparer.OrdinalIgnoreCase) +in + Result +``` + +**Output** + +`{"apple", "Pear", "banana", "ORANGE", "Cherry"}` + +## Example 4 + +Extract from a list of lists the first lists with unique country names while ignoring case. Place the extracted lists in the rows of a new table. + +**Usage** + +```powerquery-m +let + Source = { + {"USA", #date(2023, 8, 1), 567}, + {"canada", #date(2023, 8, 1), 254}, + {"Usa", #date(2023, 7, 1), 450}, + {"CANADA", #date(2023, 6, 1), 357}, + {"Panama", #date(2023, 6, 2), 20}, + {"panama", #date(2023, 7, 1), 40} + }, + DistinctByCountry = List.Distinct( + Source, + {each _{0}, Comparer.OrdinalIgnoreCase} + ), + ToTable = Table.FromRows(DistinctByCountry, {"Country", "Date", "Value"}), + ChangeTypes = Table.TransformColumnTypes( + ToTable, {{"Country", type text}, {"Date", type date}, {"Value", Int64.Type}} + ) +in + ChangeTypes +``` + +**Output** + +```powerquery-m +#table(type table[Country = text, Date = date, Value = Int64.Type], + { + {"USA", #date(2023, 8, 1), 567}, + {"canada", #date(2023, 8, 1), 254}, + {"Panama", #date(2023, 6, 2), 20} + } +) +``` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-durations.md b/query-languages/m/list-durations.md index 5a23174d3..4f2ee1c12 100644 --- a/query-languages/m/list-durations.md +++ b/query-languages/m/list-durations.md @@ -1,21 +1,18 @@ --- description: "Learn more about: List.Durations" -title: "List.Durations | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Durations" +ms.subservice: m-source --- # List.Durations ## Syntax
-List.Durations(start as duration, count as number, step as duration) as list
+List.Durations(
+    start as duration,
+    count as number,
+    step as duration
+) as list
 
## About diff --git a/query-languages/m/list-findtext.md b/query-languages/m/list-findtext.md index 5805a8f34..bfb1cc3b7 100644 --- a/query-languages/m/list-findtext.md +++ b/query-languages/m/list-findtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.FindText" -title: "List.FindText | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.FindText" +ms.subservice: m-source --- # List.FindText @@ -17,7 +10,7 @@ ms.author: dougklo
 List.FindText(list as list, text as text) as list
 
- + ## About Returns a list of the values from the list `list` which contained the value `text`. diff --git a/query-languages/m/list-first.md b/query-languages/m/list-first.md index 34d776e1f..21ff0dcd2 100644 --- a/query-languages/m/list-first.md +++ b/query-languages/m/list-first.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.First" -title: "List.First | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.First" +ms.subservice: m-source --- # List.First @@ -17,7 +10,7 @@ ms.author: dougklo
 List.First(list as list, optional defaultValue as any) as any
 
- + ## About Returns the first item in the list `list`, or the optional default value, `defaultValue`, if the list is empty. If the list is empty and a default value is not specified, the function returns `null`. diff --git a/query-languages/m/list-firstn.md b/query-languages/m/list-firstn.md index 0ef4c4051..2526decd7 100644 --- a/query-languages/m/list-firstn.md +++ b/query-languages/m/list-firstn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.FirstN" -title: "List.FirstN | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.FirstN" +ms.subservice: m-source --- # List.FirstN @@ -17,7 +10,7 @@ ms.author: dougklo
 List.FirstN(list as list, countOrCondition as any) as any
 
- + ## About * If a number is specified, up to that many items are returned. diff --git a/query-languages/m/list-functions.md b/query-languages/m/list-functions.md index 02791ce75..869e3e57a 100644 --- a/query-languages/m/list-functions.md +++ b/query-languages/m/list-functions.md @@ -1,188 +1,190 @@ --- description: "Learn more about: List functions" -title: "List functions | Microsoft Docs" -ms.date: 5/12/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List functions" +ms.date: 8/13/2025 +ms.custom: "nonautomated-date" --- # List functions These functions create and manipulate list values. - + ## Information - -|Name|Description| -|------------|---------------| -|[List.Count](list-count.md)|Returns the number of items in a list.| -|[List.NonNullCount](list-nonnullcount.md)|Returns the number of items in a list excluding null values| -|[List.IsEmpty](list-isempty.md)|Returns whether a list is empty.| - + +|Name|Description| +|------------|---------------| +|[List.Count](list-count.md)|Returns the number of items in a list.| +|[List.IsEmpty](list-isempty.md)|Returns `true` if the list is empty.| +|[List.NonNullCount](list-nonnullcount.md)|Returns the number of non-null items in the list.| + ## Selection - -|Name|Description| -|------------|---------------| -|[List.Alternate](list-alternate.md)|Returns a list with the items alternated from the original list based on a count, optional repeatInterval, and an optional offset.| -|[List.Buffer](list-buffer.md)|Buffers the list in memory. The result of this call is a stable list, which means it will have a determinimic count, and order of items.| -|[List.Distinct](list-distinct.md)|Filters a list down by removing duplicates. An optional equation criteria value can be specified to control equality comparison. The first value from each equality group is chosen.| -|[List.FindText](list-findtext.md)|Searches a list of values, including record fields, for a text value.| -|[List.First](list-first.md)|Returns the first value of the list or the specified default if empty. Returns the first item in the list, or the optional default value, if the list is empty. If the list is empty and a default value is not specified, the function returns.| -|[List.FirstN](list-firstn.md)|Returns the first set of items in the list by specifying how many items to return or a qualifying condition provided by `countOrCondition`.| -|[List.InsertRange](list-insertrange.md)|Inserts items from values at the given index in the input list.| -|[List.IsDistinct](list-isdistinct.md)|Returns whether a list is distinct.| -|[List.Last](list-last.md)|Returns the last set of items in the list by specifying how many items to return or a qualifying condition provided by `countOrCondition`.| -|[List.LastN](list-lastn.md)|Returns the last set of items in a list by specifying how many items to return or a qualifying condition.| -|[List.MatchesAll](list-matchesall.md)|Returns true if all items in a list meet a condition.| -|[List.MatchesAny](list-matchesany.md)|Returns true if any item in a list meets a condition.| -|[List.Positions](list-positions.md)|Returns a list of positions for an input list.| -|[List.Range](list-range.md)|Returns a count items starting at an offset.| -|[List.Select](list-select.md)|Selects the items that match a condition.| -|[List.Single](list-single.md)|Returns the single item of the list or throws an `Expression.Error` if the list has more than one item.| -|[List.SingleOrDefault](list-singleordefault.md)|Returns a single item from a list.| -|[List.Skip](list-skip.md)|Skips the first item of the list. Given an empty list, it returns an empty list. This function takes an optional parameter `countOrCondition` to support skipping multiple values.| - -## Transformation functions - -|Name|Description| -|------------|---------------| -|[List.Accumulate](list-accumulate.md)|Accumulates a result from the list. Starting from the initial value seed this function applies the accumulator function and returns the final result.| -|[List.Combine](list-combine.md)|Merges a list of lists into single list.| -|[List.ConformToPageReader](list-conformtopagereader.md)|This function is intended for internal use only.| -|[List.RemoveRange](list-removerange.md)|Returns a list that removes count items starting at offset. The default count is 1.| -|[List.RemoveFirstN](list-removefirstn.md)|Returns a list with the specified number of elements removed from the list starting at the first element. The number of elements removed depends on the optional `countOrCondition` parameter.| -|[List.RemoveItems](list-removeitems.md)|Removes items from `list1` that are present in `list2`, and returns a new list.| -|[List.RemoveLastN](list-removelastn.md)|Returns a list with the specified number of elements removed from the list starting at the last element. The number of elements removed depends on the optional `countOrCondition` parameter.| -|[List.Repeat](list-repeat.md)|Returns a list that repeats the contents of an input list count times.| -|[List.ReplaceRange](list-replacerange.md)|Returns a list that replaces count values in a list with a `replaceWith` list starting at an index.| -|[List.RemoveMatchingItems](list-removematchingitems.md)|Removes all occurrences of the given values in the list.| -|[List.RemoveNulls](list-removenulls.md)|Removes null values from a list.| -|[List.ReplaceMatchingItems](list-replacematchingitems.md)|Replaces occurrences of existing values in the list with new values using the provided `equationCriteria`. Old and new values are provided by the `replacements` parameters. An optional equation criteria value can be specified to control equality comparisons. For details of replacement operations and equation criteria, go to [Parameter values](#parameter-values).| -|[List.ReplaceValue](list-replacevalue.md)|Searches a list of values for the value and replaces each occurrence with the replacement value.| -|[List.Reverse](list-reverse.md)|Returns a list that reverses the items in a list.| + +|Name|Description| +|------------|---------------| +|[List.Alternate](list-alternate.md)|Returns a list comprised of all the odd numbered offset elements in a list.| +|[List.Buffer](list-buffer.md)|Buffers a list.| +|[List.Distinct](list-distinct.md)|Returns a list of values with duplicates removed.| +|[List.FindText](list-findtext.md)|Returns a list of values (including record fields) that contain the specified text.| +|[List.First](list-first.md)|Returns the first value of the list or the specified default if empty.| +|[List.FirstN](list-firstn.md)|Returns the first set of items in the list by specifying how many items to return or a qualifying condition.| +|[List.InsertRange](list-insertrange.md)|Inserts values into a list at the given index.| +|[List.IsDistinct](list-isdistinct.md)|Indicates whether there are duplicates in the list.| +|[List.Last](list-last.md)|Returns the last value of the list or the specified default if empty.| +|[List.LastN](list-lastn.md)|Returns the last value in the list. Can optionally specify how many values to return or a qualifying condition.| +|[List.MatchesAll](list-matchesall.md)|Returns `true` if the condition function is satisfied by all values in the list.| +|[List.MatchesAny](list-matchesany.md)|Returns `true` if the condition function is satisfied by any value.| +|[List.Positions](list-positions.md)|Returns a list of offsets for the input.| +|[List.Range](list-range.md)|Returns a subset of the list beginning at an offset.| +|[List.Select](list-select.md)|Returns a list of values that match the condition.| +|[List.Single](list-single.md)|Returns the one list item for a list of length one, otherwise throws an exception.| +|[List.SingleOrDefault](list-singleordefault.md)|Returns the one list item for a list of length one and the default value for an empty list.| +|[List.Skip](list-skip.md)|Returns a list that skips the specified number of elements at the beginning of the list.| + +## Transformation functions + +|Name|Description| +|------------|---------------| +|[List.Accumulate](list-accumulate.md)|AAccumulates a summary value from the items in the list.| +|[List.Combine](list-combine.md)|Returns a single list by combining multiple lists.| +|[List.ConformToPageReader](list-conformtopagereader.md)|This function is intended for internal use only.| +|[List.RemoveFirstN](list-removefirstn.md)|Returns a list that skips the specified number of elements at the beginning of the list.| +|[List.RemoveItems](list-removeitems.md)|Removes items from the first list that are present in the second list.| +|[List.RemoveLastN](list-removelastn.md)|Returns a list that removes the specified number of elements from the end of the list.| +|[List.RemoveMatchingItems](list-removematchingitems.md)|Removes all occurrences of the input values.| +|[List.RemoveNulls](list-removenulls.md)|Removes all `null` values from the specified list.| +|[List.RemoveRange](list-removerange.md)|Removes count number of values starting at the specified position.| +|[List.Repeat](list-repeat.md)|Returns a list that is `count` repetitions of the original list.| +|[List.ReplaceMatchingItems](list-replacematchingitems.md)|Replaces occurrences of existing values in the list with new values that match the condition.| +|[List.ReplaceRange](list-replacerange.md)|Replaces `count` number of values starting at `position` with the replacement values.| +|[List.ReplaceValue](list-replacevalue.md)|Searches a list for the specified value and replaces it.| +|[List.Reverse](list-reverse.md)|Reverses the order of values in the list.| |[List.Split](list-split.md)|Splits the specified list into a list of lists using the specified page size.| -|[List.Transform](list-transform.md)|Performs the function on each item in the list and returns the new list.| -|[List.TransformMany](list-transformmany.md)|Returns a list whose elements are projected from the input list.| - +|[List.Transform](list-transform.md)|Returns a new list of values computed from this list.| +|[List.TransformMany](list-transformmany.md)|Returns a list whose elements are transformed from the input list using specified functions.| +|[List.Zip](list-zip.md)|Returns a list of lists by combining items at the same position in multiple lists.| + ## Membership functions -Since all values can be tested for equality, these functions can operate over heterogeneous lists. - -|Name|Description| -|------------|---------------| -|[List.AllTrue](list-alltrue.md)|Returns true if all expressions in a list are true| -|[List.AnyTrue](list-anytrue.md)|Returns true if any expression in a list in true| -|[List.Contains](list-contains.md)|Returns true if a value is found in a list.| -|[List.ContainsAll](list-containsall.md)|Returns true if all items in values are found in a list.| -|[List.ContainsAny](list-containsany.md)|Returns true if any item in values is found in a list.| -|[List.PositionOf](list-positionof.md)|Finds the first occurrence of a value in a list and returns its position.| -|[List.PositionOfAny](list-positionofany.md)|Finds the first occurrence of any value in values and returns its position.| - -## Set operations - -|Name|Description| -|------------|---------------| -|[List.Difference](list-difference.md)|Returns the items in list 1 that do not appear in list 2. Duplicate values are supported.| -|[List.Intersect](list-intersect.md)|Returns a list from a list of lists and intersects common items in individual lists. Duplicate values are supported.| -|[List.Union](list-union.md)|Returns a list from a list of lists and unions the items in the individual lists. The returned list contains all items in any input lists. Duplicate values are matched as part of the Union.| -|[List.Zip](list-zip.md)|Returns a list of lists combining items at the same position.| - +Since all values can be tested for equality, these functions can operate over heterogeneous lists. + +|Name|Description| +|------------|---------------| +|[List.AllTrue](list-alltrue.md)|Returns `true` if all expressions are true.| +|[List.AnyTrue](list-anytrue.md)|Returns true if any expression is true.| +|[List.Contains](list-contains.md)|Indicates whether the list contains the value.| +|[List.ContainsAll](list-containsall.md)|Indicates where a list includes all the values in another list.| +|[List.ContainsAny](list-containsany.md)|Indicates where a list includes any of the values in another list.| +|[List.PositionOf](list-positionof.md)|Returns the offset(s) of a value in a list.| +|[List.PositionOfAny](list-positionofany.md)|Returns the first offset of a value in a list.| + +## Set operations + +|Name|Description| +|------------|---------------| +|[List.Difference](list-difference.md)|Returns the difference of the two given lists.| +|[List.Intersect](list-intersect.md)|Returns the intersection of the list values found in the input.| +|[List.Union](list-union.md)|Returns the union of the list values found in the input.| + ## Ordering -Ordering functions perform comparisons. All values that are compared must be comparable with each other. This means they must all come from the same datatype (or include null, which always compares smallest). Otherwise, an `Expression.Error` is thrown. - +Ordering functions perform comparisons. All values that are compared must be comparable with each other. This means they must all come from the same datatype (or include null, which always compares smallest). Otherwise, an `Expression.Error` is thrown. + Comparable data types include: -- Number -- Duration -- DateTime -- Text -- Logical -- Null - -|Name|Description| -|------------|---------------| -|[List.Max](list-max.md)|Returns the maximum item in a list, or the optional default value if the list is empty.| -|[List.MaxN](list-maxn.md)|Returns the maximum values in the list. The number of values to return or a filtering condition must be specified.| -|[List.Median](list-median.md)|Returns the median item from a list.| -|[List.Min](list-min.md)|Returns the minimum item in a list, or the optional default value if the list is empty.| -|[List.MinN](list-minn.md)|Returns the minimum values in a list. The number of values to return or a filtering condition may be specified.| -|[List.Sort](list-sort.md)|Returns a sorted list using comparison criterion.| -|[List.Percentile](list-percentile.md) | Returns one or more sample percentiles corresponding to the given probabilities.| - +- Number +- Duration +- DateTime +- Text +- Logical +- Null + +|Name|Description| +|------------|---------------| +|[List.Max](list-max.md)|Returns the maximum value or the default value for an empty list.| +|[List.MaxN](list-maxn.md)|Returns the maximum value(s) in the list. The number of values to return or a filtering condition must be specified.| +|[List.Median](list-median.md)|Returns the median value in the list.| +|[List.Min](list-min.md)|Returns the minimum value or the default value for an empty list.| +|[List.MinN](list-minn.md)|Returns the minimum value(s) in the list. The number of values to return or a filtering condition may be specified.| +|[List.Sort](list-sort.md)|Sorts a list of data according to the criteria specified.| +|[List.Percentile](list-percentile.md)|Returns one or more sample percentiles corresponding to the given probabilities.| + ## Averages -These functions operate over homogeneous lists of Numbers, DateTimes, and Durations. - -|Name|Description| -|------------|---------------| -|[List.Average](list-average.md)|Returns an average value from a list in the datatype of the values in the list.| -|[List.Mode](list-mode.md)|Returns an item that appears most commonly in a list.| -|[List.Modes](list-modes.md)|Returns all items that appear with the same maximum frequency.| -|[List.StandardDeviation](list-standarddeviation.md)|Returns the standard deviation from a list of values. **List.StandardDeviation** performs a sample based estimate. The result is a number for numbers, and a duration for DateTimes and Durations.| - +These functions operate over homogeneous lists of Numbers, DateTimes, and Durations. + +|Name|Description| +|------------|---------------| +|[List.Average](list-average.md)|Returns the average of the values. Works with number, date, datetime, datetimezone and duration values.| +|[List.Mode](list-mode.md)|Returns the most frequent value in the list.| +|[List.Modes](list-modes.md)|Returns a list of the most frequent values in the list.| +|[List.StandardDeviation](list-standarddeviation.md)|Returns a sample based estimate of the standard deviation. This function performs a sample based estimate. The result is a number for numbers, and a duration for DateTimes and Durations.| + ## Addition -These functions work over homogeneous lists of Numbers or Durations. - -|Name|Description| -|------------|---------------| -|[List.Sum](list-sum.md)|Returns the sum from a list.| - +These functions work over homogeneous lists of Numbers or Durations. + +|Name|Description| +|------------|---------------| +|[List.Sum](list-sum.md)|Returns the sum of the items in the list.| + ## Numerics -These functions only work over numbers. - -|Name|Description| -|------------|---------------| -|[List.Covariance](list-covariance.md)|Returns the covariance from two lists as a number.| -|[List.Product](list-product.md)|Returns the product from a list of numbers.| - +These functions only work over numbers. + +|Name|Description| +|------------|---------------| +|[List.Covariance](list-covariance.md)|Returns the covariance between the two lists of numbers.| +|[List.Product](list-product.md)|Returns the product of the numbers in the list.| + ## Generators -These functions generate list of values. - -|Name|Description| -|------------|---------------| -|[List.Dates](list-dates.md)|Returns a list of date values from size count, starting at start and adds an increment to every value.| -|[List.DateTimes](list-datetimes.md)|Returns a list of datetime values from size count, starting at start and adds an increment to every value.| -|[List.DateTimeZones](list-datetimezones.md)|Returns a list of of datetimezone values from size count, starting at start and adds an increment to every value.| -|[List.Durations](list-durations.md)|Returns a list of durations values from size count, starting at start and adds an increment to every value.| -|[List.Generate](list-generate.md)|Generates a list from a value function, a condition function, a next function, and an optional transformation function on the values.| -|[List.Numbers](list-numbers.md)|Returns a list of numbers from size count starting at initial, and adds an increment. The increment defaults to 1.| -|[List.Random](list-random.md)|Returns a list of count random numbers, with an optional seed parameter.| -|[List.Times](list-times.md)|Returns a list of time values of size count, starting at start.| - -## Parameter values - -### Occurrence specification - +These functions generate list of values. + +|Name|Description| +|------------|---------------| +|[List.Dates](list-dates.md)|Generates a list of `date` values given an initial value, count, and incremental duration value.| +|[List.DateTimes](list-datetimes.md)|Generates a list of `datetime` values given an initial value, count, and incremental duration value.| +|[List.DateTimeZones](list-datetimezones.md)|Generates a list of `datetimezone` values given an initial value, count, and incremental duration value.| +|[List.Durations](list-durations.md)|Generates a list of `duration` values given an initial value, count, and incremental duration value.| +|[List.Generate](list-generate.md)|Generates a list of values.| +|[List.Numbers](list-numbers.md)|Returns a list of numbers given an initial value, count, and optional increment value.| +|[List.Random](list-random.md)|Returns a list of random numbers.| +|[List.Times](list-times.md)|Generates a list of `time` values given an initial value, count, and incremental duration value.| + +## Parameter values + +### Occurrence specification + - [Occurrence.First](occurrence-type.md) = 0; - [Occurrence.Last](occurrence-type.md) = 1; - [Occurrence.All](occurrence-type.md) = 2; -### Sort order +### Sort order - [Order.Ascending](order-type.md) = 0; - [Order.Descending](order-type.md) = 1; ### Equation criteria -Equation criteria for list values can be specified as either: - +In many of the list functions, the `equationCriteria` parameter indicates how equality is determined between list elements. Equation criteria for list values can be specified as either: + - A function value that is either: - A key selector that determines the value in the list to apply the equality criteria. - - A comparer function that is used to specify the kind of comparison to apply. Built in comparer functions can be specified—go to [Comparer functions](comparer-functions.md). + - A comparer function that is used to specify the kind of comparison to apply. Built-in comparer functions can be specified—go to [Comparer functions](comparer-functions.md). - A list value that has: - Exactly two items. - The first element is the key selector as specified above. - - The second element is a comparer as specified above. - -For more information and examples, go to [List.Distinct](list-distinct.md). - + - The second element is a comparer as specified above. + +In most list functions, the comparer function used in the `equationCriteria` parameter must be one of the built-in [comparer functions](comparer-functions.md). In those list functions, using a custom comparer results in an error. However, the following list functions allow you to use a custom comparer: + +- [List.Contains](list-contains.md) +- [List.ContainsAll](list-containsall.md) +- [List.ContainsAny](list-containsany.md) +- [List.PositionOf](list-positionof.md) +- [List.PositionOfAny](list-positionofany.md) + +For more information and examples, go to [List.Distinct](list-distinct.md) and [List.PositionOf](list-positionof.md). + ### Comparison criteria Comparison criterion can be provided as either of the following values: @@ -190,10 +192,10 @@ Comparison criterion can be provided as either of the following values: - A number value to specify a sort order. For more information, go to [Sort order](#sort-order). - To compute a key to be used for sorting, a function of one argument can be used. - To both select a key and control order, comparison criterion can be a list containing the key and order. -- To completely control the comparison, a function of two arguments can be used that returns -1, 0, or 1 given the relationship between the left and right inputs. [Value.Compare](value-compare.md) is a method that can be used to delegate this logic. - -For more information and examples, go to [List.Sort](list-sort.md). - +- To completely control the comparison, a function of two arguments can be used that returns -1, 0, or 1 given the relationship between the left and right inputs. [Value.Compare](value-compare.md) is a method that can be used to delegate this logic. + +For more information and examples, go to [List.Sort](list-sort.md). + ### Replacement operations Replacement operations are specified by a list value. Each item of this list must be: diff --git a/query-languages/m/list-generate.md b/query-languages/m/list-generate.md index 4cf24b891..6f9c43aff 100644 --- a/query-languages/m/list-generate.md +++ b/query-languages/m/list-generate.md @@ -1,30 +1,28 @@ --- description: "Learn more about: List.Generate" -title: "List.Generate | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Generate" +ms.subservice: m-source --- # List.Generate - + ## Syntax
-List.Generate(initial as function, condition as function, next as function, optional selector as nullable function) as list
+List.Generate(
+    initial as function,
+    condition as function,
+    next as function,
+    optional selector as nullable function
+) as list
 
## About -Generates a list of values given four functions that generate the initial value `initial`, test against a condition `condition`, and if successful select the result and generate the next value `next`. An optional parameter, `selector`, may also be specified. +Generates a list of values using the provided functions. The `initial` function generates a starting candidate value, which is then tested against `condition`. If the candidate value is approved, then it's returned as part of the resulting list, and the next candidate value is generated by passing the newly approved value to `next`. Once a candidate value fails to match `condition`, the list generation process stops. An optional parameter, `selector`, may also be provided to transform the items in the resulting list. ## Example 1 -Create a list that starts at 10, remains greater than 0 and decrements by 1. +Create a list by starting at ten, repeatedly decrementing by one, and ensuring each item is greater than zero. **Usage** diff --git a/query-languages/m/list-insertrange.md b/query-languages/m/list-insertrange.md index b17b6c8cf..4e3951a98 100644 --- a/query-languages/m/list-insertrange.md +++ b/query-languages/m/list-insertrange.md @@ -1,30 +1,27 @@ --- description: "Learn more about: List.InsertRange" -title: "List.InsertRange | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.InsertRange" +ms.subservice: m-source --- # List.InsertRange ## Syntax
-List.InsertRange(list as list, index as number, values as list) as list
+List.InsertRange(
+    list as list,
+    index as number,
+    values as list
+) as list
 
-## About +## About Returns a new list produced by inserting the values in `values` into `list` at `index`. The first position in the list is at index 0. * `list`: The target list where values are to be inserted. * `index`: The index of the target list(`list`) where the values are to be inserted. The first position in the list is at index 0. -* `values`: The list of values which are to be inserted into `list`. +* `values`: The list of values which are to be inserted into `list`. ## Example 1 diff --git a/query-languages/m/list-intersect.md b/query-languages/m/list-intersect.md index 7f5d76895..185995908 100644 --- a/query-languages/m/list-intersect.md +++ b/query-languages/m/list-intersect.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Intersect" -title: "List.Intersect | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Intersect" +ms.subservice: m-source --- # List.Intersect @@ -17,7 +10,7 @@ ms.author: dougklo
 List.Intersect(lists as list, optional equationCriteria as any) as list
 
- + ## About Returns the intersection of the list values found in the input list `lists`. An optional parameter, `equationCriteria`, can be specified. @@ -35,3 +28,7 @@ List.Intersect({{1..5}, {2..6}, {3..7}}) **Output** `{3, 4, 5}` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-isdistinct.md b/query-languages/m/list-isdistinct.md index 4cdc6e304..8dad8b842 100644 --- a/query-languages/m/list-isdistinct.md +++ b/query-languages/m/list-isdistinct.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.IsDistinct" -title: "List.IsDistinct | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.IsDistinct" +ms.subservice: m-source --- # List.IsDistinct @@ -17,7 +10,7 @@ ms.author: dougklo
 List.IsDistinct(list as list, optional equationCriteria as any) as logical
 
- + ## About Returns a logical value whether there are duplicates in the list `list`; `true` if the list is distinct, `false` if there are duplicate values. @@ -49,3 +42,7 @@ List.IsDistinct({1, 2, 3, 3}) **Output** `false` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-isempty.md b/query-languages/m/list-isempty.md index 9b5c9029e..c72a9ad46 100644 --- a/query-languages/m/list-isempty.md +++ b/query-languages/m/list-isempty.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.IsEmpty" -title: "List.IsEmpty | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.IsEmpty" +ms.subservice: m-source --- # List.IsEmpty @@ -17,7 +10,7 @@ ms.author: dougklo
 List.IsEmpty(list as list) as logical
 
- + ## About Returns `true` if the list, `list`, contains no values (length 0). If the list contains values (length > 0), returns `false`. diff --git a/query-languages/m/list-last.md b/query-languages/m/list-last.md index 333e23b45..0717a360d 100644 --- a/query-languages/m/list-last.md +++ b/query-languages/m/list-last.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Last" -title: "List.Last | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Last" +ms.subservice: m-source --- # List.Last @@ -17,7 +10,7 @@ ms.author: dougklo
 List.Last(list as list, optional defaultValue as any) as any 
 
- + ## About Returns the last item in the list `list`, or the optional default value, `defaultValue`, if the list is empty. If the list is empty and a default value is not specified, the function returns `null`. diff --git a/query-languages/m/list-lastn.md b/query-languages/m/list-lastn.md index 4b84c5bf5..46cd1e33c 100644 --- a/query-languages/m/list-lastn.md +++ b/query-languages/m/list-lastn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.LastN" -title: "List.LastN | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.LastN" +ms.subservice: m-source --- # List.LastN @@ -17,7 +10,7 @@ ms.author: dougklo
 List.LastN(list as list, optional countOrCondition as any) as any
 
- + ## About Returns the last item of the list `list`. If the list is empty, an exception is thrown. This function takes an optional parameter, `countOrCondition`, to support gathering multiple items or filtering items. `countOrCondition` can be specified in three ways: diff --git a/query-languages/m/list-matchesall.md b/query-languages/m/list-matchesall.md index 476a27710..c1ce9f7dc 100644 --- a/query-languages/m/list-matchesall.md +++ b/query-languages/m/list-matchesall.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.MatchesAll" -title: "List.MatchesAll | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.MatchesAll" +ms.subservice: m-source --- # List.MatchesAll @@ -17,10 +10,13 @@ ms.author: dougklo
 List.MatchesAll(list as list, condition as function) as logical
 
- + ## About -Returns `true` if the condition function, `condition`, is satisfied by all values in the list `list`, otherwise returns `false`. +Returns `true` if the condition function is satisfied by all of the values in the list, otherwise returns `false`. + +* `list`: The list containing the values to check. +* `condition`: The condition to check against the values in the list. ## Example 1 @@ -49,3 +45,39 @@ List.MatchesAll({1, 2, 3}, each _ > 10) **Output** `false` + +## Example 3 + +Determine if all the text values in the list contain "anna" while ignoring case. + +**Usage** + +```powerquery-m +let + Source = {"Savannah", "Annabelle", "Annals", "wannabe", "MANNA"}, + Result = List.MatchesAll(Source, each Text.Contains(_, "anna", Comparer.OrdinalIgnoreCase)) +in + Result +``` + +**Output** + +`true` + +## Example 4 + +Determine if all the dates contain the year 2021. + +**Usage** + +```powerquery-m +let + Source = {#date(2021, 11, 28), #date(2021, 1, 14), #date(2021, 12, 31), #date(2021, 7, 6)}, + Result = List.MatchesAll(Source, each Date.Year(_) = 2021) +in + Result +``` + +**Output** + +`true` diff --git a/query-languages/m/list-matchesany.md b/query-languages/m/list-matchesany.md index 4c8f41138..51a12dbae 100644 --- a/query-languages/m/list-matchesany.md +++ b/query-languages/m/list-matchesany.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.MatchesAny" -title: "List.MatchesAny | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.MatchesAny" +ms.subservice: m-source --- # List.MatchesAny @@ -17,14 +10,17 @@ ms.author: dougklo
 List.MatchesAny(list as list, condition as function) as logical
 
- + ## About -Returns `true` if the condition function, `condition`, is satisfied by any of values in the list `list`, otherwise returns `false`. +Returns `true` if the condition function is satisfied by any of the values in the list, otherwise returns `false`. + +* `list`: The list containing the values to check. +* `condition`: The condition to check against the values in the list. ## Example 1 -Find if any of the values in the list {9, 10, 11} are greater than 10. +Determine if any of the values in the list {9, 10, 11} are greater than 10. **Usage** @@ -38,7 +34,7 @@ List.MatchesAny({9, 10, 11}, each _ > 10) ## Example 2 -Find if any of the values in the list {1, 2, 3} are greater than 10. +Determine if any of the values in the list {1, 2, 3} are greater than 10. **Usage** @@ -49,3 +45,39 @@ List.MatchesAny({1, 2, 3}, each _ > 10) **Output** `false` + +## Example 3 + +Determine if any of the text values in the list contain "cat" while ignoring case. + +**Usage** + +```powerquery-m +let + Source = {"A Brown Fox", "A Loyal Dog", "A Curious Cat", "A Wild Horse", "A Rascally Rabbit"}, + Result = List.MatchesAny(Source, each Text.Contains(_, "cat", Comparer.OrdinalIgnoreCase)) +in + Result +``` + +**Output** + +`true` + +## Example 4 + +Determine if any of the dates contain the year 2021. + +**Usage** + +```powerquery-m +let + Source = {#date(2024, 11, 28), #date(2023, 1, 14), #date(2021, 12, 31), #date(2025, 7, 6)}, + Result = List.MatchesAny(Source, each Date.Year(_) = 2021) +in + Result +``` + +**Output** + +`true` diff --git a/query-languages/m/list-max.md b/query-languages/m/list-max.md index 90c083339..8bc398418 100644 --- a/query-languages/m/list-max.md +++ b/query-languages/m/list-max.md @@ -1,21 +1,19 @@ --- description: "Learn more about: List.Max" -title: "List.Max | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Max" +ms.subservice: m-source --- # List.Max ## Syntax
-List.Max(list as list, optional default as any, optional comparisonCriteria as any, optional includeNulls as nullable logical) as any
+List.Max(
+    list as list,
+    optional default as any,
+    optional comparisonCriteria as any,
+    optional includeNulls as nullable logical
+) as any
 
## About @@ -49,3 +47,7 @@ List.Max({}, -1) **Output** `-1` + +## Related content + +[Comparison criteria](list-functions.md#comparison-criteria) diff --git a/query-languages/m/list-maxn.md b/query-languages/m/list-maxn.md index 6680bea07..80bdaa2e1 100644 --- a/query-languages/m/list-maxn.md +++ b/query-languages/m/list-maxn.md @@ -1,21 +1,19 @@ --- description: "Learn more about: List.MaxN" -title: "List.MaxN | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.MaxN" +ms.subservice: m-source --- # List.MaxN ## Syntax
-List.MaxN(list as list, countOrCondition as any, optional comparisonCriteria as any, optional includeNulls as nullable logical) as list
+List.MaxN(
+    list as list,
+    countOrCondition as any,
+    optional comparisonCriteria as any,
+    optional includeNulls as nullable logical
+) as list
 
## About @@ -25,3 +23,7 @@ Returns the maximum value(s) in the list, `list`. After the rows are sorted, opt * `list`: The list of values. * `countOrCondition`: If a number is specified, a list of up to `countOrCondition` items in ascending order is returned. If a condition is specified, a list of items that initially meet the condition is returned. Once an item fails the condition, no further items are considered. * `comparisonCriteria`: _[Optional]_ An optional `comparisonCriteria` value can be specified to determine how to compare the items in the list. If this parameter is null, the default comparer is used. + +## Related content + +[Comparison criteria](list-functions.md#comparison-criteria) diff --git a/query-languages/m/list-median.md b/query-languages/m/list-median.md index 10a1b250e..0313d0cc6 100644 --- a/query-languages/m/list-median.md +++ b/query-languages/m/list-median.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Median" -title: "List.Median | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Median" +ms.subservice: m-source --- # List.Median @@ -35,3 +28,7 @@ powerquery-mList.Median({5, 3, 1, 7, 9}) **Output** `5` + +## Related content + +[Comparison criteria](list-functions.md#comparison-criteria) diff --git a/query-languages/m/list-min.md b/query-languages/m/list-min.md index 130e60a3c..96ea35905 100644 --- a/query-languages/m/list-min.md +++ b/query-languages/m/list-min.md @@ -1,21 +1,19 @@ --- description: "Learn more about: List.Min" -title: "List.Min | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Min" +ms.subservice: m-source --- # List.Min ## Syntax
-List.Min(list as list, optional default as any, optional comparisonCriteria as any, optional includeNulls as nullable logical) as any
+List.Min(
+    list as list,
+    optional default as any,
+    optional comparisonCriteria as any,
+    optional includeNulls as nullable logical
+) as any
 
## About @@ -49,3 +47,7 @@ List.Min({}, -1) **Output** `-1` + +## Related content + +[Comparison criteria](list-functions.md#comparison-criteria) diff --git a/query-languages/m/list-minn.md b/query-languages/m/list-minn.md index 4a2807af4..0c6520293 100644 --- a/query-languages/m/list-minn.md +++ b/query-languages/m/list-minn.md @@ -1,21 +1,19 @@ --- description: "Learn more about: List.MinN" -title: "List.MinN | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.MinN" +ms.subservice: m-source --- # List.MinN ## Syntax
-List.MinN(list as list, countOrCondition as any, optional comparisonCriteria as any, optional includeNulls as nullable logical) as list
+List.MinN(
+    list as list,
+    countOrCondition as any,
+    optional comparisonCriteria as any,
+    optional includeNulls as nullable logical
+) as list
 
## About @@ -39,3 +37,7 @@ List.MinN({3, 4, 5, -1, 7, 8, 2}, 5) **Output** `{-1, 2, 3, 4, 5}` + +## Related content + +[Comparison criteria](list-functions.md#comparison-criteria) diff --git a/query-languages/m/list-mode.md b/query-languages/m/list-mode.md index 33db533a7..fff490b8a 100644 --- a/query-languages/m/list-mode.md +++ b/query-languages/m/list-mode.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Mode" -title: "List.Mode | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Mode" +ms.subservice: m-source --- # List.Mode @@ -20,7 +13,7 @@ List.Mode(list as list, optional equationCriteria as any) as any ## About -Returns the item that appears most frequently in the list, `list`. If the list is empty an exception is thrown. If multiple items appear with the same maximum frequency, the last one is chosen. An optional `comparisonCriteria` value, `equationCriteria`, can be specified to control equality testing. +Returns the item that appears most frequently in `list`. If the list is empty an exception is thrown. If multiple items appear with the same maximum frequency, the last one is chosen. An optional comparison criteria value, `equationCriteria`, can be specified to control equality testing. ## Example 1 @@ -49,3 +42,7 @@ List.Mode({"A", 1, 2, 3, 3, 4, 5, 5}) **Output** `5` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-modes.md b/query-languages/m/list-modes.md index d0f6f87a6..f44b6aa44 100644 --- a/query-languages/m/list-modes.md +++ b/query-languages/m/list-modes.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Modes" -title: "List.Modes | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Modes" +ms.subservice: m-source --- # List.Modes @@ -20,7 +13,7 @@ List.Modes(list as list, optional equationCriteria as any) as list ## About -Returns the item that appears most frequently in the list, `list`. If the list is empty an exception is thrown. If multiple items appear with the same maximum frequency, the last one is chosen. An optional `comparisonCriteria` value, `equationCriteria`, can be specified to control equality testing. +Returns the items that appear most frequently in `list`. If the list is empty an exception is thrown. If multiple items appear with the same maximum frequency, all of them are returned. An optional comparison criteria value, `equationCriteria`, can be specified to control equality testing. ## Example 1 @@ -35,3 +28,7 @@ List.Modes({"A", 1, 2, 3, 3, 4, 5, 5}) **Output** `{3, 5}` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-nonnullcount.md b/query-languages/m/list-nonnullcount.md index 054b39222..2cd72349e 100644 --- a/query-languages/m/list-nonnullcount.md +++ b/query-languages/m/list-nonnullcount.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.NonNullCount" -title: "List.NonNullCount | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.NonNullCount" +ms.subservice: m-source --- # List.NonNullCount @@ -17,6 +10,7 @@ ms.author: dougklo
 List.NonNullCount(list as list) as number
 
- -## About + +## About + Returns the number of non-null items in the list `list`. diff --git a/query-languages/m/list-numbers.md b/query-languages/m/list-numbers.md index 59af0c92d..092b09eb2 100644 --- a/query-languages/m/list-numbers.md +++ b/query-languages/m/list-numbers.md @@ -1,30 +1,27 @@ --- description: "Learn more about: List.Numbers" -title: "List.Numbers | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Numbers" +ms.subservice: m-source --- # List.Numbers ## Syntax
-List.Numbers(start as number, count as number, optional increment as nullable number) as list
+List.Numbers(
+    start as number,
+    count as number,
+    optional increment as nullable number
+) as list
 
- + ## About Returns a list of numbers given an initial value, count, and optional increment value. The default increment value is 1. * `start`: The initial value in the list. * `count`: The number of values to create. -* `increment: _[Optional]_ The value to increment by. If omitted values are incremented by 1. +* `increment`: _[Optional]_ The value to increment by. If omitted values are incremented by 1. ## Example 1 diff --git a/query-languages/m/list-percentile.md b/query-languages/m/list-percentile.md index cf60edb8c..bb0a48a21 100644 --- a/query-languages/m/list-percentile.md +++ b/query-languages/m/list-percentile.md @@ -1,27 +1,25 @@ --- description: "Learn more about: List.Percentile" -title: "List.Percentile | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Percentile" +ms.subservice: m-source --- # List.Percentile ## Syntax
-List.Percentile(list as list, percentiles as any, optional options as nullable record) as any
+List.Percentile(
+    list as list,
+    percentiles as any,
+    optional options as nullable record
+) as any
 
## About Returns one or more sample percentiles of the list `list`. If the value `percentiles` is a number between 0.0 and 1.0, it will be treated as a percentile and the result will be a single value corresponding to that probability. If the value `percentiles` is a list of numbers with values between 0.0 and 1.0, the result will be a list of percentiles corresponding to the input probability. -The PercentileMode option in `options` can be used by advanced users to pick a more-specific interpolation method but is not recommended for most uses. Predefined symbols [PercentileMode.ExcelInc](/powerquery-m/percentilemode-excelinc) and [PercentileMode.ExcelExc](/powerquery-m/percentilemode-excelexc) match the interpolation methods used by the Excel functions `PERCENTILE.INC` and `PERCENTILE.EXC`. The default behavior matches **PercentileMode.ExcelInc**. The symbols [PercentileMode.SqlCont](/powerquery-m/percentilemode-sqlcont) and [PercentileMode.SqlDisc](/powerquery-m/percentilemode-sqldisc) match the SQL Server behavior for `PERCENTILE_CONT` and `PERCENTILE_DISC`, respectively. +The PercentileMode option in `options` can be used by advanced users to pick a more-specific interpolation method but is not recommended for most uses. Predefined symbols [PercentileMode.ExcelInc](percentilemode-type.md) and [PercentileMode.ExcelExc](percentilemode-type.md) match the interpolation methods used by the Excel functions `PERCENTILE.INC` and `PERCENTILE.EXC`. The default behavior matches **PercentileMode.ExcelInc**. The symbols [PercentileMode.SqlCont](percentilemode-type.md) and [PercentileMode.SqlDisc](percentilemode-type.md) match the SQL Server behavior for `PERCENTILE_CONT` and `PERCENTILE_DISC`, respectively. ## Example 1 diff --git a/query-languages/m/list-positionof.md b/query-languages/m/list-positionof.md index 784e52bf6..8a750cb30 100644 --- a/query-languages/m/list-positionof.md +++ b/query-languages/m/list-positionof.md @@ -1,26 +1,29 @@ --- description: "Learn more about: List.PositionOf" -title: "List.PositionOf | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.PositionOf" +ms.subservice: m-source --- # List.PositionOf ## Syntax
-List.PositionOf(list as list, value as any, optional occurrence as nullable number, optional equationCriteria as any) as any
+List.PositionOf(
+    list as list,
+    value as any,
+    optional occurrence as nullable number,
+    optional equationCriteria as any
+) as any
 
## About -Returns the offset at which the value `value` appears in the list `list`. Returns -1 if the value doesn't appear. An optional occurrence parameter `occurrence` can be specified.
  • occurrence: The maximum number of occurrences to report.
+Returns the offset at which the specified value appears in a list. Returns -1 if the value doesn't appear. + +* `list`: The list to search. +* `value`: The value to find in the list. +* `occurrence`: (Optional) The specific occurrence to report. This value can be [Occurrence.First](occurrence-type.md), [Occurrence.Last](occurrence-type.md), or [Occurrence.All](occurrence-type.md). If no `occurrence` is specified, `Occurrence.First` is used. +* `equationCriteria`: (Optional) Specifies how equality is determined when comparing values. This parameter can be a key selector function, a comparer function, or a list containing both a key selector and a comparer. ## Example 1 @@ -35,3 +38,79 @@ List.PositionOf({1, 2, 3}, 3) **Output** `2` + +## Example 2 + +Find the position in the list of all instances of dates from 2022. + +**Usage** + +```powerquery-m +let + Source = { + #date(2021, 5, 10), + #date(2022, 6, 28), + #date(2023, 7, 15), + #date(2022, 12, 31), + #date(2022, 4, 8), + #date(2024, 3, 20) + }, + YearList = List.Transform(Source, each Date.Year(_)), + TargetYear = 2022, + FindPositions = List.PositionOf(YearList, TargetYear, Occurrence.All) +in + FindPositions +``` + +**Output** + +`{1, 3, 4}` + +## Example 3 + +Find the position in the list of the last occurrence of the word dog, ignoring case. + +**Usage** + +```powerquery-m +let + Source = List.PositionOf( + {"dog", "cat", "DOG", "pony", "bat", "rabbit", "dOG"}, + "dog", + Occurrence.Last, + Comparer.OrdinalIgnoreCase + ) +in + Source +``` + +**Output** + +`6` + +## Example 4 + +Find the position in the list that's within two units of the number 28. + +**Usage** + +```powerquery-m +let + Source = { 10, 15, 20, 25, 30 }, + Position = List.PositionOf( + Source, + 28, + Occurrence.First, + (x, y) => Number.Abs(x - y) <= 2 + ) +in + Position +``` + +**Output** + +`4` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-positionofany.md b/query-languages/m/list-positionofany.md index 7b773ff1a..34bd7f6ca 100644 --- a/query-languages/m/list-positionofany.md +++ b/query-languages/m/list-positionofany.md @@ -1,28 +1,29 @@ --- description: "Learn more about: List.PositionOfAny" -title: "List.PositionOfAny | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.PositionOfAny" +ms.subservice: m-source --- # List.PositionOfAny ## Syntax
-List.PositionOfAny(list as list, values as list, optional occurrence as nullable number, optional equationCriteria as any) as any
+List.PositionOfAny(
+    list as list,
+    values as list,
+    optional occurrence as nullable number,
+    optional equationCriteria as any
+) as any
 
## About -Returns the offset in list `list` of the first occurrence of a value in a list `values`. Returns -1 if no occurrence is found. An optional occurrence parameter `occurrence` can be specified. +Returns the offset at which an item from the specified list of values appears in a list. Returns -1 if no occurrence is found. -* `occurrence`: The maximum number of occurrences that can be returned. +* `list`: The list to search. +* `values`: The list of values to find in the original list. +* `occurrence`: (Optional) The specific occurrence to report. This value can be [Occurrence.First](occurrence-type.md), [Occurrence.Last](occurrence-type.md), or [Occurrence.All](occurrence-type.md). If no `occurrence` is specified, `Occurrence.First` is used. +* `equationCriteria`: (Optional) Specifies how equality is determined when comparing values. This parameter can be a key selector function, a comparer function, or a list containing both a key selector and a comparer. ## Example 1 @@ -37,3 +38,79 @@ List.PositionOfAny({1, 2, 3}, {2, 3}) **Output** `1` + +## Example 2 + +Find the position in the list of all instances of dates from either 2022 or 2023. + +**Usage** + +```powerquery-m +let + Source = { + #date(2021, 5, 10), + #date(2022, 6, 28), + #date(2023, 7, 15), + #date(2025, 12, 31), + #date(2022, 4, 8), + #date(2024, 3, 20) + }, + YearList = List.Transform(Source, each Date.Year(_)), + TargetYear = {2022, 2023}, + FindPositions = List.PositionOfAny(YearList, TargetYear, Occurrence.All) +in + FindPositions +``` + +**Output** + +`{1, 2, 4}` + +## Example 3 + +Find the position in the list of the last occurrence of either the word dog or cat, ignoring case. + +**Usage** + +```powerquery-m +let + Source = List.PositionOfAny( + {"dog", "cat", "DOG", "pony", "bat", "rabbit", "dOG"}, + {"dog", "cat"}, + Occurrence.Last, + Comparer.OrdinalIgnoreCase + ) +in + Source +``` + +**Output** + +`6` + +## Example 4 + +Find any position in the list that's within two units of either the number 17 or 28. + +**Usage** + +```powerquery-m +let + Source = { 10, 15, 20, 25, 30 }, + Position = List.PositionOfAny( + Source, + {17, 28}, + Occurrence.All, + (x, y) => Number.Abs(x - y) <= 2 + ) +in + Position +``` + +**Output** + +`{1, 4}` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-positions.md b/query-languages/m/list-positions.md index 33f12fa25..7422ccd8c 100644 --- a/query-languages/m/list-positions.md +++ b/query-languages/m/list-positions.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Positions" -title: "List.Positions | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Positions" +ms.subservice: m-source --- # List.Positions diff --git a/query-languages/m/list-product.md b/query-languages/m/list-product.md index 2ee254c35..3006b9773 100644 --- a/query-languages/m/list-product.md +++ b/query-languages/m/list-product.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Product" -title: "List.Product | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Product" +ms.subservice: m-source --- # List.Product diff --git a/query-languages/m/list-random.md b/query-languages/m/list-random.md index 0db3d9f03..afd9d81c0 100644 --- a/query-languages/m/list-random.md +++ b/query-languages/m/list-random.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Random" -title: "List.Random | Microsoft Docs" -ms.date: 3/8/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Random" +ms.subservice: m-source --- # List.Random diff --git a/query-languages/m/list-range.md b/query-languages/m/list-range.md index 5e9a0580f..fb0bba063 100644 --- a/query-languages/m/list-range.md +++ b/query-languages/m/list-range.md @@ -1,26 +1,23 @@ --- description: "Learn more about: List.Range" -title: "List.Range | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Range" +ms.subservice: m-source --- # List.Range ## Syntax
-List.Range(list as list, offset as number, optional count as nullable number) as list
+List.Range(
+    list as list,
+    offset as number,
+    optional count as nullable number
+) as list
 
## About -Returns a subset of the list beginning at the offset `list`. An optional parameter, `offset`, sets the maximum number of items in the subset. +Returns a subset of `list` beginning at `offset`. An optional parameter, `count`, sets the maximum number of items in the subset. ## Example 1 diff --git a/query-languages/m/list-removefirstn.md b/query-languages/m/list-removefirstn.md index 110aef108..8d5c2787b 100644 --- a/query-languages/m/list-removefirstn.md +++ b/query-languages/m/list-removefirstn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.RemoveFirstN" -title: "List.RemoveFirstN | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.RemoveFirstN" +ms.subservice: m-source --- # List.RemoveFirstN @@ -23,7 +16,7 @@ List.RemoveFirstN(list as list, optional countOrCondition as any) Returns a list that removes the first element of list `list`. If `list` is an empty list an empty list is returned. This function takes an optional parameter, `countOrCondition`, to support removing multiple values as listed below. * If a number is specified, up to that many items are removed. -* If a condition is specified, the returned list begins with the first element in `list` that meets the criteria. Once an item fails the condition, no further items are considered. +* If a condition is specified, any consecutive matching items at the start of `list` are removed. * If this parameter is null, the default behavior is observed. ## Example 1 diff --git a/query-languages/m/list-removeitems.md b/query-languages/m/list-removeitems.md index 8434af25a..e3c35c773 100644 --- a/query-languages/m/list-removeitems.md +++ b/query-languages/m/list-removeitems.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.RemoveItems" -title: "List.RemoveItems | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.RemoveItems" +ms.subservice: m-source --- # List.RemoveItems diff --git a/query-languages/m/list-removelastn.md b/query-languages/m/list-removelastn.md index 98f5104fd..27f30154e 100644 --- a/query-languages/m/list-removelastn.md +++ b/query-languages/m/list-removelastn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.RemoveLastN" -title: "List.RemoveLastN | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.RemoveLastN" +ms.subservice: m-source --- # List.RemoveLastN @@ -23,7 +16,7 @@ List.RemoveLastN(list as list, optional countOrCondition as any) a Returns a list that removes the last `countOrCondition` elements from the end of list `list`. If `list` has less than `countOrCondition` elements, an empty list is returned. * If a number is specified, up to that many items are removed. -* If a condition is specified, the returned list ends with the first element from the bottom in `list` that meets the criteria. Once an item fails the condition, no further items are considered. +* If a condition is specified, any consecutive matching items at the end of `list` are removed. * If this parameter is null, only one item is removed. ## Example 1 diff --git a/query-languages/m/list-removematchingitems.md b/query-languages/m/list-removematchingitems.md index ad8b21670..a031d4c03 100644 --- a/query-languages/m/list-removematchingitems.md +++ b/query-languages/m/list-removematchingitems.md @@ -1,21 +1,18 @@ --- description: "Learn more about: List.RemoveMatchingItems" -title: "List.RemoveMatchingItems | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.RemoveMatchingItems" +ms.subservice: m-source --- # List.RemoveMatchingItems ## Syntax
-List.RemoveMatchingItems(list1 as list, list2 as list, optional equationCriteria as any) as list
+List.RemoveMatchingItems(
+    list1 as list,
+    list2 as list,
+    optional equationCriteria as any
+) as list
 
## About @@ -35,3 +32,7 @@ List.RemoveMatchingItems({1, 2, 3, 4, 5, 5}, {1, 5}) **Output** `{2, 3, 4}` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-removenulls.md b/query-languages/m/list-removenulls.md index 996291694..c4b21900c 100644 --- a/query-languages/m/list-removenulls.md +++ b/query-languages/m/list-removenulls.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.RemoveNulls" -title: "List.RemoveNulls | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.RemoveNulls" +ms.subservice: m-source --- # List.RemoveNulls diff --git a/query-languages/m/list-removerange.md b/query-languages/m/list-removerange.md index c1dcd49b9..4610c6517 100644 --- a/query-languages/m/list-removerange.md +++ b/query-languages/m/list-removerange.md @@ -1,21 +1,18 @@ --- description: "Learn more about: List.RemoveRange" -title: "List.RemoveRange | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.RemoveRange" +ms.subservice: m-source --- # List.RemoveRange ## Syntax
-List.RemoveRange(list as list, index as number, optional count as nullable number) as list
+List.RemoveRange(
+    list as list,
+    index as number,
+    optional count as nullable number
+) as list
 
## About diff --git a/query-languages/m/list-repeat.md b/query-languages/m/list-repeat.md index 63a4efcfe..bb91d7474 100644 --- a/query-languages/m/list-repeat.md +++ b/query-languages/m/list-repeat.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Repeat" -title: "List.Repeat | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Repeat" +ms.subservice: m-source --- # List.Repeat diff --git a/query-languages/m/list-replacematchingitems.md b/query-languages/m/list-replacematchingitems.md index 742a6dad9..77194570a 100644 --- a/query-languages/m/list-replacematchingitems.md +++ b/query-languages/m/list-replacematchingitems.md @@ -1,21 +1,18 @@ --- description: "Learn more about: List.ReplaceMatchingItems" -title: "List.ReplaceMatchingItems | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.ReplaceMatchingItems" +ms.subservice: m-source --- # List.ReplaceMatchingItems ## Syntax
-List.ReplaceMatchingItems(list as list, replacements as list, optional equationCriteria as any) as list
+List.ReplaceMatchingItems(
+    list as list,
+    replacements as list,
+    optional equationCriteria as any
+) as list
 
## About @@ -35,3 +32,7 @@ List.ReplaceMatchingItems({1, 2, 3, 4, 5}, {{5, -5}, {1, -1}}) **Output** `{-1, 2, 3, 4, -5}` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-replacerange.md b/query-languages/m/list-replacerange.md index b4482e5fa..08ea0d655 100644 --- a/query-languages/m/list-replacerange.md +++ b/query-languages/m/list-replacerange.md @@ -1,21 +1,19 @@ --- description: "Learn more about: List.ReplaceRange" -title: "List.ReplaceRange | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.ReplaceRange" +ms.subservice: m-source --- # List.ReplaceRange ## Syntax
-List.ReplaceRange(list as list, index as number, count as number, replaceWith as list) as list
+List.ReplaceRange(
+    list as list,
+    index as number,
+    count as number,
+    replaceWith as list
+) as list
 
## About diff --git a/query-languages/m/list-replacevalue.md b/query-languages/m/list-replacevalue.md index 3d5e55747..e2016da92 100644 --- a/query-languages/m/list-replacevalue.md +++ b/query-languages/m/list-replacevalue.md @@ -1,21 +1,19 @@ --- description: "Learn more about: List.ReplaceValue" -title: "List.ReplaceValue | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.ReplaceValue" +ms.subservice: m-source --- # List.ReplaceValue ## Syntax
-List.ReplaceValue(list as list, oldValue as any, newValue as any, replacer as function) as list
+List.ReplaceValue(
+    list as list,
+    oldValue as any,
+    newValue as any,
+    replacer as function
+) as list
 
## About diff --git a/query-languages/m/list-reverse.md b/query-languages/m/list-reverse.md index d3dce0d2c..f4794430f 100644 --- a/query-languages/m/list-reverse.md +++ b/query-languages/m/list-reverse.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Reverse" -title: "List.Reverse | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Reverse" +ms.subservice: m-source --- # List.Reverse diff --git a/query-languages/m/list-select.md b/query-languages/m/list-select.md index c754228f8..803cb77c9 100644 --- a/query-languages/m/list-select.md +++ b/query-languages/m/list-select.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Select" -title: "List.Select | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Select" +ms.subservice: m-source --- # List.Select diff --git a/query-languages/m/list-single.md b/query-languages/m/list-single.md index ca28fcc9b..1ca4f4ea1 100644 --- a/query-languages/m/list-single.md +++ b/query-languages/m/list-single.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Single" -title: "List.Single | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Single" +ms.subservice: m-source --- # List.Single diff --git a/query-languages/m/list-singleordefault.md b/query-languages/m/list-singleordefault.md index 24b7a0826..a53d9277b 100644 --- a/query-languages/m/list-singleordefault.md +++ b/query-languages/m/list-singleordefault.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.SingleOrDefault" -title: "List.SingleOrDefault | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.SingleOrDefault" +ms.subservice: m-source --- # List.SingleOrDefault diff --git a/query-languages/m/list-skip.md b/query-languages/m/list-skip.md index 0d3cab12b..b947b09cc 100644 --- a/query-languages/m/list-skip.md +++ b/query-languages/m/list-skip.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Skip" -title: "List.Skip | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Skip" +ms.subservice: m-source --- # List.Skip @@ -23,7 +16,7 @@ List.Skip(list as list, optional countOrCondition as any) as list Returns a list that skips the first element of list `list`. If `list` is an empty list an empty list is returned. This function takes an optional parameter, `countOrCondition`, to support skipping multiple values as listed below. * If a number is specified, up to that many items are skipped. -* If a condition is specified, the returned list begins with the first element in `list` that meets the criteria. Once an item fails the condition, no further items are considered. +* If a condition is specified, any consecutive matching items at the start of `list` are skipped. * If this parameter is null, the default behavior is observed. ## Example 1 diff --git a/query-languages/m/list-sort.md b/query-languages/m/list-sort.md index e0dd92de5..4be38caa8 100644 --- a/query-languages/m/list-sort.md +++ b/query-languages/m/list-sort.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Sort" -title: "List.Sort | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Sort" +ms.subservice: m-source --- # List.Sort @@ -17,12 +10,12 @@ ms.author: dougklo
 List.Sort(list as list, optional comparisonCriteria as any) as list  
 
- + ## About Sorts a list of data, `list`, according to the optional criteria specified. An optional parameter, `comparisonCriteria`, can be specified as the comparison criterion. This can take the following values: -* To control the order, the comparison criterion can be an Order enum value. (`Order.Descending`, `Order.Ascending`). +* To control the order, the comparison criterion can be an Order enum value. ([Order.Descending](order-type.md), [Order.Ascending](order-type.md)). * To compute a key to be used for sorting, a function of 1 argument can be used. * To both select a key and control order, comparison criterion can be a list containing the key and order (`{each 1 / _, Order.Descending}`). * To completely control the comparison, a function of 2 arguments can be used. This function will be passed two items from the list (any two items, in any order). The function should return one of the following values: @@ -31,7 +24,7 @@ Sorts a list of data, `list`, according to the optional criteria specified. An o * `0`: The items are equal. * `1`: The first item is greater than the second item. - Value.Compare is a method that can be used to delegate this logic. + [Value.Compare](value-compare.md) is a method that can be used to delegate this logic. ## Example 1 @@ -63,7 +56,7 @@ List.Sort({2, 3, 1}, Order.Descending) ## Example 3 -Sort the list {2, 3, 1} in descending order using the Value.Compare method. +Sort the list {2, 3, 1} in descending order using the **Value.Compare** method. **Usage** diff --git a/query-languages/m/list-split.md b/query-languages/m/list-split.md index cf3cd156e..6f4f1a5db 100644 --- a/query-languages/m/list-split.md +++ b/query-languages/m/list-split.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Split" -title: "List.Split | Microsoft Docs" -ms.date: 11/17/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Split" +ms.subservice: m-source --- # List.Split diff --git a/query-languages/m/list-standarddeviation.md b/query-languages/m/list-standarddeviation.md index 48a160dea..26be73cf9 100644 --- a/query-languages/m/list-standarddeviation.md +++ b/query-languages/m/list-standarddeviation.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.StandardDeviation" -title: "List.StandardDeviation | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.StandardDeviation" +ms.subservice: m-source --- # List.StandardDeviation diff --git a/query-languages/m/list-sum.md b/query-languages/m/list-sum.md index 07ac8a7bd..f06b6862e 100644 --- a/query-languages/m/list-sum.md +++ b/query-languages/m/list-sum.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Sum" -title: "List.Sum | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Sum" +ms.subservice: m-source --- # List.Sum diff --git a/query-languages/m/list-times.md b/query-languages/m/list-times.md index 15c40d4d6..eef890274 100644 --- a/query-languages/m/list-times.md +++ b/query-languages/m/list-times.md @@ -1,21 +1,18 @@ --- description: "Learn more about: List.Times" -title: "List.Times | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Times" +ms.subservice: m-source --- # List.Times ## Syntax
-List.Times(start as time, count as number, step as duration) as list
+List.Times(
+    start as time,
+    count as number,
+    step as duration
+) as list
 
## About diff --git a/query-languages/m/list-transform.md b/query-languages/m/list-transform.md index bc4cb9058..5b6b5c417 100644 --- a/query-languages/m/list-transform.md +++ b/query-languages/m/list-transform.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Transform" -title: "List.Transform | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Transform" +ms.subservice: m-source --- # List.Transform diff --git a/query-languages/m/list-transformmany.md b/query-languages/m/list-transformmany.md index ab2933fc5..9403cdf49 100644 --- a/query-languages/m/list-transformmany.md +++ b/query-languages/m/list-transformmany.md @@ -1,23 +1,51 @@ --- description: "Learn more about: List.TransformMany" -title: "List.TransformMany | Microsoft Docs" -ms.date: 10/18/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.TransformMany" +ms.subservice: m-source --- # List.TransformMany ## Syntax
-List.TransformMany(list as list, collectionTransform as function, resultTransform as function) as list
+List.TransformMany(
+    list as list,
+    collectionTransform as function,
+    resultTransform as function
+) as list
 
- -## About -Returns a list whose elements are projected from the input list. The `collectionTransform` function is applied to each element, and the `resultTransform` function is invoked to construct the resulting list. The `collectionTransform` has the signature `(x as any) as list => ...` where `x` is an element in `list`. The `resultTransform` projects the shape of the result and has the signature `(x as any, y as any) as any => ...` where `x` is the element in `list` and `y` is the element obtained by applying the `collectionTransform` to that element. +## About + +Returns a list whose elements are projected from the input list. + +The `collectionTransform` function transforms each element into an intermediate list, and the `resultTransform` function receives the original element as well as an item from the intermediate list in order to construct the final result. + +The `collectionTransform` function has the signature `(x as any) as list => ...`, where `x` is an element in `list`. The `resultTransform` function projects the shape of the result and has the signature `(x as any, y as any) as any => ...`, where `x` is an element in `list` and `y` is an element from the list generated by passing `x` to `collectionTransform`. + +## Example 1 + +Flatten a list of people and their pets. + +**Usage** + +```powerquery-m +List.TransformMany( + { + [Name = "Alice", Pets = {"Scruffy", "Sam"}], + [Name = "Bob", Pets = {"Walker"}] + }, + each [Pets], + (person, pet) => [Name = person[Name], Pet = pet] +) +``` + +**Output** + +```powerquery-m +{ + [Name = "Alice", Pet = "Scruffy"], + [Name = "Alice", Pet = "Sam"], + [Name = "Bob", Pet = "Walker"] +} +``` diff --git a/query-languages/m/list-union.md b/query-languages/m/list-union.md index 24d67c216..ace03ec9e 100644 --- a/query-languages/m/list-union.md +++ b/query-languages/m/list-union.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Union" -title: "List.Union | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Union" +ms.subservice: m-source --- # List.Union @@ -35,3 +28,7 @@ List.Union({{1..5}, {2..6}, {3..7}}) **Output** `{1, 2, 3, 4, 5, 6, 7}` + +## Related content + +[Equation criteria](list-functions.md#equation-criteria) diff --git a/query-languages/m/list-zip.md b/query-languages/m/list-zip.md index 92622bc5f..3c8344748 100644 --- a/query-languages/m/list-zip.md +++ b/query-languages/m/list-zip.md @@ -1,14 +1,7 @@ --- description: "Learn more about: List.Zip" -title: "List.Zip | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "List.Zip" +ms.subservice: m-source --- # List.Zip diff --git a/query-languages/m/logical-from.md b/query-languages/m/logical-from.md index baf209086..03622b627 100644 --- a/query-languages/m/logical-from.md +++ b/query-languages/m/logical-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Logical.From" -title: "Logical.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Logical.From" +ms.subservice: m-source --- # Logical.From diff --git a/query-languages/m/logical-fromtext.md b/query-languages/m/logical-fromtext.md index 9819af849..c484bc4e2 100644 --- a/query-languages/m/logical-fromtext.md +++ b/query-languages/m/logical-fromtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Logical.FromText" -title: "Logical.FromText | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Logical.FromText" +ms.subservice: m-source --- # Logical.FromText diff --git a/query-languages/m/logical-functions.md b/query-languages/m/logical-functions.md index 6e131f18d..4f8111dfa 100644 --- a/query-languages/m/logical-functions.md +++ b/query-languages/m/logical-functions.md @@ -1,21 +1,15 @@ --- description: "Learn more about: Logical functions" -title: "Logical functions | Microsoft Docs" -ms.date: 5/16/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Logical functions" +ms.date: 11/21/2024 +ms.custom: "nonautomated-date" --- # Logical functions -These functions create and manipulate logical (that is, true/false) values. +These functions create and manipulate logical (that is, `true` or `false`) values. |Name|Description| |------------|---------------| -|[Logical.From](logical-from.md)|Returns a logical value from a value.| -|[Logical.FromText](logical-fromtext.md)|Returns a logical value of true or false from a text value.| -|[Logical.ToText](logical-totext.md)|Returns a text value from a logical value.| +|[Logical.From](logical-from.md)|Creates a logical from the given value.| +|[Logical.FromText](logical-fromtext.md)|Creates a logical value from the text values "true" and "false".| +|[Logical.ToText](logical-totext.md)|Returns the text "true" or "false" given a logical value.| diff --git a/query-languages/m/logical-totext.md b/query-languages/m/logical-totext.md index 9f5179f29..a01a90ba4 100644 --- a/query-languages/m/logical-totext.md +++ b/query-languages/m/logical-totext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Logical.ToText" -title: "Logical.ToText | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Logical.ToText" +ms.subservice: m-source --- # Logical.ToText diff --git a/query-languages/m/m-local-fixed-utc-variants.md b/query-languages/m/m-local-fixed-utc-variants.md new file mode 100644 index 000000000..4b2ce2574 --- /dev/null +++ b/query-languages/m/m-local-fixed-utc-variants.md @@ -0,0 +1,179 @@ +--- +description: "Learn more about: Local, fixed, and UTC variants of current time functions" +title: "Local, fixed, and UTC variants of current time functions" +ms.topic: conceptual +ms.date: 7/16/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-background +--- + +# Local, fixed, and UTC variants of current time functions + +When you work with Power Query in tools like Excel and Power BI, handling date and time values accurately is essential—especially when your data transformations depend on the current time. Power Query offers various functions to retrieve the current date and time: + +* [DateTime.LocalNow](datetime-localnow.md) +* [DateTimeZone.LocalNow](datetimezone-localnow.md) +* [DateTime.FixedLocalNow](datetime-fixedlocalnow.md) +* [DateTimeZone.FixedLocalNow](datetimezone-fixedlocalnow.md) +* [DateTimeZone.UtcNow](datetimezone-utcnow.md) +* [DateTimeZone.FixedUtcNow](datetimezone-fixedutcnow.md). + +This article explores the distinctions between these functions and clarifies when and why to use each one. In addition, it highlights a critical but often overlooked detail. Power Query Online always returns UTC time even when using a function labeled as "Local." Understanding these nuances can help you avoid unexpected results, especially when building time-sensitive reports or automating data updates in apps such as Power BI service or Power Apps. + +## Differences between functions + +Each of the current time functions have important differences. These functions vary in terms of time zone awareness, volatility (whether the value changes when called multiple times in the same query), and how they behave in different environments (desktop vs. online). The following table contains a breakdown of each function. + +| Function | Returns | Volatility | Desktop behavior | Online behavior | Typical use case | +|------------------------------|-----------------------------------------------|----------------|--------------------------------------------|--------------------------------------------------|-----------------------------------------------------------| +| `DateTime.LocalNow` | A `datetime` representing the current local time | Dynamic—returns a new value each time it's invoked during query evaluation | Returns local machine time | Returns UTC time | Quick local timestamp without time zone context | +| `DateTimeZone.LocalNow` | A `datetimezone` value representing the current local time with time zone offset | Dynamic—returns a new value each time it's invoked during query evaluation | Returns local time with offset | Returns UTC time with `+00:00` offset | Local time with time zone awareness | +| `DateTime.FixedLocalNow` | A `datetime` value representing the local time when first invoked during query evaluation | Fixed—returns the same value throughout a single query evaluation | Captures local time when first called | Captures UTC time when first called | Snapshot of local time without time zone | +| `DateTimeZone.FixedLocalNow` | A `datetimezone` value representing the local time with offset when first invoked during query evaluation | Fixed—returns the same value throughout a single query evaluation | Captures local time with offset when first called | Captures UTC time with `+00:00` offset when first called | Snapshot of local time with time zone | +| `DateTimeZone.UtcNow` | A `datetimezone` value representing the current UTC time | Dynamic—returns a new value each time it's invoked during query evaluation | Returns current UTC time | Returns current UTC time | Consistent UTC timestamp for dynamic scenarios | +| `DateTimeZone.FixedUtcNow` | A `datetimezone` value representing the UTC time when first invoked during query evaluation | Fixed—returns the same value throughout a single query evaluation | Captures UTC time when first called | Captures UTC time when first called | Fixed UTC timestamp for logging or auditing | + +In Power Query M, choosing between local time and UTC-based date and time functions is a critical design decision that affects the consistency, accuracy, and portability of your queries. Functions like `DateTime.LocalNow` and `DateTime.FixedLocalNow` are useful when your logic depends on the local system time, such as filtering for records that occurred "today" or generating timestamps for user-facing reports. These functions reflect the time zone of the environment in which the query is executed, making them suitable for Power Query Desktop scenarios where the local context is well-defined. + +However, in distributed or cloud-based environments like Power Query Online, these same functions return UTC time, not the actual local time of the user. This discrepancy can lead to subtle inconsistencies if your logic assumes a local time context. In contrast, `DateTimeZone.UtcNow` and `DateTimeZone.FixedUtcNow` provide a time-zone-neutral reference point that is consistent across environments and unaffected by daylight saving time or regional settings. These UTC-based functions are the preferred choice for scenarios involving data integration, logging, auditing, or any logic that must behave identically regardless of where or when the query runs. + +## Differences between the LocalNow and FixedLocalNow functions + +Power Query M provides four functions for retrieving the current local time: + +* `DateTime.LocalNow` returns the current local `datetime` each time the expression is evaluated. +* `DateTime.FixedLocalNow` returns the local `datetime` once per query evaluation, acting as a snapshot. +* `DateTimeZone.LocalNow` returns the current local `datetimezone` each time the expression is evaluated. +* `DateTimeZone.FixedLocalNow` returns the local `datetimezone` once per query evaluation, acting as a snapshot + +To demonstrate the difference, the following example generates a table with multiple rows. Each row captures a fresh `DateTime.LocalNow` value using a delay to ensure distinct timestamps, while each captured `DateTime.FixedLocalNow` value remains constant across all rows. + +> [!NOTE] +>All the dates and times in the output of the examples in this article depend on when the functions are run. The dates and times shown in the output are for demonstration purposes only. + +```powerquery-m +let + // Create a table with LocalNow and FixedLocalNow columns + TableWithTimes = Table.FromList( + {1..5}, + each { + _, + Function.InvokeAfter(() => DateTime.LocalNow(), #duration(0, 0, 0, 0.2)), + Function.InvokeAfter(() => DateTime.FixedLocalNow(), #duration(0, 0, 0, 0.2)) + }, + {"Index", "LocalNow", "FixedLocalNow"} + ), + + // Format both datetime columns + FormatLocalNow = Table.TransformColumns(TableWithTimes, + {{"LocalNow", each DateTime.ToText(_, "yyyy-MM-ddThh:mm:ss.fff")}}), + FormatFixedNow = Table.TransformColumns(FormatLocalNow, + {{"FixedLocalNow", each DateTime.ToText(_, "yyyy-MM-ddThh:mm:ss.fff")}}), + + // Change the table types + FinalTable = Table.TransformColumnTypes(FormatFixedNow, {{"Index", Int64.Type}, + {"LocalNow", type text}, {"FixedLocalNow", type text}}) + +in + FinalTable +``` + +The output of this example is: + +:::image type="content" source="media/m-local-fixed-utc-variants/localnow-versus-fixedlocalnow.png" alt-text="Screenshot of the table created by DateTime.LocalNow with dynamic dates and times and DateTime.FixedLocalNow with fixed dates and times."::: + +If you look at the output, you might notice that even though the `DateTime.LocalNow` function appears first in the code, the value returned for `DateTime.FixedLocalNow` shows a time that occurs before the `DateTime.LocalTime` time. Even though `DateTime.LocalNow` is listed first in the table construction, the order of evaluation in Power Query M isn't guaranteed to follow the order of fields in a table. Instead, Power Query uses a lazy evaluation model. Using this model means that fields are only evaluated when needed and the engine determines the evaluation order, not the order in your code. In this case, the `DateTime.FixedLocalNow` function is evaluated first, so the first time returned for this function occurs before the first time returned for `DateTime.LocalNow`. + +The following example shows how to produce similar results using `DateTimeZone.LocalNow` and `DateTimeZone.FixedLocalNow`. + +```powerquery-m +let + // Create a table with LocalNow and FixedLocalNow columns + TableWithTimes = Table.FromList( + {1..5}, + each { + _, + Function.InvokeAfter(() => DateTimeZone.LocalNow(), #duration(0, 0, 0, 0.2)), + Function.InvokeAfter(() => DateTimeZone.FixedLocalNow(), #duration(0, 0, 0, 0.2)) + }, + {"Index", "LocalNow", "FixedLocalNow"} + ), + + // Format both datetimezone columns + FormatLocalNow = Table.TransformColumns(TableWithTimes, + {{"LocalNow", each DateTimeZone.ToText(_, "yyyy-MM-ddThh:mm:ss.fff:zzz")}}), + FormatFixedNow = Table.TransformColumns(FormatLocalNow, + {{"FixedLocalNow", each DateTimeZone.ToText(_, "yyyy-MM-ddThh:mm:ss.fff:zzz")}}), + + // Change the table types + FinalTable = Table.TransformColumnTypes(FormatFixedNow, + {{"Index", Int64.Type}, {"LocalNow", type text}, {"FixedLocalNow", type text}}) +in + FinalTable +``` + +The output of this example in Power Query Desktop is: + +:::image type="content" source="media/m-local-fixed-utc-variants/zone-localnow-versus-fixedlocalnow.png" alt-text="Screenshot of the table created by DateTimeZone.LocalNow with dynamic dates and times and DateTimeZone.FixedLocalNow with fixed dates and times."::: + +> [!NOTE] +>If you run this example in Power Query Online, the time returned is always UTC time and the time zone portion of the returned values are always `+00:00`. + +## Differences between the UtcNow and the FixedUtcNow functions + +Power Query M provides two functions for retrieving the current UTC time: + +* `DateTimeZone.UtcNow` returns the current UTC `datetimezone` each time the expression is evaluated. +* `DateTimeZone.FixedUtcNow` returns the local `datetimezone` once per query evaluation, acting as a snapshot. + +The differences between these two functions are similar to the `LocalNow` and `FixedLocalNow` functions. However, whether the functions are run in Power Query Desktop or Power Query Online, the return values are always returned as UTC time. The following example demonstrates the differences between these two functions. + +```powerquery-m +let + // Create a table with UtcNow and FixedUtcNow columns + TableWithTimes = Table.FromList( + {1..5}, + each { + _, + Function.InvokeAfter(() => DateTimeZone.UtcNow(), #duration(0, 0, 0, 0.2)), + Function.InvokeAfter(() => DateTimeZone.FixedUtcNow(), #duration(0, 0, 0, 0.2)) + }, + {"Index", "UtcNow", "FixedUtcNow"} + ), + + // Format both datetimezone columns + FormatLocalNow = Table.TransformColumns(TableWithTimes, + {{"UtcNow", each DateTimeZone.ToText(_, "yyyy-MM-ddThh:mm:ss.fff:zzz")}}), + FormatFixedNow = Table.TransformColumns(FormatLocalNow, + {{"FixedUtcNow", each DateTimeZone.ToText(_, "yyyy-MM-ddThh:mm:ss.fff:zzz")}}), + + // Change the table types + FinalTable = Table.TransformColumnTypes(FormatFixedNow, + {{"Index", Int64.Type}, {"UtcNow", type text}, {"FixedUtcNow", type text}}) +in + FinalTable +``` + +The output of this example in both Power Query Desktop and Power Query Online is: + +:::image type="content" source="media/m-local-fixed-utc-variants/zone-utcnow-versus-fixedutcnow.png" alt-text="Screenshot of the table created by DateTimeZone.UtcNow with dynamic dates and times and DateTimeZone.FixedUtcNow with fixed dates and times."::: + +## Effects on other functions + +Other Power Query M functions that depend on the current date and time can also be affected by how the local time is returned on either Power Query Desktop or Power Query Online. For example, if you use the [DateTimeZone.ToLocal](datetimezone-tolocal.md) function to convert UTC time to local time, it still returns the UTC time on Power Query Online. + +Another example is any function that can use the current system time as a parameter. These functions include [Date.Month](date-month.md), [Date.DayOfYear](date-dayofyear.md), [DateTime.IsInCurrentYear](datetime-isincurrenthour.md ), [DateTimeZone.ZoneHours](datetimezone-zonehours.md), or any other function that can evaluate the current date and time. + +In all of these functions, if your logic depends on whether a value falls within the current day, hour, month, or year, the results might differ between environments. These differences between environments are especially noticeable if the query runs near a boundary (for example, just before or after midnight, the start of a new month, or a new year). If consistency is crucial across different environments, use the `DateTimeZone.UtcNow` or `DateTimeZone.FixedUtcNow` functions to retrieve the date and time. + +## Best practices and recommendations + +Choosing the right time function in Power Query depends on your specific use case, the environment in which your query runs (desktop vs. online), and whether you need a dynamic or fixed timestamp. Here are some best practices to help guide your decision: + +* **Be explicit about time zones**: Use the DateTimeZone functions instead of DateTime functions when time zone context matters. Use `DateTimeZone.UtcNow` or `DateTimeZone.FixedUtcNow` for consistency across environments, especially in cloud-based solutions like Power BI service. +* **Use fixed functions for repeatable results**: Use the fixed variants (such as `DateTimeZone.FixedUtcNow`) when you want the timestamp to remain constant across query evaluations. This method is especially useful for logging, auditing, or capturing the time of data ingestion. +* **Avoid local functions in Power Query Online**: Functions like `DateTime.LocalNow` and `DateTimeZone.LocalNow` return UTC time in cloud-based solutions like Power BI service, which can lead to confusion or incorrect assumptions. If you need actual local time in the service, consider adjusting UTC manually using known offsets (although this adjustment can be brittle, for example, due to daylight savings time or regional settings). +* **Test in both desktop and online environments**: Always test your queries in both Power Query Desktop and Power Query Online if your logic depends on current time. This testing helps catch discrepancies early, especially for scheduled refresh scenarios. +* **Document your time logic**: Clearly comment or document why a specific time function is used, especially if you're using a workaround for time zone handling. This information helps future collaborators understand the intent behind the logic. +* **Use UTC for scheduled workflows**: For scheduled refreshes or automated pipelines, UTC is the safest and most predictable choice. It avoids ambiguity caused by daylight saving time or regional time zone shifts. +* **Cache time values when needed**: If you need to use the same timestamp across multiple steps in a query, assign it to a variable at the top of your query using a fixed function. This variable ensures consistency throughout the transformation logic. diff --git a/query-languages/m/m-spec-basic-concepts.md b/query-languages/m/m-spec-basic-concepts.md index fa5346718..58c487a8a 100644 --- a/query-languages/m/m-spec-basic-concepts.md +++ b/query-languages/m/m-spec-basic-concepts.md @@ -1,14 +1,11 @@ --- -title: M Language basic concepts | Microsoft Docs +title: M Language basic concepts description: Discusses basic concepts that appear throughout the subsequent sections -author: dougklopfenstein +ms.topic: conceptual +ms.date: 8/2/2022 +ms.custom: nonautomated-date, intro-internal +ms.subservice: m-specification -ms.service: powerquery - -ms.topic: article -ms.date: 2/25/2020 -ms.author: dougklo -ms.custom: intro-internal --- # Basic concepts @@ -19,7 +16,7 @@ This section discusses basic concepts that appear throughout the subsequent sect A single piece of data is called a _value_. Broadly speaking, there are two general categories of values: _primitive values_, which are atomic, and _structured values_, which are constructed out of primitive values and other structured values. For example, the values -``` +```powerquery-m 1 true 3.14159 @@ -28,7 +25,7 @@ true are primitive in that they are not made up of other values. On the other hand, the values -``` +```powerquery-m {1, 2, 3} [ A = {1}, B = {2}, C = {3} ] ``` @@ -39,7 +36,7 @@ are constructed using primitive values and, in the case of the record, other str An _expression_ is a formula used to construct values. An expression can be formed using a variety of syntactic constructs. The following are some examples of expressions. Each line is a separate expression. -``` +```powerquery-m "Hello World" // a text value 123 // a number 1 + 2 // sum of two numbers @@ -56,7 +53,7 @@ The simplest form of expression, as seen above, is a literal representing a valu More complex expressions are built from other expressions, called _sub-expressions_. For example: -``` +```powerquery-m 1 + 2 ``` @@ -74,7 +71,7 @@ The environment used to evaluate a sub-expression is determined by the parent ex For example, the _record-initializer-expression_ evaluates the sub-expression for each field with a modified environment. The modified environment includes a variable for each of the fields of the record, except the one being initialized. Including the other fields of the record allows the fields to depend upon the values of the fields. For example: -``` +```powerquery-m [ x = 1, // environment: y, z y = 2, // environment: x, z @@ -84,7 +81,7 @@ For example, the _record-initializer-expression_ evaluates the sub-expression fo Similarly, the _let-expression_ evaluates the sub-expression for each variable with an environment containing each of the variables of the let except the one being initialized. The _let-expression_ evaluates the expression following the in with an environment containing all the variables: -``` +```powerquery-m let x = 1, // environment: y, z @@ -98,7 +95,7 @@ in To form the environments for the sub-expressions, the new variables are "merged" with the variables in the parent environment. The following example shows the environments for nested records: -``` +```powerquery-m [ a = [ @@ -113,7 +110,7 @@ To form the environments for the sub-expressions, the new variables are "merged" The following example shows the environments for a record nested within a let: -``` +```powerquery-m Let a = [ @@ -128,7 +125,7 @@ in Merging variables with an environment may introduce a conflict between variables (since each variable in an environment must have a unique name). The conflict is resolved as follows: if the name of a new variable being merged is the same as an existing variable in the parent environment, then the new variable will take precedence in the new environment. In the following example, the inner (more deeply nested) variable `x` will take precedence over the outer variable `x`. -``` +```powerquery-m [ a = [ @@ -157,16 +154,16 @@ The simplest form of identifier reference is an _exclusive-identifier-reference_ _exclusive-identifier-reference:
      identifier_ -It is an error for an _exclusive-identifier-reference_ to refer to a variable that is not part of the environment of the expression that the identifier appears within, or to refer to an identifier that is currently being initialized. +It is an error for an _exclusive-identifier-reference_ to refer to a variable that is not part of the environment of the expression that the identifier appears within. -An _inclusive-identifier-reference_ can be used to gain access to the environment that includes the identifier being initialized. If it used in a context where there is no identifier being initialized, then it is equivalent to an _exclusive-identifier-reference_. +It is an error for an _exclusive-identifier-reference_ to refer to an identifier that is currently being initialized if the referenced identifier is defined inside a _record-initializer-expression_ or _let-expression_. Instead, an _inclusive-identifier-reference_ can be used to gain access to the environment that includes the identifier being initialized. If an _inclusive-identifier-reference_ is used in any other situation, then it is equivalent to an _exclusive-identifier-reference_. _inclusive-identifier-reference:_
      `@` _identifier_ This is useful when defining recursive functions since the name of the function would normally not be in scope. -``` +```powerquery-m [ Factorial = (n) => if n <= 1 then @@ -184,7 +181,7 @@ As with a _record-initializer-expression_, an _inclusive-identifier-reference_ c Consider the following expression which initializes a record: -``` +```powerquery-m [ C = A + B, A = 1 + 1, @@ -194,7 +191,7 @@ Consider the following expression which initializes a record: When evaluated, this expression produces the following record value: -``` +```powerquery-m [ C = 6, A = 2, @@ -204,7 +201,7 @@ When evaluated, this expression produces the following record value: The expression states that in order to perform the `A + B` calculation for field `C`, the values of both field `A` and field `B` must be known. This is an example of a _dependency ordering_ of calculations that is provided by an expression. The M evaluator abides by the dependency ordering provided by expressions, but is free to perform the remaining calculations in any order it chooses. For example, the computation order could be: -``` +```powerquery-m A = 1 + 1 B = 2 + 2 C = A + B @@ -212,7 +209,7 @@ C = A + B Or it could be: -``` +```powerquery-m B = 2 + 2 A = 1 + 1 C = A + B @@ -233,9 +230,8 @@ It does, however, rely on being able to reorder computations. Since expressions Once a value has been calculated, it is _immutable_, meaning it can no longer be changed. This simplifies the model for evaluating an expression and makes it easier to reason about the result since it is not possible to change a value once it has been used to evaluate a subsequent part of the expression. For instance, a record field is only computed when needed. However, once computed, it remains fixed for the lifetime of the record. Even if the attempt to compute the field raised an error, that same error will be raised again on every attempt to access that record field. -An important exception to the immutable-once-calculated rule applies to list and table values. Both have _streaming semantics_. That is, repeated enumeration of the items in a list or the rows in a table can produce varying results. Streaming semantics enables the construction of M expressions that transform data sets that would not fit in memory at once. +An important exception to the immutable-once-calculated rule applies to list, table, and binary values, which have _streaming semantics_. Streaming semantics allow M to transform data sets that don't fit into memory all at once. With streaming, the values returned when enumerating a given table, list, or binary value are produced on demand each time they're requested. Since the expressions defining the enumerated values are evaluated each time they're enumerated, the output they produce can be different across multiple enumerations. This doesn't mean that multiple enumerations always results in different values, just that they can be different if the data source or M logic being used is non-deterministic. Also, note that function application is _not_ the same as value construction. Library functions may expose external state (such as the current time or the results of a query against a database that evolves over time), rendering them _non-deterministic_. While functions defined in M will not, as such, expose any such non-deterministic behavior, they can if they are defined to invoke other functions that are non-deterministic. -A final source of non-determinsm in M are _errors_. Errors stop evaluations when they occur (up to the level where they are handled by a try expression). It is not normally observable whether `a + b` caused the evaluation of `a` before `b` or `b` before `a` (ignoring concurrency here for simplicity). However, if the subexpression that was evaluated first raises an error, then it can be determined which of the two expressions was evaluated first. - +A final source of non-determinism in M are _errors_. Errors stop evaluations when they occur (up to the level where they are handled by a try expression). It is not normally observable whether `a + b` caused the evaluation of `a` before `b` or `b` before `a` (ignoring concurrency here for simplicity). However, if the subexpression that was evaluated first raises an error, then it can be determined which of the two expressions was evaluated first. diff --git a/query-languages/m/m-spec-conditionals.md b/query-languages/m/m-spec-conditionals.md index d50b7c2e4..d8946fb28 100644 --- a/query-languages/m/m-spec-conditionals.md +++ b/query-languages/m/m-spec-conditionals.md @@ -1,13 +1,10 @@ --- -title: M Language Conditionals | Microsoft Docs +title: M Language Conditionals description: Describes using conditionals in the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 2/28/2020 -ms.author: dougklo +ms.topic: conceptual +ms.date: 6/13/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- @@ -16,7 +13,7 @@ ms.author: dougklo The _if-expression_ selects from two expressions based on the value of a logical input value and evaluates only the selected expression. _if-expression:_
-       `if` _if-condition_ `then` _true-expression_ `else` _false-expression
+       `if` _if-condition_ `then` _true-expression_ `else` _false-expression
if-condition:
      expression
true-expression:
@@ -26,14 +23,14 @@ false-expression:
The following are examples of _if-expressions_: -``` +```powerquery-m if 2 > 1 then 2 else 1 // 2 if 1 = 1 then "yes" else "no" // "yes" ``` The following holds when evaluating an _if-expression_: -* If the value produced by evaluating the _if-condition_ is not a logical value, then an error with reason code `"Expression.Error"` is raised. +* If the value produced by evaluating the _if-condition_ isn't a logical value, then an error with reason code `"Expression.Error"` is raised. * The _true-expression_ is only evaluated if the _if-condition_ evaluates to the value `true`. @@ -41,5 +38,4 @@ The following holds when evaluating an _if-expression_: * The result of the _if-expression_ is the value of the _true-expression_ if the _if-condition_ is `true`, and the value of the _false-expression_ if the _if-condition_ is `false`. -* Errors raised during the evaluation of the _if-condition_, _true-expression_, or _falseexpression_ are propagated. - +* Errors raised during the evaluation of the _if-condition_, _true-expression_, or _false-expression_ are propagated. diff --git a/query-languages/m/m-spec-consolidated-grammar.md b/query-languages/m/m-spec-consolidated-grammar.md index 4e658329c..b812907ef 100644 --- a/query-languages/m/m-spec-consolidated-grammar.md +++ b/query-languages/m/m-spec-consolidated-grammar.md @@ -1,13 +1,10 @@ --- -title: M Language Consolidated Grammar | Microsoft Docs +title: M Language Consolidated Grammar description: Describes all of the grammar associated with the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 11/29/2021 -ms.author: dougklo +ms.topic: conceptual +ms.date: 01/29/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- # Consolidated Grammar @@ -20,7 +17,8 @@ lexical-elements:
      lexical-element lexical-elementsopt
lexical-element:
      whitespace
-      token comment_ +      token
+      comment_ ### White space @@ -146,7 +144,7 @@ _verbatim-literal:_
### Identifiers -_identifier:
+_identifier:
      regular-identifier
      quoted-identifier
regular-identifier:
@@ -206,7 +204,7 @@ _keyword:_ one of
      `section shared then true try type #binary #date #datetime`
      `#datetimezone #duration #infinity #nan #sections #shared #table #time` -### Operators and punctuators +### Operators and punctuators _operator-or-punctuator:_ one of
      `, ; = < <= > >= <> + - * / & ( ) [ ] { } @ ? ?? => .. ...` @@ -262,15 +260,13 @@ logical-and-expression:
_is-expression:
      as-expression
-      is-expression_ `is` _nullable-primitive-type
-nullable-primitive-type:_
-      `nullable`_opt primitive-type_ +      is-expression_ `is` _primitive-or-nullable-primitive-type_ #### As expression _as-expression:
      equality-expression
-      as-expression_ `as` _nullable-primitive-type_ +      as-expression_ `as` _primitive-or-nullable-primitive-type_ #### Equality expression @@ -420,9 +416,6 @@ required-field-selector:_
      `[` _field-name_ `]`
_optional-field-selector:_
      `[` _field-name_ `] ?`
-_field-name:
-      generalized-identifier
-      quoted-identifier
implicit-target-field-selection:
      field-selector
projection:
@@ -453,15 +446,15 @@ fixed-parameter-list:
      parameter
      parameter_ `,` _fixed-parameter-list
parameter:
-      parameter-name parameter-typeopt
+      parameter-name parameter-typeopt
parameter-name:
      identifier
parameter-type:
-      assertion
+      primitive-or-nullable-primitive-type-assertion
return-type:
-      assertion
-assertion:_
-      `as` _nullable-primitive-type
+      primitive-or-nullable-primitive-type-assertion
+primitive-or-nullable-primitive-type-assertion:_
+      `as` _primitive-or-nullable-primitive-type
optional-parameter-list:
      optional-parameter
      optional-parameter_ `,` _optional-parameter-list
@@ -504,18 +497,20 @@ _type-expression:
      primary-expression_
      `type` _primary-type
type:
-      parenthesized-expression
+      primary-expression
      primary-type
primary-type:
-      primitive-type
+      primitive-or-nullable-primitive-type
      record-type
      list-type
      function-type
      table-type
-      nullable-type
-primitive-type:_ one of
-      `any anynonnull binary date datetime datetimezone duration function`
-      `list logical none null number record table text type`
+      nullable-type_
+_primitive-or-nullable-primitive-type:_
+      `nullable`_opt primitive-type_
+_primitive-type:_ one of
+      `any anynonnull binary date datetime datetimezone duration function list logical`
+      `none null number record table text time type`
_record-type:_
      `[` _open-record-marker_ `]`
      `[` _field-specification-listopt_ `]`
@@ -537,7 +532,7 @@ _list-type:_
_item-type:
      type
function-type:_
-      `function (` _parameter-specification-listopt_ `)` _return-type
+      `function (` _parameter-specification-listopt_ `)` _return-type
parameter-specification-list:
      required-parameter-specification-list
      required-parameter-specification-list_ `,` _optional-parameter-specification-list
@@ -553,11 +548,15 @@ optional-parameter-specification-list:
optional-parameter-specification:_
      `optional` _parameter-specification
parameter-specification:
-      parameter-name parameter-type
+      parameter-name parameter-type
+parameter-type:
+      type-assertion
+type-assertion:_
+      `as` _type
table-type:_
      `table` _row-type
row-type:_
-      `[` _field-specification-list_ `]`
+      `[` _field-specification-list_opt `]`
_nullable-type:_
      `nullable` _type_ @@ -569,15 +568,23 @@ _error-raising-expression:_
#### Error handling expression _error-handling-expression:_
-      `try` _protected-expression otherwise-clauseopt
+      `try` _protected-expression +error-handleropt
protected-expression:
      expression
+_error-handler:_
+      otherwise-clause
+      catch-clause
otherwise-clause:_
-      `otherwise` _default-expression
-default-expression:
-      expression_ - -### Literal Attributes +      `otherwise` _default-expression_
+_default-expression_:
+      _expression_
+_catch-clause:_
+      `catch` _catch-function_
+_catch-function:_
+      `(`_parameter-nameopt_`)` `=>` _function-body_
+ +### Literal Attributes _literal-attributes:
      record-literal
diff --git a/query-languages/m/m-spec-error-handling.md b/query-languages/m/m-spec-error-handling.md index 4bdb8b9d2..ab62496c9 100644 --- a/query-languages/m/m-spec-error-handling.md +++ b/query-languages/m/m-spec-error-handling.md @@ -1,13 +1,10 @@ --- -title: M Language Error Handling | Microsoft Docs +title: M Language Error Handling description: Describes error handling in the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 2/28/2020 -ms.author: dougklo +ms.topic: conceptual +ms.date: 8/2/2022 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- # Error Handling @@ -29,20 +26,20 @@ _error-raising-expression:_
Text values can be used as shorthand for error values. For example: -``` +```powerquery-m error "Hello, world" // error with message "Hello, world" ``` Full error values are records and can be constructed using the `Error.Record` function: -``` +```powerquery-m error Error.Record("FileNotFound", "File my.txt not found", "my.txt") ``` The above expression is equivalent to: -``` +```powerquery-m error [ Reason = "FileNotFound", Message = "File my.txt not found", @@ -60,44 +57,54 @@ Raising an error will cause the current expression evaluation to stop, and the e ## Handling errors -An _error-handling-expression_ is used to handle an error: +An _error-handling-expression_ (informally known as a "try expression") is used to handle an error: -_error-handling-expression:
-      `try` _protected-expression otherwise-clauseopt
+_error-handling-expression:_
+      `try` _protected-expression +error-handleropt
protected-expression:
      expression
+_error-handler:_
+      otherwise-clause
+      catch-clause
otherwise-clause:_
-      `otherwise` _default-expression
-default-expression:
-      expression_ +      `otherwise` _default-expression_
+_default-expression_:
+      _expression_
+_catch-clause:_
+      `catch` _catch-function_
+_catch-function:_
+      `(`_parameter-name_opt`)` `=>` _function-body_
-The following holds when evaluating an _error-handling-expression_ without an _otherwiseclause_: +The following holds when evaluating an _error-handling-expression_ without an _error-handler_: -* If the evaluation of the protected-expression does not result in an error and produces a value x, the value produced by the error-handling-expression is a record of the following form: +* If the evaluation of the _protected-expression_ does not result in an error and produces a value x, the value produced by the _error-handling-expression_ is a record of the following form: -``` +```powerquery-m [ HasErrors = false, Value = x ] ``` -* If the evaluation of the protected-expression raises an error value e, the result of the error-handling-expression is a record of the following form: +* If the evaluation of the _protected-expression_ raises an error value e, the result of the _error-handling-expression_ is a record of the following form: -``` +```powerquery-m [ HasErrors = true, Error = e ] ``` -The following holds when evaluating an _error-handling-expression_ with an _otherwiseclause_: +The following holds when evaluating an _error-handling-expression_ with an _error-handler_: -* The protected-expression must be evaluated before the otherwise-clause. +* The _protected-expression_ must be evaluated before the _error-handler_. -* The otherwise-clause must be evaluated if and only if the evaluation of the protectedexpression raises an error. +* The _error-handler_ must be evaluated if and only if the evaluation of the _protected-expression_ raises an error. -* If the evaluation of the _protected-expression_ raises an error, the value produced by the _error-handling-expression_ is the result of evaluating the otherwise-clause. +* If the evaluation of the _protected-expression_ raises an error, the value produced by the _error-handling-expression_ is the result of evaluating the _error-handler_. -* Errors raised during the evaluation of the otherwise-clause are propagated. +* Errors raised during the evaluation of the _error-handler_ are propagated. + +* When the _error-handler_ being evaluated is a _catch-clause_, the _catch-function_ is invoked. If that function accepts a parameter, the error value will be passed as its value. The following example illustrates an _error-handling-expression_ in a case where no error is raised: -``` +```powerquery-m let x = try "A" in @@ -107,7 +114,7 @@ in The following example shows raising an error and then handling it: -``` +```powerquery-m let x = try error "A" in @@ -115,25 +122,53 @@ in // [ Reason = "Expression.Error", Message = "A", Detail = null ] ``` -An otherwise clause can be used to replace errors handled by a try expression with an alternative value: - +The preceding example can be rewritten with less syntax by using a _catch-clause_ with a _catch-function_ that accepts a parameter: +```powerquery-m +let + x = try error "A" catch (e) => e +in + x +// [ Reason = "Expression.Error", Message = "A", Detail = null ] ``` + +An _otherwise-clause_ can be used to replace errors handled by a try expression with an alternative value: + +```powerquery-m try error "A" otherwise 1 // 1 ``` -If the otherwise clause also raises an error, then so does the entire try expression: +A _catch-clause_ with a zero-parameter _catch-function_ is effectively a longer, alternative syntax for an _otherwise-clause_: +```powerquery-m +try error "A" catch () => 1 +// 1 ``` + +If the _error-handler_ also raises an error, then so does the entire try expression: + +```powerquery-m try error "A" otherwise error "B" // error with message "B" ``` +```powerquery-m +try error "A" catch () => error "B" +// error with message "B" +``` + +```powerquery-m +try error "A" catch (e) => error "B" +// error with message "B" +``` + + + ## Errors in record and let initializers The following example shows a record initializer with a field `A` that raises an error and is accessed by two other fields `B` and `C`. Field `B` does not handle the error that is raised by `A`, but `C` does. The final field `D` does not access `A` and so it is not affected by the error in `A`. -``` +```powerquery-m [ A = error "A", B = A + 1, @@ -147,7 +182,7 @@ The following example shows a record initializer with a field `A` that raises an The result of evaluating the above expression is: -``` +```powerquery-m [ A = // error with message "A" B = // error with message "A" @@ -158,7 +193,7 @@ The result of evaluating the above expression is: Error handling in M should be performed close to the cause of errors to deal with the effects of lazy field initialization and deferred closure evaluations. The following example shows an unsuccessful attempt at handling an error using a `try` expression: -``` +```powerquery-m let f = (x) => [ a = error "bad", b = x ], g = try f(42) otherwise 123 @@ -172,7 +207,7 @@ In this example, the definition `g` was meant to handle the error raised when ca While an expression is being developed, an author may want to leave out the implementation for some parts of the expression, but may still want to be able to execute the expression. One way to handle this case is to raise an error for the unimplemented parts. For example: -``` +```powerquery-m (x, y) => if x > y then x - y @@ -188,7 +223,6 @@ _not-implemented-expression:_
For example, the following is equivalent to the previous example: -``` +```powerquery-m (x, y) => if x > y then x - y else ... ``` - diff --git a/query-languages/m/m-spec-functions.md b/query-languages/m/m-spec-functions.md index 514ace79d..e368b12aa 100644 --- a/query-languages/m/m-spec-functions.md +++ b/query-languages/m/m-spec-functions.md @@ -1,13 +1,10 @@ --- -title: M Language Functions | Microsoft Docs +title: M Language Functions description: Describes using functions in the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 4/7/2020 -ms.author: dougklo +ms.topic: conceptual +ms.date: 7/7/2023 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- @@ -20,7 +17,7 @@ A _function_ is a value that represents a mapping from a set of argument values Functions are written using a _function-expression_: _function-expression:_
-      `(` _parameter-listopt_ `)` _function-return-typeopt_ `=>` _function-body
+      `(` _parameter-listopt_ `)` _return-typeopt_ `=>` _function-body
function-body:
      expression
parameter-list:
@@ -29,34 +26,34 @@ parameter-list:
      optional-parameter-list
fixed-parameter-list:
      parameter
-      parameter_ `,` _fixed-parameter-list
+      parameter_ `,` _fixed-parameter-list
parameter:
      parameter-name parameter-typeopt
parameter-name:
      identifier
parameter-type:
-      assertion
-function-return-type:
-      assertion
-assertion:_
-      `as` _nullable-primiitve-type
+      primitive-or-nullable-primitive-type-assertion
+return-type:
+      primitive-or-nullable-primitive-type-assertion
+primitive-or-nullable-primitive-type-assertion:_
+      `as` _primitive-or-nullable-primitive-type
optional-parameter-list:
      optional-parameter
      optional-parameter_ `,` _optional-parameter-list
optional-parameter:_
-      `optional` _parameter
-nullable-primitve-type
-      `nullable`_opt primitive-type_ +      `optional` _parameter_
+_primitive-or-nullable-primitive-type:_
+      `nullable`_opt primitive-type_ -The following is an example of a function that requires exactly two values `x` and `y`, and produces the result of applying the `+` operator to those values. The `x` and `y` are _parameters_ that are part of the _formal-parameter-list_ of the function, and the `x + y` is the _function body_: +The following is an example of a function that requires exactly two values `x` and `y`, and produces the result of applying the `+` operator to those values. The `x` and `y` are _parameters_ that are part of the _parameter-list_ of the function, and the `x + y` is the _function-body_: -``` +```powerquery-m (x, y) => x + y ``` -The result of evaluating a _function-expression_ is to produce a function value (not to evaluate the _function-body_). As a convention in this document, function values (as opposed to function expressions) are shown with the _formal-parameter-list_ but with an ellipsis (`...`) instead of the _function-body_. For example, once the function expression above has been evaluated, it would be shown as the following function value: +The result of evaluating a _function-expression_ is to produce a function value (not to evaluate the _function-body_). As a convention in this document, function values (as opposed to function expressions) are shown with the _parameter-list_ but with an ellipsis (`...`) instead of the _function-body_. For example, once the function expression above has been evaluated, it would be shown as the following function value: -``` +```powerquery-m (x, y) => ... ``` @@ -66,13 +63,12 @@ The following operators are defined for function values: | -------- | ------ | | `x = y` | Equal | | `x <> y` | Not equal | -| | | -The native type of function values is a custom function type (derived from the intrinsic type `function`) that lists the parameter names and specifies all parameter types and the return type to be `any`. (See [Function types](m-spec-types.md#function-types) for details on function types.) +The native type of function values is a custom function type (derived from the intrinsic type `function`) that lists the parameter names and specifies all parameter types and the return type to be `any`. (Go to [Function types](m-spec-types.md#function-types) for details on function types.) ## Invoking functions -The _function-body_ of a function is executed by _invoking_ the function value using an _invokeexpression_. Invoking a function value means the _function-body_ of the function value is evaluated and a value is returned or an error is raised. +The _function-body_ of a function is executed by _invoking_ the function value using an _invoke-expression_. Invoking a function value means the _function-body_ of the function value is evaluated and a value is returned or an error is raised. _invoke-expression:
      primary-expression_ `(` _argument-listopt_ `)`
@@ -83,7 +79,7 @@ Each time a function value is invoked, a set of values are specified as an _argu An _argument-list_ is used to specify a fixed number of arguments directly as a list of expressions. The following example defines a record with a function value in a field, and then invokes the function from another field of the record: -``` +```powerquery-m [ MyFunction = (x, y, z) => x + y + z, Result1 = MyFunction(1, 2, 3) // 6 @@ -92,45 +88,46 @@ An _argument-list_ is used to specify a fixed number of arguments directly as a The following holds when invoking a function: -* The environment used to evaluate the _function-body_ of the function includes a variable that corresponds to each parameter, with the same name as the parameter. The value of each parameter corresponds to a value constructed from the _argument-list_ of the _invokeexpression_, as defined in [Parameters](#parameters). +* The environment used to evaluate the _function-body_ of the function includes a variable that corresponds to each parameter, with the same name as the parameter. The value of each parameter corresponds to a value constructed from the _argument-list_ of the _invoke-expression_, as defined in [Parameters](#parameters). + * All of the expressions corresponding to the function arguments are evaluated before the _function-body_ is evaluated. -* Errors raised when evaluating the expressions in the _expression-list_ or _functionexpression_ are propagated. +* Errors raised when evaluating the expressions in the _expression-list_ or _function-body_ are propagated. -* The number of arguments constructed from the _argument-list_ must be compatible with the formal parameters of the function, or an error is raised with reason code `"Expression.Error"`. The process for determining compatibility is defined in [Parameters](#parameters). +* The number of arguments constructed from the _argument-list_ must be compatible with the parameters of the function, or an error is raised with reason code `"Expression.Error"`. The process for determining compatibility is defined in [Parameters](#parameters). ## Parameters -There are two kinds of formal parameters that may be present in a _formal-parameter-list_: +There are two kinds of parameters that may be present in a _parameter-list_: -* A _required_ parameter indicates that an argument corresponding to the parameter must always be specified when a function is invoked. Required parameters must be specified first in the _formal-parameter-list_. The function in the following example defines required parameters `x` and `y`: +* A _required_ parameter indicates that an argument corresponding to the parameter must always be specified when a function is invoked. Required parameters must be specified first in the _parameter-list_. The function in the following example defines required parameters `x` and `y`: -``` + ```powerquery-m [ MyFunction = (x, y) => x + y, Result1 = MyFunction(1, 1), // 2 Result2 = MyFunction(2, 2) // 4 ] -``` + ``` -* An _optional_ parameter indicates that an argument corresponding to the parameter may be specified when a function is invoked, but is not required to be specified. If an argument that corresponds to an optional parameter is not specified when the function is invoked, then the value `null` is used instead. Optional parameters must appear after any required parameters in a _formal-parameter-list_. The function in the following example defines a fixed parameter `x` and an optional parameter `y`: +* An _optional_ parameter indicates that an argument corresponding to the parameter may be specified when a function is invoked, but is not required to be specified. If an argument that corresponds to an optional parameter is not specified when the function is invoked, then the value `null` is used instead. Optional parameters must appear after any required parameters in a _parameter-list_. The function in the following example defines a fixed parameter `x` and an optional parameter `y`: -``` + ```powerquery-m [ - MyFunction = fn(x, optional y) => + MyFunction = (x, optional y) => if (y = null) x else x + y, Result1 = MyFunction(1), // 1 Result2 = MyFunction(1, null), // 1 Result3 = MyFunction(2, 2), // 4 ] -``` + ``` -The number of arguments that are specified when a function is invoked must be compatible with the formal parameter list. Compatibility of a set of arguments `A` for a function `F` is computed as follows: +The number of arguments that are specified when a function is invoked must be compatible with the parameter list. Compatibility of a set of arguments `A` for a function `F` is computed as follows: -* Let the value _N_ represent the number of arguments `A` constructed from the _argumentlist_. For example: +* Let the value _N_ represent the number of arguments `A` constructed from the _argument-list_. For example: -``` + ```powerquery-m MyFunction() // N = 0 MyFunction(1) // N = 1 MyFunction(null) // N = 1 @@ -138,25 +135,25 @@ The number of arguments that are specified when a function is invoked must be co MyFunction(1, 2, 3) // N = 3 MyFunction(1, 2, null) // N = 3 MyFunction(1, 2, {3, 4}) // N = 3 -``` + ``` * Let the value _Required_ represent the number of fixed parameters of `F` and _Optional_ the number of optional parameters of `F`. For example: -``` -() // Required = 0, Optional = 0 -(x) // Required = 1, Optional = 0 -(optional x) // Required = 0, Optional = 1 -(x, optional y) // Required = 1, Optional = 1 -``` + ```powerquery-m + () // Required = 0, Optional = 0 + (x) // Required = 1, Optional = 0 + (optional x) // Required = 0, Optional = 1 + (x, optional y) // Required = 1, Optional = 1 + ``` * Arguments `A` are compatible with function `F` if the following are true: - * (_N >= Fixed_) and (_N <= (Fixed + Optional_)) - * The argument types are compatible with `F`'s corresponding parameter types + * (_N >= Fixed_) and (_N <= (Fixed + Optional_)) + * The argument types are compatible with `F`'s corresponding parameter types * If the function has a declared return type, then the result value of the body of function `F` is compatible with `F`'s return type if the following is true: - * The value yielded by evaluating the function body with the supplied arguments for the function parameters has a type that is compatible with the return type. + * The value yielded by evaluating the function body with the supplied arguments for the function parameters has a type that is compatible with the return type. * If the function body yields a value incompatible with the function's return type, an error with reason code `"Expression.Error"` is raised. @@ -164,7 +161,7 @@ The number of arguments that are specified when a function is invoked must be co In order to write a function value that is recursive, it is necessary to use the scoping operator (`@`) to reference the function within its scope. For example, the following record contains a field that defines the `Factorial` function, and another field that invokes it: -``` +```powerquery-m [ Factorial = (x) => if x = 0 then 1 else x * @Factorial(x - 1), @@ -174,7 +171,7 @@ In order to write a function value that is recursive, it is necessary to use the Similarly, mutually recursive functions can be written as long as each function that needs to be accessed has a name. In the following example, part of the `Factorial` function has been refactored into a second `Factorial2` function. -``` +```powerquery-m [ Factorial = (x) => if x = 0 then 1 else Factorial2(x), Factorial2 = (x) => x * Factorial(x - 1), @@ -186,7 +183,7 @@ Similarly, mutually recursive functions can be written as long as each function A function can return another function as a value. This function can in turn depend on one or more parameters to the original function. In the following example, the function associated with the field `MyFunction` returns a function that returns the parameter specified to it: -``` +```powerquery-m [ MyFunction = (x) => () => x, MyFunction1 = MyFunction(1), @@ -201,7 +198,7 @@ Each time the function is invoked, a new function value will be returned that ma In addition to parameters, the _function-body_ of a _function-expression_ can reference variables that are present in the environment when the function is initialized. For example, the function defined by the field `MyFunction` accesses the field `C` of the enclosing record `A`: -``` +```powerquery-m [ A = [ @@ -216,7 +213,7 @@ When `MyFunction` is invoked, it accesses the value of the variable `C`, even th ## Simplified declarations -The _each-expression_ is a syntactic shorthand for declaring untyped functions taking a single formal parameter named `_` (underscore). +The _each-expression_ is a syntactic shorthand for declaring untyped functions taking a single parameter named `_` (underscore). _each-expression:_
      `each` _each-expression-body
@@ -227,7 +224,7 @@ Simplified declarations are commonly used to improve the readability of higher-o For example, the following pairs of declarations are semantically equivalent: -``` +```powerquery-m each _ + 1 (_) => _ + 1 each [A] @@ -236,4 +233,3 @@ each [A] Table.SelectRows( aTable, each [Weight] > 12 ) Table.SelectRows( aTable, (_) => _[Weight] > 12 ) ``` - diff --git a/query-languages/m/m-spec-introduction.md b/query-languages/m/m-spec-introduction.md index d0f86bd53..03351bf1d 100644 --- a/query-languages/m/m-spec-introduction.md +++ b/query-languages/m/m-spec-introduction.md @@ -1,24 +1,20 @@ --- -title: Power Query M Formula Language Introduction | Microsoft Docs +title: Power Query M formula language introduction description: Provides an overview of the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - ms.topic: overview -ms.date: 2/25/2020 -ms.author: dougklo - +ms.date: 8/25/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- # Introduction -## Overview +## Overview -Microsoft Power Query provides a powerful "get data" experience that encompasses many features. A core capability of Power Query is to filter and combine, that is, to "mash-up" data from one or more of a rich collection of supported data sources. Any such data mashup is expressed using the Power Query Formula Language (informally known as "M"). Power Query embeds M documents in Excel and Power BI workbooks to enable repeatable mashup of data. +Microsoft Power Query provides a powerful "get data" experience that encompasses many features. A core capability of Power Query is to filter and combine, that is, to "mash-up" data from one or more of a rich collection of supported data sources. Any such data mashup is expressed using the Power Query formula language (informally known as "M"). Power Query embeds M documents in a wide range of Microsoft products, including Excel, Power BI, Analysis Services, and Dataverse, to enable repeatable mashup of data. This document provides the specification for M. After a brief introduction that aims at building some first intuition and familiarity with the language, the document covers the language precisely in several progressive steps: - + 1. The _lexical structure_ defines the set of texts that are lexically valid. 2. Values, expressions, environments and variables, identifiers, and the evaluation model form the language's _basic concepts_. @@ -31,29 +27,29 @@ This document provides the specification for M. After a brief introduction that 6. _Functions_, another kind of special values, provide the foundation for a rich standard library for M and allow for the addition of new abstractions. -7. _Errors_ can occur when applying operators or functions during expression evaluation. While errors are not values, there are ways to _handle errors_ that map errors back to values. +7. _Errors_ can occur when applying operators or functions during expression evaluation. While errors aren't values, there are ways to _handle errors_ that map errors back to values. 8. _Let expressions_ allow for the introduction of auxiliary definitions used to build up complex expressions in smaller steps. 9. _If expressions_ support conditional evaluation. -10. _Sections_ provide a simple modularity mechanism. (Sections are not yet leveraged by Power Query.) +10. _Sections_ provide a simple modularity mechanism. (Sections aren't yet leveraged by Power Query.) 11. Finally, a _consolidated grammar_ collects the grammar fragments from all other sections of this document into a single complete definition. - + For computer language theorists: the formula language specified in this document is a mostly pure, higher-order, dynamically typed, partially lazy functional language. ## Expressions and values The central construct in M is the _expression_. An expression can be evaluated (computed), yielding a single _value_. -Although many values can be written literally as an expression, a value is not an expression. For example, the expression `1` evaluates to the value _1_; the expressions `1+1` evaluates to the value _2_. This distinction is subtle, but important. Expressions are recipes for evaluation; values are the results of evaluation. +Although many values can be written literally as an expression, a value isn't an expression. For example, the expression `1` evaluates to the value _1_; the expressions `1+1` evaluates to the value _2_. This distinction is subtle, but important. Expressions are recipes for evaluation; values are the results of evaluation. -The following examples illustrate the different kinds of values available in M. As a convention, a value is written using the literal form in which they would appear in an expression that evaluates to just that value. (Note that the `//` indicates the start of a comment which continues to the end of the line.) +The following examples illustrate the different kinds of values available in M. As a convention, a value is written using the literal form in which they would appear in an expression that evaluates to just that value. (Note that the `//` indicates the start of a comment that continues to the end of the line.) * A _primitive_ value is single-part value, such as a number, logical, text, or null. A null value can be used to indicate the absence of any data. - ``` + ```powerquery-m 123 // A number true // A logical "abc" // A text @@ -62,36 +58,37 @@ The following examples illustrate the different kinds of values available in M. * A _list_ value is an ordered sequence of values. M supports infinite lists, but if written as a literal, lists have a fixed length. The curly brace characters `{` and `}` denote the beginning and end of a list. - ``` + ```powerquery-m {123, true, "A"} // list containing a number, a logical, and // a text {1, 2, 3} // list of three numbers ``` -* A _record_ is a set of _fields_. A field is a name/value pair where the name is a text value that is unique within the field's record. The literal syntax for record values allows the names to be written without quotes, a form also referred to as _identifiers_. The following shows a record containing three fields named "`A`", "`B`", and "`C`", which have values `1`, `2`, and `3`. +* A _record_ is a set of _fields_. A field is a name/value pair where the name is a text value that's unique within the field's record. The literal syntax for record values allows the names to be written without quotes, a form also referred to as _identifiers_. The following shows a record containing three fields named "`A`", "`B`", and "`C`", which have values `1`, `2`, and `3`. - ``` + ```powerquery-m [ A = 1, B = 2, C = 3 ] ``` -* A _table_ is a set of values organized into columns (which are identified by name), and rows. There is no literal syntax for creating a table, but there are several standard functions that can be used to create tables from lists or records. + +* A _table_ is a set of values organized into columns (which are identified by name), and rows. There's no literal syntax for creating a table, but there are several standard functions that can be used to create tables from lists or records. For example: - ``` + ```powerquery-m #table( {"A", "B"}, { {1, 2}, {3, 4} } ) ``` - This creates a table of the following shape: + This creates a table of the following shape: - ![Example table in M formula language](media/table-example.png) - -* A _function_ is a value which, when invoked with arguments, produces a new value. Function are written by listing the function's _parameters_ in parentheses, followed by the goes-to symbol `=>`, followed by the expression defining the function. That expression typically refers to the parameters (by name). + :::image type="content" source="media/table-example.png" alt-text="Image of an example table in the M formula language."::: - ``` +* A _function_ is a value that, when invoked with arguments, produces a new value. A function is written by listing the function's _parameters_ in parentheses, followed by the goes-to symbol `=>`, followed by the expression defining the function. That expression typically refers to the parameters (by name). + + ```powerquery-m (x, y) => (x + y) / 2` ``` @@ -99,15 +96,15 @@ The following examples illustrate the different kinds of values available in M. The evaluation model of the M language is modeled after the evaluation model commonly found in spreadsheets, where the order of calculation can be determined based on dependencies between the formulas in the cells. -If you have written formulas in a spreadsheet such as Excel, you may recognize the formulas on the left will result in the values on the right when calculated: +If you've written formulas in a spreadsheet such as Excel, you might recognize the formulas on the left result in the values on the right when calculated: -![Formula resulting in value](media/m-spec-formula-value.png) - -In M, parts of an expression can reference other parts of the expression by name, and the evaluation process will automatically determine the order in which referenced expressions are calculated. +:::image type="content" source="media/m-spec-formula-value.png" alt-text="Screenshots of of the formulas on the right resulting in the values on the left."::: -We can use a record to produce an expression which is equivalent to the above spreadsheet example. When initializing the value of a field, we can refer to other fields within the record by using the name of the field, as follows: +In M, parts of an expression can reference other parts of the expression by name, and the evaluation process automatically determines the order in which referenced expressions are calculated. -``` +You can use a record to produce an expression that's equivalent to the previous spreadsheet example. When initializing the value of a field, you can refer to other fields within the record by using the name of the field, as shown in the following example: + +```powerquery-m [ A1 = A2 * 2, A2 = A3 + 1, @@ -115,9 +112,9 @@ We can use a record to produce an expression which is equivalent to the above sp ] ``` -The above expression is equivalent to the following (in that both evaluate to equal values): +The previous expression is equivalent to the following example (in that both evaluate to equal values): -``` +```powerquery-m [ A1 = 4, A2 = 2, @@ -125,27 +122,27 @@ The above expression is equivalent to the following (in that both evaluate to eq ] ``` -Records can be contained within, or _nest_, within other records. We can use the _lookup operator_ (`[]`) to access the fields of a record by name. For example, the following record has a field named `Sales` containing a record, and a field named `Total` that accesses the `FirstHalf` and `SecondHalf` fields of the `Sales` record: +Records can be contained within, or _nest_, within other records. You can use the _lookup operator_ (`[]`) to access the fields of a record by name. For example, the following record has a field named `Sales` containing a record, and a field named `Total` that accesses the `FirstHalf` and `SecondHalf` fields of the `Sales` record: -``` +```powerquery-m [ Sales = [ FirstHalf = 1000, SecondHalf = 1100 ], Total = Sales[FirstHalf] + Sales[SecondHalf] ] ``` -The above expression is equivalent to the following when it is evaluated: \ +The previous expression is equivalent to the following example when it's evaluated: -``` +```powerquery-m [ Sales = [ FirstHalf = 1000, SecondHalf = 1100 ], Total = 2100 ] ``` -Records can also be contained within lists. We can use the _positional index operator_ (`{}`) to access an item in a list by its numeric index. The values within a list are referred to using a zero-based index from the beginning of the list. For example, the indexes `0` and `1` are used to reference the first and second items in the list below: +Records can also be contained within lists. You can use the _positional index operator_ (`{}`) to access an item in a list by its numeric index. The values within a list are referred to using a zero-based index from the beginning of the list. For example, the indexes `0` and `1` are used to reference the first and second items in the following list: -``` +```powerquery-m [ Sales = { @@ -166,21 +163,20 @@ Records can also be contained within lists. We can use the _positional index ope ] ``` -List and record member expressions (as well as let expressions, introduced further below) are evaluated using _lazy evaluation_, which means that they are evaluated only as needed. All other expressions are evaluated using _eager evaluation_, which means that they are evaluated immediately, when encountered during the evaluation process. A good way to think about this is to remember that evaluating a list or record expression will return a list or -record value that itself remembers how its list items or record fields need to be computed, when requested (by lookup or index operators). +List and record member expressions (as well as [let expressions](#let-expression)) are evaluated using _lazy evaluation_, which means that they are evaluated only as needed. All other expressions are evaluated using _eager evaluation_, which means that they are evaluated immediately when encountered during the evaluation process. A good way to think about this is to remember that evaluating a list or record expression returns a list or record value that itself remembers how its list items or record fields need to be computed, when requested (by lookup or index operators). ## Functions -In M, a _function_ is a mapping from a set of input values to a single output value. A function is written by first naming the required set of input values (the parameters to the function) and then providing an expression that will compute the result of the function using those input values (the body of the function) following the goes-to (`=>`) symbol. For example: +In M, a _function_ is a mapping from a set of input values to a single output value. A function is written by first naming the required set of input values (the parameters to the function) and then providing an expression that computes the result of the function using those input values (the body of the function) following the goes-to (`=>`) symbol. For example: -``` +```powerquery-m (x) => x + 1 // function that adds one to a value (x, y) => x + y // function that adds two values ``` -A function is a value just like a number or a text value. The following example shows a function which is the value of an Add field which is then _invoked_, or executed, from several other fields. When a function is invoked, a set of values are specified which are logically substituted for the required set of input values within the function body expression. +A function is a value just like a number or a text value. The following example shows a function that's the value of an Add field, which is then _invoked_, or executed, from several other fields. When a function is invoked, a set of values are specified that are logically substituted for the required set of input values within the function body expression. -``` +```powerquery-m [ Add = (x, y) => x + y, OnePlusOne = Add(1, 1), // 2 @@ -190,9 +186,9 @@ A function is a value just like a number or a text value. The following example ## Library -M includes a common set of definitions available for use from an expression called the _standard library_, or just library for short. These definitions consist of a set of named values. The names of values provided by a library are available for use within an expression without having been defined explicitly by the expression. For example: +M includes a common set of definitions available for use from an expression called the _standard library_, or just _library_ for short. These definitions consist of a set of named values. The names of values provided by a library are available for use within an expression without having been defined explicitly by the expression. For example: -``` +```powerquery-m Number.E // Euler's number e (2.7182...) Text.PositionOf("Hello", "ll") // 2 ``` @@ -201,9 +197,9 @@ Text.PositionOf("Hello", "ll") // 2 M includes a set of operators that can be used in expressions. _Operators_ are applied to _operands_ to form symbolic expressions. For example, in the expression `1 + 2` the numbers `1` and `2` are operands and the operator is the addition operator (`+`). -The meaning of an operator can vary depending on what kind of values its operands are. For example, the plus operator can be used with other kinds of values than numbers: +The meaning of an operator can vary depending on what kind of values its operands are. For example, the plus operator can be used with other kinds of values besides numbers: -``` +```powerquery-m 1 + 2 // numeric addition: 3 #time(12,23,0) + #duration(0,0,2,0) // time arithmetic: #time(12,25,0) @@ -211,44 +207,44 @@ The meaning of an operator can vary depending on what kind of values its operand Another example of an operator with operand-depending meaning is the combination operator (`&`): -``` +```powerquery-m "A" & "BC" // text concatenation: "ABC" {1} & {2, 3} // list concatenation: {1, 2, 3} [ a = 1 ] & [ b = 2 ] // record merge: [ a = 1, b = 2 ] ``` -Note that not all combinations of values may be supported by an operator. For example: +Note that some operators don't support all combinations of values. For example: -``` -1 + "2" // error: adding number and text is not supported +```powerquery-m +1 + "2" // error: adding number and text isn't supported ``` -Expressions that, when evaluated, encounter undefined operator conditions evaluate to errors. More on errors in M later. +Expressions that, when evaluated, encounter undefined operator conditions evaluate to [errors](#errors). ## Metadata -_Metadata_ is information about a value that is associated with a value. Metadata is represented as a record value, called a _metadata record_. The fields of a metadata record can be used to store the metadata for a value. +_Metadata_ is information about a value that's associated with a value. Metadata is represented as a record value, called a _metadata record_. The fields of a metadata record can be used to store the metadata for a value. -Every value has a metadata record. If the value of the metadata record has not been specified, then the metadata record is empty (has no fields). +Every value has a metadata record. If the value of the metadata record hasn't been specified, then the metadata record is empty (has no fields). -Metadata records provide a way to associate additional information with any kind of value in an unobtrusive way. Associating a metadata record with a value does not change the value or its behavior. +Metadata records provide a way to associate additional information with any kind of value in an unobtrusive way. Associating a metadata record with a value doesn't change the value or its behavior. -A metadata record value `y` is associated with an existing value `x` using the syntax `x meta y`. For example, the following associates a metadata record with `Rating` and `Tags` fields with the text value `"Mozart"`: +A metadata record value `y` is associated with an existing value `x` using the syntax `x meta y`. For example, the following code associates a metadata record with `Rating` and `Tags` fields with the text value `"Mozart"`: -``` +```powerquery-m "Mozart" meta [ Rating = 5, Tags = {"Classical"} ] ``` For values that already carry a non-empty metadata record, the result of applying meta is that of computing the record merge of the existing and the new metadata record. For example, the following two expressions are equivalent to each other and to the previous expression: -``` +```powerquery-m ("Mozart" meta [ Rating = 5 ]) meta [ Tags = {"Classical"} ] "Mozart" meta ([ Rating = 5 ] & [ Tags = {"Classical"} ]) ``` -A metadata record can be accessed for a given value using the _Value.Metadata_ function. In the following example, the expression in the `ComposerRating` field accesses the metadata record of the value in the `Composer` field, and then accesses the `Rating` field of the metadata record. +A metadata record can be accessed for a given value using the [Value.Metadata](value-metadata.md) function. In the following example, the expression in the `ComposerRating` field accesses the metadata record of the value in the `Composer` field, and then accesses the `Rating` field of the metadata record. -``` +```powerquery-m [ Composer = "Mozart" meta [ Rating = 5, Tags = {"Classical"} ], ComposerRating = Value.Metadata(Composer)[Rating] // 5 @@ -257,9 +253,9 @@ A metadata record can be accessed for a given value using the _Value.Metadata_ f ## Let expression -Many of the examples shown so far have included all the literal values of the expression in the result of the expression. The _let_ expression allows a set of values to be computed, assigned names, and then used in a subsequent expression that follows the _in_. For example, in our sales data example, we could do: +Many of the examples shown so far have included all the literal values of the expression in the result of the expression. The `let` expression allows a set of values to be computed, assigned names, and then used in a subsequent expression that precedes the `in`. For example, in our sales data example, you could do: -``` +```powerquery-m let Sales2007 = [ @@ -274,32 +270,34 @@ let FirstHalf = 1200, SecondHalf = 1300, Total = FirstHalf + SecondHalf // 2500 - ] - in Sales2007[Total] + Sales2008[Total] // 4600 + ], + TotalSales = Sales2007[Total] + Sales2008[Total] +in + TotalSales // 4600 ``` -The result of the above expression is a number value (`4600`) which was computed from the values bound to the names `Sales2007` and `Sales2008`. +The result of the above expression is a number value (`4600`) that's computed from the values bound to the names `Sales2007` and `Sales2008`. ## If expression The `if` expression selects between two expressions based on a logical condition. For example: -``` +```powerquery-m if 2 > 1 then 2 + 2 else 1 + 1 ``` -The first expression (`2 + 2`) is selected if the logical expression (`2 > 1`) is true, and the second expression (`1 + 1`) is selected if it is false. The selected expression (in this case `2 + 2`) is evaluated and becomes the result of the `if` expression (`4`). +The first expression (`2 + 2`) is selected if the logical expression (`2 > 1`) is true, and the second expression (`1 + 1`) is selected if it's false. The selected expression (in this case `2 + 2`) is evaluated and becomes the result of the `if` expression (`4`). ## Errors -An _error_ is an indication that the process of evaluating an expression could not produce a value. +An _error_ is an indication that the process of evaluating an expression couldn't produce a value. -Errors are raised by operators and functions encountering error conditions or by using the error expression. Errors are handled using the try expression. When an error is raised, a value is specified that can be used to indicate why the error occurred. +Errors are raised by operators and functions encountering error conditions or by using the error expression. Errors are handled using the `try` expression. When an error is raised, a value is specified that can be used to indicate why the error occurred. -``` +```powerquery-m let Sales = [ Revenue = 2000, @@ -307,33 +305,35 @@ let Sales = UnitPrice = if Units = 0 then error "No Units" else Revenue / Units ], - UnitPrice = try Number.ToText(Sales[UnitPrice]) -in "Unit Price: " & - (if UnitPrice[HasError] then UnitPrice[Error][Message] - else UnitPrice[Value]) + UnitPrice = try Number.ToText(Sales[UnitPrice]), + Result = "Unit Price: " & + (if UnitPrice[HasError] then UnitPrice[Error][Message] + else UnitPrice[Value]) +in + Result ``` The above example accesses the `Sales[UnitPrice]` field and formats the value producing the result: -``` +```powerquery-m "Unit Price: 2" ``` -If the `Units` field had been zero, then the `UnitPrice` field would have raised an error which would have been handled by the `try`. The resulting value would then have been: +If the `Units` field had been zero, then the `UnitPrice` field would have raised an error, which would have been handled by the `try`. The resulting value would then have been: -``` -"No Units" +```powerquery-m +"Unit Price: No Units" ``` -A `try` expression converts proper values and errors into a record value that indicates whether the try expression handled and error, or not, and either the proper value or the error record it extracted when handling the error. For example, consider the following expression that raises an error and then handles it right away: +A `try` expression converts proper values and errors into a record value that indicates whether the `try` expression handled an error, or not, and either the proper value or the error record it extracted when handling the error. For example, consider the following expression that raises an error and then handles it right away: -``` +```powerquery-m try error "negative unit count" ``` -This expression evaluates to the following nested record value, explaining the `[HasError]`, `[Error]`, and `[Message]` field lookups in the unit-price example before. +This expression evaluates to the following nested record value, explaining the `[HasError]`, `[Error]`, and `[Message]` field lookups in the previous unit-price example. -``` +```powerquery-m [ HasError = true, Error = @@ -344,9 +344,10 @@ This expression evaluates to the following nested record value, explaining the ` ] ] ``` + A common case is to replace errors with default values. The `try` expression can be used with an optional `otherwise` clause to achieve just that in a compact form: -``` +```powerquery-m try error "negative unit count" otherwise 42 // 42 ``` diff --git a/query-languages/m/m-spec-let.md b/query-languages/m/m-spec-let.md index 22de2258f..7c96a6f0e 100644 --- a/query-languages/m/m-spec-let.md +++ b/query-languages/m/m-spec-let.md @@ -1,13 +1,10 @@ --- -title: M Language Let | Microsoft Docs +title: M Language Let description: Describes using the let expression in the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 4/7/2020 -ms.author: dougklo +ms.topic: conceptual +ms.date: 10/7/2022 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- @@ -29,9 +26,9 @@ variable-name:
The following example shows intermediate results being calculated and stored in variables `x`, `y`, and `z` which are then used in a subsequent calculation `x + y + z`: -``` +```powerquery-m let x = 1 + 1, - y = 2 + 2, + y = 2 + 2, z = y + 1 in x + y + z @@ -39,7 +36,7 @@ in The result of this expression is: -``` +```powerquery-m 11 // (1 + 1) + (2 + 2) + (2 + 2 + 1) ``` @@ -55,11 +52,10 @@ The following holds when evaluating expressions within the _let-expression_: A let expression can be seen as syntactic sugar over an implicit record expression. The following expression is equivalent to the example above: -``` +```powerquery-m [ x = 1 + 1, y = 2 + 2, z = y + 1, result = x + y + z ][result] ``` - diff --git a/query-languages/m/m-spec-lexical-structure.md b/query-languages/m/m-spec-lexical-structure.md index 58b74129f..fa406c045 100644 --- a/query-languages/m/m-spec-lexical-structure.md +++ b/query-languages/m/m-spec-lexical-structure.md @@ -1,13 +1,10 @@ --- -title: M Language lexical structure | Microsoft Docs +title: M Language lexical structure description: Describes the lexical structure of the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 11/29/2021 -ms.author: dougklo +ms.topic: conceptual +ms.date: 8/2/2022 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- @@ -27,7 +24,7 @@ A document either consists of exactly one _expression_ or of groups of _definiti ## Grammar conventions -The lexical and syntactic grammars are presented using _grammar productions_. Each grammar production defines a non-terminal symbol and the possible expansions of that nonterminal symbol into sequences of non-terminal or terminal symbols. In grammar productions, _non-terminal+ symbols are shown in italic type, and _terminal_ symbols are shown in a fixed-width font. +The lexical and syntactic grammars are presented using _grammar productions_. Each grammar production defines a non-terminal symbol and the possible expansions of that nonterminal symbol into sequences of non-terminal or terminal symbols. In grammar productions, _non-terminal+_ symbols are shown in italic type, and _terminal_ symbols are shown in a fixed-width font. The first line of a grammar production is the name of the non-terminal symbol being defined, followed by a colon. Each successive indented line contains a possible expansion of the nonterminal given as a sequence of non-terminal or terminal symbols. For example, the production: @@ -42,7 +39,6 @@ _variable-list:
      variable
      variable-list_ `,` _variable_ - defines a _variable-list_ to either consist of a _variable_ or consist of a _variable-list_ followed by a _variable_. In other words, the definition is recursive and specifies that a variable list consists of one or more variables, separated by commas. A subscripted suffix "opt" is used to indicate an optional symbol. The production: @@ -123,7 +119,6 @@ Two forms of comments are supported: single-line comments and delimited comments Delimited comments may span multiple lines. - _comment:
      single-line-comment
      delimited-comment
@@ -149,7 +144,7 @@ Comments do not nest. The character sequences `/*` and `*/` have no special mean Comments are not processed within text literals. The example -``` +```powerquery-m /* Hello, world */ "Hello, world" @@ -159,7 +154,7 @@ includes a delimited comment. The example -``` +```powerquery-m // Hello, world // "Hello, world" // This is an example of a text literal @@ -181,13 +176,13 @@ _token:
M text values can contain arbitrary Unicode characters. Text literals, however, are limited to graphic characters and require the use of _escape sequences_ for non-graphic characters. For example, to include a carriage-return, linefeed, or tab character in a text literal, the `#(cr)`, `#(lf)`, and `#(tab)` escape sequences can be used, respectively. To embed the escapesequence start characters `#(` in a text literal, the `#` itself needs to be escaped: -``` +```powerquery-m #(#)( ``` Escape sequences can also contain short (four hex digits) or long (eight hex digits) Unicode code-point values. The following three escape sequences are therefore equivalent: -``` +```powerquery-m #(000D) // short Unicode hexadecimal value #(0000000D) // long Unicode hexadecimal value #(cr) // compact escape shorthand for carriage return @@ -195,7 +190,7 @@ Escape sequences can also contain short (four hex digits) or long (eight hex dig Multiple escape codes can be included in a single escape sequence, separated by commas; the following two sequences are thus equivalent: -``` +```powerquery-m #(cr,lf) #(cr)#(lf) ``` @@ -279,7 +274,7 @@ hex-digit:_ one of
A number can be specified in hexadecimal format by preceding the _hex-digits_ with the characters `0x`. For example: -``` +```powerquery-m 0xff // 255 ``` @@ -304,13 +299,13 @@ _double-quote-escape-sequence:_
To include quotes in a text value, the quote mark is repeated, as follows: -``` +```powerquery-m "The ""quoted"" text" // The "quoted" text ``` The [_character-escape-sequence_](#character-escape-sequences) production can be used to write characters in text values without having to directly encode them as Unicode characters in the document. For example, a carriage return and line feed can be written in a text value as: -``` +```powerquery-m "Hello world#(cr,lf)" ``` @@ -321,7 +316,6 @@ A verbatim literal is used to store a sequence of Unicode characters that were e _verbatim-literal:_
      `#!"` _text-literal-charactersopt_ `"` - ### Identifiers An _identifier_ is a name used to refer to a value. Identifiers can either be regular identifiers or quoted identifiers. @@ -372,7 +366,7 @@ Note that escape sequences and double-quotes to escape quotes can be used in a _ The following example uses identifier quoting for names containing a space character: -``` +```powerquery-m [ #"1998 Sales" = 1000, #"1999 Sales" = 1100, @@ -382,7 +376,7 @@ The following example uses identifier quoting for names containing a space chara The following example uses identifier quoting to include the `+` operator in an identifier: -``` +```powerquery-m [ #"A + B" = A + B, A = 1, @@ -394,7 +388,7 @@ The following example uses identifier quoting to include the `+` operator in an There are two places in M where no ambiguities are introduced by identifiers that contain blanks or that are otherwise keywords or number literals. These places are the names of record fields in a record literal and in a field access operator (`[ ]`) There, M allows such identifiers without having to use quoted identifiers. -``` +```powerquery-m [ Data = [ Base Line = 100, Rate = 1.8 ], Progression = Data[Base Line] * Data[Rate] diff --git a/query-languages/m/m-spec-operators.md b/query-languages/m/m-spec-operators.md index 48e7a66f5..cd987576c 100644 --- a/query-languages/m/m-spec-operators.md +++ b/query-languages/m/m-spec-operators.md @@ -1,13 +1,10 @@ --- -title: M Language Operators | Microsoft Docs +title: M Language Operators description: Describes using operators in the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 11/29/2021 -ms.author: dougklo +ms.topic: conceptual +ms.date: 2/13/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- # Operator behavior @@ -25,7 +22,7 @@ _parenthesized-expression:_
For example: -``` +```powerquery-m 1 + 2 * 3 // 7 (1 + 2) * 3 // 9 ``` @@ -136,12 +133,12 @@ The following table summarizes the M operators, listing the operator categories
- + - + @@ -173,13 +170,13 @@ A metadata record is just a regular record and can contain any fields and values Every value has a default metadata record, even if one has not been specified. The default metadata record is empty. The following examples show accessing the metadata record of a text value using the `Value.Metadata` standard library function: -``` +```powerquery-m Value.Metadata( "Mozart" ) // [] ``` Metadata records are generally _not preserved_ when a value is used with an operator or function that constructs a new value. For example, if two text values are concatenated using the `&` operator, the metadata of the resulting text value is the empty record `[]`. The following expressions are equivalent: -``` +```powerquery-m "Amadeus " & ("Mozart" meta [ Rating = 5 ]) "Amadeus " & "Mozart" ``` @@ -192,7 +189,7 @@ The only operator that returns results that carry metadata is the [meta operator Values can be _cyclic_. For example: -``` +```powerquery-m let l = {0, @l} in l // {0, {0, {0, ... }}} [A={B}, B={A}] @@ -201,7 +198,7 @@ let l = {0, @l} in l M handles cyclic values by keeping construction of records, lists, and tables lazy. An attempt to construct a cyclic value that does not benefit from interjected lazy structured values yields an error: -``` +```powerquery-m [A=B, B=A] // [A = Error.Record("Expression.Error", // "A cyclic reference was encountered during evaluation"), @@ -244,7 +241,7 @@ The _item-access-expression_ `x{y}` returns: For example: -``` +```powerquery-m {"a","b","c"}{0} // "a" {1, [A=2], 3}{1} // [A=2] {true, false}{2} // error @@ -258,19 +255,19 @@ The _item-access-expression_ also supports the form `x{y}?`, which returns `null For example: -``` +```powerquery-m {"a","b","c"}{0}? // "a" {1, [A=2], 3}{1}? // [A=2] {true, false}{2}? // null -#table({"A","B"},{{0,1},{2,1}}){0} // [A=0,B=1] -#table({"A","B"},{{0,1},{2,1}}){[A=2]} // [A=2,B=1] -#table({"A","B"},{{0,1},{2,1}}){[B=3]} // null -#table({"A","B"},{{0,1},{2,1}}){[B=1]} // error +#table({"A","B"},{{0,1},{2,1}}){0}? // [A=0,B=1] +#table({"A","B"},{{0,1},{2,1}}){[A=2]}? // [A=2,B=1] +#table({"A","B"},{{0,1},{2,1}}){[B=3]}? // null +#table({"A","B"},{{0,1},{2,1}}){[B=1]}? // error ``` Item access does not force the evaluation of list or table items other than the one being accessed. For example: -``` +```powerquery-m { error "a", 1, error "c"}{1} // 1 { error "a", error "b"}{1} // error "b" ``` @@ -333,16 +330,16 @@ The simplest form of field access is _required field selection_. It uses the ope For example: -``` +```powerquery-m [A=1,B=2][B] // 2 [A=1,B=2][C] // error [A=1,B=2][C]? // null ``` -Collective access of multiple fields is supported by the operators for _required record projection_ and _optional record projection_. The operator `x[[y1],[y2],...]` projects the record to a new record with fewer fields (selected by `y1`, `y2`, `...`). If a selected field does not exist, an error is raised. The operator `x[[y1],[y2],...]` projects the record to a new record with the fields selected by `y1`, `y2`, `...`; if a field is missing, `null` is used instead. +Collective access of multiple fields is supported by the operators for _required record projection_ and _optional record projection_. The operator `x[[y1],[y2],...]` projects the record to a new record with fewer fields (selected by `y1`, `y2`, `...`). If a selected field does not exist, an error is raised. The operator `x[[y1],[y2],...]?` projects the record to a new record with the fields selected by `y1`, `y2`, `...`; if a field is missing, `null` is used instead. For example: -``` +```powerquery-m [A=1,B=2][[B]] // [B=2] [A=1,B=2][[C]] // error [A=1,B=2][[B],[C]]? // [B=2,C=null] @@ -350,44 +347,45 @@ For example: The forms `[y]` and `[y]?` are supported as a _shorthand_ reference to the identifier `_` (underscore). The following two expressions are equivalent: -``` +```powerquery-m [A] _[A] ``` The following example illustrates the shorthand form of field access: -``` +```powerquery-m let _ = [A=1,B=2] in [A] //1 ``` The form `[[y1],[y2],...]` and `[[y1],[y2],...]?` are also supported as a shorthand and the following two expressions are likewise equivalent: -``` +```powerquery-m [[A],[B]] _[[A],[B]] ``` -The shorthand form is particularly useful in combination with the `each` shorthand, a way to introduce a function of a single parameter named `_` (for details, see [Simplified declarations](m-spec-functions.md#simplified-declarations). Together, the two shorthands simplify common higher-order functional expressions: +The shorthand form is particularly useful in combination with the `each` shorthand, a way to introduce a function of a single parameter named `_` (for details, see [Simplified declarations](m-spec-functions.md#simplified-declarations)). Together, the two shorthands simplify common higher-order functional expressions: -``` +```powerquery-m List.Select( {[a=1, b=1], [a=2, b=4]}, each [a] = [b]) // {[a=1, b=1]} ``` The above expression is equivalent to the following more cryptic looking longhand: -``` +```powerquery-m List.Select( {[a=1, b=1], [a=2, b=4]}, (_) => _[a] = _[b]) // {[a=1, b=1]} ``` Field access does not force the evaluation of fields other than the one(s) being accessed. For example: -``` +```powerquery-m [A=error "a", B=1, C=error "c"][B] // 1 [A=error "a", B=error "b"][B] // error "b" ``` + The following holds when a field access operator `x[y]`, `x[y]?`, `x[[y]]`, or `x[[y]]?` is evaluated: * Errors raised during the evaluation of expression `x` are propagated. @@ -410,7 +408,7 @@ _metadata-expression:
The following example constructs a text value with a metadata record using the `meta` operator and then accesses the metadata record of the resulting value using `Value.Metadata`: -``` +```powerquery-m Value.Metadata( "Mozart" meta [ Rating = 5 ] ) // [Rating = 5 ] Value.Metadata( "Mozart" meta [ Rating = 5 ] )[Rating] @@ -429,7 +427,7 @@ The following holds when applying the metadata combining operator `x meta y`: The standard library functions `Value.RemoveMetadata` and `Value.ReplaceMetadata` can be used to remove all metadata from a value and to replace a value's metadata (rather than merge metadata into possibly existing metadata). The following expressions are equivalent: -``` +```powerquery-m x meta y Value.ReplaceMetadata(x, Value.Metadata(x) & y) Value.RemoveMetadata(x) meta (Value.Metadata(x) & y) @@ -446,7 +444,7 @@ _equality-expression:
For example: -``` +```powerquery-m 1 = 1 // true 1 = 2 // false 1 <> 1 // false @@ -457,7 +455,7 @@ null = null // true Metadata is not part of equality or inequality comparison. For example: -``` +```powerquery-m (1 meta [ a = 1 ]) = (1 meta [ a = 2 ]) // true (1 meta [ a = 1 ]) = 1 // true ``` @@ -478,7 +476,7 @@ The following holds when applying the equality operators `x = y` and `x <> y`: * The following is always true: -``` +```powerquery-m (x = y) = not (x <> y) ``` @@ -486,7 +484,7 @@ The equality operators are defined for the following types: * The `null` value is only equal to itself. -``` +```powerquery-m null = null // true null = true // false null = false // false @@ -494,7 +492,7 @@ The equality operators are defined for the following types: * The logical values `true` and `false` are only equal to themselves. For example: -``` +```powerquery-m true = true // true false = false // true true = false // false @@ -511,7 +509,7 @@ The equality operators are defined for the following types: For example: -``` +```powerquery-m 1 = 1, // true 1.0 = 1 // true 2 = 1 // false @@ -539,11 +537,11 @@ The equality operators are defined for the following types: For example: -``` + ```powerquery-m {1, 2} = {1, 2} // true {2, 1} = {1, 2} // false {1, 2, 3} = {1, 2} // false -``` + ``` * Two records are equal if all of the following are true: @@ -555,12 +553,12 @@ The equality operators are defined for the following types: For example: -``` + ```powerquery-m [ A = 1, B = 2 ] = [ A = 1, B = 2 ] // true [ B = 2, A = 1 ] = [ A = 1, B = 2 ] // true [ A = 1, B = 2, C = 3 ] = [ A = 1, B = 2 ] // false [ A = 1 ] = [ A = 1, B = 2 ] // false -``` + ``` * Two tables are equal if all of the following are true: @@ -574,11 +572,11 @@ The equality operators are defined for the following types: For example: -``` + ```powerquery-m #table({"A","B"},{{1,2}}) = #table({"A","B"},{{1,2}}) // true #table({"A","B"},{{1,2}}) = #table({"X","Y"},{{1,2}}) // false #table({"A","B"},{{1,2}}) = #table({"B","A"},{{2,1}}) // true -``` + ``` * A function value is equal to itself, but may or may not be equal to another function value. If two function values are considered equal, then they will behave identically when invoked. @@ -597,7 +595,7 @@ _relational-expression:
      additive-expression_ `<` _relational-expression
      additive-expression_ `>` _relational-expression
      additive-expression_ `<=` _relational-expression
-      additive-expression `>=` _relational-expression_ +      additive-expression_ `>=` _relational-expression_ These operators are used to determine the relative ordering relationship between two values, as shown in the following table: @@ -607,11 +605,10 @@ These operators are used to determine the relative ordering relationship between | `x > y` | `true` if `x` is greater than `y`, `false` otherwise | | `x <= y` | `true` if `x` is less than or equal to `y`, `false` otherwise | | `x >= y` | `true` if `x` is greater than or equal to `y`, `false` otherwise | -| | | For example: -``` +```powerquery-m 0 <= 1 // true null < 1 // null null <= null // null @@ -624,15 +621,13 @@ The following holds when evaluating an expression containing the relational oper * Errors raised when evaluating the `x` or `y` operand expressions are propagated. -* The values produced by evaluating both the `x` and `y` expressions must be a number, date, datetime, datetimezone, duration, logical, null or time value. Otherwise, an error with reason code `"Expression.Error"` is raised. - -* If either or both operands are `null`, the result is the `null` value. +* The values produced by evaluating both the `x` and `y` expressions must be a binary, date, datetime, datetimezone, duration, logical, number, null, text or time value. Otherwise, an error with reason code `"Expression.Error"` is raised. -* If both operands are logical, the value `true` is considered to be greater than `false`. +* Both operands must be the same kind of value or `null`. Otherwise, an error with reason code `"Expression.Error"` is raised. -* If both operands are durations, then the values are compared according to the total number of 100-nanosecond ticks they represent. +* If either or both operands are `null`, the result is the `null` value. -* Two times are compared by comparing their hour parts and, if equal, their minute parts and, if equal, their second parts. +* Two binaries are compared byte by byte. * Two dates are compared by comparing their year parts and, if equal, their month parts and, if equal, their day parts. @@ -640,10 +635,14 @@ The following holds when evaluating an expression containing the relational oper * Two datetimezones are compared by normalizing them to UTC by subtracting their hour/minute offset and then comparing their datetime components. +* Two durations are compared according to the total number of 100-nanosecond ticks they represent. + +* Two logicals are compared such that `true` is considered to be greater than `false`. + * Two numbers `x` and `y` are compared according to the rules of the IEEE 754 standard: - * If either operand is `#nan`, the result is `false` for all relational operators. - * When neither operand is `#nan`, the operators compare the values of the two floatingpoint operands with respect to the ordering `-∞ < -max < ... < -min < -0.0 = +0.0 < +min < ... < +max < +∞` where min and max are the smallest and largest positive finite values that can be represented. The M names for -∞ and +∞ are `-#infinity` and `#infinity`. + * If either operand is `#nan`, the result is `false` for all relational operators. + * When neither operand is `#nan`, the operators compare the values of the two floatingpoint operands with respect to the ordering `-∞ < -max < ... < -min < -0.0 = +0.0 < +min < ... < +max < +∞` where min and max are the smallest and largest positive finite values that can be represented. The M names for -∞ and +∞ are `-#infinity` and `#infinity`. Notable effects of this ordering are: @@ -653,6 +652,11 @@ The following holds when evaluating an expression containing the relational oper * A `#infinity` value is considered greater than all other number values, but equal to another `#infinity`. +* Two texts are compared by using a character-by-character ordinal, case-sensitive, culture-insensitive comparison. + +* Two times are compared by comparing their hour parts and, if equal, their minute parts and, if equal, their second parts. + + ## Conditional logical operators The `and` and `or` operators are called the conditional logical operators. @@ -670,23 +674,21 @@ The `and` operator returns `false` when at least one of its operands is `false`. Truth tables for the `or` and `and` operators are shown below, with the result of evaluating the left operand expression on the vertical axis and the result of evaluating the right operand expression on the horizontal axis. -| *`and`* | `true` | `false` | `null` | `error` | +| _`and`_ | `true` | `false` | `null` | `error` | | --- | --- | --- | --- | --- | | **`true`** | `true` | `false` | `null` | `error` | | **`false`** | `false` | `false` | `false` | `false` | | **`null`** | `null` | `false` | `null` | `error` | | **`error`** | `error` | `error` | `error` | `error` | -| | | | | | -| *`or`* | `true` | `false` | `null` | `error` | +| _`or`_ | `true` | `false` | `null` | `error` | | --- | --- | --- | --- | --- | | **`or`** | `true` | `false` | `null` | `error` | | **`true`** | `true` | `true` | `true` | `true` | | **`false`** | `true` | `false` | `null` | `error` | | **`null`** | `true` | `null` | `null` | `error` | | **`error`** | `error` | `error` | `error` | `error` | -| | | | | | - + The following holds when evaluating an expression containing conditional logical operators: * Errors raised when evaluating the `x` or `y` expressions are propagated. @@ -701,7 +703,7 @@ The following holds when evaluating an expression containing conditional logical The last two properties give the conditional logical operators their "conditional" qualification; properties also referred to as "short-circuiting". These properties are useful to write compact _guarded predicates_. For example, the following expressions are equivalent: -``` +```powerquery-m d <> 0 and n/d > 1 if d <> 0 then n/d > 1 else false ``` @@ -726,7 +728,6 @@ Numbers in M are stored using a variety of representations to retain as much inf | --------- | --------- | | `Precision.Decimal` | 128-bit decimal representation with a range of ±1.0 x 10-28 to ±7.9 x 1028 and 28-29 significant digits. | | `Precision.Double` | Scientific representation using mantissa and exponent; conforms to the 64-bit binary double-precision IEEE 754 arithmetic standard [IEEE 754-2008](https://ieeexplore.ieee.org/servlet/opac?punumber=4610933). | -| | | Arithmetic operations are performed by choosing a precision, converting both operands to that precision (if necessary), then performing the actual operation, and finally returning a number in the chosen precision. @@ -758,7 +759,6 @@ The interpretation of the addition operator (`x + y`) is dependent on the kind o | `type duration` | `type` _datetime_ | `type` _datetime_ | | | `type` _datetime_ | `null` | `null` | | | `null` | `type` _datetime_ | `null` | | -| | | | | In the table, `type` _datetime_ stands for any of `type date`, `type datetime`, `type datetimezone`, or `type time`. When adding a duration and a value of some type _datetime_, the resulting value is of that same type. @@ -772,24 +772,23 @@ The sum of two numbers is computed using the _addition operator_, producing a nu For example: -``` +```powerquery-m 1 + 1 // 2 #nan + #infinity // #nan ``` The addition operator `+` over numbers uses Double Precision; the standard library function `Value.Add` can be used to specify Decimal Precision. The following holds when computing a sum of numbers: -* The sum in Double Precision is computed according to the rules of 64-bit binary doubleprecision IEEE 754 arithmetic [IEEE 754-2008](https://ieeexplore.ieee.org/servlet/opac?punumber=4610933). The following table lists the results of all possible combinations of nonzero finite values, zeros, infinities, and NaN's. In the table, `x` and `y` are nonzero finite values, and `z` is the result of `x + y`. If `x` and `y` have the same magnitude but opposite signs, `z` is positive zero. If `x + y` is too large to be represented in the destination type, `z` is an infinity with the same sign as `x + y`. - +* The sum in Double Precision is computed according to the rules of 64-bit binary doubleprecision IEEE 754 arithmetic [IEEE 754-2008](https://ieeexplore.ieee.org/servlet/opac?punumber=4610933). The following table lists the results of all possible combinations of nonzero finite values, zeros, infinities, and NaN's. In the table, `x` and `y` are nonzero finite values, and `z` is the result of `x + y`. If `x` and `y` have the same magnitude but opposite signs, `z` is positive zero. If `x + y` is too large to be represented in the destination type, `z` is an infinity with the same sign as `x + y`. + | + | y | +0 | -0 | +∞ | -∞ | NaN | | --- | --- | --- | --- | --- | --- | --- | - | x | z | x | x | +∞ | -∞ | NaN | - | +0 | y | +0 | +0 | +∞ | -∞ | NaN | - | -0 | y | +0 | -0 | +∞ | -∞ | NaN | - | +∞ | +∞ | +∞ | +∞ | +∞ | NaN | NaN | - | -∞ | -∞ | -∞ | -∞ | NaN | -∞ | NaN | - | NaN | NaN | NaN | NaN | NaN | NaN | NaN | - | | | | | | | | + | **x** | z | x | x | +∞ | -∞ | NaN | + | **+0** | y | +0 | +0 | +∞ | -∞ | NaN | + | **-0** | y | +0 | -0 | +∞ | -∞ | NaN | + | **+∞** | +∞ | +∞ | +∞ | +∞ | NaN | NaN | + | **-∞** | -∞ | -∞ | -∞ | NaN | -∞ | NaN | + | **NaN** | NaN | NaN | NaN | NaN | NaN | NaN | * The sum in Decimal Precision is computed without losing precision. The scale of the result is the larger of the scales of the two operands. @@ -797,7 +796,7 @@ The addition operator `+` over numbers uses Double Precision; the standard libra The sum of two durations is the duration representing the sum of the number of 100nanosecond ticks represented by the durations. For example: -``` +```powerquery-m #duration(2,1,0,15.1) + #duration(0,1,30,45.3) // #duration(2, 2, 31, 0.4) ``` @@ -808,21 +807,21 @@ A _datetime_ `x` and a duration `y` may be added using `x + y` to compute a new * If the datetime's days since epoch value is specified, construct a new datetime with the following information elements: - * Calculate a new days since epoch equivalent to dividing the magnitude of y by the number of 100-nanosecond ticks in a 24-hour period, truncating the decimal portion of the result, and adding this value to the x's days since epoch. + * Calculate a new days since epoch equivalent to dividing the magnitude of y by the number of 100-nanosecond ticks in a 24-hour period, truncating the decimal portion of the result, and adding this value to the x's days since epoch. - * Calculate a new ticks since midnight equivalent to adding the magnitude of y to the x's ticks since midnight, modulo the number of 100-nanosecond ticks in a 24-hour period. If x does not specify a value for ticks since midnight, a value of 0 is assumed. + * Calculate a new ticks since midnight equivalent to adding the magnitude of y to the x's ticks since midnight, modulo the number of 100-nanosecond ticks in a 24-hour period. If x does not specify a value for ticks since midnight, a value of 0 is assumed. - * Copy x's value for minutes offset from UTC unchanged. + * Copy x's value for minutes offset from UTC unchanged. * If the datetime's days since epoch value is unspecified, construct a new datetime with the following information elements specified: - * Calculate a new ticks since midnight equivalent to adding the magnitude of y to the x's ticks since midnight, modulo the number of 100-nanosecond ticks in a 24-hour period. If x does not specify a value for ticks since midnight, a value of 0 is assumed. + * Calculate a new ticks since midnight equivalent to adding the magnitude of y to the x's ticks since midnight, modulo the number of 100-nanosecond ticks in a 24-hour period. If x does not specify a value for ticks since midnight, a value of 0 is assumed. - * Copy x's values for days since epoch and minutes offset from UTC unchanged. + * Copy x's values for days since epoch and minutes offset from UTC unchanged. The following examples show calculating the absolute temporal sum when the datetime specifies the _days since epoch_: -``` +```powerquery-m #date(2010,05,20) + #duration(0,8,0,0) //#datetime( 2010, 5, 20, 8, 0, 0 ) //2010-05-20T08:00:00 @@ -842,7 +841,7 @@ The following examples show calculating the absolute temporal sum when the datet The following example shows calculating the datetime offset by duration for a given time: -``` +```powerquery-m #time(8,0,0) + #duration(30,5,0,0) //#time(13, 0, 0) //13:00:00 @@ -864,7 +863,6 @@ The interpretation of the subtraction operator (`x - y`) is dependent on the kin | `type` _datetime_ | `type duration` | `type` _datetime_ | Datetime offset by negated duration | | `type` _datetime_ | `null` | `null` | | | `null` | `type` _datetime_ | `null` | | -| | | | | In the table, `type` _datetime_ stands for any of `type date`, `type datetime`, `type datetimezone`, or `type time`. When subtracting a duration from a value of some type _datetime_, the resulting value is of that same type. @@ -876,32 +874,31 @@ Errors raised when evaluating either operand are propagated. The difference between two numbers is computed using the _subtraction operator_, producing a number. For example: -``` +```powerquery-m 1 - 1 // 0 #nan - #infinity // #nan ``` The subtraction operator `-` over numbers uses Double Precision; the standard library function `Value.Subtract` can be used to specify Decimal Precision. The following holds when computing a difference of numbers: -* The difference in Double Precision is computed according to the rules of 64-bit binary double-precision IEEE 754 arithmetic [IEEE 754-2008](https://ieeexplore.ieee.org/servlet/opac?punumber=4610933). The following table lists the results of all possible combinations of nonzero finite values, zeros, infinities, and NaN's. In the table, `x` and `y` are nonzero finite values, and `z` is the result of `x - y`. If `x` and `y` are equal, `z` is positive zero. If `x - y` is too large to be represented in the destination type, `z` is an infinity with the same sign as `x - y`. - +* The difference in Double Precision is computed according to the rules of 64-bit binary double-precision IEEE 754 arithmetic [IEEE 754-2008](https://ieeexplore.ieee.org/servlet/opac?punumber=4610933). The following table lists the results of all possible combinations of nonzero finite values, zeros, infinities, and NaN's. In the table, `x` and `y` are nonzero finite values, and `z` is the result of `x - y`. If `x` and `y` are equal, `z` is positive zero. If `x - y` is too large to be represented in the destination type, `z` is an infinity with the same sign as `x - y`. + | - | y | +0 | -0 | +∞ | -∞ | NaN | | --- | --- | --- | --- | --- | --- | --- | - | x | z | x | x | -∞ | +∞ | NaN | - | +0 | -y | +0 | +0 | -∞ | +∞ | NaN | - | -0 | -y | -0 | +0 | -∞ | +∞ | NaN | - | +∞ | +∞ | +∞ | +∞ | NaN | +∞ | NaN | - | -∞ | -∞ | -∞ | -∞ | -∞ | NaN | NaN | - | NaN | NaN | NaN | NaN | NaN | NaN | NaN | - | | | | | | | | - + | **x** | z | x | x | -∞ | +∞ | NaN | + | **+0** | -y | +0 | +0 | -∞ | +∞ | NaN | + | **-0** | -y | -0 | +0 | -∞ | +∞ | NaN | + | **+∞** | +∞ | +∞ | +∞ | NaN | +∞ | NaN | + | **-∞** | -∞ | -∞ | -∞ | -∞ | NaN | NaN | + | **NaN** | NaN | NaN | NaN | NaN | NaN | NaN | + * The difference in Decimal Precision is computed without losing precision. The scale of the result is the larger of the scales of the two operands. #### Difference of durations The difference of two durations is the duration representing the difference between the number of 100-nanosecond ticks represented by each duration. For example: -``` +```powerquery-m #duration(1,2,30,0) - #duration(0,0,0,30.45) // #duration(1, 2, 29, 29.55) ``` @@ -910,7 +907,7 @@ The difference of two durations is the duration representing the difference betw A _datetime_ `x` and a duration `y` may be subtracted using `x - y` to compute a new _datetime_. Here, _datetime_ stands for any of `date`, `datetime`, `datetimezone`, or `time`. The resulting _datetime_ has a distance from `x` on a linear timeline that is exactly the magnitude of `y`, in the direction opposite the sign of `y`. Subtracting positive durations yields results that are backwards in time relative to `x`, while subtracting negative values yields results that are forwards in time. -``` +```powerquery-m #date(2010,05,20) - #duration(00,08,00,00) //#datetime(2010, 5, 19, 16, 0, 0) //2010-05-19T16:00:00 @@ -923,7 +920,7 @@ A _datetime_ `x` and a duration `y` may be subtracted using `x - y` to compute a Two _datetimes_ `t` and `u` may be subtracted using `t - u` to compute the duration between them. Here, _datetime_ stands for any of `date`, `datetime`, `datetimezone`, or `time`. The duration produced by subtracting `u` from `t` must yield `t` when added to `u`. -``` +```powerquery-m #date(2010,01,31) - #date(2010,01,15) // #duration(16,00,00,00) // 16.00:00:00 @@ -940,7 +937,7 @@ Two _datetimes_ `t` and `u` may be subtracted using `t - u` to compute the durat Subtracting `t - u` when `u > t` results in a negative duration: -``` +```powerquery-m #time(01,30,00) - #time(08,00,00) // #duration(0, -6, -30, 0) ``` @@ -962,16 +959,16 @@ The interpretation of the multiplication operator (`x * y`) is dependent on the | `type number` | `type duration` | `type duration` | Multiple of duration | | `type duration` | `null` | `null` | | | `null` | `type duration` | `null` | | -| | | | | For other combinations of values than those listed in the table, an error with reason code `"Expression.Error"` is raised. Each combination is covered in the following sections. Errors raised when evaluating either operand are propagated. #### Numeric product + The product of two numbers is computed using the _multiplication operator_, producing a number. For example: -``` +```powerquery-m 2 * 4 // 8 6 * null // null #nan * #infinity // #nan @@ -983,14 +980,13 @@ The multiplication operator `*` over numbers uses Double Precision; the standard | * | +y | -y | +0 | -0 | +∞ | -∞ | NaN | | --- | --- | --- | --- | --- | --- | --- | --- | - | +x | +z | -z | +0 | -0 | +∞ | -∞ | NaN | - | -x | -z | +z | -0 | +0 | -∞ | +∞ | NaN | - | +0 | +0 | -0 | +0 | -0 | NaN | NaN | NaN | - | -0 | -0 | +0 | -0 | +0 | NaN | NaN | NaN | - | +∞ | +∞ | -∞ | NaN | NaN | +∞ | -∞ | NaN | - | -∞ | -∞ | +∞ | NaN | NaN | -∞ | +∞ | NaN | - | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | - | | | | | | | | | + | **+x** | +z | -z | +0 | -0 | +∞ | -∞ | NaN | + | **-x** | -z | +z | -0 | +0 | -∞ | +∞ | NaN | + | **+0** | +0 | -0 | +0 | -0 | NaN | NaN | NaN | + | **-0** | -0 | +0 | -0 | +0 | NaN | NaN | NaN | + | **+∞** | +∞ | -∞ | NaN | NaN | +∞ | -∞ | NaN | + | **-∞** | -∞ | +∞ | NaN | NaN | -∞ | +∞ | NaN | + | **NaN** | NaN | NaN | NaN | NaN | NaN | NaN | NaN | * The product in Decimal Precision is computed without losing precision. The scale of the result is the larger of the scales of the two operands. @@ -998,7 +994,7 @@ The multiplication operator `*` over numbers uses Double Precision; the standard The product of a duration and a number is the duration representing the number of 100nanosecond ticks represented by the duration operand times the number operand. For example: -``` +```powerquery-m #duration(2,1,0,15.1) * 2 // #duration(4, 2, 0, 30.2) ``` @@ -1013,10 +1009,9 @@ The interpretation of the division operator (`x / y`) is dependent on the kind o | `type number` | `null` | `null` | | | `null` | `type number` | `null` | | | `type duration` | `type number` | `type duration` | Fraction of duration | -| `type duration` | `type duration` | `type duration` | Numeric quotient of durations | +| `type duration` | `type duration` | `type number` | Numeric quotient of durations | | `type duration` | `null` | `null` | | | `null` | `type duration` | `null` | | -| | | | | For other combinations of values than those listed in the table, an error with reason code `"Expression.Error"` is raised. Each combination is covered in the following sections. @@ -1026,7 +1021,7 @@ Errors raised when evaluating either operand are propagated. The quotient of two numbers is computed using the _division operator_, producing a number. For example: -``` +```powerquery-m 8 / 2 // 4 8 / 0 // #infinity 0 / 0 // #nan @@ -1040,30 +1035,30 @@ The division operator `/` over numbers uses Double Precision; the standard libra | / | +y | -y | +0 | -0 | +∞ | -∞ | NaN | | --- | --- | --- | --- | --- | --- | --- | --- | - | +x | +z | -z | +∞ | -∞ | +0 | -0 | NaN | - | -x | -z | +z | -∞ | +∞ | -0 | +0 | NaN | - | +0 | +0 | -0 | NaN | NaN | +0 | -0 | NaN | - | -0 | -0 | +0 | NaN | NaN | -0 | +0 | NaN | - | +∞ | +∞ | -∞ | +∞ | -∞ | NaN | NaN | NaN | - | -∞ | -∞ | +∞ | -∞ | +∞ | NaN | NaN | NaN | - | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | - | | | | | | | | | - + | **+x** | +z | -z | +∞ | -∞ | +0 | -0 | NaN | + | **-x** | -z | +z | -∞ | +∞ | -0 | +0 | NaN | + | **+0** | +0 | -0 | NaN | NaN | +0 | -0 | NaN | + | **-0** | -0 | +0 | NaN | NaN | -0 | +0 | NaN | + | **+∞** | +∞ | -∞ | +∞ | -∞ | NaN | NaN | NaN | + | **-∞** | -∞ | +∞ | -∞ | +∞ | NaN | NaN | NaN | + | **NaN** | NaN | NaN | NaN | NaN | NaN | NaN | NaN | + * The sum in Decimal Precision is computed without losing precision. The scale of the result is the larger of the scales of the two operands. #### Quotient of durations The quotient of two durations is the number representing the quotient of the number of 100nanosecond ticks represented by the durations. For example: -``` +```powerquery-m #duration(2,0,0,0) / #duration(0,1,30,0) // 32 ``` #### Scaled durations + The quotient of a duration `x` and a number `y` is the duration representing the quotient of the number of 100-nanosecond ticks represented by the duration `x` and the number `y`. For example: -``` +```powerquery-m #duration(2,0,0,0) / 32 // #duration(0,1,30,0) ``` @@ -1083,7 +1078,6 @@ The combination operator (`x & y`) is defined over the following kinds of values | `type list` | `type list` | `type list` | Concatenation | | `type record` | `type record` | `type record` | Merge | | `type table` | `type table` | `type table` | Concatenation | -| | | | | ### Concatenation @@ -1091,13 +1085,13 @@ Two text, two list, or two table values can be concatenated using `x & y`. The following example illustrates concatenating text values: -``` +```powerquery-m "AB" & "CDE" // "ABCDE" ``` The following example illustrates concatenating lists: -``` +```powerquery-m {1, 2} & {3} // {1, 2, 3} ``` @@ -1121,7 +1115,7 @@ Two records can be merged using `x & y`, producing a record that includes fields The following examples illustrate merging records: -``` +```powerquery-m [ x = 1 ] & [ y = 2 ] // [ x = 1, y = 2 ] [ x = 1, y = 2 ] & [ x = 3, z = 4 ] // [ x = 3, y = 2, z = 4 ] ``` @@ -1146,10 +1140,11 @@ A date `x` can be merged with a time `y` using `x & y`, producing a datetime tha The following example illustrates merging a date and a time: -``` +```powerquery-m #date(2013,02,26) & #time(09,17,00) // #datetime(2013,02,26,09,17,00) ``` + The following holds when merging two records using `x + y`: * Errors raised when evaluating the `x` or `y` expressions are propagated. @@ -1168,20 +1163,19 @@ _unary-expression:
### Unary plus operator -The unary plus operator (`+x`) is defined for the following kinds of values: - +The unary plus operator (`+x`) is defined for the following kinds of values: + | X | Result | Interpretation | | --- | --- | --- | | `type number` | `type number` | Unary plus | | `type duration` | `type duration` | Unary plus | | `null` | `null | | -| | | | For other values, an error with reason code `"Expression.Error"` is raised. The unary plus operator allows a `+` sign to be applied to a number, datetime, or null value. The result is that same value. For example: -``` +```powerquery-m + - 1 // -1 + + 1 // 1 + #nan // #nan @@ -1203,13 +1197,12 @@ The unary minus operator (`-x`) is defined for the following kinds of values: | `type number` | `type number ` | Negation | | `type duration` | `type duration` | Negation | | `null` | `null` | | -| | | | For other values, an error with reason code `"Expression.Error"` is raised. The unary minus operator is used to change the sign of a number or duration. For example: -``` +```powerquery-m - (1 + 1) // -2 - - 1 // 1 - - - 1 // -1 @@ -1233,11 +1226,10 @@ The logical negation operator (`not`) is defined for the following kinds of valu | --- | --- | --- | | `type logical` | `type logical` | Negation | | `null` | `null` | | -| | | | - + This operator computes the logical `not` operation on a given logical value. For example: -``` +```powerquery-m not true // false not false // true not (true and true) // false @@ -1261,22 +1253,21 @@ The type compatibility operator `x is y` is defined for the following types of | X | Y | Result | | --- | --- | --- | -| `type any` | _nullable-primitive-type_ | `type logical` | -| | | | - -The expression `x is y` returns `true` if the ascribed type of `x` is compatible with `y`, and returns `false` if the ascribed type of `x` is incompatible with `y`. `y` must be a _nullable-primitivetype_. +| `type any` | _primitive-or-nullable-primitive-type_ | `type logical` | + +The expression `x is y` returns `true` if the ascribed type of `x` is compatible with `y`, and returns `false` if it is not compatible. `y` must be a primitive type or a nullable primitive type. _is-expression:
      as-expression
-      is-expression_ `is` _nullable-primitive-type
-nullable-primitive-type:_
-      `nullable`_opt primitive-type_ +      is-expression_ `is` _primitive-or-nullable-primitive-type
+primitive-or-nullable-primitive-type:_
+      `nullable`_opt primitive-type_
Type compatibility, as supported by the `is` operator, is a subset of [general type compatibility](m-spec-types.md) and is defined using the following rules: -* If `x` is null then it is compatible iff y is a nullable type or the type `any`. +* If `x` is null then it is compatible if `y` is the type `any`, the type `null`, or a nullable primitive type. -* If `x` is non-null then if it is a compatible if the the primitive type of `x` is the same as `y`. +* If `x` is non-null then it is compatible if the primitive type of `x` is the same as `y`. The following holds when evaluating the expression `x is y`: @@ -1288,14 +1279,15 @@ The type assertion operator `x as y` is defined for the following types of value | X | Y | Result | | --- | --- | --- | -| `type any` | _nullable-primitive-type_ | `type any` | -| | | | - -The expression `x as y` asserts that the value `x` is compatible with `y` as per the `is` operator. If it is not compatible, an error is raised. `y` must be a _nullable-primitive-type_. +| `type any` | _primitive-or-nullable-primitive-type_ | `type any` | + +The expression `x as y` asserts that the value `x` is compatible with `y` as per the `is` operator. If it is not compatible, an error is raised. `y` must be a primitive type or a nullable primitive type. _as-expression:
      equality-expression
-      as-expression_ `as` _nullable-primitive-type_ +      as-expression_ `as` _primitive-or-nullable-primitive-type
+primitive-or-nullable-primitive-type:_
+      `nullable`_opt primitive-type_ The expression `x as y` is evaluated as follows: @@ -1305,7 +1297,7 @@ The expression `x as y` is evaluated as follows: Examples: -``` +```powerquery-m 1 as number // 1 "A" as number // error null as nullable number // null diff --git a/query-languages/m/m-spec-sections.md b/query-languages/m/m-spec-sections.md index da2cce491..f33748a3b 100644 --- a/query-languages/m/m-spec-sections.md +++ b/query-languages/m/m-spec-sections.md @@ -1,13 +1,10 @@ --- -title: M Language Sections | Microsoft Docs +title: M Language Sections description: Describes using sections in the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 8/23/2021 -ms.author: dougklo +ms.topic: conceptual +ms.date: 10/7/2022 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- # Sections @@ -27,14 +24,14 @@ section-member:
_section-member-name:
      identifier_ -In M, a section is an organizational concept that allows related expressions to be named and grouped within a document. Each section has a _section-name_, which identifies the section and qualifies the names of the _section-members_ declared within the section. A _sectionmember_ consists of a _member-name_ and an _expression_. Section member expressions may refer to other section members within the same section directly by member name. +In M, a section is an organizational concept that allows related expressions to be named and grouped within a document. Each section has a _section-name_, which identifies the section and qualifies the names of the _section-members_ declared within the section. A _section-member_ consists of a _member-name_ and an _expression_. Section member expressions may refer to other section members within the same section directly by member name. The following example shows a section-document: -``` +```powerquery-m section Section1; -A = 1; //1 +A = 1; //1 B = 2; //2 C = A + B; //3 ``` @@ -46,21 +43,21 @@ _section-access-expression:
The following example shows a set of two documents containing sections that are mutually referential: -``` +```powerquery-m section Section1; A = "Hello"; //"Hello" B = 1 + Section2!A; //3 section Section2; A = 2; //2 -B = Section1!A & " world!"; /"Hello, world" +B = Section1!A & " world!"; //"Hello, world" ``` Section members may optionally be declared as `shared`, which omits the requirement to use a _section-access-expression_ when referring to shared members outside of the containing section. Shared members in external sections may be referred to by their unqualified member name so long as no member of the same name is declared in the referring section and no other section has a like-named shared member. The following example illustrates the behavior of shared members when used across sections within the same set of documents: -``` +```powerquery-m section Section1; shared A = 1; // 1 @@ -75,7 +72,7 @@ C = Section1!A + 2; // 3 Defining a shared member with the same name in different sections will produce a valid global environment, however accessing the shared member will raise an error when accessed. -``` +```powerquery-m section Section1; shared A = 1; @@ -116,7 +113,7 @@ The `#sections` intrinsic variable returns all sections within the global enviro The following example shows a document consisting of two sections and the record produced by evaluating the `#sections` intrinsic variable within the context of that document: -``` +```powerquery-m section Section1; A = 1; B = 2; @@ -134,16 +131,16 @@ D = "world"; The following holds when evaluating `#sections`: -* The `#sections` intrinsic variable preserves the evaluation state of all section member expressions within the document. +* The `#sections` intrinsic variable preserves the evaluation state of all section member expressions within the document. * The `#sections` intrinsic variable does not force the evaluation of any unevaluated section members. ### #shared -The `#shared` intrinsic variable returns a record containing the names and values of all shared section members currently in scope. +The `#shared` intrinsic variable returns the contents of the global environment as a record. (The global environment consists of all shared section members as well as any identifiers directly included in the global environment by the expression evaluator.) This record is keyed by identifier name, with each value being the value of the associated identifier. -The following example shows a document with two shared members and the corresponding record produced by evaluating the #shared intrinsic variable within the context of that document: +The following example shows a document with two shared members and the corresponding record produced by evaluating the `#shared` intrinsic variable within the context of that document: -``` +```powerquery-m section Section1; shared A = 1; B = 2; @@ -160,6 +157,6 @@ shared D = "world"; The following holds when evaluating `#shared`: -* The `#shared` intrinsic variable preserves the evaluation state of all shared member expressions within the document. +* The `#shared` intrinsic variable preserves the evaluation state of the global environment. -* The `#shared` intrinsic variable does not force the evaluation of any unevaluated section members. +* The `#shared` intrinsic variable does not force the evaluation of any unevaluated value. diff --git a/query-languages/m/m-spec-types.md b/query-languages/m/m-spec-types.md index 292d5053a..68061059d 100644 --- a/query-languages/m/m-spec-types.md +++ b/query-languages/m/m-spec-types.md @@ -1,20 +1,17 @@ --- -title: M Language types | Microsoft Docs +title: M Language types description: Describes using types in the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 11/29/2021 -ms.author: dougklo +ms.topic: conceptual +ms.date: 1/29/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- # Types A _type value_ is a value that _classifies_ other values. A value that is classified by a type is said to _conform_ to that type. The M type system consists of the following kinds of types: -* Primitive types, which classify primitive values (`binary`, `date`, `datetime`, `datetimezone`, `duration`, `list`, `logical`, `null`, `number`, `record`, `text`, `time`, `type`) and also include a number of abstract types (`function`, `table`, `any`, and `none`) +* Primitive types, which classify primitive values (`binary`, `date`, `datetime`, `datetimezone`, `duration`, `list`, `logical`, `null`, `number`, `record`, `text`, `time`, `type`) and also include a number of abstract types (`function`, `table`, `any`, `anynonnull` and `none`) * Record types, which classify record values based on field names and value types @@ -28,56 +25,55 @@ A _type value_ is a value that _classifies_ other values. A value that is classi * Type types, which classify values that are types -The set of _primitive types_ includes the types of primitive values a number of _abstract types_, types that do not uniquely classify any values: `function`, `table`, `any`, and `none`. All function values conform to the abstract type `function`, all table values to the abstract type `table`, all values to the abstract type `any`, and no values to the abstract type `none`. An expression of type `none` must raise an error or fail to terminate since no value could be produced that conforms to type `none`. Note that the primitive types `function` and `table` are abstract because no function or table is directly of those types, respectively. The primitive types `record` and `list` are non-abstract because they represent an open record with no defined fields and a list of type any, respectively. +The set of _primitive types_ includes the types of primitive values, and a number of _abstract types_, which are types that do not uniquely classify any values: `function`, `table`, `any`, `anynonnull` and `none`. All function values conform to the abstract type `function`, all table values to the abstract type `table`, all values to the abstract type `any`, all non-null values to the abstract type `anynonnull`, and no values to the abstract type `none`. An expression of type `none` must raise an error or fail to terminate since no value could be produced that conforms to type `none`. Note that the primitive types `function` and `table` are abstract because no function or table is directly of those types, respectively. The primitive types `record` and `list` are non-abstract because they represent an open record with no defined fields and a list of type any, respectively. -All types that are not members of the closed set of primitive types are collectively referred to as _custom types_. Custom types can be written using a `type-expression`: +All types that are not members of the closed set of primitive types plus their nullable counterparts are collectively referred to as _custom types_. Custom types can be written using a `type-expression`: -_type-expression:
+_type-expression:
      primary-expression_
      `type` _primary-type
-type:
-      parenthesized-expression
-      primary-type
primary-type:
-      primitive-type
+      primitive-or-nullable-primitive-type
      record-type
      list-type
      function-type
      table-type
-      nullable-type
-primitive-type:_ one of
-      `any binary date datetime datetimezone duration function list logical`
-      `none null number record table text time type` +      nullable-type_
+_primitive-or-nullable-primitive-type:_
+      `nullable`_opt primitive-type_
+_primitive-type:_ one of
+      `any anynonnull binary date datetime datetimezone duration function list logical`
+      `none null number record table text time type`
The _primitive-type_ names are _contextual keywords_ recognized only in a _type_ context. The use of parentheses in a _type_ context moves the grammar back to a regular expression context, requiring the use of the type keyword to move back into a type context. For example, to invoke a function in a _type_ context, parentheses can be used: -``` +```powerquery-m type nullable ( Type.ForList({type number}) ) // type nullable {number} ``` Parentheses can also be used to access a variable whose name collides with a _primitive-type_ name: -``` +```powerquery-m let record = type [ A = any ] in type {(record)} // type {[ A = any ]} ``` The following example defines a type that classifies a list of numbers: -``` +```powerquery-m type { number } ``` Similarly, the following example defines a custom type that classifies records with mandatory fields named `X` and `Y` whose values are numbers: -``` +```powerquery-m type [ X = number, Y = number ] ``` The ascribed type of a value is obtained using the standard library function [Value.Type](value-type.md), as shown in the following examples: -``` +```powerquery-m Value.Type( 2 ) // type number Value.Type( {2} ) // type list Value.Type( [ X = 1, Y = 2 ] ) // type record @@ -85,7 +81,7 @@ Value.Type( [ X = 1, Y = 2 ] ) // type record The `is` operator is used to determine whether a value's type is compatible with a given type, as shown in the following examples: -``` +```powerquery-m 1 is number // true 1 is text // false {2} is list // true @@ -93,17 +89,17 @@ The `is` operator is used to determine whether a value's type is compatible with The `as` operator checks if the value is compatible with the given type, and raises an error if it is not. Otherwise, it returns the original value. -``` +```powerquery-m Value.Type( 1 as number ) // type number {2} as text // error, type mismatch ``` -Note that the `is` and `as` operators only accept primitive types as their right operand. M does not provide means to check values for conformance to custom types. +Note that the `is` and `as` operators only accept a _primitive or nullable primitive type_ (i.e. a _non-custom type_) as their right operand. M does not provide means to check values for conformance to custom types. A type `X` is _compatible_ with a type `Y` if and only if all values that conform to `X` also conform to `Y`. All types are compatible with type `any` and no types (but `none` itself) are compatible with type `none`. The following graph shows the compatibility relation. (Type compatibility is reflexive and transitive. It forms a lattice with type `any` as the top and type `none` as the bottom value.) The names of abstract types are set in _italics_. ![Type compatibility](media/m-spec-type-compatibility.png) - + The following operators are defined for type values: | Operator | Result | @@ -111,7 +107,6 @@ The following operators are defined for type values: | `x = y` | Equal | | `x <> y` | Not equal | | `x ?? y` | Coalesce | -| | | The native type of type values is the intrinsic type `type`. @@ -119,7 +114,7 @@ The native type of type values is the intrinsic type `type`. Types in the M language form a disjoint hierarchy rooted at type `any`, which is the type that classifies all values. Any M value conforms to exactly one primitive subtype of `any`. The closed set of primitive types deriving from type `any` are as follows: -* `type null`, which classifies the null value. +* `type null`, which classifies the null value. * `type logical`, which classifies the values true and false. * `type number`, which classifies number values. * `type time`, which classifies time values. @@ -134,7 +129,8 @@ Types in the M language form a disjoint hierarchy rooted at type `any`, which is * `type record`, which classifies record values. * `type table`, which classifies table values. * `type function`, which classifies function values. -* `type anynonnull`, which classifies all values excluding null. The intrinsic type `none` classifies no values. +* `type anynonnull`, which classifies all values excluding null. +* `type none`, which classifies no values. ## Any Type @@ -153,7 +149,7 @@ The result of evaluating a _list-type_ is a _list type value_ whose base type is The following examples illustrate the syntax for declaring homogeneous list types: -``` +```powerquery-m type { number } // list of numbers type { record } // list of records type {{ text }} // list of lists of text values @@ -167,7 +163,7 @@ The item type of a list type indicates a bound: all items of a conforming list c Any value that is a record conforms to the intrinsic type record, which does not place any restrictions on the field names or values within a record value. A _record-type value_ is used to restrict the set of valid names as well as the types of values that are permitted to be associated with those names. -_record-type:_
+_record-type:_
      `[` _open-record-marker_ `]`
      `[` _field-specification-listopt_ `]`
      `[` _field-specification-list , open-record-marker_ `]`
@@ -187,7 +183,7 @@ The result of evaluating a _record-type_ is a type value whose base type is `rec The following examples illustrate the syntax for declaring record types: -``` +```powerquery-m type [ X = number, Y = number] type [ Name = text, Age = number ] type [ Title = text, optional Description = text ] @@ -196,7 +192,7 @@ type [ Name = text, ... ] Record types are _closed_ by default, meaning that additional fields not present in the _fieldspecification-list_ are not allowed to be present in conforming values. Including the _openrecord-marker_ in the record type declares the type to be _open_, which permits fields not present in the field specification list. The following two expressions are equivalent: -``` +```powerquery-m type record // primitive type classifying all records type [ ... ] // custom type classifying all records ``` @@ -213,34 +209,34 @@ A conforming value may contain field names not listed in the field specification Any function value conforms to the primitive type `function`, which does not place any restrictions on the types of the function's formal parameters or the function's return value. A custom _function-type value_ is used to place type restrictions on the signatures of conformant function values. -_function-type:_
-      `function (` _parameter-specification-listopt_ `)` _function-return-type
+function-type:_
+      `function (` _parameter-specification-listopt_ `)` _return-type
parameter-specification-list:
      required-parameter-specification-list
      required-parameter-specification-list_ `,` _optional-parameter-specification-list
      optional-parameter-specification-list
required-parameter-specification-list:
      required-parameter-specification
-      required-parameter-specification_ `,` _required-parameter-specification-list
+      required-parameter-specification_ `,` _required-parameter-specification-list
required-parameter-specification:
      parameter-specification
optional-parameter-specification-list:
      optional-parameter-specification
-      optional-parameter-specification_ `,` _optional-parameter-specification-list
+      optional-parameter-specification_ `,` _optional-parameter-specification-list
optional-parameter-specification:_
-      `optional` _parameter-specification
+      `optional` _parameter-specification
parameter-specification:
-      parameter-name parameter-type
-function-return-type:
-      assertion
-assertion:_
-      `as` _nullable-primitive-type_ +      parameter-name parameter-type
+parameter-type:
+      type-assertion
+type-assertion:_
+      `as` _type_ The result of evaluating a _function-type_ is a type value whose base type is `function`. The following examples illustrate the syntax for declaring function types: -``` +```powerquery-m type function (x as text) as number type function (y as number, optional z as text) as any ``` @@ -249,6 +245,13 @@ A function value conforms to a function type if the return type of the function Formal parameter names are ignored for the purposes of determining function type conformance. +Specifying a parameter as optional implicitly makes its type nullable. The following create identical function types: + +```powerquery-m +type function (optional x as text) as any +type function (optional x as nullable text) as any +``` + ## Table types A _table-type value_ is used to define the structure of a table value. @@ -256,13 +259,13 @@ A _table-type value_ is used to define the structure of a table value. _table-type:_
      `table` _row-type
row-type:_
-      `[` _field-specification-list_ `]` +      `[` _field-specification-listopt_ `]` The result of evaluating a _table-type_ is a type value whose base type is `table`. The _row type_ of a table specifies the column names and column types of the table as a closed record type. So that all table values conform to the type `table`, its row type is type `record` (the empty open record type). Thus, type table is abstract since no table value can have type `table`'s row type (but all table values have a row type that is compatible with type `table`'s row type). The following example shows the construction of a table type: -``` +```powerquery-m type table [A = text, B = number, C = binary] // a table type with three columns named A, B, and C // of column types text, number, and binary, respectively @@ -270,10 +273,9 @@ type table [A = text, B = number, C = binary] A table-type value also carries the definition of a table value's _keys_. A key is a set of column names. At most one key can be designated as the table's _primary key_. (Within M, table keys have no semantic meaning. However, it is common for external data sources, such as databases or OData feeds, to define keys over tables. Power Query uses key information to improve performance of advanced functionality, such as cross-source join operations.) -The standard library functions `Type.TableKeys`, `Type.AddTableKey`, and -`Type.ReplaceTableKeys` can be used to obtain the keys of a table type, add a key to a table type, and replace all keys of a table type, respectively. +The standard library functions `Type.TableKeys`, `Type.AddTableKey`, and `Type.ReplaceTableKeys` can be used to obtain the keys of a table type, add a key to a table type, and replace all keys of a table type, respectively. -``` +```powerquery-m Type.AddTableKey(tableType, {"A", "B"}, false) // add a non-primary key that combines values from columns A and B Type.ReplaceTableKeys(tableType, {}) @@ -289,14 +291,14 @@ _nullable-type:_
The result is an abstract type that allows values of type _T_ or the value `null`. -``` +```powerquery-m 42 is nullable number // true null is nullable number // true ``` Ascription of `type nullable` _T_ reduces to ascription of `type null` or `type` _T_. (Recall that nullable types are abstract and no value can be directly of abstract type.) -``` +```powerquery-m Value.Type(42 as nullable number) // type number Value.Type(null as nullable number) // type null ``` @@ -310,8 +312,7 @@ The following hold (for any type T): The following are pairwise equivalent (for any type T): - -    `type nullable any`
+    `type nullable any`
    `any`
    `Type.NonNullable(type any)`
@@ -319,45 +320,52 @@ The following are pairwise equivalent (for any type T):     `type nullable none`
    `type null`
- +     `Type.NonNullable(type null)`
    `type none`
    type nullable nullable T
    type nullable T
- -    Type.NonNullable(Type.NonNullable(type T))
+ +    Type.NonNullable(Type.NonNullable(type T))
    Type.NonNullable(type T)
- -    Type.NonNullable(type nullable T)
+ +    Type.NonNullable(type nullable T)
    Type.NonNullable(type T)
    type nullable (Type.NonNullable(type T))
    type nullable T - ## Ascribed type of a value -A value's _ascribed type_ is the type to which a value is _declared_ to conform. When a value is ascribed a type, only a limited conformance check occurs. _M does not perform conformance checking beyond a nullable primitive type. M program authors that choose to ascribe values with type definitions more complex than a nullable primitive-type must ensure that such values conform to these types._ +A value's _ascribed type_ is the type to which a value is _declared_ to conform. -A value may be ascribed a type using the library function `Value.ReplaceType`. The function either returns a new value with the type ascribed or raises an error if the new type is incompatible with the value's native primitive type. In particular, the function raises an error when an attempt is made to ascribe an abstract type, such as `any`. +A value may be ascribed a type using the library function `Value.ReplaceType`. This function either returns a new value with the type ascribed or raises an error if the new type is incompatible with the value. + +When a value is ascribed a type, only a limited conformance check occurs: +* The type being ascribed must be non-abstract, non-nullable, and compatible with the value's intrinsic (native) _primitive-type_. +* When a custom type that defines structure is ascribed, it must match the structure of the value. + * For records: The type must be closed, must define the same number of fields as the value, and must not contain any optional fields. (The type's field names and field types will replace those currently associated with the record. However, existing field values will not be checked against the new field types.) + * For tables: The type must define the same number of columns as the value. (The type's column names and column types will replace those currently associated with the table. However, existing column values will not be checked against the new column types.) + * For functions: The type must define the same number of required parameters, as well as the same number of optional parameters, as the value. (The type's parameter and return assertions, as well as its parameter names, will replace those associated with the function value's current type. However, the new assertions will have no effect on the actual behavior of the function.) + * For lists: The value must be a list. (However, existing list items will not be checked against the new item type.) Library functions may choose to compute and ascribe complex types to results based on the ascribed types of the input values. The ascribed type of a value may be obtained using the library function `Value.Type`. For example: -``` +```powerquery-m Value.Type( Value.ReplaceType( {1}, type {number} ) // type {number} ``` ## Type equivalence and compatibility -Type equivalence is not defined in M. Any two type values that are compared for equality may or may not return `true`. However, the relation between those two types (whether `true` or `false`) will always be the same. +Type equivalence is not defined in M. An M implementation may optionally choose to use its own rules to perform equality comparisons between type values. Comparing two type values for equality should evaluate to `true` if they are considered identical by the implementation, and `false` otherwise. In either case, the response returned must be consistent if the same two values are repeatedly compared. Note that within a given implementation, comparing some identical type values (such as `(type text) = (type text)`) may return `true`, while comparing others (such as `(type [a = text]) = (type [a = text])`) may not. -Compatibility between a given type and a nullable primitive type can be determined using the library function `Type.Is`, which accepts an arbitrary type value as its first and a nullable primitive type value as its second argument: +Compatibility between a given type and either a primitive type or a nullable primitive type can be determined using the library function `Type.Is`, which accepts an arbitrary type value as its first argument and a primitive or nullable primitive type value as its second argument: -``` +```powerquery-m Type.Is(type text, type nullable text) // true Type.Is(type nullable text, type text) // false Type.Is(type number, type text) // false @@ -369,7 +377,7 @@ There is no support in M for determining compatibility of a given type with a cu The standard library does include a collection of functions to extract the defining characteristics from a custom type, so specific compatibility tests can be implemented as M expressions. Below are some examples; consult the M library specification for full details. -``` +```powerquery-m Type.ListItem( type {number} ) // type number Type.NonNullable( type nullable text ) @@ -390,3 +398,7 @@ Type.FunctionReturn( // type number ``` +## Related content + +* [Types and type conversion](type-conversion.md) +* [Types in the Power Query M formula language](power-query-m-type-system.md) diff --git a/query-languages/m/m-spec-values.md b/query-languages/m/m-spec-values.md index 9b18cc325..88ea9ad36 100644 --- a/query-languages/m/m-spec-values.md +++ b/query-languages/m/m-spec-values.md @@ -1,13 +1,10 @@ --- -title: M Language values | Microsoft Docs +title: M Language values description: Describes using values in the Power Query M formula language -author: dougklopfenstein - -ms.service: powerquery - -ms.topic: article -ms.date: 11/29/2021 -ms.author: dougklo +ms.topic: conceptual +ms.date: 8/21/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- # Values @@ -31,14 +28,13 @@ A value is data produced by evaluating an expression. This section describes the | _Table_ | `#table({"X","Y"},{{0,1},{1,0}})` | | _Function_ | `(x) => x + 1` | | _Type_ | `type { number }`    `type table [ A = any, B = text ]` | -| | | - + The following sections cover each value kind in detail. Types and type ascription are defined formally in [Types](m-spec-types.md). Function values are defined in [Functions](m-spec-functions.md). The following sections list the operators defined for each value kind and give examples. The full definition of operator semantics follows in [Operators](m-spec-operators.md). ## Null A _null value_ is used to represent the absence of a value, or a value of indeterminate or unknown state. A null value is written using the literal `null`. The following operators are defined for null values: - + | Operator | Result | | -------- | ------ | | `x > y` | Greater than | @@ -48,8 +44,7 @@ A _null value_ is used to represent the absence of a value, or a value of indete | `x = y` | Equal | | `x <> y` | Not equal | | `x ?? y` | Coalesce | -| | | - + The native type of the `null` value is the intrinsic type `null`. ## Logical @@ -68,15 +63,14 @@ A _logical value_ is used for Boolean operations has the value true or false. A | `x ?? y` | Coalesce | | `x and y` | Conditional logical AND | | `not x` | Logical NOT | -| | | - + The native type of both logical values (`true` and `false`) is the intrinsic type `logical`. ## Number A _number value_ is used for numeric and arithmetic operations. The following are examples of number literals: -``` +```powerquery-m 3.14 // Fractional number -1.5 // Fractional number 1.0e3 // Fractional number with exponent @@ -122,7 +116,6 @@ The following operators are defined for number values: | `x ?? y` | Coalesce | | `+x` | Unary plus | | `-x` | Negation | -| | | The native type of number values is the intrinsic type `number`. @@ -130,9 +123,9 @@ The native type of number values is the intrinsic type `number`. A _time value_ stores an opaque representation of time of day. A time is encoded as the number of _ticks since midnight_, which counts the number of 100-nanosecond ticks that have elapsed on a 24-hour clock. The maximum number of _ticks since midnight_ corresponds to 23:59:59.9999999 hours. -Time values may be constructed using the #time instrinsic. +Although there is no literal syntax for times, several standard library functions are provided to construct them. Times may also be constructed using the intrinsic function `#time`: -``` +```powerquery-m #time(hour, minute, second) ``` @@ -155,7 +148,6 @@ The following operators are defined for time values: | `x < y` | Less than | | `x <= y` | Less than or equal | | `x ?? y` | Coalesce | -| | | The following operators permit one or both of their operands to be a date: @@ -166,17 +158,16 @@ The following operators permit one or both of their operands to be a date: | `x - y` | `time` | `duration` | Date offset by negated duration | | `x - y` | `time` | `time` | Duration between dates | | `x & y` | `date` | `time` | Merged datetime | -| | | | | - + The native type of time values is the intrinsic type `time`. ## Date A _date value_ stores an opaque representation of a specific day. A date is encoded as a number of _days since epoch_, starting from January 1, 0001 Common Era on the Gregorian calendar. The maximum number of days since epoch is 3652058, corresponding to December 31, 9999. -Date values may be constructed using the `#date` intrinsic. +Although there is no literal syntax for dates, several standard library functions are provided to construct them. Dates may also be constructed using the intrinsic function `#date`: -``` +```powerquery-m #date(year, month, day) ``` @@ -199,7 +190,6 @@ The following operators are defined for date values: | `x < y` | Less than | | `x <= y` | Less than or equal | | `x ?? y` | Coalesce | -| | | The following operators permit one or both of their operands to be a date: @@ -210,16 +200,16 @@ The following operators permit one or both of their operands to be a date: | `x - y` | `date` | `duration` | Date offset by negated duration | | `x - y` | `date` | `date` | Duration between dates | | `x & y` | `date` | `time` | Merged datetime | -| | | | | The native type of date values is the intrinsic type `date`. ## DateTime + A _datetime value_ contains both a date and time. -DateTime values may be constructed using the `#datetime` intrinsic. +Although there is no literal syntax for datetimes, several standard library functions are provided to construct them. Datetimes may also be constructed using the intrinsic function `#datetime`: -``` +```powerquery-m #datetime(year, month, day, hour, minute, second) ``` @@ -244,17 +234,15 @@ The following operators are defined for datetime values: | `x < y` | Less than | | `x <= y` | Less than or equal | | `x ?? y` | Coalesce | -| | | - + The following operators permit one or both of their operands to be a datetime: - + | Operator | Left Operand | Right Operand | Meaning | | -------- | ------------ | ------------- | ------- | | `x + y` | `datetime` | `duration` | Datetime offset by duration | | `x + y` | `duration` | `datetime` | Datetime offset by duration | | `x - y` | `datetime` | `duration` | Datetime offset by negated duration | | `x - y` | `datetime` | `datetime` | Duration between datetimes | -| | | | | The native type of datetime values is the intrinsic type `datetime`. @@ -262,9 +250,9 @@ The native type of datetime values is the intrinsic type `datetime`. A _datetimezone_ value contains a datetime and a timezone. A _timezone_ is encoded as a number of _minutes offset from UTC_, which counts the number of minutes the time portion of the _datetime_ should be offset from Universal Coordinated Time (UTC). The minimum number of _minutes offset from UTC_ is -840, representing a UTC offset of -14:00, or fourteen hours earlier than UTC. The maximum number of _minutes offset from UTC_ is 840, corresponding to a UTC offset of 14:00. -DateTimeZone values may be constructed using the `#datetimezone` intrinsic. +Although there is no literal syntax for datetimezones, several standard library functions are provided to construct them. Datetimezones may also be constructed using the intrinsic function `#datetimezone`: -``` +```powerquery-m #datetimezone( year, month, day, hour, minute, second, @@ -295,28 +283,25 @@ The following operators are defined for datetimezone values: | `x < y` | Less than | | `x <= y` | Less than or equal | | `x ?? y` | Coalesce | -| | | - + The following operators permit one or both of their operands to be a datetimezone: - + | Operator | Left Operand | Right Operand | Meaning | | -------- | ------------ | ------------- | ------- | | `x + y` | `datetimezone` | `duration` | Datetimezone offset by duration | | `x + y` | `duration` | `datetimezone` | Datetimezone offset by duration | | `x - y` | `datetimezone` | `duration` | Datetimezone offset by negated duration | | `x - y` | `datetimezone` | `datetimezone` | Duration between datetimezones | -| | | | | The native type of datetimezone values is the intrinsic type `datetimezone`. ## Duration -A _duration value_ stores an opaque representation of the distance between two points on a timeline measured 100-nanosecond ticks. The magnitude of a _duration_ can be either positive or negative, with positive values denoting progress forwards in time and negative values denoting progress backwards in time. The minimum value that can be stored in a _duration_ is -9,223,372,036,854,775,808 ticks, or 10,675,199 days 2 hours 48 minutes 05.4775808 seconds backwards in time. The maximum value that can be stored in a _duration_ is 9,223,372,036,854,775,807 ticks, or 10,675,199 days 2 hours 48 minutes -05.4775807 seconds forwards in time. +A _duration value_ stores an opaque representation of the distance between two points on a timeline measured 100-nanosecond ticks. The magnitude of a _duration_ can be either positive or negative, with positive values denoting progress forwards in time and negative values denoting progress backwards in time. The minimum value that can be stored in a _duration_ is -9,223,372,036,854,775,808 ticks, or 10,675,199 days 2 hours 48 minutes 05.4775808 seconds backwards in time. The maximum value that can be stored in a _duration_ is 9,223,372,036,854,775,807 ticks, or 10,675,199 days 2 hours 48 minutes 05.4775807 seconds forwards in time. -Duration values may be constructed using the `#duration` intrinsic function: +Although there is no literal syntax for durations, several standard library functions are provided to construct them. Durations may also be constructed using the intrinsic function `#duration`: -``` +```powerquery-m #duration(0, 0, 0, 5.5) // 5.5 seconds #duration(0, 0, 0, -5.5) // -5.5 seconds #duration(0, 0, 5, 30) // 5.5 minutes @@ -336,7 +321,6 @@ The following operators are defined on duration values: | `x < y` | Less than | | `x <= y` | Less than or equal | | `x ?? y` | Coalesce | -| | | Additionally, the following operators allow one or both of their operands to be a duration value: @@ -351,7 +335,7 @@ Additionally, the following operators allow one or both of their operands to be | `x * y` | `duration` | `number` | N times a duration | | `x * y` | `number` | `duration` | N times a duration | | `x / y` | `duration` | `number` | Fraction of a duration | -| | | | | +| `x / y` | `duration` | `duration` | Numeric quotient of durations | The native type of duration values is the intrinsic type `duration`. @@ -374,11 +358,11 @@ _double-quote-escape-sequence:_
The following is an example of a _text_ value: -``` +```powerquery-m "ABC" // the text value ABC ``` -The following operators are defined on _text_ values: +The following operators are defined on _text_ values: | Operator | Result | | -------- | ------ | @@ -390,20 +374,23 @@ The following operators are defined on _text_ values: | `x <= y` | Less than or equal | | `x & y` | Concatenation | | `x ?? y` | Coalesce | -| | | The native type of text values is the intrinsic type `text`. ## Binary -A _binary value_ represents a sequence of bytes. There is no literal format. Several standard library functions are provided to construct binary values. For example, `#binary` can be used to construct a binary value from a list of bytes: +A _binary value_ represents a sequence of bytes. -``` +Although there is no literal syntax for binary values, several standard library functions are provided to construct them. Binary values may also be constructed using the intrinsic function `#binary`. + +The following example constructs a binary value from a list of bytes: + +```powerquery-m #binary( {0x00, 0x01, 0x02, 0x03} ) ``` The following operators are defined on _binary_ values: - + | Operator | Result | | -------- | ------ | | `x = y` | Equal | @@ -413,7 +400,6 @@ The following operators are defined on _binary_ values: | `x < y` | Less than | | `x <= y` | Less than or equal | | `x ?? y` | Coalesce | -| | | The native type of binary values is the intrinsic type _binary_. @@ -421,7 +407,7 @@ The native type of binary values is the intrinsic type _binary_. A _list value_ is a value which produces a sequence of values when enumerated. A value produced by a list can contain any kind of value, including a list. Lists can be constructed using the initialization syntax, as follows: -_list-expression:_
+_list-expression:_
      { _item-listopt_ }
_item-list:
      item
@@ -432,7 +418,7 @@ item:
The following is an example of a _list-expression_ that defines a list with three text values: `"A"`, `"B"`, and `"C"`. -``` +```powerquery-m {"A", "B", "C"} ``` @@ -443,13 +429,13 @@ The value `"A"` is the first item in the list, and the value `"C"` is the last i To include a sequence of whole number in a list, the `a..b` form can be used: -``` +```powerquery-m { 1, 5..9, 11 } // { 1, 5, 6, 7, 8, 9, 11 } ``` The number of items in a list, known as the _list count_, can be determined using the `List.Count` function. -``` +```powerquery-m List.Count({true, false}) // 2 List.Count({}) // 0 ``` @@ -458,7 +444,7 @@ A list may effectively have an infinite number of items; `List.Count` for such l If a list contains no items, it is called an _empty list_. An empty list is written as: -``` +```powerquery-m {} // empty list ``` @@ -470,11 +456,10 @@ The following operators are defined for lists: | `x <> y` | Not equal | | `x & y` | Concatenate | | `x ?? y` | Coalesce | -| | | For example: -``` +```powerquery-m {1, 2} & {3, 4, 5} // {1, 2, 3, 4, 5} {1, 2} = {1, 2} // true {2, 1} <> {1, 2} // true @@ -498,13 +483,13 @@ field-name:
The following example constructs a record with a field named `x` with value `1`, and a field named `y` with value `2`. -``` +```powerquery-m [ x = 1, y = 2 ] ``` The following example constructs a record with `a` field named a with a nested record value. The nested record has a field named `b` with value `2`. -``` +```powerquery-m [ a = [ b = 2 ] ] ``` @@ -528,13 +513,13 @@ The following holds when evaluating a record expression: * Every field name that is specified must be unique within the record, or it is an error. Names are compared using an ordinal comparison. -``` +```powerquery-m [ x = 1, x = 2 ] // error: field names must be unique [ X = 1, x = 2 ] // OK ``` A record with no fields is called an _empty record_, and is written as follows: -``` +```powerquery-m [] // empty record ``` @@ -542,27 +527,27 @@ Although the order of the fields of a record is not significant when accessing a The same two records produce different results when the fields are obtained: -``` +```powerquery-m Record.FieldNames([ x = 1, y = 2 ]) // [ "x", "y" ] Record.FieldNames([ y = 1, x = 2 ]) // [ "y", "x" ] ``` The number of fields in a record can be determined using the `Record.FieldCount` function. For example: -``` -Record.FieldCount([ x = 1, y = 2 }) // 2 +```powerquery-m +Record.FieldCount([ x = 1, y = 2 ]) // 2 Record.FieldCount([]) // 0 ``` In addition to using the record initialization syntax `[ ]`, records can be constructed from a list of values, and a list of field names or a record type. For example: -``` +```powerquery-m Record.FromList({1, 2}, {"a", "b"}) ``` The above is equivalent to: -``` +```powerquery-m [ a = 1, b = 2 ] ``` @@ -574,11 +559,10 @@ The following operators are defined for record values: | `x <> y` | Not equal | | `x & y` | Merge | | `x ?? y` | Coalesce | -| | | The following examples illustrate the above operators. Note that record merge uses the fields from the right operand to override fields from the left operand, should there be an overlap in field names. -``` +```powerquery-m [ a = 1, b = 2 ] & [ c = 3 ] // [ a = 1, b = 2, c = 3 ] [ a = 1, b = 2 ] & [ a = 3 ] // [ a = 3, b = 2 ] [ a = 1, b = 2 ] = [ b = 2, a = 1 ] // true @@ -589,19 +573,19 @@ The native type of record values is the intrinsic type `record`, which specifies ## Table -A _table value_ is an ordered sequence of rows. A _row_ is an ordered sequence of value. The table's type determines the length of all rows in the table, the names of the table's columns, the types of the table's columns, and the structure of the table's keys (if any). +A _table value_ is an ordered sequence of rows. A _row_ is an ordered sequence of column values. The table's type determines the length of all rows in the table, the names of the table's columns, the types of the table's columns, and the structure of the table's keys (if any). -There is no literal syntax for tables. Several standard library functions are provided to construct binary values. For example, `#table` can be used to construct a table from a list of row lists and a list of header names: +Although there is no literal syntax for tables, several standard library functions are provided to construct them. Tables may also be constructed using the intrinsic function `#table`. -``` +The following example constructs a table from a list of column names and a list of rows. The resulting table will contain two columns of `type any` and three rows. + +```powerquery-m #table({"x", "x^2"}, {{1,1}, {2,4}, {3,9}}) ``` -The above example constructs a table with two columns, both of which are of `type any`. - `#table` can also be used to specify a full table type: -``` +```powerquery-m #table( type table [Digit = number, Name = text], {{1,"one"}, {2,"two"}, {3,"three"}} @@ -618,11 +602,10 @@ The following operators are defined for table values: | `x <> y` | Not equal | | `x & y` | Concatenation | | `x ?? y` | Coalesce | -| | | Table concatenation aligns like-named columns and fills in `null` for columns appearing in only one of the operand tables. The following example illustrates table concatenation: -``` +```powerquery-m #table({"A","B"}, {{1,2}}) & #table({"B","C"}, {{3,4}}) ``` @@ -631,13 +614,13 @@ Table concatenation aligns like-named columns and fills in `null` for columns ap | --- | --- | ---| | `1` | `2` | `null` | | `null` | `3` | `4` | -| | | -The native type of table values is a custom table type (derived from the intrinsic type `table`) that lists the column names, specifies all column types to be any, and has no keys. (See [Table types](m-spec-types.md#table-types) for details on table types.) +The native type of table values is a custom table type (derived from the intrinsic type `table`) that lists the column names, specifies all column types to be any, and has no keys. (Go to [Table types](m-spec-types.md#table-types) for details on table types.) ## Function A _function value_ is a value that maps a set of arguments to a single value. The details of _function_ values are described in [Functions](m-spec-functions.md). ## Type + A _type value_ is a value that classifies other values. The details of _type_ values are described in [Types](m-spec-types.md). diff --git a/query-languages/m/m-working-with-case.md b/query-languages/m/m-working-with-case.md new file mode 100644 index 000000000..48d03d0a1 --- /dev/null +++ b/query-languages/m/m-working-with-case.md @@ -0,0 +1,484 @@ +--- +description: "Learn more about: Capitalization in Power Query M" +title: "Capitalization of text in Power Query M" +ms.date: 5/30/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-background +--- + +# Capitalization in Power Query M + +Working with text data can sometimes be messy. For example, the name of the city Redmond might be represented in a database using different casings ("Redmond", "redmond", and "REDMOND"). This could cause a problem when transforming the data in Power Query because the Power Query M formula language is case sensitive. + +Thankfully, Power Query M provides functions to clean and normalize the case of text data. There are functions to convert text to lower case (abc), upper case (ABC), or proper case (Abc). In addition, Power Query M also provides several ways to ignore case altogether. + +This article shows you how to change the capitalization of words in text, lists, and tables. It also describes various ways to ignore case while manipulating data in text, lists, and tables. In addition, this article discusses how to sort according to case. + +## Changing case in text + +There are three functions that convert text to lower case, upper case, and proper case. The functions are [Text.Lower](text-lower.md), [Text.Upper](text-upper.md), and [Text.Proper](text-proper.md). The following simple examples demonstrate how these functions can be used in text. + +### Convert all characters in text to lower case + +The following example demonstrates how to convert all characters in a string to lower case. + +```powerquery-m +let + Source = Text.Lower("The quick brown fox jumps over the lazy dog.") +in + Source +``` + +This code produces the following output: + +`the quick brown fox jumps over the lazy dog.` + +### Convert all characters in text to upper case + +The following example demonstrates how to convert all characters in a text string to upper case. + +```powerquery-m +let + Source = Text.Upper("The quick brown fox jumps over the lazy dog.") +in + Source +``` + +This code produces the following output: + +`THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.` + +### Convert all words to initial caps + +The following example demonstrates how to convert all words in the sentence to initial capitalization. + +```powerquery-m +let + Source = Text.Proper("The quick brown fox jumps over the lazy dog.") +in + Source +``` + +This code produces the following output: + +`The Quick Brown Fox Jumps Over The Lazy Dog.` + +## Changing case in lists + +When changing case in lists, the most common function to use is [List.Transform](list-transform.md). The following simple examples demonstrate how this function can be used in lists. + +### Convert all items to lower case + +The following example shows how to change all items in a list to lower case. + +```powerquery-m +let + Source = {"Squash", "Pumpkin", "ApPlE", "pear", "orange", "APPLE", "Pear", "pear"}, + #"Lower Case" = List.Transform(Source, Text.Lower) +in + #"Lower Case" +``` + +This code produces the following output: + +:::image type="content" source="media/list-lower-case.png" alt-text="Screenshot of the list created by the list transform function that produces lower case results."::: + +### Convert all items to upper case + +The following example demonstrates how to change all items in a list to upper case. + +```powerquery-m +let + Source = {"Squash", "Pumpkin", "ApPlE", "pear", "orange", "APPLE", "Pear", "pear"}, + #"Upper Case" = List.Transform(Source, Text.Upper) +in + #"Upper Case" +``` + +This code produces the following output: + +:::image type="content" source="media/list-upper-case.png" alt-text="Screenshot of the list created by the list transform function that produces upper case results."::: + +### Convert all items to proper case + +The following exmaple demonstrates how to change all items in a list to proper case. + +```powerquery-m +let + Source = {"Squash", "Pumpkin", "ApPlE", "pear", "orange", "APPLE", "Pear", "pear"}, + #"Proper Case" = List.Transform(Source, Text.Proper) +in + #"Proper Case" +``` + +This code produces the following output: + +:::image type="content" source="media/list-proper-case.png" alt-text="Screenshot of the list created by the list transform function that produces proper case results."::: + +## Changing case in tables + +When changing case in tables, the most common function to use is [Table.TransformColumns](table-transformcolumns.md). There's also a function you can use to change the case of text that's contained in a row, called [Table.TransformRows](table-transformrows.md). However, this function isn't used as often. + +The following simple examples demonstrate how the `Table.TransformColumns` function can be used to change the case in tables. + +### Convert all items in a table column to lower case + +The following example demonstrates how to change all items in a table column to lower case, in this case, the customer names. + +```powerquery-m +let + Source = #table(type table [CUSTOMER = text, FRUIT = text], + { + {"Tulga", "Squash"}, + {"suSanna", "Pumpkin"}, + {"LESLIE", "ApPlE"}, + {"Willis", "pear"}, + {"Dilbar", "orange"}, + {"ClaudiA", "APPLE"}, + {"afonso", "Pear"}, + {"SErgio", "pear"} + }), + #"Lower Case" = Table.TransformColumns(Source, {"CUSTOMER", Text.Lower}) +in + #"Lower Case" +``` + +This code produces the following output: + +:::image type="content" source="media/table-lower-case.png" alt-text="Screenshot of the table created by the table transform columns function that produces lower case results."::: + +### Convert all items in a table column to upper case + +The following example demonstrates how to change all items in a table column to upper case, in this case, the fruit names. + +```powerquery-m +let + Source = #table(type table [CUSTOMER = text, FRUIT = text], + { + {"Tulga", "Squash"}, + {"suSanna", "Pumpkin"}, + {"LESLIE", "ApPlE"}, + {"Willis", "pear"}, + {"Dilbar", "orange"}, + {"ClaudiA", "APPLE"}, + {"afonso", "Pear"}, + {"SErgio", "pear"} + }), + #"Upper Case" = Table.TransformColumns(Source, {"FRUIT", Text.Upper}) +in + #"Upper Case" +``` + +This code produces the following output: + +:::image type="content" source="media/table-upper-case.png" alt-text="Screenshot of the table created by the table transform columns function that produces upper case results."::: + +### Convert all items in a table to proper case + +The following example demonstrates how to change all items in both of the table columns to proper case. + +```powerquery-m +let + Source = #table(type table [CUSTOMER = text, FRUIT = text], + { + {"Tulga", "Squash"}, + {"suSanna", "Pumpkin"}, + {"LESLIE", "ApPlE"}, + {"Willis", "pear"}, + {"Dilbar", "orange"}, + {"ClaudiA", "APPLE"}, + {"afonso", "Pear"}, + {"SErgio", "pear"} + }), + #"Customer Case" = Table.TransformColumns(Source, {"CUSTOMER", Text.Proper}), + #"Proper Case" = Table.TransformColumns(#"Customer Case", {"FRUIT", Text.Proper}) +in + #"Proper Case" +``` + +This code produces the following output: + +:::image type="content" source="media/table-proper-case.png" alt-text="Screenshot of the table created by the table transform columns function that produces proper case results in both columns."::: + +## Ignoring case + +In many cases when searching or replacing items, you might need to ignore the case of the item you're looking for. Because the Power Query M formula language is case sensitive, comparisons between items that are identical but have different cases results in identifying the items as being different, not identical. One method of ignoring case involves using the [Comparer.OrdinalIgnoreCase](comparer-ordinalignorecase.md) function in functions that include either an `equationCriteria` parameter or a `comparer` parameter. Another method of ignoring case involves using the `IgnoreCase` option (if available) in functions that include an `options` parameter. + +### Ignoring case in text + +Searches in text sometimes require that you ignore case to be able to find all the instances of the searched for text.Text functions generally use the `Comparer.OrdinalIgnoreCase` function in the `comparer` parameter to ignore case when testing for equality. + +The following example shows how to ignore case when determining if a sentence contains a specific word, regardless of case. + +```powerquery-m +let + Source = Text.Contains( + "The rain in spain falls mainly on the plain.", + "Spain", + Comparer.OrdinalIgnoreCase + ) +in + Source +``` + +This code produces the following output: + +`true` + +The following example shows how to retrieve the initial position of the last occurrence of the word "the" in the sentence, regardless of case. + +```powerquery-m +let + Source = Text.PositionOf( + "THE RAIN IN SPAIN FALLS MAINLY ON THE PLAIN.", + "the", + Occurrence.Last, + Comparer.OrdinalIgnoreCase + ) +in + Source +``` + +This code produces the following output: + +`34` + +### Ignoring case in lists + +Any list function that contains an optional `equationCriteria` parameter can use the [Comparer.OrdinalIgnoreCase](comparer-ordinalignorecase.md) function to ignore case in the list. + +The following example checks whether a list contains a specific item, while ignoring case. In this example, [List.Contains](list-contains.md) can only compare one item in the list, you can't compare a list to a list. For that, you need to use [List.ContainsAny](list-containsany.md). + +```powerquery-m +let + Source = List.Contains( + {"Squash", "Pumpkin", "ApPlE", "pear", "orange", "APPLE", "Pear", "pear"}, + "apple", + Comparer.OrdinalIgnoreCase + ) +in + Source +``` + +This code produces the following output: + + `true` + +The following examples check whether a list contains all the specified items in the second parameter (`value`), while ignoring case. If any one item isn't contained in the list, such as `cucumber` in the second example, the function returns FALSE. + +```powerquery-m +let + Source = List.ContainsAll( + {"Squash", "Pumpkin", "ApPlE", "pear", "orange", "APPLE", "Pear", "pear"}, + {"apple", "pear", "squash", "pumpkin"}, + Comparer.OrdinalIgnoreCase + ) +in + Source +``` + +This code produces the following output: + + `true` + +```powerquery-m +let + Source = List.ContainsAll( + {"Squash", "Pumpkin", "ApPlE", "pear", "orange", "APPLE", "Pear", "pear"}, + {"apple", "pear", "squash", "pumpkin", "cucumber"}, + Comparer.OrdinalIgnoreCase + ) +in + Source +``` + +This code produces the following output: + + `false` + +The following example checks whether any of the items in the list are apples or pears, while ignoring case. + +```powerquery-m +let + Source = List.ContainsAny( + {"Squash", "Pumpkin", "ApPlE", "PEAR", "orange", "APPLE", "Pear", "peaR"}, + {"apple","pear"}, + Comparer.OrdinalIgnoreCase + ) +in + Source +``` + +This code produces the following output: + + `true` + +The following example keeps only unique items, while ignoring case. + +```powerquery-m +let + Source = List.Distinct( + {"Squash", "Pumpkin", "ApPlE", "PEAR", "orange", "APPLE", "Pear", "peaR"}, + Comparer.OrdinalIgnoreCase + ) +in + Source +``` + +This code produces the following output: + +:::image type="content" source="media/list-distinct.png" alt-text="Screenshot of the list created by the list distinct function while ignoring case."::: + +In the previous example, the output displays the case of the first unique item found in the list. So, although there are two apples (`ApPlE` and `APPLE`), only the first example found is displayed. + +The following example keeps only unique items while ignoring case, but also returns all lower case results. + +```powerquery-m +let + Source = List.Distinct( + {"Squash", "Pumpkin", "ApPlE", "PEAR", "orange", "APPLE", "Pear", "peaR"}, + Comparer.OrdinalIgnoreCase + ), + #"Lower Case" = List.Transform(Source, Text.Lower) +in + #"Lower Case" +``` + +This code produces the following output: + +:::image type="content" source="media/list-distinct-lower-case.png" alt-text="Screenshot of the list created by the list distinct function while ignoring case, but also outputting lower case."::: + +### Ignoring case in tables + +Tables have several ways to ignore case. Table functions such as [Table.Contains](table-contains.md), [Table.Distinct](table-distinct.md), and [Table.PositionOf](table-positionof.md) all contain `equationCriteria` parameters. These parameters can use the [Comparer.OrdinalIgnoreCase](comparer-ordinalignorecase.md) function to ignore case in tables, in much the same way as the lists in the previous sections. Table functions, such as [Table.MatchesAnyRows](table-matchesanyrows.md) that contain a `condition` parameter can also use [Comparer.OrdinalIgnoreCase](comparer-ordinalignorecase.md) wrapped in other table functions to ignore case. Other table functions, specifically for fuzzy matching, can use the `IgnoreCase` option. + +The following example demonstrates how to select specific rows that contain the word "pear" while ignoring case. This example uses the `condition` parameter of [Table.SelectRows](table-selectrows.md) with [Text.Contains](text-contains.md) as the conditional to make the comparisons while ignoring case. + +```powerquery-m +let + Source = #table(type table[CUSTOMER = text, FRUIT = text], + { + {"Tulga", "Squash"}, + {"suSanna", "Pumpkin"}, + {"LESLIE", "ApPlE"}, + {"Willis", "pear"}, + {"Dilbar", "orange"}, + {"ClaudiA", "APPLE"}, + {"afonso", "Pear"}, + {"SErgio", "pear"} + }), + #"Select Rows" = Table.SelectRows( + Source, each Text.Contains([FRUIT], "pear", Comparer.OrdinalIgnoreCase)) +in + #"Select Rows" +``` + +This code produces the following output: + +:::image type="content" source="media/ignore-case-table.png" alt-text="Screenshot of the table created by the table select rows function while ignoring case."::: + +The following sample shows how to determine if any of the rows in a table contain a `pear` in the `FRUIT` column. This example uses [Comparer.OrdinalIgnoreCase](comparer-ordinalignorecase.md) in a [Text.Contains](text-contains.md) function using the `condition` parameter of the [Table.MatchesAnyRows](table-matchesanyrows.md) function. + +```powerquery-m +let + Source = #table(type table [CUSTOMER = text, FRUIT = text], + { + {"Tulga", "Squash"}, + {"suSanna", "Pumpkin"}, + {"LESLIE", "ApPlE"}, + {"Willis", "PEAR"}, + {"Dilbar", "orange"}, + {"ClaudiA", "APPLE"}, + {"afonso", "Pear"}, + {"SErgio", "peAR"} + }), + #"Select Rows" = Table.MatchesAnyRows(Source, + each Text.Contains([FRUIT], "pear", Comparer.OrdinalIgnoreCase)) +in + #"Select Rows" +``` + +This code produces the following output: + +`true` + +The following example demonstrates how to take a table with values entered by users that contains a column listing their favorite fruits, using no set format. This column is first fuzzy matched to extract the names of their favorite fruit, which is then displayed in its own column, named **Cluster**. Then the **Cluster** column is examined to determine the different distinct fruits that are in the column. Once the unique fruits are determined, a final step is to change all of the fruit names to lower case. + +```powerquery-m +let + // Load a table of user's favorite fruits into Source + Source = #table(type table [Fruit = text], {{"blueberries"}, + {"Blue berries are simply the best"}, {"strawberries"}, {"Strawberries = <3"}, + {"Apples"}, {"'sples"}, {"4ppl3s"}, {"Bananas"}, {"fav fruit is bananas"}, + {"Banas"}, {"My favorite fruit, by far, is Apples. I simply love them!"}} + ), + // Create a Cluster column and fuzzy match the fruits into that column + #"Cluster fuzzy match" = Table.AddFuzzyClusterColumn( + Source, "Fruit", "Cluster", + [IgnoreCase = true, IgnoreSpace = true, Threshold = 0.5] + ), + // Find the distinct fruits from the Cluster column + #"Ignore cluster case" = Table.Distinct( + Table.SelectColumns(#"Cluster fuzzy match", "Cluster"), + Comparer.OrdinalIgnoreCase + ), + // Set all of the distinct fruit names to lower case + #"Set lower case" = Table.TransformColumns(#"Ignore cluster case", + {"Cluster", Text.Lower} + ) +in + #"Set lower case" +``` + +This code produces the following output: + +:::image type="content" source="media/fuzzy-match-table.png" alt-text="Screenshot of the table created by fuzzy matching while ignoring case."::: + +## Case and sorting + +Lists and tables can both be sorted using either [List.Sort](list-sort.md) or [Table.Sort](table-sort.md), respectively. However, sorting text depends on the case of the associated items in the list or table to determine the actual sort order (either ascending or descending). + +The most common form of sorting uses text that is either all lower case, all upper case, or proper case. If there is a mix of these cases, the ascending sort order is as follows: + +1. Any text in the list or table column that begins with a capital letter is first. +1. If there is matching text, but one is proper case and another is all upper case, the upper case version is first. +1. Lower case is then sorted. + +For descending order, the previously listed steps are processed in reverse. + +For example, the following sample has a mixture of all lower case, all upper case, and proper case text to be sorted in ascending order. + +```powerquery-m +let + Source = { "Alpha", "Beta", "Zulu", "ALPHA", "gamma", "alpha", + "beta", "Gamma", "Sierra", "zulu", "GAMMA", "ZULU" }, + SortedList = List.Sort(Source, Order.Ascending) +in + SortedList +``` + +This code produces the following output: + +:::image type="content" source="media/sorted-list.png" alt-text="Screenshot of the list created by sorting text with all lower case, all upper case, and proper case text."::: + +Although not common, you might have a mix of upper and lower case letters in text to sort. The ascending sort order in this case is: + +1. Any text in the list or table column that begins with a capital letter is first. +1. If there is matching text, the text with the maximum number of upper case letters to the left is done next. +1. Lower case is then sorted, with the maximum number of upper case letters to the right done first. + +In any case, it might be more convenient to convert the text to a consistent case before sorting. + +## Power BI Desktop normalization + +Power Query M is case sensitive and distinguishes between different capitalizations of the same text. For example, "Foo", "foo", and "FOO" are treated as different. However, when the data is loaded into Power BI Desktop, the text values are normalized, meaning Power BI Desktop treats them as the same value regardless of their capitalization. Therefore, if you need to transform data while maintaining case sensitivity in your data, you should handle data transformation in Power Query before loading the data to Power BI Desktop. + +For example, the following table in Power Query shows different cases in each row of the table. + +:::image type="content" source="media/table-case-sensitive.png" alt-text="Screenshot of a table containing the text foo and too with various cases."::: + +When this table is loaded into Power BI Desktop, the text values become normalized, resulting in the following table. + +:::image type="content" source="media/table-loaded-power-bi-desktop.png" alt-text="Screenshot of the same table loaded in Power BI Desktop, with the case of each word normalized."::: + +The first instance of "foo" and the first instance of "too" determine the case of "foo" and "too" throughout the rest of the rows in the Power BI Desktop table. In this example, all instances of "foo" are normalized to the value "Foo" and all instances of "too" are normalized to the value "TOO". diff --git a/query-languages/m/media/durations/add-seconds-for-duration.png b/query-languages/m/media/durations/add-seconds-for-duration.png new file mode 100644 index 000000000..b72c775ad Binary files /dev/null and b/query-languages/m/media/durations/add-seconds-for-duration.png differ diff --git a/query-languages/m/media/fuzzy-match-table.png b/query-languages/m/media/fuzzy-match-table.png new file mode 100644 index 000000000..3ba256aaf Binary files /dev/null and b/query-languages/m/media/fuzzy-match-table.png differ diff --git a/query-languages/m/media/ignore-case-table.png b/query-languages/m/media/ignore-case-table.png new file mode 100644 index 000000000..9bc8cf5ff Binary files /dev/null and b/query-languages/m/media/ignore-case-table.png differ diff --git a/query-languages/m/media/list-distinct-lower-case.png b/query-languages/m/media/list-distinct-lower-case.png new file mode 100644 index 000000000..13679888d Binary files /dev/null and b/query-languages/m/media/list-distinct-lower-case.png differ diff --git a/query-languages/m/media/list-distinct.png b/query-languages/m/media/list-distinct.png new file mode 100644 index 000000000..ce99cb950 Binary files /dev/null and b/query-languages/m/media/list-distinct.png differ diff --git a/query-languages/m/media/list-lower-case.png b/query-languages/m/media/list-lower-case.png new file mode 100644 index 000000000..44a6331de Binary files /dev/null and b/query-languages/m/media/list-lower-case.png differ diff --git a/query-languages/m/media/list-proper-case.png b/query-languages/m/media/list-proper-case.png new file mode 100644 index 000000000..0a26a6d7c Binary files /dev/null and b/query-languages/m/media/list-proper-case.png differ diff --git a/query-languages/m/media/list-upper-case.png b/query-languages/m/media/list-upper-case.png new file mode 100644 index 000000000..9f6d5c8cc Binary files /dev/null and b/query-languages/m/media/list-upper-case.png differ diff --git a/query-languages/m/media/m-local-fixed-utc-variants/localnow-versus-fixedlocalnow.png b/query-languages/m/media/m-local-fixed-utc-variants/localnow-versus-fixedlocalnow.png new file mode 100644 index 000000000..378806c70 Binary files /dev/null and b/query-languages/m/media/m-local-fixed-utc-variants/localnow-versus-fixedlocalnow.png differ diff --git a/query-languages/m/media/m-local-fixed-utc-variants/zone-localnow-versus-fixedlocalnow.png b/query-languages/m/media/m-local-fixed-utc-variants/zone-localnow-versus-fixedlocalnow.png new file mode 100644 index 000000000..4b1bc9bdb Binary files /dev/null and b/query-languages/m/media/m-local-fixed-utc-variants/zone-localnow-versus-fixedlocalnow.png differ diff --git a/query-languages/m/media/m-local-fixed-utc-variants/zone-utcnow-versus-fixedutcnow.png b/query-languages/m/media/m-local-fixed-utc-variants/zone-utcnow-versus-fixedutcnow.png new file mode 100644 index 000000000..6c3197264 Binary files /dev/null and b/query-languages/m/media/m-local-fixed-utc-variants/zone-utcnow-versus-fixedutcnow.png differ diff --git a/query-languages/m/media/madvancededitor.png b/query-languages/m/media/madvancededitor.png index 9e9cd05f7..10e983975 100644 Binary files a/query-languages/m/media/madvancededitor.png and b/query-languages/m/media/madvancededitor.png differ diff --git a/query-languages/m/media/mstep1.png b/query-languages/m/media/mstep1.png index 5cf63d91d..5ec2d3646 100644 Binary files a/query-languages/m/media/mstep1.png and b/query-languages/m/media/mstep1.png differ diff --git a/query-languages/m/media/sorted-list.png b/query-languages/m/media/sorted-list.png new file mode 100644 index 000000000..9e63bc5bb Binary files /dev/null and b/query-languages/m/media/sorted-list.png differ diff --git a/query-languages/m/media/table-case-sensitive.png b/query-languages/m/media/table-case-sensitive.png new file mode 100644 index 000000000..c3d73a9df Binary files /dev/null and b/query-languages/m/media/table-case-sensitive.png differ diff --git a/query-languages/m/media/table-loaded-power-bi-desktop.png b/query-languages/m/media/table-loaded-power-bi-desktop.png new file mode 100644 index 000000000..580565555 Binary files /dev/null and b/query-languages/m/media/table-loaded-power-bi-desktop.png differ diff --git a/query-languages/m/media/table-lower-case.png b/query-languages/m/media/table-lower-case.png new file mode 100644 index 000000000..4c7026a16 Binary files /dev/null and b/query-languages/m/media/table-lower-case.png differ diff --git a/query-languages/m/media/table-proper-case.png b/query-languages/m/media/table-proper-case.png new file mode 100644 index 000000000..a001e2548 Binary files /dev/null and b/query-languages/m/media/table-proper-case.png differ diff --git a/query-languages/m/media/table-upper-case.png b/query-languages/m/media/table-upper-case.png new file mode 100644 index 000000000..b15d71f09 Binary files /dev/null and b/query-languages/m/media/table-upper-case.png differ diff --git a/query-languages/m/metadata.md b/query-languages/m/metadata.md index a882b4440..14659bbe0 100644 --- a/query-languages/m/metadata.md +++ b/query-languages/m/metadata.md @@ -1,33 +1,42 @@ --- description: "Learn more about: Metadata" -title: "Metadata | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Metadata" +ms.topic: conceptual +ms.date: 8/28/2024 +ms.custom: "nonautomated-date" +ms.subservice: m-background --- + # Metadata -**Metadata** is information about a value that is associated with a value. **Metadata** is represented as a record value, called a metadata record. The fields of a **metadata record** can be used to store the metadata for a value. Every value has a metadata record. If the value of the metadata record has not been specified, then the metadata record is empty (has no fields). Associating a metadata record with a value does not change the value’s behavior in evaluations except for those that explicitly inspect metadata records. - -A metadata record value is associated with a value x using the syntax value meta [record]. For example, the following associates a metadata record with Rating and Tags fields with the text value "Mozart": - + +**Metadata** is information about a value that is associated with a value. **Metadata** is represented as a record value, called a metadata record. The fields of a **metadata record** can be used to store the metadata for a value. Every value has a metadata record. If the value of the metadata record hasn't been specified, then the metadata record is empty (has no fields). Associating a metadata record with a value doesn't change the value’s behavior in evaluations except for those that explicitly inspect metadata records. + +## Metadata records + +A metadata record value is associated with a value x using the syntax value meta [record]. For example, the following associates a metadata record with Rating and Tags fields with the text value "Mozart": + ```powerquery-m -"Mozart" meta [ Rating = 5, -Tags = {"Classical"} ] -``` -A metadata record can be accessed for a value using the `Value.Metadata` function. In the following example, the expression in the ComposerRating field accesses the metadata record of the value in the Composer field, and then accesses the Rating field of the metadata record. - +"Mozart" meta [ Rating = 5, +Tags = {"Classical"} ] +``` + +A metadata record can be accessed for a value using the [Value.Metadata](value-metadata.md) function. In the following example, the expression in the ComposerRating field accesses the metadata record of the value in the Composer field, and then accesses the Rating field of the metadata record. + ```powerquery-m [ - Composer = "Mozart" meta [ Rating = 5, Tags = {"Classical"} ], - ComposerRating = Value.Metadata(Composer)[Rating] // 5 + Composer = "Mozart" meta [ Rating = 5, Tags = {"Classical"} ], + ComposerRating = Value.Metadata(Composer)[Rating] // 5 ] -``` -Metadata records are not preserved when a value is used with an operator or function that constructs a new value. For example, if two text values are concatenated using the & operator, the metadata of the resulting text value is an empty record []. - -The standard library functions `Value.RemoveMetadata` and `Value.ReplaceMetadata` can be used to remove all metadata from a value and to replace a value’s metadata. - +``` + +Metadata records aren't preserved when a value is used with an operator or function that constructs a new value. For example, if two text values are concatenated using the & operator, the metadata of the resulting text value is an empty record []. + +The standard library functions [Value.RemoveMetadata](value-removemetadata.md) and [Value.ReplaceMetadata](value-replacemetadata.md) can be used to remove all metadata from a value and to replace a value's metadata. + +## Limitations + +Some hosts that use Power Query to transform or move data don't support storing custom metadata into storage. The following hosts don't support storing the custom metadata: + +* Power BI dataflows +* Fabric Dataflow Gen2 +* Power Platform dataflows diff --git a/query-languages/m/missingfield-type.md b/query-languages/m/missingfield-type.md index d62a21b5c..17eab34b0 100644 --- a/query-languages/m/missingfield-type.md +++ b/query-languages/m/missingfield-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: MissingField.Type" -title: "MissingField.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "MissingField.Type" +ms.subservice: m-source --- # MissingField.Type diff --git a/query-languages/m/module-versions.md b/query-languages/m/module-versions.md new file mode 100644 index 000000000..37ccf55ac --- /dev/null +++ b/query-languages/m/module-versions.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Module.Versions" +title: "Module.Versions" +ms.subservice: m-source +--- +# Module.Versions + +## Syntax + +
+Module.Versions() as record
+
+ +## About + +Returns a record of module versions for the current module and its dependencies. diff --git a/query-languages/m/mysql-database.md b/query-languages/m/mysql-database.md index c6ffb486d..b7017924c 100644 --- a/query-languages/m/mysql-database.md +++ b/query-languages/m/mysql-database.md @@ -1,36 +1,33 @@ --- description: "Learn more about: MySQL.Database" -title: "MySQL.Database | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "MySQL.Database" +ms.subservice: m-source --- # MySQL.Database ## Syntax
-MySQL.Database(server as text, database as text, optional options as nullable record) as table
+MySQL.Database(
+    server as text,
+    database as text,
+    optional options as nullable record
+) as table
 
## About -Returns a table of SQL tables, views, and stored scalar functions available in a MySQL database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: +Returns a table of SQL tables, views, and stored scalar functions available in a MySQL database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: -* `Encoding` : A TextEncoding value that specifies the character set used to encode all queries sent to the server (default is null). -* `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). -* `NavigationPropertyNameGenerator` : A function that is used for the creation of names for navigation properties. -* `Query` : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. -* `CommandTimeout` : A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. -* `ConnectionTimeout` : 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. -* `TreatTinyAsBoolean` : A logical (true/false) that determines whether to force tinyint columns on the server as logical values. The default value is true. -* `OldGuids` : A logical (true/false) that sets whether char(36) columns (if false) or binary(16) columns (if true) will be treated as GUIDs. The default value is false. -* `ReturnSingleDatabase` : A logical (true/false) that sets whether to return all tables of all databases (if false) or to return tables and views of the specified database (if true). The default value is false. -* `HierarchicalNavigation` : A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). +* `Encoding`: A TextEncoding value that specifies the character set used to encode all queries sent to the server (default is null). +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). +* `NavigationPropertyNameGenerator`: A function that is used for the creation of names for navigation properties. +* `Query`: A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. +* `CommandTimeout`: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. +* `ConnectionTimeout`: 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. +* `TreatTinyAsBoolean`: A logical (true/false) that determines whether to force tinyint columns on the server as logical values. The default value is true. +* `OldGuids`: A logical (true/false) that sets whether char(36) columns (if false) or binary(16) columns (if true) will be treated as GUIDs. The default value is false. +* `ReturnSingleDatabase`: A logical (true/false) that sets whether to return all tables of all databases (if false) or to return tables and views of the specified database (if true). The default value is false. +* `HierarchicalNavigation`: A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). - The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. - +The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. diff --git a/query-languages/m/number-abs.md b/query-languages/m/number-abs.md index 81f330683..2aeee3f04 100644 --- a/query-languages/m/number-abs.md +++ b/query-languages/m/number-abs.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Abs" -title: "Number.Abs | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Abs" +ms.subservice: m-source --- # Number.Abs @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.Abs(number as nullable number) as nullable number
 
- + ## About Returns the absolute value of `number`. If `number` is null, **Number.Abs** returns null. diff --git a/query-languages/m/number-acos.md b/query-languages/m/number-acos.md index 1c2e35974..723ff31d1 100644 --- a/query-languages/m/number-acos.md +++ b/query-languages/m/number-acos.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Acos" -title: "Number.Acos | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Acos" +ms.subservice: m-source --- # Number.Acos @@ -16,7 +9,8 @@ ms.author: dougklo
 Number.Acos(number as nullable number) as nullable number
-
- -## About + + +## About + Returns the arccosine of `number`. diff --git a/query-languages/m/number-asin.md b/query-languages/m/number-asin.md index ba0e89cb4..cf0b7ae7b 100644 --- a/query-languages/m/number-asin.md +++ b/query-languages/m/number-asin.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Asin" -title: "Number.Asin | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Asin" +ms.subservice: m-source --- # Number.Asin @@ -17,6 +10,7 @@ ms.author: dougklo
 Number.Asin(number as nullable number) as nullable number
 
- -## About + +## About + Returns the arcsine of `number`. diff --git a/query-languages/m/number-atan.md b/query-languages/m/number-atan.md index 6f1d871b4..a0e685f5d 100644 --- a/query-languages/m/number-atan.md +++ b/query-languages/m/number-atan.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Number.Atan" -title: "Number.Atan | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Atan" +ms.subservice: m-source --- # Number.Atan ## Syntax
-Number.Atan(number as nullable number) as nullable number  
+Number.Atan(number as nullable number) as nullable number
 
- -## About + +## About + Returns the arctangent of `number`. diff --git a/query-languages/m/number-atan2.md b/query-languages/m/number-atan2.md index 98ea3159a..2d2e7b7c2 100644 --- a/query-languages/m/number-atan2.md +++ b/query-languages/m/number-atan2.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Atan2" -title: "Number.Atan2 | Microsoft Docs" -ms.date: 1/20/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Atan2" +ms.subservice: m-source --- # Number.Atan2 @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.Atan2(y as nullable number, x as nullable number) as nullable number
 
- + ## About Returns the angle, in radians, whose tangent is the quotient `y`/`x` of the two numbers `y` and `x`. diff --git a/query-languages/m/number-bitwiseand.md b/query-languages/m/number-bitwiseand.md index f6846b58a..9bc768652 100644 --- a/query-languages/m/number-bitwiseand.md +++ b/query-languages/m/number-bitwiseand.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.BitwiseAnd" -title: "Number.BitwiseAnd | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.BitwiseAnd" +ms.subservice: m-source --- # Number.BitwiseAnd @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.BitwiseAnd(number1 as nullable number, number2 as nullable number) as nullable number
 
- -## About + +## About Returns the result of performing a bitwise "And" operation between `number1` and `number2`. diff --git a/query-languages/m/number-bitwisenot.md b/query-languages/m/number-bitwisenot.md index 6ffa96d80..1a4ec6433 100644 --- a/query-languages/m/number-bitwisenot.md +++ b/query-languages/m/number-bitwisenot.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.BitwiseNot" -title: "Number.BitwiseNot | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.BitwiseNot" +ms.subservice: m-source --- # Number.BitwiseNot @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.BitwiseNot(number as any) as any
 
- -## About + +## About Returns the result of performing a bitwise "Not" operation on `number`. diff --git a/query-languages/m/number-bitwiseor.md b/query-languages/m/number-bitwiseor.md index 6f900a47e..a9c3464d7 100644 --- a/query-languages/m/number-bitwiseor.md +++ b/query-languages/m/number-bitwiseor.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.BitwiseOr" -title: "Number.BitwiseOr | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.BitwiseOr" +ms.subservice: m-source --- # Number.BitwiseOr @@ -17,6 +10,7 @@ ms.author: dougklo
 Number.BitwiseOr(number1 as nullable number, number2 as nullable number) as nullable number
 
- -## About + +## About + Returns the result of performing a bitwise "Or" between `number1` and `number2`. diff --git a/query-languages/m/number-bitwiseshiftleft.md b/query-languages/m/number-bitwiseshiftleft.md index eae049a94..b52a080ed 100644 --- a/query-languages/m/number-bitwiseshiftleft.md +++ b/query-languages/m/number-bitwiseshiftleft.md @@ -1,24 +1,16 @@ --- description: "Learn more about: Number.BitwiseShiftLeft" -title: "Number.BitwiseShiftLeft | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.BitwiseShiftLeft" +ms.subservice: m-source --- # Number.BitwiseShiftLeft ## Syntax
-Number.BitwiseShiftLeft(number1 as nullable number, number2 as nullable number) as nullable number 
+Number.BitwiseShiftLeft(number1 as nullable number, number2 as nullable number) as nullable number
 
- -## About -Returns the result of performing a bitwise shift to the left on `number1`, by the specified number of bits `number2`. +## About +Returns the result of performing a bitwise shift to the left on `number1`, by the specified number of bits `number2`. diff --git a/query-languages/m/number-bitwiseshiftright.md b/query-languages/m/number-bitwiseshiftright.md index 26a1dcb00..d7ab9a98b 100644 --- a/query-languages/m/number-bitwiseshiftright.md +++ b/query-languages/m/number-bitwiseshiftright.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.BitwiseShiftRight" -title: "Number.BitwiseShiftRight | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.BitwiseShiftRight" +ms.subservice: m-source --- # Number.BitwiseShiftRight @@ -17,6 +10,7 @@ ms.author: dougklo
 Number.BitwiseShiftRight(number1 as nullable number, number2 as nullable number) as nullable number
 
- -## About + +## About + Returns the result of performing a bitwise shift to the right on `number1`, by the specified number of bits `number2`. diff --git a/query-languages/m/number-bitwisexor.md b/query-languages/m/number-bitwisexor.md index 3491a890d..925d5f448 100644 --- a/query-languages/m/number-bitwisexor.md +++ b/query-languages/m/number-bitwisexor.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.BitwiseXor" -title: "Number.BitwiseXor | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.BitwiseXor" +ms.subservice: m-source --- # Number.BitwiseXor @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.BitwiseXor(number1 as nullable number, number2 as nullable number) as nullable number
 
- -## About + +## About Returns the result of performing a bitwise "XOR" (Exclusive-OR) between `number1` and `number2`. diff --git a/query-languages/m/number-combinations.md b/query-languages/m/number-combinations.md index 6c21f1323..01773b321 100644 --- a/query-languages/m/number-combinations.md +++ b/query-languages/m/number-combinations.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Combinations" -title: "Number.Combinations | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Combinations" +ms.subservice: m-source --- # Number.Combinations @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.Combinations(setSize as nullable number, combinationSize as nullable number) as nullable number
 
- + ## About Returns the number of unique combinations from a list of items, `setSize` with specified combination size, `combinationSize`. diff --git a/query-languages/m/number-cos.md b/query-languages/m/number-cos.md index d9526a5a2..a347ebb3e 100644 --- a/query-languages/m/number-cos.md +++ b/query-languages/m/number-cos.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Cos" -title: "Number.Cos | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Cos" +ms.subservice: m-source --- # Number.Cos @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.Cos(number as nullable number) as nullable number
 
- + ## About Returns the cosine of `number`. diff --git a/query-languages/m/number-cosh.md b/query-languages/m/number-cosh.md index 0cec81c04..41df4cae1 100644 --- a/query-languages/m/number-cosh.md +++ b/query-languages/m/number-cosh.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Number.Cosh" -title: "Number.Cosh | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Cosh" +ms.subservice: m-source --- # Number.Cosh ## Syntax
-Number.Cosh(number as nullable number) as nullable number 
+Number.Cosh(number as nullable number) as nullable number
 
- -## About + +## About + Returns the hyperbolic cosine of `number`. diff --git a/query-languages/m/number-e.md b/query-languages/m/number-e.md index d073a36e2..36f14b8c2 100644 --- a/query-languages/m/number-e.md +++ b/query-languages/m/number-e.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.E" -title: "Number.E | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.E" +ms.subservice: m-source --- # Number.E diff --git a/query-languages/m/number-epsilon.md b/query-languages/m/number-epsilon.md index f59459cab..b0bc9b7fe 100644 --- a/query-languages/m/number-epsilon.md +++ b/query-languages/m/number-epsilon.md @@ -1,18 +1,10 @@ --- description: "Learn more about: Number.Epsilon" -title: "Number.Epsilon | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Epsilon" +ms.subservice: m-source --- # Number.Epsilon - -## About +## About + A constant value that represents the smallest positive number a floating-point number can hold. - diff --git a/query-languages/m/number-exp.md b/query-languages/m/number-exp.md index 432469501..575d0dcf3 100644 --- a/query-languages/m/number-exp.md +++ b/query-languages/m/number-exp.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Exp" -title: "Number.Exp | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Exp" +ms.subservice: m-source --- # Number.Exp @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.Exp(number as nullable number) as nullable number
 
- + ## About Returns the result of raising e to the power of `number` (exponential function). diff --git a/query-languages/m/number-factorial.md b/query-languages/m/number-factorial.md index 45e82cade..bc3723f31 100644 --- a/query-languages/m/number-factorial.md +++ b/query-languages/m/number-factorial.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Factorial" -title: "Number.Factorial | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Factorial" +ms.subservice: m-source --- # Number.Factorial @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.Factorial(number as nullable number) as nullable number
 
- + ## About Returns the factorial of the number `number`. diff --git a/query-languages/m/number-from.md b/query-languages/m/number-from.md index 1178f7721..2ed2d05c7 100644 --- a/query-languages/m/number-from.md +++ b/query-languages/m/number-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.From" -title: "Number.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.From" +ms.subservice: m-source --- # Number.From @@ -39,7 +32,7 @@ Get the `number` value of `"4"`. **Usage** ```powerquery-m -powerquery-mNumber.From("4") +Number.From("4") ``` **Output** @@ -73,3 +66,9 @@ Number.From("12.3%") **Output** `0.123` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard numeric format strings](standard-numeric-format-strings.md) +* [Custom numeric format strings](custom-numeric-format-strings.md) diff --git a/query-languages/m/number-fromtext.md b/query-languages/m/number-fromtext.md index 1298a3dbd..4cdbaeefd 100644 --- a/query-languages/m/number-fromtext.md +++ b/query-languages/m/number-fromtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.FromText" -title: "Number.FromText | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.FromText" +ms.subservice: m-source --- # Number.FromText @@ -17,7 +10,7 @@ ms.author: dougklo
 Number.FromText(text as nullable text, optional culture as nullable text) as nullable number
 
- + ## About Returns a `number` value from the given text value, `text`. @@ -52,3 +45,9 @@ Number.FromText("5.0e-10") **Output** `5E-10` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard numeric format strings](standard-numeric-format-strings.md) +* [Custom numeric format strings](custom-numeric-format-strings.md) diff --git a/query-languages/m/number-functions.md b/query-languages/m/number-functions.md index 2f5a4c514..cefd50385 100644 --- a/query-languages/m/number-functions.md +++ b/query-languages/m/number-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Number functions" -title: "Number functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number functions" +ms.date: 8/11/2025 +ms.custom: "nonautomated-date" --- # Number functions @@ -18,9 +12,9 @@ These functions create and manipulate number values. |Name|Description| |------------|---------------| -|[Number.IsEven](number-iseven.md)|Returns true if a value is an even number.| -|[Number.IsNaN](number-isnan.md)|Returns true if a value is Number.NaN.| -|[Number.IsOdd](number-isodd.md)|Returns true if a value is an odd number.| +|[Number.IsEven](number-iseven.md)|Returns `true` if a value is an even number.| +|[Number.IsNaN](number-isnan.md)|Returns `true` if a value is [Number.NaN](number-nan.md).| +|[Number.IsOdd](number-isodd.md)|Returns `true` if a value is an odd number.| ## Conversion and formatting @@ -36,7 +30,7 @@ These functions create and manipulate number values. |[Int64.From](int64-from.md)|Returns a 64-bit integer number value from the given value.| |[Number.From](number-from.md)|Returns a number value from a value.| |[Number.FromText](number-fromtext.md)|Returns a number value from a text value.| -|[Number.ToText](number-totext.md)|Returns a text value from a number value.| +|[Number.ToText](number-totext.md)|Converts the given number to text.| |[Percentage.From](percentage-from.md)|Returns a percentage value from the given value.| |[Single.From](single-from.md)|Returns a Single number value from the given value.| @@ -45,9 +39,9 @@ These functions create and manipulate number values. |Name|Description| |------------|---------------| |[Number.Round](number-round.md)|Returns a nullable number (n) if value is an integer.| -|[Number.RoundAwayFromZero](number-roundawayfromzero.md)|Returns Number.RoundUp(value) when value >= 0 and Number.RoundDown(value) when value < 0.| +|[Number.RoundAwayFromZero](number-roundawayfromzero.md)|Returns [Number.RoundUp(value)](number-roundup.md) when value >= 0 and [Number.RoundDown(value)](number-rounddown.md) when value < 0.| |[Number.RoundDown](number-rounddown.md)|Returns the largest integer less than or equal to a number value.| -|[Number.RoundTowardZero](number-roundtowardzero.md)|Returns Number.RoundDown(x) when x >= 0 and Number.RoundUp(x) when x < 0.| +|[Number.RoundTowardZero](number-roundtowardzero.md)|Returns [Number.RoundDown(x)](number-rounddown.md) when x >= 0 and [Number.RoundUp(x)](number-roundup.md) when x < 0.| |[Number.RoundUp](number-roundup.md)|Returns the larger integer greater than or equal to a number value.| ## Operations @@ -65,7 +59,7 @@ These functions create and manipulate number values. |[Number.Mod](number-mod.md)|Divides two numbers and returns the remainder of the resulting number.| |[Number.Permutations](number-permutations.md)|Returns the number of total permutations of a given number of items for the optional permutation size.| |[Number.Power](number-power.md)|Returns a number raised by a power.| -|[Number.Sign](number-sign.md)|Returns 1 for positive numbers, -1 for negative numbers or 0 for zero.| +|[Number.Sign](number-sign.md)|Returns 1 for positive numbers, -1 for negative numbers, or 0 for zero.| |[Number.Sqrt](number-sqrt.md)|Returns the square root of a number.| ## Random diff --git a/query-languages/m/number-integerdivide.md b/query-languages/m/number-integerdivide.md index 3cc0a24d4..5a3d0c0bf 100644 --- a/query-languages/m/number-integerdivide.md +++ b/query-languages/m/number-integerdivide.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Number.IntegerDivide" -title: "Number.IntegerDivide | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.IntegerDivide" +ms.subservice: m-source --- # Number.IntegerDivide ## Syntax
-Number.IntegerDivide(number1 as nullable number, number2 as nullable number, optional precision as nullable number) as nullable number
+Number.IntegerDivide(
+    number1 as nullable number,
+    number2 as nullable number,
+    optional precision as nullable number
+) as nullable number
 
## About diff --git a/query-languages/m/number-iseven.md b/query-languages/m/number-iseven.md index 1aba6f6e3..8f30887f9 100644 --- a/query-languages/m/number-iseven.md +++ b/query-languages/m/number-iseven.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.IsEven" -title: "Number.IsEven | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.IsEven" +ms.subservice: m-source --- # Number.IsEven diff --git a/query-languages/m/number-isnan.md b/query-languages/m/number-isnan.md index 39ea66ebe..8b07b02c7 100644 --- a/query-languages/m/number-isnan.md +++ b/query-languages/m/number-isnan.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.IsNaN" -title: "Number.IsNaN | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.IsNaN" +ms.subservice: m-source --- # Number.IsNaN diff --git a/query-languages/m/number-isodd.md b/query-languages/m/number-isodd.md index 1a2d1588d..5127aec1e 100644 --- a/query-languages/m/number-isodd.md +++ b/query-languages/m/number-isodd.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.IsOdd" -title: "Number.IsOdd | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.IsOdd" +ms.subservice: m-source --- # Number.IsOdd diff --git a/query-languages/m/number-ln.md b/query-languages/m/number-ln.md index 7e0e6f4e8..6dd17a156 100644 --- a/query-languages/m/number-ln.md +++ b/query-languages/m/number-ln.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Ln" -title: "Number.Ln | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Ln" +ms.subservice: m-source --- # Number.Ln diff --git a/query-languages/m/number-log.md b/query-languages/m/number-log.md index b565e158d..1c817f957 100644 --- a/query-languages/m/number-log.md +++ b/query-languages/m/number-log.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Log" -title: "Number.Log | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Log" +ms.subservice: m-source --- # Number.Log diff --git a/query-languages/m/number-log10.md b/query-languages/m/number-log10.md index f8742dbd3..2bcecf289 100644 --- a/query-languages/m/number-log10.md +++ b/query-languages/m/number-log10.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Log10" -title: "Number.Log10 | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Log10" +ms.subservice: m-source --- # Number.Log10 diff --git a/query-languages/m/number-mod.md b/query-languages/m/number-mod.md index 807400dc4..1b8dfecb4 100644 --- a/query-languages/m/number-mod.md +++ b/query-languages/m/number-mod.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Number.Mod" -title: "Number.Mod | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Mod" +ms.subservice: m-source --- # Number.Mod ## Syntax
-Number.Mod(number as nullable number, divisor as nullable number, optional precision as nullable number) as nullable number
+Number.Mod(
+    number as nullable number,
+    divisor as nullable number,
+    optional precision as nullable number
+) as nullable number
 
## About diff --git a/query-languages/m/number-nan.md b/query-languages/m/number-nan.md index 48488acb5..8caaf9f15 100644 --- a/query-languages/m/number-nan.md +++ b/query-languages/m/number-nan.md @@ -1,17 +1,10 @@ --- description: "Learn more about: Number.NaN" -title: "Number.NaN | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.NaN" +ms.subservice: m-source --- # Number.NaN - -## About -A constant value that represents 0 divided by 0. +## About + +A constant value that represents 0 divided by 0. diff --git a/query-languages/m/number-negativeinfinity.md b/query-languages/m/number-negativeinfinity.md index 2053ad8c4..d3373c653 100644 --- a/query-languages/m/number-negativeinfinity.md +++ b/query-languages/m/number-negativeinfinity.md @@ -1,17 +1,10 @@ --- description: "Learn more about: Number.NegativeInfinity" -title: "Number.NegativeInfinity | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.NegativeInfinity" +ms.subservice: m-source --- # Number.NegativeInfinity - -## About +## About + A constant value that represents -1 divided by 0. diff --git a/query-languages/m/number-permutations.md b/query-languages/m/number-permutations.md index 3b2eab368..72a39f06b 100644 --- a/query-languages/m/number-permutations.md +++ b/query-languages/m/number-permutations.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Permutations" -title: "Number.Permutations | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Permutations" +ms.subservice: m-source --- # Number.Permutations diff --git a/query-languages/m/number-pi.md b/query-languages/m/number-pi.md index 17d4a7731..5a16826a6 100644 --- a/query-languages/m/number-pi.md +++ b/query-languages/m/number-pi.md @@ -1,17 +1,10 @@ --- description: "Learn more about: Number.PI" -title: "Number.PI | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.PI" +ms.subservice: m-source --- # Number.PI - -## About -A constant that represents 3.1415926535897932, the value for pi up to 16 decimal digits. +## About + +A constant that represents 3.1415926535897932, the value for pi up to 16 decimal digits. diff --git a/query-languages/m/number-positiveinfinity.md b/query-languages/m/number-positiveinfinity.md index 363ea0488..337757b3c 100644 --- a/query-languages/m/number-positiveinfinity.md +++ b/query-languages/m/number-positiveinfinity.md @@ -1,17 +1,10 @@ --- description: "Learn more about: Number.PositiveInfinity" -title: "Number.PositiveInfinity | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.PositiveInfinity" +ms.subservice: m-source --- # Number.PositiveInfinity - -## About +## About + A constant value that represents 1 divided by 0. diff --git a/query-languages/m/number-power.md b/query-languages/m/number-power.md index aa054f937..e4f72d331 100644 --- a/query-languages/m/number-power.md +++ b/query-languages/m/number-power.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Number.Power" -title: "Number.Power | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Power" +ms.subservice: m-source --- # Number.Power - + ## Syntax
 Number.Power(number as nullable number, power as nullable number) as nullable number
 
- + ## About Returns the result of raising `number` to the power of `power`. If `number` or `power` are null, **Number.Power** returns null. diff --git a/query-languages/m/number-random.md b/query-languages/m/number-random.md index e445594dd..ecf2a9a49 100644 --- a/query-languages/m/number-random.md +++ b/query-languages/m/number-random.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Random" -title: "Number.Random | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Random" +ms.subservice: m-source --- # Number.Random diff --git a/query-languages/m/number-randombetween.md b/query-languages/m/number-randombetween.md index a2004cf8a..70a7254c7 100644 --- a/query-languages/m/number-randombetween.md +++ b/query-languages/m/number-randombetween.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.RandomBetween" -title: "Number.RandomBetween | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.RandomBetween" +ms.subservice: m-source --- # Number.RandomBetween diff --git a/query-languages/m/number-round.md b/query-languages/m/number-round.md index 7fc8b786b..7a9178369 100644 --- a/query-languages/m/number-round.md +++ b/query-languages/m/number-round.md @@ -1,28 +1,25 @@ --- description: "Learn more about: Number.Round" -title: "Number.Round | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Round" +ms.subservice: m-source --- # Number.Round ## Syntax
-Number.Round(number as nullable number, optional digits as nullable number, optional roundingMode as nullable number) as nullable number
+Number.Round(
+    number as nullable number,
+    optional digits as nullable number,
+    optional roundingMode as nullable number
+) as nullable number
 
- -## About + +## About Returns the result of rounding `number` to the nearest number. If `number` is null, **Number.Round** returns null. -By default, `number` is rounded to the nearest integer, and ties are broken by rounding to the nearest even number (using [RoundingMode.ToEven](/powerquery-m/roundingmode-toeven), also known as "banker's rounding"). +By default, `number` is rounded to the nearest integer, and ties are broken by rounding to the nearest even number (using [RoundingMode.ToEven](roundingmode-type.md), also known as "banker's rounding"). However, these defaults can be overridden via the following optional parameters. diff --git a/query-languages/m/number-roundawayfromzero.md b/query-languages/m/number-roundawayfromzero.md index ad49dd546..d9c15f822 100644 --- a/query-languages/m/number-roundawayfromzero.md +++ b/query-languages/m/number-roundawayfromzero.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.RoundAwayFromZero" -title: "Number.RoundAwayFromZero | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.RoundAwayFromZero" +ms.subservice: m-source --- # Number.RoundAwayFromZero diff --git a/query-languages/m/number-rounddown.md b/query-languages/m/number-rounddown.md index b48865130..e704d0fd1 100644 --- a/query-languages/m/number-rounddown.md +++ b/query-languages/m/number-rounddown.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.RoundDown" -title: "Number.RoundDown | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.RoundDown" +ms.subservice: m-source --- # Number.RoundDown diff --git a/query-languages/m/number-roundtowardzero.md b/query-languages/m/number-roundtowardzero.md index 2083faa6f..6faeee29d 100644 --- a/query-languages/m/number-roundtowardzero.md +++ b/query-languages/m/number-roundtowardzero.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.RoundTowardZero" -title: "Number.RoundTowardZero | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.RoundTowardZero" +ms.subservice: m-source --- # Number.RoundTowardZero diff --git a/query-languages/m/number-roundup.md b/query-languages/m/number-roundup.md index 50cae1ccc..7bca5155f 100644 --- a/query-languages/m/number-roundup.md +++ b/query-languages/m/number-roundup.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.RoundUp" -title: "Number.RoundUp | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.RoundUp" +ms.subservice: m-source --- # Number.RoundUp diff --git a/query-languages/m/number-sign.md b/query-languages/m/number-sign.md index fc67475d0..8c9cbfaed 100644 --- a/query-languages/m/number-sign.md +++ b/query-languages/m/number-sign.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Sign" -title: "Number.Sign | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Sign" +ms.subservice: m-source --- # Number.Sign diff --git a/query-languages/m/number-sin.md b/query-languages/m/number-sin.md index 16c2bd278..9bb675efb 100644 --- a/query-languages/m/number-sin.md +++ b/query-languages/m/number-sin.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Sin" -title: "Number.Sin | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Sin" +ms.subservice: m-source --- # Number.Sin diff --git a/query-languages/m/number-sinh.md b/query-languages/m/number-sinh.md index defbdb7d0..3406a925e 100644 --- a/query-languages/m/number-sinh.md +++ b/query-languages/m/number-sinh.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Sinh" -title: "Number.Sinh | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Sinh" +ms.subservice: m-source --- # Number.Sinh @@ -17,6 +10,7 @@ ms.author: dougklo
 Number.Sinh(number as nullable number) as nullable number
 
- -## About + +## About + Returns the hyperbolic sine of `number`. diff --git a/query-languages/m/number-sqrt.md b/query-languages/m/number-sqrt.md index 2d5a40cf2..8f3246723 100644 --- a/query-languages/m/number-sqrt.md +++ b/query-languages/m/number-sqrt.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Sqrt" -title: "Number.Sqrt | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Sqrt" +ms.subservice: m-source --- # Number.Sqrt diff --git a/query-languages/m/number-tan.md b/query-languages/m/number-tan.md index 807387815..c04ffb1ee 100644 --- a/query-languages/m/number-tan.md +++ b/query-languages/m/number-tan.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Tan" -title: "Number.Tan | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Tan" +ms.subservice: m-source --- # Number.Tan diff --git a/query-languages/m/number-tanh.md b/query-languages/m/number-tanh.md index bc8712783..1fc724a6b 100644 --- a/query-languages/m/number-tanh.md +++ b/query-languages/m/number-tanh.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Number.Tanh" -title: "Number.Tanh | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.Tanh" +ms.subservice: m-source --- # Number.Tanh @@ -17,6 +10,7 @@ ms.author: dougklo
 Number.Tanh(number as nullable number) as nullable number
 
- -## About + +## About + Returns the hyperbolic tangent of `number`. diff --git a/query-languages/m/number-totext.md b/query-languages/m/number-totext.md index 510f8e13b..4d636c0c6 100644 --- a/query-languages/m/number-totext.md +++ b/query-languages/m/number-totext.md @@ -1,41 +1,31 @@ --- description: "Learn more about: Number.ToText" -title: "Number.ToText | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Number.ToText" +ms.subservice: m-source --- # Number.ToText ## Syntax
-Number.ToText(number as nullable number, optional format as nullable text, optional culture as nullable text) as nullable text
+Number.ToText(
+    number as nullable number,
+    optional format as nullable text,
+    optional culture as nullable text
+) as nullable text
 
## About -Formats the numeric value `number` to a text value according to the format specified by `format`. The format is a single character code optionally followed by a number precision specifier. The following character codes may be used for `format`. +Converts the numeric value `number` to a text value according to the format specified by `format`. -* "D" or "d": (Decimal) Formats the result as integer digits. The precision specifier controls the number of digits in the output. -* "E" or "e": (Exponential/scientific) Exponential notation. The precision specifier controls the maximum number of decimal digits (default is 6). -* "F" or "f": (Fixed-point) Integral and decimal digits. -* "G" or "g": (General) Most compact form of either fixed-point or scientific. -* "N" or "n": (Number) Integral and decimal digits with group separators and a decimal separator. -* "P" or "p": (Percent) Number multiplied by 100 and displayed with a percent symbol. -* "R" or "r": (Round-trip) A text value that can round-trip an identical number. The precision specifier is ignored. -* "X" or "x": (Hexadecimal) A hexadecimal text value. +The format is a text value indicating how the number should be converted. For more details on the supported format values, go to [Standard numeric format strings](standard-numeric-format-strings.md) and [Custom numeric format strings](custom-numeric-format-strings.md). -An optional `culture` may also be provided (for example, "en-US"). +An optional `culture` may also be provided (for example, "en-US") to control the culture-dependent behavior of `format`. ## Example 1 -Format a number as text without format specified. +Convert a number to text without specifying a format. **Usage** @@ -49,7 +39,7 @@ Number.ToText(4) ## Example 2 -Format a number as text in Exponential format. +Convert a number to exponential format. **Usage** @@ -63,7 +53,7 @@ Number.ToText(4, "e") ## Example 3 -Format a number as text in Decimal format with limited precision. +Convert a number to percentage format with only one decimal place. **Usage** @@ -74,3 +64,9 @@ Number.ToText(-0.1234, "P1") **Output** `"-12.3 %"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard numeric format strings](standard-numeric-format-strings.md) +* [Custom numeric format strings](custom-numeric-format-strings.md) diff --git a/query-languages/m/occurrence-type.md b/query-languages/m/occurrence-type.md index e7982028d..0d6060c90 100644 --- a/query-languages/m/occurrence-type.md +++ b/query-languages/m/occurrence-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Occurrence.Type" -title: "Occurrence.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Occurrence.Type" +ms.subservice: m-source --- # Occurrence.Type diff --git a/query-languages/m/odata-feed.md b/query-languages/m/odata-feed.md index b1ef03b5e..b0fb43ee2 100644 --- a/query-languages/m/odata-feed.md +++ b/query-languages/m/odata-feed.md @@ -1,21 +1,18 @@ --- description: "Learn more about: OData.Feed" -title: "OData.Feed | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "OData.Feed" +ms.subservice: m-source --- # OData.Feed ## Syntax
-OData.Feed(serviceUri as text, optional headers as nullable record, optional options as any) as any
+OData.Feed(
+    serviceUri as text,
+    optional headers as nullable record,
+    optional options as any
+) as any
 
## About diff --git a/query-languages/m/odataomitvalues-type.md b/query-languages/m/odataomitvalues-type.md index 4e8830367..07a20cc92 100644 --- a/query-languages/m/odataomitvalues-type.md +++ b/query-languages/m/odataomitvalues-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: ODataOmitValues.Type" -title: "ODataOmitValues.Type | Microsoft Docs" -ms.date: 6/27/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "ODataOmitValues.Type" +ms.subservice: m-source --- # ODataOmitValues.Type diff --git a/query-languages/m/odbc-datasource.md b/query-languages/m/odbc-datasource.md index 78715f560..be534fa33 100644 --- a/query-languages/m/odbc-datasource.md +++ b/query-languages/m/odbc-datasource.md @@ -1,13 +1,8 @@ --- description: "Learn more about: Odbc.DataSource" -title: "Odbc.DataSource | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Odbc.DataSource" +ms.subservice: m-source +ms.custom: sfi-ropc-nochange --- # Odbc.DataSource @@ -21,11 +16,11 @@ Odbc.DataSource(connectionString as any, optional options as nulla Returns a table of SQL tables and views from the ODBC data source specified by the connection string `connectionString`. `connectionString` can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: -* `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). -* `HierarchicalNavigation` : A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). -* `ConnectionTimeout` : A duration that controls how long to wait before abandoning an attempt to make a connection to the server. The default value is 15 seconds. -* `CommandTimeout` : 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` : A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). +* `HierarchicalNavigation`: A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). +* `ConnectionTimeout`: A duration that controls how long to wait before abandoning an attempt to make a connection to the server. The default value is 15 seconds. +* `CommandTimeout`: 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`: A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. ## Example 1 diff --git a/query-languages/m/odbc-inferoptions.md b/query-languages/m/odbc-inferoptions.md index 1c1cbbb22..3af778da6 100644 --- a/query-languages/m/odbc-inferoptions.md +++ b/query-languages/m/odbc-inferoptions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Odbc.InferOptions" -title: "Odbc.InferOptions | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Odbc.InferOptions" +ms.subservice: m-source +ms.custom: sfi-ropc-nochange --- # Odbc.InferOptions diff --git a/query-languages/m/odbc-query.md b/query-languages/m/odbc-query.md index 9ed3d6405..7de933dda 100644 --- a/query-languages/m/odbc-query.md +++ b/query-languages/m/odbc-query.md @@ -1,29 +1,28 @@ --- description: "Learn more about: Odbc.Query" -title: "Odbc.Query | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Odbc.Query" +ms.subservice: m-source +ms.custom: sfi-ropc-nochange --- # Odbc.Query ## Syntax
-Odbc.Query(connectionString as any, query as text, optional options as nullable record) as table
+Odbc.Query(
+    connectionString as any,
+    query as text,
+    optional options as nullable record
+) as table
 
## About Returns the result of running `query` with the connection string `connectionString` using ODBC. `connectionString` can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: -* `ConnectionTimeout` : A duration that controls how long to wait before abandoning an attempt to make a connection to the server. The default value is 15 seconds. -* `CommandTimeout` : 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` : A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. +* `ConnectionTimeout`: A duration that controls how long to wait before abandoning an attempt to make a connection to the server. The default value is 15 seconds. +* `CommandTimeout`: 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`: A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. ## Example 1 diff --git a/query-languages/m/oledb-datasource.md b/query-languages/m/oledb-datasource.md index b9a4fc31b..f0df8d2a8 100644 --- a/query-languages/m/oledb-datasource.md +++ b/query-languages/m/oledb-datasource.md @@ -1,13 +1,8 @@ --- description: "Learn more about: OleDb.DataSource" -title: "OleDb.DataSource | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "OleDb.DataSource" +ms.subservice: m-source +ms.custom: sfi-ropc-nochange --- # OleDb.DataSource @@ -18,14 +13,15 @@ OleDb.DataSource(connectionString as any, optional options as null ## About -Returns a table of SQL tables and views from the OLE DB data source specified by the connection string `connectionString`. `connectionString` can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: -* `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). -* `NavigationPropertyNameGenerator` : A function that is used for the creation of names for navigation properties. -* `Query` : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. -* `HierarchicalNavigation` : A logical (true/false) that sets whether to view the tables grouped by their schema names (default is true). -* `ConnectionTimeout` : 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. -* `CommandTimeout` : 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` : A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. - The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. - +Returns a table of SQL tables and views from the OLE DB data source specified by the connection string `connectionString`. `connectionString` can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: + +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). +* `NavigationPropertyNameGenerator`: A function that is used for the creation of names for navigation properties. +* `Query`: A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. +* `HierarchicalNavigation`: A logical (true/false) that sets whether to view the tables grouped by their schema names (default is true). +* `ConnectionTimeout`: 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. +* `CommandTimeout`: 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`: A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. + +The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. diff --git a/query-languages/m/oledb-query.md b/query-languages/m/oledb-query.md index 5c7afa0dc..51b61ce59 100644 --- a/query-languages/m/oledb-query.md +++ b/query-languages/m/oledb-query.md @@ -1,24 +1,25 @@ --- description: "Learn more about: OleDb.Query" -title: "OleDb.Query | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "OleDb.Query" +ms.subservice: m-source +ms.custom: sfi-ropc-nochange --- # OleDb.Query ## Syntax
-OleDb.Query(connectionString as any, query as text, optional options as nullable record) as table
+OleDb.Query(
+    connectionString as any,
+    query as text,
+    optional options as nullable record
+) as table
 
## About -Returns the result of running `query` with the connection string `connectionString` using OLE DB. `connectionString` can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: -* `ConnectionTimeout` : 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. -* `CommandTimeout` : 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` : A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. + +Returns the result of running `query` with the connection string `connectionString` using OLE DB. `connectionString` can be text or a record of property value pairs. Property values can either be text or number. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: + +* `ConnectionTimeout`: 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. +* `CommandTimeout`: 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`: A logical (true/false) that determines whether to produce SQL Server-compatible connection string options for Windows authentication. The default value is true. diff --git a/query-languages/m/operators.md b/query-languages/m/operators.md index 99aca5385..a52c9481b 100644 --- a/query-languages/m/operators.md +++ b/query-languages/m/operators.md @@ -1,147 +1,147 @@ --- description: "Learn more about: Operators" -title: "Operators | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Operators" +ms.topic: conceptual +ms.date: 6/13/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-background --- + # Operators -The Power Query M formula language includes a set of operators that can be used in an expression. **Operators** are applied to **operands** to form symbolic expressions. For example, in the expression 1 + 2 the numbers 1 and 2 are operands and the operator is the addition operator (+). + +The Power Query M formula language includes a set of operators that can be used in an expression. **Operators** are applied to **operands** to form symbolic expressions. For example, in the expression `1 + 2` the numbers `1` and `2` are operands and the operator is the addition operator (`+`). The meaning of an operator can vary depending on the type of operand values. The language has the following operators: -### Plus operator (+) - +### Plus operator (+) + |Expression|Equals| |--------------|----------| -|1 + 2|Numeric addition: 3| -|#time(12,23,0) + #duration(0,0,2,0)|Time arithmetic: #time(12,25,0)| +|`1 + 2`|Numeric addition: `3`| +|`#time(12,23,0) + #duration(0,0,2,0)`|Time arithmetic: `#time(12,25,0)`| ### Combination operator (&) |Function|Equals| |------------|----------| -|"A" & "BC"|Text concatenation: "ABC"| -|{1} & {2, 3}|List concatenation: {1, 2, 3}| -|[ a = 1 ] & [ b = 2 ]|Record merge: [ a = 1, b = 2 ]| +|`"A" & "BC"`|Text concatenation: `"ABC"`| +|`{1} & {2, 3}`|List concatenation: `{1, 2, 3}`| +|`[ a = 1 ] & [ b = 2 ]`|Record merge: `[ a = 1, b = 2 ]`| -### List of M operators -**Common operators** which apply to null, logical, number, time, date, datetime, datetimezone, duration, text, binary) +### List of M operators + +**Common operators** that apply to `null`, `logical`, `number`, `time`, `date`, `datetime`, `datetimezone`, `duration`, `text`, `binary` |Operator|Description| |------------|---------------| -|>|Greater than| -|>=|Greater than or equal| -|<|Less than| -|<=|Less than or equal| -|=|Equal| -|<>|Not equal| +|`>`|Greater than| +|`>=`|Greater than or equal| +|`<`|Less than| +|`<=`|Less than or equal| +|`=`|Equal| +|`<>`|Not equal| +|`??`|Null coalescing| **Logical operators** (In addition to **Common operators**) |Operator|Description| |------------|---------------| -|or|Conditional logical OR| -|and|Conditional logical AND| -|not|Logical NOT| +|`or`|Conditional logical `OR`| +|`and`|Conditional logical `AND`| +|`not`|Logical `NOT`| **Number operators** (In addition to **Common operators**) |Operator|Description| |------------|---------------| -|+|Sum| -|-|Difference| -|*|Product| -|/|Quotient| -|+x|Unary plus| -|-x|Negation| +|`+`|Sum| +|`-`|Difference| +|`*`|Product| +|`/`|Quotient| +|`+x`|Unary plus| +|`-x`|Negation| **Text operators** (In addition to **Common operators**) |Operator|Description| |------------|---------------| -|&|Concatenation| +|`&`|Concatenation| -**List, record, table operators** +**List, record, table operators** |Operator|Description| |------------|---------------| -|=|Equal| -|<>|Not equal| -|&|Concatenation| +|`=`|Equal| +|`<>`|Not equal| +|`&`|Concatenation| -**Record lookup operator** +**Record lookup operator** |Operator|Description| |------------|---------------| -|[]|Access the fields of a record by name.| +|`[]`|Access the fields of a record by name.| -**List indexer operator** +**List indexer operator** |Operator|Description| |------------|---------------| -|{}|Access an item in a list by its zero-based numeric index.| +|`{}`|Access an item in a list by its zero-based numeric index.| -**Type compatibility and assertion operators** +**Type compatibility and assertion operators** |Operator|Description| |------------|---------------| -|is|The expression x is y returns true if the type of x is compatible with y, and returns false if the type of x is not compatible with y.| -|as|The expression x as y asserts that the value x is compatible with y as per the is operator.| +|`is`|The expression `x is y` returns `true` if the type of `x` is compatible with `y`, and returns `false` if the type of `x` is not compatible with `y`.| +|`as`|The expression `x as y` asserts that the value `x` is compatible with `y` as per the `is` operator.| -**Date operators** +**Date operators** |Operator|Left Operand|Right Operand|Meaning| |------------|----------------|-----------------|-----------| -|x + y|time|duration|Date offset by duration| -|x + y|duration|time|Date offset by duration| -|x - y|time|duration|Date offset by negated duration| -|x - y|time|time|Duration between dates| -|x & y|date|time|Merged datetime| +|`x + y`|`time`|`duration`|Date offset by duration| +|`x + y`|`duration`|`time`|Date offset by duration| +|`x - y`|`time`|`duration`|Date offset by negated duration| +|`x - y`|`time`|`time`|Duration between dates| +|`x & y`|`date`|`time`|Merged datetime| -**Datetime operators** +**Datetime operators** |Operator|Left Operand|Right Operand|Meaning| |------------|----------------|-----------------|-----------| -|x + y|datetime|duration|Datetime offset by duration| -|x + y|duration|datetime|Datetime offset by duration| -|x - y|datetime|duration|Datetime offset by negated duration| -|x - y|datetime|datetime|Duration between datetimes| +|`x + y`|`datetime`|`duration`|Datetime offset by duration| +|`x + y`|`duration`|`datetime`|Datetime offset by duration| +|`x - y`|`datetime`|`duration`|Datetime offset by negated duration| +|`x - y`|`datetime`|`datetime`|Duration between datetimes| -**Datetimezone operators** +**Datetimezone operators** |Operator|Left Operand|Right Operand|Meaning| |------------|----------------|-----------------|-----------| -|x + y|datetimezone|duration|Datetimezone offset by duration| -|x + y|duration|datetimezone|Datetimezone offset by duration| -|x - y|datetimezone|duration|Datetimezone offset by negated duration| -|x - y|datetimezone|datetimezone|Duration between datetimezones| +|`x + y`|`datetimezone`|`duration`|Datetimezone offset by duration| +|`x + y`|`duration`|`datetimezone`|Datetimezone offset by duration| +|`x - y`|`datetimezone`|`duration`|Datetimezone offset by negated duration| +|`x - y`|`datetimezone`|`datetimezone`|Duration between datetimezones| -**Duration operators** +**Duration operators** |Operator|Left Operand|Right Operand|Meaning| |------------|----------------|-----------------|-----------| -|x + y|datetime|duration|Datetime offset by duration| -|x + y|duration|datetime|Datetime offset by duration| -|x + y|duration|duration|Sum of durations| -|x - y|datetime|duration|Datetime offset by negated duration| -|x - y|datetime|datetime|Duration between datetimes| -|x - y|duration|duration|Difference of durations| -|x * y|duration|number|N times a duration| -|x * y|number|duration|N times a duration| -|x / y|duration|number|Fraction of a duration| +|`x + y`|`datetime`|`duration`|Datetime offset by duration| +|`x + y`|`duration`|`datetime`|Datetime offset by duration| +|`x + y`|`duration`|`duration`|Sum of durations| +|`x - y`|`datetime`|`duration`|Datetime offset by negated duration| +|`x - y`|`datetime`|`datetime`|Duration between datetimes| +|`x - y`|`duration`|`duration`|Difference of durations| +|`x * y`|`duration`|`number`|N times a duration| +|`x * y`|`number`|`duration`|N times a duration| +|`x / y`|`duration`|`number`|Fraction of a duration| > [!NOTE] -> Not all combinations of values may be supported by an operator. Expressions that, when evaluated, encounter undefined operator conditions evaluate to errors. For more information about errors in M, see [Errors](errors.md) +> Not all combinations of values can be supported by an operator. Expressions that, when evaluated, encounter undefined operator conditions evaluate to errors. For more information about errors in M, go to [Errors](errors.md) **Error example**: |Function|Equals| |------------|----------| -|1 + "2"|Error: adding number and text is not supported| - +|`1 + "2"`|Error: adding number and text is not supported| + \ No newline at end of file diff --git a/query-languages/m/oracle-database.md b/query-languages/m/oracle-database.md index 160638f06..95413b2c4 100644 --- a/query-languages/m/oracle-database.md +++ b/query-languages/m/oracle-database.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Oracle.Database" -title: "Oracle.Database | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Oracle.Database" +ms.subservice: m-source --- # Oracle.Database @@ -19,13 +13,13 @@ Oracle.Database(server as text, optional options as nullable recor ## About -Returns a table of SQL tables and views from the Oracle database on server `server`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: +Returns a table of SQL tables and views from the Oracle database on server `server`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: -* `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). -* `NavigationPropertyNameGenerator` : A function that is used for the creation of names for navigation properties. -* `Query` : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. -* `CommandTimeout` : A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. -* `ConnectionTimeout` : 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. -* `HierarchicalNavigation` : A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). +* `NavigationPropertyNameGenerator`: A function that is used for the creation of names for navigation properties. +* `Query`: A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. +* `CommandTimeout`: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. +* `ConnectionTimeout`: 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. +* `HierarchicalNavigation`: A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). - The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. +The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. diff --git a/query-languages/m/order-type.md b/query-languages/m/order-type.md index 3bd01dfef..da9f8e4ac 100644 --- a/query-languages/m/order-type.md +++ b/query-languages/m/order-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Order.Type" -title: "Order.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Order.Type" +ms.subservice: m-source --- # Order.Type diff --git a/query-languages/m/pdf-tables.md b/query-languages/m/pdf-tables.md index f4de3ad1c..31a97248b 100644 --- a/query-languages/m/pdf-tables.md +++ b/query-languages/m/pdf-tables.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Pdf.Tables" -title: "Pdf.Tables | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Pdf.Tables" +ms.subservice: m-source --- # Pdf.Tables diff --git a/query-languages/m/percentage-from.md b/query-languages/m/percentage-from.md index cccd3182a..727abef14 100644 --- a/query-languages/m/percentage-from.md +++ b/query-languages/m/percentage-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Percentage.From" -title: "Percentage.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Percentage.From" +ms.subservice: m-source --- # Percentage.From @@ -35,3 +28,7 @@ Percentage.From("12.3%") **Output** `0.123` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/percentilemode-type.md b/query-languages/m/percentilemode-type.md index 10c3cbada..4cef140d6 100644 --- a/query-languages/m/percentilemode-type.md +++ b/query-languages/m/percentilemode-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: PercentileMode.Type" -title: "PercentileMode.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "PercentileMode.Type" +ms.subservice: m-source --- # PercentileMode.Type diff --git a/query-languages/m/postgresql-database.md b/query-languages/m/postgresql-database.md index 266a61017..fd7dc01d8 100644 --- a/query-languages/m/postgresql-database.md +++ b/query-languages/m/postgresql-database.md @@ -1,32 +1,29 @@ --- description: "Learn more about: PostgreSQL.Database" -title: "PostgreSQL.Database | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "PostgreSQL.Database" +ms.subservice: m-source --- # PostgreSQL.Database ## Syntax
-PostgreSQL.Database(server as text, database as text, optional options as nullable record) as table
+PostgreSQL.Database(
+    server as text,
+    database as text,
+    optional options as nullable record
+) as table
 
## About -Returns a table of SQL tables and views available in a PostgreSQL database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: +Returns a table of SQL tables and views available in a PostgreSQL database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: -* `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). -* `NavigationPropertyNameGenerator` : A function that is used for the creation of names for navigation properties. -* `Query` : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. -* `CommandTimeout` : A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. -* `ConnectionTimeout` : 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. -* `HierarchicalNavigation` : A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). +* `NavigationPropertyNameGenerator`: A function that is used for the creation of names for navigation properties. +* `Query`: A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. +* `CommandTimeout`: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. +* `ConnectionTimeout`: 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. +* `HierarchicalNavigation`: A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). - The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. - +The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. diff --git a/query-languages/m/power-query-m-function-reference.md b/query-languages/m/power-query-m-function-reference.md index fea43be15..283076315 100644 --- a/query-languages/m/power-query-m-function-reference.md +++ b/query-languages/m/power-query-m-function-reference.md @@ -1,24 +1,19 @@ --- description: "Learn more about: Power Query M function reference" -title: "Power Query M function reference | Microsoft Docs" -ms.date: 7/31/2019 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Power Query M function reference" +ms.date: 6/9/2025 +ms.custom: "nonautomated-date" --- # Power Query M function reference -The Power Query M function reference includes articles for each of the over 700 functions. The reference articles you see here on docs.microsoft.com are auto-generated from in-product help. To learn more about functions and how they work in an expression, see [Understanding Power Query M functions](understanding-power-query-m-functions.md). +The Power Query M function reference includes articles for each of the over 700 functions. These reference articles are auto-generated from in-product help. To learn more about functions and how they work in an expression, go to [Understanding Power Query M functions](understanding-power-query-m-functions.md). ## Functions by category * [Accessing data functions](accessing-data-functions.md) * [Binary functions](binary-functions.md) * [Combiner functions](combiner-functions.md) -* [Comparer functions](comparer-functions.md) +* [Comparer functions](comparer-functions.md) * [Date functions](date-functions.md) * [DateTime functions](datetime-functions.md) * [DateTimeZone functions](datetimezone-functions.md) @@ -26,19 +21,16 @@ The Power Query M function reference includes articles for each of the over 700 * [Error handling](error-handling.md) * [Expression functions](expression-functions.md) * [Function values](function-values.md) -* [List functions](list-functions.md) +* [List functions](list-functions.md) * [Lines functions](lines-functions.md) * [Logical functions](logical-functions.md) * [Number functions](number-functions.md) * [Record functions](record-functions.md) -* [Replacer functions](replacer-functions.md) -* [Splitter functions](splitter-functions.md) +* [Replacer functions](replacer-functions.md) +* [Splitter functions](splitter-functions.md) * [Table functions](table-functions.md) * [Text functions](text-functions.md) * [Time functions](time-functions.md) * [Type functions](type-functions.md) * [Uri functions](uri-functions.md) * [Value functions](value-functions.md) - - - diff --git a/query-languages/m/power-query-m-language-specification.md b/query-languages/m/power-query-m-language-specification.md index dd4472428..9505bd5cb 100644 --- a/query-languages/m/power-query-m-language-specification.md +++ b/query-languages/m/power-query-m-language-specification.md @@ -1,17 +1,14 @@ --- description: "Learn more about: Power Query M language specification" -title: "Power Query M language specification | Microsoft Docs" -ms.date: 4/7/2020 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Power Query M language specification" +ms.topic: conceptual +ms.date: 11/14/2024 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- # Power Query M language specification -The specification describes the values, expressions, environments and variables, identifiers, and the evaluation model that form the Power Query M language’s basic concepts. +The specification describes the values, expressions, environments and variables, identifiers, and the evaluation model that form the Power Query M language's basic concepts. The specification is contained in the following topics. @@ -27,4 +24,3 @@ The specification is contained in the following topics. * [Error Handling](m-spec-error-handling.md) * [Sections](m-spec-sections.md) * [Consolidated Grammar](m-spec-consolidated-grammar.md) - diff --git a/query-languages/m/power-query-m-type-system.md b/query-languages/m/power-query-m-type-system.md index 0cff589e5..dd914a56a 100644 --- a/query-languages/m/power-query-m-type-system.md +++ b/query-languages/m/power-query-m-type-system.md @@ -1,14 +1,10 @@ ---- +--- description: "Learn more about: Types in the Power Query M formula language" -title: "Power Query M type system | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Power Query M type system" +ms.topic: conceptual +ms.date: 8/2/2022 +ms.custom: "nonautomated-date" +ms.subservice: m-specification --- # Types in the Power Query M formula language @@ -20,7 +16,7 @@ Developers should have a thorough understanding of the type system in-order to d By exploring the M type system more carefully, many of these issues can be clarified, and developers will be empowered to craft the solutions they need. Knowledge of predicate calculus and naïve set theory should be adequate to understand the notation used. - + ## PRELIMINARIES (1) *B* := { _true_; _false_ }
@@ -46,13 +42,13 @@ _Fn is the set of all sets of n record fields._ (8) *F*\* := ( ⋃*0≤i≤∞* *F**i* ) ∖ { _F_ | ⟨_b1_, _n1_, _t1_⟩, ⟨_b2_, _n2_, _t2_⟩ ∈ _F_ ⋀ _n1_ = _n2_ }
_F\* is the set of all sets (of any length) of record fields, except for the sets where more than one field has the same name._ - + (9) *C* := ⟨*N*,*T*⟩
_C is the set of column types, for tables. Each column has a name and a type._ (10) *C**n* ⊂ ⋃_0≤i≤n_ ⟨*i*, *C*⟩
_Cn is the set of all ordered sequences of n column types._ - + (11) _C_\* := ( ⋃_0≤i≤∞_ *C**i* ) ∖ { *C**m* | ⟨*a*, ⟨*n1*, *t1*⟩⟩, ⟨*b*, ⟨*n2*, *t2*⟩⟩ ∈ _Cm_ ⋀ *n1* = *n2* }
_C\* is the set of all combinations (of any length) of column types, except for those where more than one column has the same name._ @@ -81,7 +77,7 @@ _A Primitive Type is one from this list of M keywords._ (19) *T**N* := { *tn*, u ∈ *T* | *tn* = u+null } = nullable *t*
_Any type can additionally be marked as being nullable, by using the_ "nullable" _keyword._ - + (20) *T* := _TF_ ∪ _TL_ ∪ _TR_ ∪ _TT_ ∪ _TP_ ∪ _TN_
_The set of all M types is the union of these six sets of types: Function Types, List Types, Record Types, Table Types, Primitive Types, and Nullable Types._ @@ -102,15 +98,15 @@ Some identities are needed to define some special cases, and may also help eluci (25) nullable nullable *t* ∈ *T* = nullable *t*
(26) *NonNullable*(nullable *t* ∈ *T*) = *NonNullable*(*t*)
(27) *NonNullable*(any) = anynonnull
- + ## TYPE COMPATIBILITY As defined elsewhere, an M type is compatable with another M type if and only if all values that conform to the first type also conform to the second type. -Here is defined a compatability relation that does not depend on conforming values, and is based on the properties of the types themselves. It is anticiplated that this relation, as defined in this document, is completely equivalent to the original semantic definition. +Here is defined a compatibility relation that does not depend on conforming values, and is based on the properties of the types themselves. It is anticipated that this relation, as defined in this document, is completely equivalent to the original semantic definition. -The "is compatible with" relation : ≤ : *B* ← *T* × *T*
-In the below section, a lowercase *t* will always represent an M Type, an element of *T*. +The "is compatible with" relation : ≤ : *B* ← *T* × *T*
+In the below section, a lowercase *t* will always represent an M Type, an element of *T*. A *Φ* will represent a subset of *F*\*, or of *C*\*. @@ -170,18 +166,13 @@ _A record type with a non-optional field is compatible with a record type identi (46) _ta_ ∈ *T**R*o = ⟨true, (_Φ_, ⟨b, n, u⟩)⟩, _tb_ ∈ *T**R*o = ⟨true, _Φ_⟩ → _ta_ ≤ _tb_
_An open record type is compatible with another open record type with one fewer field._ - + (47) _ta_ ∈ _TT_ = (_Φ_, ⟨i, ⟨n, _ua_⟩⟩), _tb_ ∈ _TT_ = (_Φ_, ⟨i, ⟨n, _ub_⟩⟩) ∧ _ua_ ≤ _ub_ → _ta_ ≤ _tb_
_A table type is compatible with a second table type, which is identical but for one column having a differing type, when the types for that column are compatible._ -## REFERENCES - -Microsoft Corporation (2015 August)
-Microsoft Power Query for Excel Formula Language Specification [PDF]
-Retrieved from https://msdn.microsoft.com/library/mt807488.aspx - -Microsoft Corporation (n.d.)
-Power Query M function reference [web page]
-Retrieved from https://msdn.microsoft.com/library/mt779182.aspx - +## Related content +* [Power Query M language specification](power-query-m-language-specification.md) +* [Power Query M function reference](power-query-m-function-reference.md) +* [Types and type conversion](type-conversion.md) +* [Types](m-spec-types.md) diff --git a/query-languages/m/precision-type.md b/query-languages/m/precision-type.md index a94aff04c..7b2b924ff 100644 --- a/query-languages/m/precision-type.md +++ b/query-languages/m/precision-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Precision.Type" -title: "Precision.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Precision.Type" +ms.subservice: m-source --- # Precision.Type diff --git a/query-languages/m/progress-datasourceprogress.md b/query-languages/m/progress-datasourceprogress.md new file mode 100644 index 000000000..9cdeef2fe --- /dev/null +++ b/query-languages/m/progress-datasourceprogress.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Progress.DataSourceProgress" +title: "Progress.DataSourceProgress" +ms.subservice: m-source +--- +# Progress.DataSourceProgress + +## Syntax + +
+Progress.DataSourceProgress() as any
+
+ +## About + +This function is intended for internal use only. diff --git a/query-languages/m/quick-tour-of-the-power-query-m-formula-language.md b/query-languages/m/quick-tour-of-the-power-query-m-formula-language.md index 08ffeef2d..06c807e8d 100644 --- a/query-languages/m/quick-tour-of-the-power-query-m-formula-language.md +++ b/query-languages/m/quick-tour-of-the-power-query-m-formula-language.md @@ -1,96 +1,90 @@ --- description: "Learn more about: Quick tour of the Power Query M formula language" -title: "Quick tour | Microsoft Docs" -ms.date: 12/12/2018 -ms.service: powerquery -ms.reviewer: ehvonleh +title: "Quick tour" +ms.date: 1/27/2025 +ms.custom: nonautomated-date, intro-internal ms.topic: conceptual -author: dougklopfenstein -ms.author: dougklo -ms.custom: intro-internal - +ms.subservice: m-background --- # Quick tour of the Power Query M formula language -This quick tour describes creating Power Query M formula language queries. - -> [!NOTE] -> M is a case-sensitive language. - -## Create a query with Query Editor +This quick tour describes creating Power Query M formula language queries. + +> [!NOTE] +> M is a case-sensitive language. + +## Create a query with the Power Query editor + +To create an advanced query, you use the [Power Query advanced editor](/power-query/power-query-ui#the-advanced-editor). A mashup query is composed of variables, expressions, and values encapsulated by a `let` expression. A variable can contain spaces by using the # identifier with the name in quotes as in `#"Variable name"`. + +A `let` expression follows this structure: -To create an advanced query, you use the **Query Editor**. A mashup query is composed of variables, expressions, and values encapsulated by a **let** expression. A variable can contain spaces by using the # identifier with the name in quotes as in #"Variable name". - -A **let** expression follows this structure: - ```powerquery-m -let - Variablename = expression, - #"Variable name" = expression2 -in - Variablename +let + Variablename = expression, + #"Variable name" = expression2 +in + Variablename ``` -To create an M query in the **Query Editor**, you follow this basic process: - -- Create a series of query formula steps that start with the **let** statement. Each step is defined by a step variable name. An M **variable** can include spaces by using the # character as #"Step Name". A formula step can be a custom formula. Please note that the Power Query Formula Language is case sensitive. - -- Each query formula step builds upon a previous step by referring to a step by its variable name. - -- Output a query formula step using the **in** statement. Generally, the last query step is used as the in final data set result. - - -To learn more about expressions and values, see [Expressions, values, and let expression](expressions-values-and-let-expression.md). - -## Simple Power Query M formula steps +To create an M query in the advanced editor, you follow this basic process: + +1. Create a series of query formula steps that start with the `let` statement. Each step is defined by a step variable name. An M _variable_ can include spaces by using the # character, such as `#"Step Name"`. A formula step can be a custom formula. Also note that the Power Query formula language is case sensitive. + +2. Each query formula step builds upon a previous step by referring to a step by its variable name. + +3. Output a query formula step using the `in` statement. Generally, the last query step is used as the `in` final data set result. + +To learn more about expressions and values, go to [Expressions, values, and let expression](expressions-values-and-let-expression.md). + +## Simple Power Query M formula steps + +Let's assume you created the following transform in the Power Query editor. This query converts product names to the appropriate case, in this instance, to all initial capitalization. + +:::image type="content" source="media/mstep1.png" alt-text="Screenshot of the Power Query editor showing the results of converting the Item column entries to initial capitalization."::: + +To begin with, you have a table that looks like this: + +|:::no-loc text="OrderID":::|:::no-loc text="CustomerID":::|:::no-loc text="Item":::|:::no-loc text="Price":::| +|-----------|--------------|--------|---------| +|1|1|:::no-loc text="fishing rod":::|100| +|2|1|:::no-loc text="1 lb. worms":::|5| +|3|2|:::no-loc text="fishing net":::|25| + +And, you want to capitalize the first letter in each word in the Item column to produce the following table: + +|:::no-loc text="OrderID":::|:::no-loc text="CustomerID":::|:::no-loc text="Item":::|:::no-loc text="Price":::| +|-----------|--------------|--------|---------| +|1|1|:::no-loc text="Fishing Rod":::|100| +|2|1|:::no-loc text="1 Lb. Worms":::|5| +|3|2|:::no-loc text="Fishing Net":::|25| + +The M formula steps to project the original table into the results table look like this in the Power Query advanced editor: + +:::image type="content" source="media/madvancededitor.png" alt-text="Screenshot of the Power Query advanced editor with all of the M formula steps to produce the table and capitalize initial letters."::: + +Here's the code you can paste into the Power Query advanced editor: -Let's assume you created the following transform in the **Query Editor** to convert product names to proper case. - -![Intro to M Step 1](media/mstep1.png "Intro to M Step 1") - -**You have a table that looks like this:** - -|OrderID|CustomerID|Item|Price| -|-----------|--------------|--------|---------| -|1|1|fishing rod|100| -|2|1|1 lb. worms|5| -|3|2|fishing net|25| - -**And, you want to capitalize each word in the Item column to produce the following table:** - -|OrderID|CustomerID|Item|Price| -|-----------|--------------|--------|---------| -|1|1|Fishing Rod|100| -|2|1|1 Lb. Worms|5| -|3|2|Fishing Net|25| - -**The M formula steps to project the original table into the results table looks like this:** - -![Advanced Editor](media/madvancededitor.png "Advanced Editor") - -Here's the code you can paste into **Query Editor**: - ```powerquery-m -let Orders = Table.FromRecords({ - [OrderID = 1, CustomerID = 1, Item = "fishing rod", Price = 100.0], - [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0], - [OrderID = 3, CustomerID = 2, Item = "fishing net", Price = 25.0]}), - #"Capitalized Each Word" = Table.TransformColumns(Orders, {"Item", Text.Proper}) -in - #"Capitalized Each Word" -``` +let Orders = Table.FromRecords({ + [OrderID = 1, CustomerID = 1, Item = "fishing rod", Price = 100.0], + [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0], + [OrderID = 3, CustomerID = 2, Item = "fishing net", Price = 25.0]}), + #"Capitalized Each Word" = Table.TransformColumns(Orders, {"Item", Text.Proper}) +in + #"Capitalized Each Word" +``` -**Let’s review each formula step.** - -1. **Orders** – Create a \[Table](#_Table_value) with data for Orders. - -2. \#**"Capitalized Each Word"** – To capitalize each word, you use Table.TransformColumns(). - -3. **in #"Capitalized Each Word"** – Output the table with each word capitalized. - -## See also +Let's review each formula step. + +1. **Orders**: Create a table with data for Orders. -[Expressions, values, and let expression](expressions-values-and-let-expression.md) -[Operators](operators.md) -[Type conversion](type-conversion.md) +2. **#"Capitalized Each Word"**: To capitalize each word, you use [Table.TransformColumns](table-transformcolumns.md). + +3. **in #"Capitalized Each Word"**: Output the table with the first letter of each word capitalized. +## Related content + +* [Expressions, values, and let expression](expressions-values-and-let-expression.md) +* [Operators](operators.md) +* [Type conversion](type-conversion.md) diff --git a/query-languages/m/quotestyle-type.md b/query-languages/m/quotestyle-type.md index b06765ea5..0cf40d016 100644 --- a/query-languages/m/quotestyle-type.md +++ b/query-languages/m/quotestyle-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: QuoteStyle.Type" -title: "QuoteStyle.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "QuoteStyle.Type" +ms.subservice: m-source --- # QuoteStyle.Type diff --git a/query-languages/m/rankkind-type.md b/query-languages/m/rankkind-type.md index 9c33df335..6fdc6c232 100644 --- a/query-languages/m/rankkind-type.md +++ b/query-languages/m/rankkind-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: RankKind.Type" -title: "RankKind.Type | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "RankKind.Type" +ms.subservice: m-source --- # RankKind.Type diff --git a/query-languages/m/rdata-frombinary.md b/query-languages/m/rdata-frombinary.md index 863921174..b110dd198 100644 --- a/query-languages/m/rdata-frombinary.md +++ b/query-languages/m/rdata-frombinary.md @@ -1,23 +1,16 @@ --- description: "Learn more about: RData.FromBinary" -title: "RData.FromBinary | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "RData.FromBinary" +ms.subservice: m-source --- # RData.FromBinary ## Syntax
-RData.FromBinary(stream as binary) as any  
+RData.FromBinary(stream as binary) as any
 
-## About -Returns a record of data frames from the RData file. - +## About + +Returns a record of data frames from the RData file. diff --git a/query-languages/m/record-addfield.md b/query-languages/m/record-addfield.md index 8170f365d..4bafe18bc 100644 --- a/query-languages/m/record-addfield.md +++ b/query-languages/m/record-addfield.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Record.AddField" -title: "Record.AddField | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.AddField" +ms.subservice: m-source --- # Record.AddField ## Syntax
-Record.AddField(record as record, fieldName as text, value as any, optional delayed as nullable logical) as record
+Record.AddField(
+    record as record,
+    fieldName as text,
+    value as any,
+    optional delayed as nullable logical
+) as record
 
## About diff --git a/query-languages/m/record-combine.md b/query-languages/m/record-combine.md index ff4275a7a..36922daa8 100644 --- a/query-languages/m/record-combine.md +++ b/query-languages/m/record-combine.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.Combine" -title: "Record.Combine | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.Combine" +ms.subservice: m-source --- # Record.Combine diff --git a/query-languages/m/record-field.md b/query-languages/m/record-field.md index 1997b24a7..6a7996cf3 100644 --- a/query-languages/m/record-field.md +++ b/query-languages/m/record-field.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.Field" -title: "Record.Field | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.Field" +ms.subservice: m-source --- # Record.Field diff --git a/query-languages/m/record-fieldcount.md b/query-languages/m/record-fieldcount.md index ba2fe3f14..c38eb9616 100644 --- a/query-languages/m/record-fieldcount.md +++ b/query-languages/m/record-fieldcount.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.FieldCount" -title: "Record.FieldCount | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.FieldCount" +ms.subservice: m-source --- # Record.FieldCount diff --git a/query-languages/m/record-fieldnames.md b/query-languages/m/record-fieldnames.md index 8f217c725..d53570f37 100644 --- a/query-languages/m/record-fieldnames.md +++ b/query-languages/m/record-fieldnames.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.FieldNames" -title: "Record.FieldNames | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.FieldNames" +ms.subservice: m-source --- # Record.FieldNames diff --git a/query-languages/m/record-fieldordefault.md b/query-languages/m/record-fieldordefault.md index cd45fb9b2..30861c5a1 100644 --- a/query-languages/m/record-fieldordefault.md +++ b/query-languages/m/record-fieldordefault.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Record.FieldOrDefault" -title: "Record.FieldOrDefault | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.FieldOrDefault" +ms.subservice: m-source --- # Record.FieldOrDefault ## Syntax
-Record.FieldOrDefault(record as nullable record, field as text, optional defaultValue as any) as any
+Record.FieldOrDefault(
+    record as nullable record,
+    field as text,
+    optional defaultValue as any
+) as any
 
## About diff --git a/query-languages/m/record-fieldvalues.md b/query-languages/m/record-fieldvalues.md index 5f5b652d9..75ad89ea7 100644 --- a/query-languages/m/record-fieldvalues.md +++ b/query-languages/m/record-fieldvalues.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.FieldValues" -title: "Record.FieldValues | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.FieldValues" +ms.subservice: m-source --- # Record.FieldValues diff --git a/query-languages/m/record-fromlist.md b/query-languages/m/record-fromlist.md index bb2c7b769..25e27c39a 100644 --- a/query-languages/m/record-fromlist.md +++ b/query-languages/m/record-fromlist.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.FromList" -title: "Record.FromList | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.FromList" +ms.subservice: m-source --- # Record.FromList diff --git a/query-languages/m/record-fromtable.md b/query-languages/m/record-fromtable.md index cec02eb21..f16422cd8 100644 --- a/query-languages/m/record-fromtable.md +++ b/query-languages/m/record-fromtable.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.FromTable" -title: "Record.FromTable | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.FromTable" +ms.subservice: m-source --- # Record.FromTable diff --git a/query-languages/m/record-functions.md b/query-languages/m/record-functions.md index e0d6b6b9a..e1dec6e1e 100644 --- a/query-languages/m/record-functions.md +++ b/query-languages/m/record-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Record functions" -title: "Record functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record functions" +ms.date: 6/19/2025 +ms.custom: "nonautomated-date" --- # Record functions @@ -33,9 +27,9 @@ These functions create and manipulate record values. |[GeometryPoint.From](geometrypoint-from.md)|Creates a record representing a geometric point from parts.| |[Record.AddField](record-addfield.md)|Adds a field from a field name and value.| |[Record.Combine](record-combine.md)|Combines the records in a list.| -|[Record.RemoveFields](record-removefields.md)|Returns a new record that reorders the given fields with respect to each other. Any fields not specified remain in their original locations.| +|[Record.RemoveFields](record-removefields.md)|Removes the specified field(s) from the input record.| |[Record.RenameFields](record-renamefields.md)|Returns a new record that renames the fields specified. The resultant fields will retain their original order. This function supports swapping and chaining field names. However, all target names plus remaining field names must constitute a unique set or an error will occur.| -|[Record.ReorderFields](record-reorderfields.md)|Returns a new record that reorders fields relative to each other. Any fields not specified remain in their original locations. Requires two or more fields.| +|[Record.ReorderFields](record-reorderfields.md)|Reorders record fields to match the order of a list of field names.| |[Record.TransformFields](record-transformfields.md)|Transforms fields by applying transformOperations. For more more information about values supported by transformOperations, go to [Parameter Values](#parameter-values).| ## Selection diff --git a/query-languages/m/record-hasfields.md b/query-languages/m/record-hasfields.md index 7f2c64c13..49e6a24bb 100644 --- a/query-languages/m/record-hasfields.md +++ b/query-languages/m/record-hasfields.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.HasFields" -title: "Record.HasFields | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.HasFields" +ms.subservice: m-source --- # Record.HasFields diff --git a/query-languages/m/record-removefields.md b/query-languages/m/record-removefields.md index 2404a7ddd..534beb22a 100644 --- a/query-languages/m/record-removefields.md +++ b/query-languages/m/record-removefields.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Record.RemoveFields" -title: "Record.RemoveFields | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.RemoveFields" +ms.subservice: m-source --- # Record.RemoveFields ## Syntax
-Record.RemoveFields(record as record, fields as any, optional missingField as nullable number) as record
+Record.RemoveFields(
+    record as record,
+    fields as any,
+    optional missingField as nullable number
+) as record
 
## About diff --git a/query-languages/m/record-renamefields.md b/query-languages/m/record-renamefields.md index 02d1be618..a75382544 100644 --- a/query-languages/m/record-renamefields.md +++ b/query-languages/m/record-renamefields.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Record.RenameFields" -title: "Record.RenameFields | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.RenameFields" +ms.subservice: m-source --- # Record.RenameFields ## Syntax
-Record.RenameFields(record as record, renames as list, optional missingField as nullable number) as record  
+Record.RenameFields(
+    record as record,
+    renames as list,
+    optional missingField as nullable number
+) as record  
 
## About -Returns a record after renaming fields in the input `record` to the new field names specified in list `renames`. For multiple renames, a nested list can be used ({ {old1, new1}, {old2, new2} }. +Returns a record after renaming fields in the input `record` to the new field names specified in list `renames`. For multiple renames, a nested list can be used ({ {old1, new1}, {old2, new2} }). ## Example 1 diff --git a/query-languages/m/record-reorderfields.md b/query-languages/m/record-reorderfields.md index 56a82443d..6a893855f 100644 --- a/query-languages/m/record-reorderfields.md +++ b/query-languages/m/record-reorderfields.md @@ -1,26 +1,30 @@ --- description: "Learn more about: Record.ReorderFields" -title: "Record.ReorderFields | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.ReorderFields" +ms.subservice: m-source --- # Record.ReorderFields ## Syntax
-Record.ReorderFields(record as record, fieldOrder as list, optional missingField as nullable number) as record
+Record.ReorderFields(
+    record as record,
+    fieldOrder as list,
+    optional missingField as nullable number
+) as record
 
## About -Returns a record after reordering the fields in `record` in the order of fields specified in list `fieldOrder`. Field values are maintained and fields not listed in `fieldOrder` are left in their original position. +Reorders the fields of a record to match the order of a list of field names. + +* `record`: The record containing the fields to reorder. +* `fieldOrder`: A list containing the new order of the fields to apply to the record. Field values are maintained and fields not listed in this parameter are left in their original positions. +* `missingField`: Specifies the expected action for missing values in a row that contains fewer fields than expected. The following values are valid: + * `MissingField.Error`: (Default) Indicates that missing fields should result in an error. If no value is entered for the `missingField` parameter, this value is used. + * `MissingField.Ignore`: Indicates that missing fields should be ignored. + * `MissingField.UseNull`: Indicates that missing fields should be included as `null` values. ## Example 1 @@ -38,3 +42,25 @@ Record.ReorderFields( **Output** `[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0]` + +## Example 2 + +Reorder some of the fields in the record and include `null` for any missing fields. + +**Usage** + +```powerquery-m +let + Source = [CustomerID = 3, First Name = "Paul", Phone = "543-7890", Purchase = "Fishing Rod"], + reorderedRecord = Record.ReorderFields( + Source, + {"Purchase", "Last Name", "First Name"}, + MissingField.UseNull + ) +in + reorderedRecord +``` + +**Output** + +`[CustomerID = 3, Purchase = "Fishing Rod", Phone = "543-7890", Last Name = null, First Name = "Paul"]` diff --git a/query-languages/m/record-selectfields.md b/query-languages/m/record-selectfields.md index 73da6b9ef..cc0729ccf 100644 --- a/query-languages/m/record-selectfields.md +++ b/query-languages/m/record-selectfields.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Record.SelectFields" -title: "Record.SelectFields | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.SelectFields" +ms.subservice: m-source --- # Record.SelectFields ## Syntax
-Record.SelectFields(record as record, fields as any, optional missingField as nullable number) as record
+Record.SelectFields(
+    record as record,
+    fields as any,
+    optional missingField as nullable number
+) as record
 
## About diff --git a/query-languages/m/record-tolist.md b/query-languages/m/record-tolist.md index 0d1f6b870..656a1ba40 100644 --- a/query-languages/m/record-tolist.md +++ b/query-languages/m/record-tolist.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.ToList" -title: "Record.ToList | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.ToList" +ms.subservice: m-source --- # Record.ToList diff --git a/query-languages/m/record-totable.md b/query-languages/m/record-totable.md index 7b29059a5..04ea58a2d 100644 --- a/query-languages/m/record-totable.md +++ b/query-languages/m/record-totable.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Record.ToTable" -title: "Record.ToTable | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.ToTable" +ms.subservice: m-source --- # Record.ToTable diff --git a/query-languages/m/record-transformfields.md b/query-languages/m/record-transformfields.md index 22d52e6ff..eb9fba1ad 100644 --- a/query-languages/m/record-transformfields.md +++ b/query-languages/m/record-transformfields.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Record.TransformFields" -title: "Record.TransformFields | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Record.TransformFields" +ms.subservice: m-source --- # Record.TransformFields ## Syntax
-Record.TransformFields(record as record, transformOperations as list, optional missingField as nullable number) as record
+Record.TransformFields(
+    record as record,
+    transformOperations as list,
+    optional missingField as nullable number
+) as record
 
## About diff --git a/query-languages/m/relativeposition-type.md b/query-languages/m/relativeposition-type.md index ad3a01578..1e63ba463 100644 --- a/query-languages/m/relativeposition-type.md +++ b/query-languages/m/relativeposition-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: RelativePosition.Type" -title: "RelativePosition.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "RelativePosition.Type" +ms.subservice: m-source --- # RelativePosition.Type diff --git a/query-languages/m/replacer-functions.md b/query-languages/m/replacer-functions.md index 5a8441ded..8ce9109fb 100644 --- a/query-languages/m/replacer-functions.md +++ b/query-languages/m/replacer-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Replacer functions" -title: "Replacer functions | Microsoft Docs" +title: "Replacer functions" ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +ms.custom: "nonautomated-date" --- # Replacer functions diff --git a/query-languages/m/replacer-replacetext.md b/query-languages/m/replacer-replacetext.md index a598f0363..c9cc0ef5a 100644 --- a/query-languages/m/replacer-replacetext.md +++ b/query-languages/m/replacer-replacetext.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Replacer.ReplaceText" -title: "Replacer.ReplaceText | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Replacer.ReplaceText" +ms.subservice: m-source --- # Replacer.ReplaceText ## Syntax
-Replacer.ReplaceText(text as nullable text, old as text, new as text) as nullable text
+Replacer.ReplaceText(
+    text as nullable text,
+    old as text,
+    new as text
+) as nullable text
 
## About diff --git a/query-languages/m/replacer-replacevalue.md b/query-languages/m/replacer-replacevalue.md index 9b9daf6e5..eb350787a 100644 --- a/query-languages/m/replacer-replacevalue.md +++ b/query-languages/m/replacer-replacevalue.md @@ -1,21 +1,17 @@ --- description: "Learn more about: Replacer.ReplaceValue" -title: "Replacer.ReplaceValue | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Replacer.ReplaceValue" +ms.subservice: m-source --- # Replacer.ReplaceValue ## Syntax
-Replacer.ReplaceValue(value as any, old as any, new as any) as any
+Replacer.ReplaceValue(
+    value as any,
+    old as any,
+    new as any) as any
 
## About diff --git a/query-languages/m/roundingmode-type.md b/query-languages/m/roundingmode-type.md index d82213352..73b5c244c 100644 --- a/query-languages/m/roundingmode-type.md +++ b/query-languages/m/roundingmode-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: RoundingMode.Type" -title: "RoundingMode.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "RoundingMode.Type" +ms.subservice: m-source --- # RoundingMode.Type diff --git a/query-languages/m/rowexpression-column.md b/query-languages/m/rowexpression-column.md index 60eac020d..bdbb7a405 100644 --- a/query-languages/m/rowexpression-column.md +++ b/query-languages/m/rowexpression-column.md @@ -1,14 +1,7 @@ --- description: "Learn more about: RowExpression.Column" -title: "RowExpression.Column | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "RowExpression.Column" +ms.subservice: m-source --- # RowExpression.Column diff --git a/query-languages/m/rowexpression-from.md b/query-languages/m/rowexpression-from.md index a4e1ebba1..8334e08a8 100644 --- a/query-languages/m/rowexpression-from.md +++ b/query-languages/m/rowexpression-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: RowExpression.From" -title: "RowExpression.From | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "RowExpression.From" +ms.subservice: m-source --- # RowExpression.From @@ -17,14 +10,14 @@ ms.author: dougklo
 RowExpression.From(function as function) as record
 
- -## About + +## About Returns the abstract syntax tree (AST) for the body of `function`, normalized into a _row expression_: * The function must be a 1-argument lambda. -* All references to the function parameter are replaced with `RowExpression.Row`. -* All references to columns are replaced with RowExpression.Column(_columnName_). +* All references to the function parameter are replaced with [`RowExpression.Row`](rowexpression-row.md). +* All references to columns are replaced with [`RowExpression.Column(columnName)`](rowexpression-column.md). * The AST will be simplified to contain only nodes of the kinds: * `Constant` * `Invocation` @@ -32,13 +25,14 @@ Returns the abstract syntax tree (AST) for the body of `function`, normalized in * `Binary` * `If` * `FieldAccess` - * `NotImplemented` An error is raised if a row expression AST cannot be returned for the body of `function`. + +This function is identical to [`ItemExpression.From`](itemexpression-from.md). ## Example 1 -Returns the AST for the body of the function each [CustomerID] = "ALFKI" +Returns the AST for the body of the function `each [CustomerID] = "ALFKI"`. **Usage** diff --git a/query-languages/m/rowexpression-row.md b/query-languages/m/rowexpression-row.md index 5764148c8..b2f5f0a15 100644 --- a/query-languages/m/rowexpression-row.md +++ b/query-languages/m/rowexpression-row.md @@ -1,17 +1,12 @@ --- description: "Learn more about: RowExpression.Row" -title: "RowExpression.Row | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "RowExpression.Row" +ms.subservice: m-source --- # RowExpression.Row ## About An abstract syntax tree (AST) node representing the row in a row expression. + +This value is identical to [`ItemExpression.Item`](itemexpression-item.md). diff --git a/query-languages/m/salesforce-data.md b/query-languages/m/salesforce-data.md index 3e8332c80..db053e5b6 100644 --- a/query-languages/m/salesforce-data.md +++ b/query-languages/m/salesforce-data.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Salesforce.Data" -title: "Salesforce.Data | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Salesforce.Data" +ms.subservice: m-source --- # Salesforce.Data @@ -19,7 +13,8 @@ Salesforce.Data(optional loginUrl as any, optional options as null ## About -Returns the objects on the Salesforce account provided in the credentials. The account will be connected through the provided environment `loginUrl`. If no environment is provided then the account will connect to production (https://login.salesforce.com). An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: -* `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is false). -* `ApiVersion` : The Salesforce API version to use for this query. When not specified, API version 29.0 is used. -* `Timeout` : A duration that controls how long to wait before abandoning the request to the server. The default value is source-specific. +Returns the objects on the Salesforce account provided in the credentials. The account will be connected through the provided environment `loginUrl`. If no environment is provided then the account will connect to production (https://login.salesforce.com). An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: + +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is false). +* `ApiVersion`: The Salesforce API version to use for this query. When not specified, API version 29.0 is used. +* `Timeout`: A duration that controls how long to wait before abandoning the request to the server. The default value is source-specific. diff --git a/query-languages/m/salesforce-reports.md b/query-languages/m/salesforce-reports.md index 463e3fa77..8d3e4e8c9 100644 --- a/query-languages/m/salesforce-reports.md +++ b/query-languages/m/salesforce-reports.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Salesforce.Reports" -title: "Salesforce.Reports | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Salesforce.Reports" +ms.subservice: m-source --- # Salesforce.Reports @@ -21,5 +15,5 @@ Salesforce.Reports(optional loginUrl as nullable text, optional option Returns the reports on the Salesforce account provided in the credentials. The account will be connected through the provided environment `loginUrl`. If no environment is provided then the account will connect to production (https://login.salesforce.com). An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: -* `ApiVersion` : The Salesforce API version to use for this query. When not specified, API version 29.0 is used. -* `Timeout` : A duration that controls how long to wait before abandoning the request to the server. The default value is source-specific. +* `ApiVersion`: The Salesforce API version to use for this query. When not specified, API version 29.0 is used. +* `Timeout`: A duration that controls how long to wait before abandoning the request to the server. The default value is source-specific. diff --git a/query-languages/m/sapbusinesswarehouse-cubes.md b/query-languages/m/sapbusinesswarehouse-cubes.md index 4c4625a0e..3502ab067 100644 --- a/query-languages/m/sapbusinesswarehouse-cubes.md +++ b/query-languages/m/sapbusinesswarehouse-cubes.md @@ -1,22 +1,22 @@ --- description: "Learn more about: SapBusinessWarehouse.Cubes" -title: "SapBusinessWarehouse.Cubes | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SapBusinessWarehouse.Cubes" +ms.subservice: m-source --- # SapBusinessWarehouse.Cubes ## Syntax
-SapBusinessWarehouse.Cubes(server as text, systemNumberOrSystemId as text, clientId as text, optional optionsOrLogonGroup as any, optional options as nullable record) as table
+SapBusinessWarehouse.Cubes(
+    server as text,
+    systemNumberOrSystemId as text,
+    clientId as text,
+    optional optionsOrLogonGroup as any,
+    optional options as nullable record
+) as table
 
## About + Returns a table of InfoCubes and queries grouped by InfoArea from an SAP Business Warehouse instance at server `server` with system number `systemNumberOrSystemId` and Client ID `clientId`. An optional record parameter, `optionsOrLogonGroup`, may be specified to control options. diff --git a/query-languages/m/sapbusinesswarehouseexecutionmode-type.md b/query-languages/m/sapbusinesswarehouseexecutionmode-type.md index 01e78a479..32e0a5e8d 100644 --- a/query-languages/m/sapbusinesswarehouseexecutionmode-type.md +++ b/query-languages/m/sapbusinesswarehouseexecutionmode-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: SapBusinessWarehouseExecutionMode.Type" -title: "SapBusinessWarehouseExecutionMode.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SapBusinessWarehouseExecutionMode.Type" +ms.subservice: m-source --- # SapBusinessWarehouseExecutionMode.Type diff --git a/query-languages/m/saphana-database.md b/query-languages/m/saphana-database.md index 44a41dddf..98c053cd3 100644 --- a/query-languages/m/saphana-database.md +++ b/query-languages/m/saphana-database.md @@ -1,25 +1,23 @@ --- description: "Learn more about: SapHana.Database" -title: "SapHana.Database | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SapHana.Database" +ms.subservice: m-source --- # SapHana.Database ## Syntax
-SapHana.Database(**server** as text, optional **options** as nullable record) as table
+SapHana.Database(server as text, optional options as nullable record) as table
 
## About -Returns a table of multidimensional packages from the SAP HANA database `server`. An optional record parameter, `options`, may be specified to control the following options: -* `Query` : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. -* `Distribution` : A SapHanaDistribution that sets the value of the "Distribution" property in the connection string. Statement routing is the method of evaluating the correct server node of a distributed system before statement execution. The default value is SapHanaDistribution.All. - + +Returns a table of multidimensional packages from the SAP HANA database `server`. An optional record parameter, `options`, may be specified to control the following options: + +* `Query`: A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. +* `Distribution`: A [SapHanaDistribution](saphanadistribution-type.md) that sets the value of the "Distribution" property in the connection string. Statement routing is the method of evaluating the correct server node of a distributed system before statement execution. The default value is [SapHanaDistribution.All](/powerquery-m/saphanadistribution-type). +* `Implementation`: Specifies the implementation of the SAP HANA connector to use. +* `EnableColumnBinding`: Binds variables to the columns of a SAP HANA result set when fetching data. May potentially improve performance at the cost of slightly higher memory utilization. The default value is false. +* `ConnectionTimeout`: A duration that controls how long to wait before abandoning an attempt to make a connection to the server. The default value is 15 seconds. +* `CommandTimeout`: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. diff --git a/query-languages/m/saphanadistribution-type.md b/query-languages/m/saphanadistribution-type.md index c88a54183..873ea355d 100644 --- a/query-languages/m/saphanadistribution-type.md +++ b/query-languages/m/saphanadistribution-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: SapHanaDistribution.Type" -title: "SapHanaDistribution.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SapHanaDistribution.Type" +ms.subservice: m-source --- # SapHanaDistribution.Type diff --git a/query-languages/m/saphanarangeoperator-type.md b/query-languages/m/saphanarangeoperator-type.md index c245d5cdb..58539e179 100644 --- a/query-languages/m/saphanarangeoperator-type.md +++ b/query-languages/m/saphanarangeoperator-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: SapHanaRangeOperator.Type" -title: "SapHanaRangeOperator.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SapHanaRangeOperator.Type" +ms.subservice: m-source --- # SapHanaRangeOperator.Type diff --git a/query-languages/m/sharepoint-contents.md b/query-languages/m/sharepoint-contents.md index 739082577..cad2473f2 100644 --- a/query-languages/m/sharepoint-contents.md +++ b/query-languages/m/sharepoint-contents.md @@ -1,14 +1,7 @@ --- description: "Learn more about: SharePoint.Contents" -title: "SharePoint.Contents | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SharePoint.Contents" +ms.subservice: m-source --- # SharePoint.Contents @@ -20,7 +13,8 @@ SharePoint.Contents(url as text, optional options as nullable reco ## About -Returns a table containing a row for each folder and document found at the specified SharePoint site, `url`. Each row contains properties of the folder or file and a link to its content. `options` may be specified to control the following options: +Returns a table containing a row for each folder and document found at the specified SharePoint site, `url`. Each row contains properties of the folder or file and a link to its content. `options` may be specified to control the following options: + +* `ApiVersion`: A number (14 or 15) or the text "Auto" that specifies the SharePoint API version to use for this site. When not specified, API version 14 is used. When Auto is specified, the server version will be automatically discovered if possible, otherwise version defaults to 14. Non-English SharePoint sites require at least version 15. -* `ApiVersion` : A number (14 or 15) or the text "Auto" that specifies the SharePoint API version to use for this site. When not specified, API version 14 is used. When Auto is specified, the server version will be automatically discovered if possible, otherwise version defaults to 14. Non-English SharePoint sites require at least version 15. - +* `Implementation`: Optional. Specifies which version of the SharePoint connector to use. Accepted values are `2.0` or `null`. If the value is `2.0`, the 2.0 implementation of the SharePoint connector is used. If the value is `null`, the original implementation of the SharePoint connector is used. diff --git a/query-languages/m/sharepoint-files.md b/query-languages/m/sharepoint-files.md index 07e325239..d922e9a53 100644 --- a/query-languages/m/sharepoint-files.md +++ b/query-languages/m/sharepoint-files.md @@ -1,14 +1,7 @@ --- description: "Learn more about: SharePoint.Files" -title: "SharePoint.Files | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SharePoint.Files" +ms.subservice: m-source --- # SharePoint.Files @@ -20,7 +13,6 @@ SharePoint.Files(url as text, optional options as nullable record) ## About -Returns a table containing a row for each document found at the specified SharePoint site, `url`, and subfolders. Each row contains properties of the folder or file and a link to its content. `options` may be specified to control the following options: +Returns a table containing a row for each document found at the specified SharePoint site, `url`, and subfolders. Each row contains properties of the folder or file and a link to its content. `options` may be specified to control the following options: -* `ApiVersion` : A number (14 or 15) or the text "Auto" that specifies the SharePoint API version to use for this site. When not specified, API version 14 is used. When Auto is specified, the server version will be automatically discovered if possible, otherwise version defaults to 14. Non-English SharePoint sites require at least version 15. - +* `ApiVersion`: A number (14 or 15) or the text "Auto" that specifies the SharePoint API version to use for this site. When not specified, API version 14 is used. When Auto is specified, the server version will be automatically discovered if possible, otherwise version defaults to 14. Non-English SharePoint sites require at least version 15. diff --git a/query-languages/m/sharepoint-tables.md b/query-languages/m/sharepoint-tables.md index 40a925a05..f44ad0ad9 100644 --- a/query-languages/m/sharepoint-tables.md +++ b/query-languages/m/sharepoint-tables.md @@ -1,14 +1,7 @@ --- description: "Learn more about: SharePoint.Tables" -title: "SharePoint.Tables | Microsoft Docs" -ms.date: 9/14/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SharePoint.Tables" +ms.subservice: m-source --- # SharePoint.Tables @@ -20,9 +13,9 @@ SharePoint.Tables(url as text, optional options as nullable record ## About -Returns a table containing a row for each List item found at the specified SharePoint list, `url`. Each row contains properties of the List. `options` may be specified to control the following options: +Returns a table containing a row for each List item found at the specified SharePoint list, `url`. Each row contains properties of the List. `options` may be specified to control the following options: -* `ApiVersion` : A number (14 or 15) or the text "Auto" that specifies the SharePoint API version to use for this site. When not specified, API version 14 is used. When Auto is specified, the server version will be automatically discovered if possible, otherwise version defaults to 14. Non-English SharePoint sites require at least version 15. -* `Implementation` -* `ViewMode` - +* `ApiVersion`: A number (14 or 15) or the text "Auto" that specifies the SharePoint API version to use for this site. When not specified, API version 14 is used. When Auto is specified, the server version will be automatically discovered if possible, otherwise version defaults to 14. Non-English SharePoint sites require at least version 15. +* `Implementation`: Optional. Specifies which version of the SharePoint connector to use. Accepted values are "2.0" or null. If the value is "2.0", the 2.0 implementation of the SharePoint connector is used. If the value is null, the original implementation of the SharePoint connector is used. +* `ViewMode`: Optional. This option is only valid for implementation 2.0. Accepted values are "All" and "Default". If no value is specified, the value is set to "All". When "All"; is specified, the view includes all user-created and system-defined columns. When "Default" is specified, the view will match what the user sees when looking at the list online in whichever view that user set as Default in their settings. If the user edits their default view to add or remove either user-created or system-defined columns, or by creating a new view and setting it as default, these changes will propagate through the connector. +* `DisableAppendNoteColumns`: Prevents the connector from using a separate endpoint for note columns. diff --git a/query-languages/m/sharpbinary.md b/query-languages/m/sharpbinary.md index 7ed89ff30..56481c3bb 100644 --- a/query-languages/m/sharpbinary.md +++ b/query-languages/m/sharpbinary.md @@ -1,14 +1,7 @@ --- description: "Learn more about: #binary" -title: "#binary | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "#binary" +ms.subservice: m-source --- # #binary ## Syntax diff --git a/query-languages/m/sharpdate.md b/query-languages/m/sharpdate.md index 61e4f562d..0a4102d05 100644 --- a/query-languages/m/sharpdate.md +++ b/query-languages/m/sharpdate.md @@ -1,21 +1,18 @@ --- description: "Learn more about: #date" -title: "#date | Microsoft Docs" -ms.date: 6/21/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "#date" +ms.subservice: m-source --- # #date ## Syntax
-#date(year as number, month as number, day as number) as date
+#date(
+    year as number,
+    month as number,
+    day as number
+) as date
 
## About @@ -25,3 +22,68 @@ Creates a date value from whole numbers representing the year, month, and day. R * 1 ≤ year ≤ 9999 * 1 ≤ month ≤ 12 * 1 ≤ day ≤ 31 + +## Example 1 + +Create a date representing December 26, 2023. + +**Usage** + +```powerquery-m +#date(2023, 12, 26) +``` + +**Output** + +`#date(2023, 12, 26)` + +## Example 2 + +Convert a date to text using a custom format and the German culture. + +**Usage** + +```powerquery-m +Date.ToText(#date(2023, 12, 26), [Format="dd MMM yyyy", Culture="de-DE"]) +``` + +**Output** + +`"26 Dez 2023"` + +## Example 3 + +Get the rows from a table that contain a date in 2023. + +**Usage** + +```powerquery-m +let +Source = #table(type table [Account Code = text, Posted Date = date, Sales = number], + { + {"US-2004", #date(2023,1,20), 580}, + {"CA-8843", #date(2023,7,18), 280}, + {"PA-1274", #date(2022,1,12), 90}, + {"PA-4323", #date(2023,4,14), 187}, + {"US-1200", #date(2022,12,14), 350}, + {"PTY-507", #date(2023,6,4), 110} + }), + #"Filtered rows" = Table.SelectRows( + Source, + each Date.Year([Posted Date]) = 2023 + ) +in + #"Filtered rows" +``` + +**Output** + +```powerquery-m +#table (type table [Account Code = text, Posted Date = date, Sales = number], +{ + {"US-2004", #date(2023, 1, 20), 580}, + {"CA-8843", #date(2023, 7, 18), 280}, + {"PA-4323", #date(2023, 4, 14), 187}, + {"PTY-507", #date(2023, 6, 4), 110} +}) +``` diff --git a/query-languages/m/sharpdatetime.md b/query-languages/m/sharpdatetime.md index 93d20dad1..22b65f785 100644 --- a/query-languages/m/sharpdatetime.md +++ b/query-languages/m/sharpdatetime.md @@ -1,21 +1,21 @@ --- description: "Learn more about: #datetime" -title: "#datetime | Microsoft Docs" -ms.date: 11/17/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "#datetime" +ms.subservice: m-source --- # #datetime ## Syntax
-#datetime(year as number, month as number, day as number, hour as number, minute as number, second as number) as datetime
+#datetime(
+    year as number,
+    month as number,
+    day as number,
+    hour as number,
+    minute as number,
+    second as number
+) as datetime
 
## About diff --git a/query-languages/m/sharpdatetimezone.md b/query-languages/m/sharpdatetimezone.md index 6cb72e1b3..8b3113d82 100644 --- a/query-languages/m/sharpdatetimezone.md +++ b/query-languages/m/sharpdatetimezone.md @@ -1,21 +1,23 @@ --- description: "Learn more about: #datetimezone" -title: "#datetimezone | Microsoft Docs" -ms.date: 11/17/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "#datetimezone" +ms.subservice: m-source --- # #datetimezone ## Syntax
-#datetimezone(year as number, month as number, day as number, hour as number, minute as number, second as number, offsetHours as number, offsetMinutes as number) as datetimezone
+#datetimezone(
+    year as number,
+    month as number,
+    day as number,
+    hour as number,
+    minute as number,
+    second as number,
+    offsetHours as number,
+    offsetMinutes as number
+) as datetimezone
 
## About diff --git a/query-languages/m/sharpduration.md b/query-languages/m/sharpduration.md index 742c1154b..7802a7715 100644 --- a/query-languages/m/sharpduration.md +++ b/query-languages/m/sharpduration.md @@ -1,21 +1,19 @@ --- description: "Learn more about: #duration" -title: "#duration | Microsoft Docs" -ms.date: 6/21/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "#duration" +ms.subservice: m-source --- # #duration ## Syntax
-#duration(days as number, hours as number, minutes as number, seconds as number) as duration
+#duration(
+    days as number,
+    hours as number,
+    minutes as number,
+    seconds as number
+) as duration
 
## About diff --git a/query-languages/m/sharptable.md b/query-languages/m/sharptable.md index 13320ae51..d3bf66331 100644 --- a/query-languages/m/sharptable.md +++ b/query-languages/m/sharptable.md @@ -1,16 +1,9 @@ --- -description: "Learn more about: #table" -title: "#table | Microsoft Docs" -ms.date: 10/17/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +description: "Learn more about: #table" +title: "#table" +ms.subservice: m-source --- -# #table +# #table ## Syntax @@ -19,6 +12,89 @@ ms.author: dougklo ## About -Creates a table value from columns `columns` and the list `rows` where each element of the list is an inner list that contains the column values for a single row. `columns` may be a list of column names, a table type, a number of columns, or null. - +Creates a table value from `columns` and `rows`. The `columns` value can be a list of column names, a table type, a number of columns, or null. The `rows` value is a list of lists, where each element contains the column values for a single row. + +## Example 1 + +Create an empty table. + +**Usage** + +```powerquery-m +#table({}, {}) +``` + +**Output** + +```powerquery-m +#table({}, {}) +``` + +## Example 2 + +Create a table by inferring the number of columns from the first row. + +**Usage** + +```powerquery-m +#table(null, {{"Betty", 90.3}, {"Carl", 89.5}}) +``` + +**Output** + +```powerquery-m +#table({"Column1", "Column2"}, {{"Betty", 90.3}, {"Carl", 89.5}}) +``` + +## Example 3 + +Create a table by specifying the number of columns. + +**Usage** + +```powerquery-m +#table(2, {{"Betty", 90.3}, {"Carl", 89.5}}) +``` + +**Output** + +```powerquery-m +#table({"Column1", "Column2"}, {{"Betty", 90.3}, {"Carl", 89.5}}) +``` + +## Example 4 + +Create a table by providing a list of column names. + +**Usage** + +```powerquery-m +#table({"Name", "Score"}, {{"Betty", 90.3}, {"Carl", 89.5}}) +``` + +**Output** + +```powerquery-m +#table({"Name", "Score"}, {{"Betty", 90.3}, {"Carl", 89.5}}) +``` + +## Example 5 + +Create a table with an explicit type. + +**Usage** + +```powerquery-m +#table(type table [Name = text, Score = number], {{"Betty", 90.3}, {"Carl", 89.5}}) +``` + +**Output** + +```powerquery-m +#table(type table [Name = text, Score = number], {{"Betty", 90.3}, {"Carl", 89.5}}) +``` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/sharptime.md b/query-languages/m/sharptime.md index c2cdc796e..36a835662 100644 --- a/query-languages/m/sharptime.md +++ b/query-languages/m/sharptime.md @@ -1,21 +1,18 @@ --- description: "Learn more about: #time" -title: "#time | Microsoft Docs" -ms.date: 6/21/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "#time" +ms.subservice: m-source --- # #time ## Syntax
-#time(hour as number, minute as number, second as number) as time
+#time(
+    hour as number,
+    minute as number,
+    second as number
+) as time
 
## About diff --git a/query-languages/m/single-from.md b/query-languages/m/single-from.md index 38a7f4725..b86a4119b 100644 --- a/query-languages/m/single-from.md +++ b/query-languages/m/single-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Single.From" -title: "Single.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Single.From" +ms.subservice: m-source --- # Single.From @@ -35,3 +28,7 @@ Single.From("1.5") **Output** `1.5` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/soda-feed.md b/query-languages/m/soda-feed.md index af8fbc087..34dc8297b 100644 --- a/query-languages/m/soda-feed.md +++ b/query-languages/m/soda-feed.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Soda.Feed" -title: "Soda.Feed | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Soda.Feed" +ms.subservice: m-source --- # Soda.Feed - + ## Syntax
 Soda.Feed(url as text) as table
 
- -## About + +## About + Returns a table from the contents at the specified URL `url` formatted according to the SODA 2.0 API. The URL must point to a valid SODA-compliant source that ends in a .csv extension. diff --git a/query-languages/m/splitter-functions.md b/query-languages/m/splitter-functions.md index c4cd462d0..9f1ae8768 100644 --- a/query-languages/m/splitter-functions.md +++ b/query-languages/m/splitter-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Splitter functions" -title: "Splitter functions | Microsoft Docs" +title: "Splitter functions" ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +ms.custom: "nonautomated-date" --- # Splitter functions diff --git a/query-languages/m/splitter-splitbynothing.md b/query-languages/m/splitter-splitbynothing.md index 1407069c7..0a631ced7 100644 --- a/query-languages/m/splitter-splitbynothing.md +++ b/query-languages/m/splitter-splitbynothing.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Splitter.SplitByNothing" -title: "Splitter.SplitByNothing | Microsoft Docs" -ms.date: 8/1/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitByNothing" +ms.subservice: m-source --- # Splitter.SplitByNothing @@ -19,7 +12,5 @@ Splitter.SplitByNothing() as function ## About -Returns a function that does no splitting, returning its argument as a single element list. - - +Returns a function that does no splitting, returning its argument as a single element list. diff --git a/query-languages/m/splitter-splittextbyanydelimiter.md b/query-languages/m/splitter-splittextbyanydelimiter.md index ecde57598..135815ede 100644 --- a/query-languages/m/splitter-splittextbyanydelimiter.md +++ b/query-languages/m/splitter-splittextbyanydelimiter.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Splitter.SplitTextByAnyDelimiter" -title: "Splitter.SplitTextByAnyDelimiter | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitTextByAnyDelimiter" +ms.subservice: m-source --- # Splitter.SplitTextByAnyDelimiter ## Syntax
-Splitter.SplitTextByAnyDelimiter(delimiters as list, optional quoteStyle as nullable number, optional startAtEnd as nullable logical) as function
+Splitter.SplitTextByAnyDelimiter(
+    delimiters as list,
+    optional quoteStyle as nullable number,
+    optional startAtEnd as nullable logical
+) as function
 
## About diff --git a/query-languages/m/splitter-splittextbycharactertransition.md b/query-languages/m/splitter-splittextbycharactertransition.md index b82a50648..039169366 100644 --- a/query-languages/m/splitter-splittextbycharactertransition.md +++ b/query-languages/m/splitter-splittextbycharactertransition.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Splitter.SplitTextByCharacterTransition" -title: "Splitter.SplitTextByCharacterTransition | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitTextByCharacterTransition" +ms.subservice: m-source --- # Splitter.SplitTextByCharacterTransition diff --git a/query-languages/m/splitter-splittextbydelimiter.md b/query-languages/m/splitter-splittextbydelimiter.md index 6fe2ba818..aca3027c4 100644 --- a/query-languages/m/splitter-splittextbydelimiter.md +++ b/query-languages/m/splitter-splittextbydelimiter.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Splitter.SplitTextByDelimiter" -title: "Splitter.SplitTextByDelimiter | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitTextByDelimiter" +ms.subservice: m-source --- # Splitter.SplitTextByDelimiter ## Syntax
-Splitter.SplitTextByDelimiter(delimiter as text, optional quoteStyle as nullable number) as function
+Splitter.SplitTextByDelimiter(
+    delimiter as text,
+    optional quoteStyle as nullable number,
+    optional csvStyle as nullable number
+) as function
 
## About diff --git a/query-languages/m/splitter-splittextbyeachdelimiter.md b/query-languages/m/splitter-splittextbyeachdelimiter.md index 2798a7e6b..6c3d2cc30 100644 --- a/query-languages/m/splitter-splittextbyeachdelimiter.md +++ b/query-languages/m/splitter-splittextbyeachdelimiter.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Splitter.SplitTextByEachDelimiter" -title: "Splitter.SplitTextByEachDelimiter | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitTextByEachDelimiter" +ms.subservice: m-source --- # Splitter.SplitTextByEachDelimiter ## Syntax
-Splitter.SplitTextByEachDelimiter(delimiters as list, optional quoteStyle as nullable number, optional startAtEnd as nullable logical) as function
+Splitter.SplitTextByEachDelimiter(
+    delimiters as list,
+    optional quoteStyle as nullable number,
+    optional startAtEnd as nullable logical
+) as function
 
## About diff --git a/query-languages/m/splitter-splittextbylengths.md b/query-languages/m/splitter-splittextbylengths.md index 13c719ff8..1dc3ad6d4 100644 --- a/query-languages/m/splitter-splittextbylengths.md +++ b/query-languages/m/splitter-splittextbylengths.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Splitter.SplitTextByLengths" -title: "Splitter.SplitTextByLengths | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitTextByLengths" +ms.subservice: m-source --- # Splitter.SplitTextByLengths diff --git a/query-languages/m/splitter-splittextbypositions.md b/query-languages/m/splitter-splittextbypositions.md index 9b6991b27..fd23921cf 100644 --- a/query-languages/m/splitter-splittextbypositions.md +++ b/query-languages/m/splitter-splittextbypositions.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Splitter.SplitTextByPositions" -title: "Splitter.SplitTextByPositions | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitTextByPositions" +ms.subservice: m-source --- # Splitter.SplitTextByPositions diff --git a/query-languages/m/splitter-splittextbyranges.md b/query-languages/m/splitter-splittextbyranges.md index 71270ef78..6583bdb01 100644 --- a/query-languages/m/splitter-splittextbyranges.md +++ b/query-languages/m/splitter-splittextbyranges.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Splitter.SplitTextByRanges" -title: "Splitter.SplitTextByRanges | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitTextByRanges" +ms.subservice: m-source --- # Splitter.SplitTextByRanges diff --git a/query-languages/m/splitter-splittextbyrepeatedlengths.md b/query-languages/m/splitter-splittextbyrepeatedlengths.md index 4d2b9823a..bda24c80d 100644 --- a/query-languages/m/splitter-splittextbyrepeatedlengths.md +++ b/query-languages/m/splitter-splittextbyrepeatedlengths.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Splitter.SplitTextByRepeatedLengths" -title: "Splitter.SplitTextByRepeatedLengths | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitTextByRepeatedLengths" +ms.subservice: m-source --- # Splitter.SplitTextByRepeatedLengths diff --git a/query-languages/m/splitter-splittextbywhitespace.md b/query-languages/m/splitter-splittextbywhitespace.md index 9e6d4833e..5c04f6396 100644 --- a/query-languages/m/splitter-splittextbywhitespace.md +++ b/query-languages/m/splitter-splittextbywhitespace.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Splitter.SplitTextByWhitespace" -title: "Splitter.SplitTextByWhitespace | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Splitter.SplitTextByWhitespace" +ms.subservice: m-source --- # Splitter.SplitTextByWhitespace diff --git a/query-languages/m/sql-database.md b/query-languages/m/sql-database.md index 1c7c46449..b02118a14 100644 --- a/query-languages/m/sql-database.md +++ b/query-languages/m/sql-database.md @@ -1,19 +1,18 @@ --- description: "Learn more about: Sql.Database" -title: "Sql.Database | Microsoft Docs" -ms.date: 11/23/2020 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Sql.Database" +ms.subservice: m-source --- # Sql.Database ## Syntax
-Sql.Database(server as text, database as text, optional options as nullable record) as table
+Sql.Database(
+    server as text,
+    database as text,
+    optional options as nullable record
+) as table
 
## About @@ -31,6 +30,6 @@ Returns a table of SQL tables, views, and stored functions from the SQL Server d * `UnsafeTypeConversions`: A logical (true/false) that, if true, attempts to fold type conversions which could fail and cause the entire query to fail. Not recommended for general use. * `ContextInfo`: A binary value that is used to set the CONTEXT_INFO before running each command. * `OmitSRID`: A logical (true/false) that, if true, omits the SRID when producing Well-Known Text from geometry and geography types. +* `EnableCrossDatabaseFolding`: A logical (true/false) value that, if true, allows query folding across databases on the same server. The default value is false. -The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. - +The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. diff --git a/query-languages/m/sql-databases.md b/query-languages/m/sql-databases.md index 6f94943bc..a61923384 100644 --- a/query-languages/m/sql-databases.md +++ b/query-languages/m/sql-databases.md @@ -1,12 +1,7 @@ --- description: "Learn more about: Sql.Databases" -title: "Sql.Databases | Microsoft Docs" -ms.date: 11/23/2020 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Sql.Databases" +ms.subservice: m-source --- # Sql.Databases @@ -30,7 +25,8 @@ Returns a table of databases on the specified SQL server, `server`. An optional * `UnsafeTypeConversions`: A logical (true/false) that, if true, attempts to fold type conversions which could fail and cause the entire query to fail. Not recommended for general use. * `ContextInfo`: A binary value that is used to set the CONTEXT_INFO before running each command. * `OmitSRID`: A logical (true/false) that, if true, omits the SRID when producing Well-Known Text from geometry and geography types. +* `EnableCrossDatabaseFolding`: A logical (true/false) value that, if true, allows query folding across databases on the same server. The default value is false. The record parameter is specified as [option1 = value1, option2 = value2...] for example. -Does not support setting a SQL query to run on the server. [`Sql.Database`](sql-database.md) should be used instead to run a SQL query. +Does not support setting a SQL query to run on the server. [`Sql.Database`](sql-database.md) should be used instead to run a SQL query. diff --git a/query-languages/m/sqlexpression-schemafrom.md b/query-languages/m/sqlexpression-schemafrom.md index d2d350ee5..8b380ad4f 100644 --- a/query-languages/m/sqlexpression-schemafrom.md +++ b/query-languages/m/sqlexpression-schemafrom.md @@ -1,14 +1,7 @@ --- description: "Learn more about: SqlExpression.SchemaFrom" -title: "SqlExpression.SchemaFrom | Microsoft Docs" -ms.date: 10/18/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SqlExpression.SchemaFrom" +ms.subservice: m-source --- # SqlExpression.SchemaFrom diff --git a/query-languages/m/sqlexpression-toexpression.md b/query-languages/m/sqlexpression-toexpression.md index c6f3fc25d..9a93614fd 100644 --- a/query-languages/m/sqlexpression-toexpression.md +++ b/query-languages/m/sqlexpression-toexpression.md @@ -1,14 +1,7 @@ --- description: "Learn more about: SqlExpression.ToExpression" -title: "SqlExpression.ToExpression | Microsoft Docs" -ms.date: 10/18/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "SqlExpression.ToExpression" +ms.subservice: m-source --- # SqlExpression.ToExpression diff --git a/query-languages/m/standard-date-and-time-format-strings.md b/query-languages/m/standard-date-and-time-format-strings.md new file mode 100644 index 000000000..59931e34b --- /dev/null +++ b/query-languages/m/standard-date-and-time-format-strings.md @@ -0,0 +1,589 @@ +--- +description: "Learn more about: Standard date and time format strings" +title: "Standard date and time format strings" +ms.date: 10/11/2024 +ms.custom: "nonautomated-date" +s.subservice: m-background +--- +# Standard date and time format strings + +A standard date and time format string uses a single character as the format specifier to define the text representation of a time and date value. Any date and time format string that contains more than one character, including white space, is interpreted as a [custom date and time format string](custom-date-and-time-format-strings.md). A standard or custom format string can be used to define the text representation that results from a formatting operation. + +## Table of format specifiers + + The following table describes the standard date and time format specifiers. + +|Format specifier|Description|Examples| +|----------------------|-----------------|--------------| +|"d"|Short date pattern.

More information: [The short date ("d") format specifier](#ShortDate).|2009-06-15T13:45:30 -> 6/15/2009 (en-US)

2009-06-15T13:45:30 -> 15/06/2009 (fr-FR)

2009-06-15T13:45:30 -> 2009/06/15 (ja-JP)| +|"D"|Long date pattern.

More information: [The long date ("D") format specifier](#LongDate).|2009-06-15T13:45:30 -> Monday, June 15, 2009 (en-US)

2009-06-15T13:45:30 -> понедельник, 15 июня 2009 г. (ru-RU)

2009-06-15T13:45:30 -> Montag, 15. Juni 2009 (de-DE)| +|"f"|Full date/time pattern (short time).

More information: [The full date short time ("f") format specifier](#FullDateShortTime).|2009-06-15T13:45:30 -> Monday, June 15, 2009 1:45 PM (en-US)

2009-06-15T13:45:30 -> den 15 juni 2009 13:45 (sv-SE)

2009-06-15T13:45:30 -> Δευτέρα, 15 Ιουνίου 2009 1:45 μμ (el-GR)| +|"F"|Full date/time pattern (long time).

More information: [The full date long time ("F") format specifier](#FullDateLongTime).|2009-06-15T13:45:30 -> Monday, June 15, 2009 1:45:30 PM (en-US)

2009-06-15T13:45:30 -> den 15 juni 2009 13:45:30 (sv-SE)

2009-06-15T13:45:30 -> Δευτέρα, 15 Ιουνίου 2009 1:45:30 μμ (el-GR)| +|"g"|General date/time pattern (short time).

More information: [The general date short time ("g") format specifier](#GeneralDateShortTime).|2009-06-15T13:45:30 -> 6/15/2009 1:45 PM (en-US)

2009-06-15T13:45:30 -> 15/06/2009 13:45 (es-ES)

2009-06-15T13:45:30 -> 2009/6/15 13:45 (zh-CN)| +|"G"|General date/time pattern (long time).

More information: [The general date long time ("G") format specifier](#GeneralDateLongTime).|2009-06-15T13:45:30 -> 6/15/2009 1:45:30 PM (en-US)

2009-06-15T13:45:30 -> 15/06/2009 13:45:30 (es-ES)

2009-06-15T13:45:30 -> 2009/6/15 13:45:30 (zh-CN)| +|"M", "m"|Month/day pattern.

More information: [The month ("M", "m") format specifier](#MonthDay).|2009-06-15T13:45:30 -> June 15 (en-US)

2009-06-15T13:45:30 -> 15. juni (da-DK)

2009-06-15T13:45:30 -> 15 Juni (id-ID)| +|"O", "o"|round-trip date/time pattern.

More information: [The round-trip ("O", "o") format specifier](#Roundtrip).|2009-06-15T13:45:30 (Local) --> 2009-06-15T13:45:30.0000000-07:00

2009-06-15T13:45:30 (Utc) --> 2009-06-15T13:45:30.0000000+00:00

2009-06-15T13:45:30 (Unspecified) --> 2009-06-15T13:45:30.0000000| +|"R", "r"|RFC1123 pattern.

More information: [The RFC1123 ("R", "r") format specifier](#RFC1123).|2009-06-15T13:45:30 -> Mon, 15 Jun 2009 13:45:30 GMT | +|"s"|Sortable date/time pattern.

More information: [The sortable ("s") format specifier](#Sortable).|2009-06-15T13:45:30 (Local) -> 2009-06-15T13:45:30

2009-06-15T13:45:30 (Utc) -> 2009-06-15T13:45:30| +|"t"|Short time pattern.

More information: [The short time ("t") format specifier](#ShortTime).|2009-06-15T13:45:30 -> 1:45 PM (en-US)

2009-06-15T13:45:30 -> 13:45 (hr-HR)

2009-06-15T13:45:30 -> 01:45 م (ar-EG)| +|"T"|Long time pattern.

More information: [The long time ("T") format specifier](#LongTime).|2009-06-15T13:45:30 -> 1:45:30 PM (en-US)

2009-06-15T13:45:30 -> 13:45:30 (hr-HR)

2009-06-15T13:45:30 -> 01:45:30 م (ar-EG)| +|"u"|Universal sortable date/time pattern.

More information: [The universal sortable ("u") format specifier](#UniversalSortable).|2009-06-15T13:45:30 -> 2009-06-15 13:45:30Z| +|"Y", "y"|Year month pattern.

More information: [The year month ("Y") format specifier](#YearMonth).|2009-06-15T13:45:30 -> June 2009 (en-US)

2009-06-15T13:45:30 -> juni 2009 (da-DK)

2009-06-15T13:45:30 -> Juni 2009 (id-ID)| +|Any other single character|Unknown specifier.|Throws a run-time expression error.| + +## How standard format strings work + +In a formatting operation, a standard format string is simply an alias for a custom format string. The advantage of using an alias to refer to a custom format string is that, although the alias remains invariant, the custom format string itself can vary. This is important because the string representations of date and time values typically vary by culture. For example, the "d" standard format string indicates that a date and time value is to be displayed using a short date pattern. For the invariant culture, this pattern is "MM/dd/yyyy". For the fr-FR culture, it is "dd/MM/yyyy". For the ja-JP culture, it is "yyyy/MM/dd". + +If a standard format string in a formatting operation maps to a particular culture's custom format string, your application can define the specific culture whose custom format strings are used in one of these ways: + +- You can use the default (or current) culture. The following example displays a date using the current culture's short date format. In this case, the current culture is en-US. + + ```powerquery -m + let + Source = + { + Date.ToText(#date(2024, 3, 15), [Format = "d"]) + //Displays 3/15/2024 + } + in + Source + ``` + +- You can pass a culture used to format the date according to the rules of that specific culture. The following example displays a date using the short date format of the pt-BR culture. + + ```powerquery-m + let + Source = + { + Date.ToText(#date(2024, 3, 15), [Format = "d", Culture = "pt-BR"]) + //Displays 15/03/2024 + } + in + Source + ``` + +In some cases, the standard format string serves as a convenient abbreviation for a longer custom format string that is invariant. Four standard format strings fall into this category: "O" (or "o"), "R" (or "r"), "s", and "u". These strings correspond to custom format strings defined by the invariant culture. They produce string representations of date and time values that are intended to be identical across cultures. The following table provides information on these four standard date and time format strings. + +|Standard format string|Defined by|Custom format string| +|----------------------|----------|--------------------| +|"O" or "o"|None|yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK| +|"R" or "r"|IETF RFC 1123 specification|ddd, dd MMM yyyy HH':'mm':'ss 'GMT'| +|"s"|ISO 8601|yyyy'-'MM'-'dd'T'HH':'mm':'ss| +|"u"|Sortable because it uses leading zeros for year, month, day, hour, minute, and second|yyyy'-'MM'-'dd HH':'mm':'ss'Z'| + +Standard format strings can also be used in parsing operations, which require an input string to exactly conform to a particular pattern for the parse operation to succeed. Many standard format strings map to multiple custom format strings, so a date and time value can be represented in a variety of formats and the parse operation still succeeds. + +The following sections describe the standard format specifiers for [Date](date-functions.md), [DateTime](datetime-functions.md), [DateTimeZone](datetimezone-functions.md), and [Time](time-functions.md) values. + +## Date formats + +This group includes the following formats: + +- [The short date ("d") format specifier](#the-short-date-d-format-specifier) +- [The long date ("D") format specifier](#the-long-date-d-format-specifier) + + + +### The short date ("d") format specifier + +The "d" standard format specifier represents a custom date format defined by a specific culture. For example, the custom format text returned by the invariant culture is "MM/dd/yyyy". + +The following example uses the "d" format specifier to display a date value. + +```powerquery-m +let + Source = + { + Date.ToText(#date(2024, 4, 10), [Format = "d", Culture = ""]), + // Displays 04/10/2024 + + Date.ToText(#date(2024, 4, 10), [Format = "d", Culture = "en-US"]), + // Displays 4/10/2024 + + Date.ToText(#date(2024, 4, 10), [Format = "d", Culture = "en-NZ"]), + // Displays 10/4/2024 + + Date.ToText(#date(2024, 4, 10), [Format = "d", Culture = "de-DE"]) + // Displays 10.4.2024 + } +in + Source +``` + +[Back to table](#table) + + + +### The long date ("D") format specifier + +The "D" standard format specifier represents a custom date format defined by a specific culture. For example, the custom format string for the invariant culture is "dddd, dd MMMM yyyy". + +The following example uses the "D" format specifier to display a date and time value. + +```powerquery-m +let + Source = + { + Date.ToText(#date(2024, 4, 10), [Format = "D", Culture = ""]), + // Displays Wednesday, 10 April, 2024 + + Date.ToText(#date(2024, 4, 10), [Format = "D", Culture = "en-US"]), + // Displays Wednesday, April 10, 2024 + + Date.ToText(#date(2024, 4, 10), [Format = "D", Culture = "pt-BR"]), + // Displays quarta-feira, 10 de abril de 2024 + + Date.ToText(#date(2024, 4, 10), [Format = "D", Culture = "es-MX"]) + // Displays miércoles, 10 de abril de 2024 + } +in + Source +``` + +[Back to table](#table) + +## Date and time formats + +This group includes the following formats: + +- [The full date short time ("f") format specifier](#the-full-date-short-time-f-format-specifier) +- [The full date long time ("F") format specifier](#the-full-date-long-time-f-format-specifier) +- [The general date short time ("g") format specifier](#the-general-date-short-time-g-format-specifier) +- [The general date long time ("G") format specifier](#the-general-date-long-time-g-format-specifier) +- [The round-trip ("O", "o") format specifier](#the-round-trip-o-o-format-specifier) +- [The RFC1123 ("R", "r") format specifier](#the-rfc1123-r-r-format-specifier) +- [The sortable ("s") format specifier](#the-sortable-s-format-specifier) +- [The universal sortable ("u") format specifier](#the-universal-sortable-u-format-specifier) + + + +### The full date short time ("f") format specifier + +The "f" standard format specifier represents a combination of the long date ("D") and short time ("t") patterns, separated by a space. + +The result string is affected by the formatting information of a specific culture. + +The following example uses the "f" format specifier to display a date and time value. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "f", Culture = "en-US"]), + // Displays Wednesday, April 10, 2024 6:30 AM + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "f", Culture = "fr-FR"]) + // Displays mercredi 10 avril 2024 06:30 + } +in + Source +``` + +[Back to table](#table) + + + +### The full date long time ("F") format specifier + +The "F" standard format specifier represents a custom date and time format defined by a specific culture. For example, the custom format string for the invariant culture is "dddd, dd MMMM yyyy HH:mm:ss". + +The result string is affected by the formatting information of a specific culture. + +The following example uses the "F" format specifier to display a date and time value. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "F", Culture = ""]), + // Displays Wednesday, 10 April, 2024 06:30:00 + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "F", Culture = "en-US"]), + // Displays Wednesday, April 10, 2024 6:30:00 AM + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "F", Culture = "fr-FR"]) + // Displays mercredi 10 avril 2024 06:30:00 + } +in + Source +``` + +[Back to table](#table) + + + +### The general date short time ("g") format specifier + +The "g" standard format specifier represents a combination of the short date ("d") and short time ("t") patterns, separated by a space. The resulting text is affected by the formatting information of a specific culture. + +The result string is affected by the formatting information of a specific culture. + +The following example uses the "g" format specifier to display a date and time value. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "g", Culture = ""]), + // Displays 04/10/2024 06:30 + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "g", Culture = "en-US"]), + // Displays 4/10/2024 6:30 AM + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "g", Culture = "fr-BE"]) + // Displays 10-04-24 06:30 + } +in + Source +``` + +[Back to table](#table) + + + +### The general date long time ("G") format specifier + +The "G" standard format specifier represents a combination of the short date ("d") and long time ("T") patterns, separated by a space. The resulting text is affected by the formatting information of a specific culture. + +The result string is affected by the formatting information of a specific culture. + +The following example uses the "G" format specifier to display a date and time value. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "G", Culture = ""]), + // Displays 04/10/2024 06:30:00 + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "G", Culture = "en-US"]), + // Displays 4/10/2024 6:30:00 AM + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "G", Culture = "nl-BE"]) + // Displays 10/04/2024 6:30:00 + } +in + Source +``` + +[Back to table](#table) + + + +### The round-trip ("O", "o") format specifier + +The "O" or "o" standard format specifier represents a custom date and time format string using a pattern that preserves time zone information and emits a result string that complies with ISO 8601. For **DateTimeZone** values, this format specifier is designed to preserve date, time, and timezone values in text. + +The "O" or "o" standard format specifier corresponds to the "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffxxx" custom format string for **DateTimeZone** values. In this text, the pairs of single quotation marks that delimit individual characters, such as the hyphens, the colons, and the letter "T", indicate that the individual character is a literal that can't be changed. The apostrophes don't appear in the output string. + +The "O" or "o" standard format specifier (and the "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffxxx" custom format) takes advantage of the ways that ISO 8601 represents time zone information to preserve the **DateTimeZone** values: + +- The time zone component of [DateTimeZone.ToLocal](datetimezone-tolocal.md) date and time values is an offset from UTC (for example, +01:00, -07:00). + +- The time zone component of [DateTimeZone.ToUtc](datetimezone-toutc.md) date and time values uses +00.00 to represent UTC. + +Because the "O" or "o" standard format specifier conforms to an international standard, the formatting or parsing operation that uses the specifier always uses the invariant culture and the Gregorian calendar. + +The following example uses the "o" format specifier to display a series of **DateTimeZone** values on a system in the U.S. Pacific Time zone. + +```powerquery-m +let + date1 = #datetimezone(2024, 6, 15, 13, 45, 30, 0, 0), + Source = + { + Text.Format("#{0} (Unspecified) --> #{1}", {date1, DateTimeZone.ToText(date1, [Format = "O"])}), + Text.Format("#{0} (Utc) --> #{1}", {date1, DateTimeZone.ToText(DateTimeZone.ToUtc(date1), [Format = "O"])}), + Text.Format("#{0} (Local) --> #{1}", {date1, DateTimeZone.ToText(DateTimeZone.ToLocal(date1), [Format = "O"])}) + } +in + Source + +// The example displays the following output: +// 6/15/2024 1:45:30 PM +00:00 (Unspecified) --> 2024-06-15T13:45:30.0000000+00:00 +// 6/15/2024 1:45:30 PM +00:00 (Utc) --> 2024-06-15T13:45:30.0000000+00:00 +// 6/15/2024 1:45:30 PM +00:00 (Local) --> 2024-06-15T08:45:30.0000000-07:00 + +``` + +> [!NOTE] +>The value returned by [DateTimeZone.ToLocal](datetimezone-tolocal.md) depends on whether you're running Power Query on a local machine or online. For example, in the sample above on a system in the U.S. Pacific Time zone, Power Query Desktop returns `-07:00` for the **Local** time because it's reading the time set on your local machine. However, Power Query Online returns `+00:00` because it's reading the time set on the cloud virtual machines, which are set to UTC. + +The following example uses the "o" format specifier to create a formatted string, and then restores the original date and time value by calling a date and time parsing routine. + +```powerquery-m +let + // Round-trip a local time + #"Origin Local Date" = DateTimeZone.ToLocal( + #datetimezone(2024, 4, 10, 6, 30, 0, 0, 0) + ), + #"Local Date Text" = DateTimeZone.ToText( + #"Origin Local Date", [Format = "o"] + ), + #"New Local Date" = DateTimeZone.FromText(#"Local Date Text"), + #"Local Round Trip" = Text.Format( + "Round-tripped #{0} Local to #{1} Local.", + { + DateTimeZone.ToText(#"Origin Local Date"), + DateTimeZone.ToText(#"New Local Date") + } + ), + + // Round-trip a UTC time + #"Origin UTC Date" = DateTimeZone.ToUtc( + #datetimezone(2024, 4, 12, 9, 30, 0, 0, 0) + ), + #"UTC Date Text" = DateTimeZone.ToText( + #"Origin UTC Date", [Format = "o"] + ), + #"New UTC Date" = DateTimeZone.FromText(#"UTC Date Text"), + #"UTC Round Trip" = Text.Format( + "Round-tripped #{0} UTC to #{1} UTC.", + { + DateTimeZone.ToText(#"Origin UTC Date"), + DateTimeZone.ToText(#"New UTC Date") + } + ), + + // Round-trip an 18 hour offset time + #"Origin Offset Date" = DateTimeZone.ToLocal( + #datetimezone(2024, 4, 10, 6, 30, 0, 0, 0) + #duration(0, 18, 0, 0) + ), + #"Offset Date Text" = DateTimeZone.ToText( + #"Origin Offset Date", [Format = "o"] + ), + #"New Offset Date" = DateTimeZone.FromText(#"Offset Date Text"), + #"Offset Round Trip" = Text.Format( + "Round-tripped #{0} to #{1}.", + { + DateTimeZone.ToText(#"Origin Offset Date"), + DateTimeZone.ToText(#"New Offset Date") + } + ), + + #"Round Trip Results" = + {#"Local Round Trip", #"UTC Round Trip", #"Offset Round Trip"} +in + #"Round Trip Results" + +// The example displays the following output in Power Query Desktop: +// Round-tripped 4/9/2024 11:30:00 PM -07:00 Local to 4/9/2024 11:30:00 PM -07:00 Local. +// Round-tripped 4/12/2024 9:30:00 AM +00:00 UTC to 4/12/2024 9:30:00 AM +00:00 UTC. +// Round-tripped 4/10/2024 5:30:00 PM -07:00 to 4/10/2024 5:30:00 PM -07:00. + +// The example displays the following output in Power Query Online: +// Round-tripped 4/10/2024 6:30:00 AM +00:00 Local to 4/10/2024 6:30:00 AM +00:00 Local. +// Round-tripped 4/12/2024 9:30:00 AM +00:00 UTC to 4/12/2024 9:30:00 AM +00:00 UTC. +// Round-tripped 4/11/2024 12:30:00 AM +00:00 to 4/11/2024 12:30:00 AM +00:00. +``` + +[Back to table](#table) + + + +### The RFC1123 ("R", "r") format specifier + +The "R" or "r" standard format specifier represents a custom date and time format string that's not defined by a specific culture. It is always the same, regardless of the culture used or the format provider supplied. The custom format string is "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'". When this standard format specifier is used, the formatting or parsing operation always uses the invariant culture. + +Although the RFC 1123 standard expresses a time as Coordinated Universal Time (UTC), the formatting operation doesn't modify the value of the date and time that's being formatted. Therefore, you must convert the DateTime value to UTC by calling the [DateTimeZone.ToUtc](datetimezone-toutc.md) function method before you perform the formatting operation. + +The following example uses the "r" format specifier to display a time and date value on a system in the U.S. Pacific Time zone (seven hours behind UTC). + +```powerquery-m +let + date1 = #datetimezone(2024, 4, 10, 6, 30, 0, -7, 0), + dateOffset = DateTimeZone.ToUtc(date1), + Source = + { + DateTimeZone.ToText(date1, [Format = "r"]), + // Displays Wed, 10 Apr 2024 13:30:00 GMT + + DateTimeZone.ToText(dateOffset, [Format = "r"]) + // Displays Wed, 10 Apr 2024 13:30:00 GMT + } +in + Source +``` + +[Back to table](#table) + + + +### The sortable ("s") format specifier + +The "s" standard format specifier represents a custom date and time format string that reflects a defined standard (ISO 8601), and is read-only. Therefore, it is always the same, regardless of the culture used or the format provider supplied. The custom format string is "yyyy'-'MM'-'dd'T'HH':'mm':'ss". The purpose of the "s" format specifier is to produce result strings that sort consistently in ascending or descending order based on date and time values. + +When this standard format specifier is used, the formatting or parsing operation always uses the invariant culture. + +The following example uses the "s" format specifier to display a date and time value on a system in the U.S. Pacific Time zone. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "s", Culture = "en-US"]) + // Displays 2024-04-10T06:30:00 + } +in + Source +``` + +[Back to table](#table) + + + +### The universal sortable ("u") format specifier + +The "u" standard format specifier represents a custom date and time format string that is always the same, regardless of the culture used or the format provider supplied. The custom format string is "yyyy'-'MM'-'dd HH':'mm':'ss'Z'". The pattern reflects a defined standard, and the property is read-only. When this standard format specifier is used, the formatting or parsing operation always uses the invariant culture. + +Although the result string should express a time as Coordinated Universal Time (UTC), no conversion of the original **DateTimeZone** value is performed during the formatting operation. Therefore, you must convert a **DateTimeZone** value to UTC by calling the [DateTimeZone.ToUtc](datetimezone-toutc.md) function before formatting it. + +The following example uses the "u" format specifier to display a date and time value. + +```powerquery-m +let + date1 = #datetimezone(2024, 4, 10, 6, 30, 0, -7, 0), + dateOffset = DateTimeZone.ToUtc(date1), + Source = + { + DateTimeZone.ToText(dateOffset, [Format = "u"]), + // Displays 2024-04-10 13:30:00Z + } +in + Source +``` + +[Back to table](#table) + +## Time formats + +This group includes the following formats: + +- [The short time ("t") format specifier](#the-short-time-t-format-specifier) +- [The long time ("T") format specifier](#the-long-time-t-format-specifier) + + + +### The short time ("t") format specifier + +The "t" standard format specifier represents a custom date and time format string that is defined by the specified culture. For example, the custom format string for the invariant culture is "HH:mm". + +The result string is affected by the formatting information of a specific culture. + +The following example uses the "t" format specifier to display a date and time value. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "t", Culture = ""]), + // Displays 06:30 + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "t", Culture = "en-US"]), + // Displays 6:30 AM + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "t", Culture = "es-ES"]) + // Displays 6:30 + } +in + Source +``` + +[Back to table](#table) + + + +### The long time ("T") format specifier + +The "T" standard format specifier represents a custom date and time format string that is defined by the specific culture. For example, the custom format string for the invariant culture is "HH:mm:ss". + +The following example uses the "T" format specifier to display a date and time value. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "T", Culture = ""]), + // Displays 06:30:00 + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "T", Culture = "en-US"]), + // Displays 6:30:00 AM + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "T", Culture = "es-ES"]) + // Displays 6:30:00 + } +in + Source +``` +[Back to table](#table) + +## Partial date formats + +This group includes the following formats: + +- [The month ("M", "m") format specifier](#the-month-m-m-format-specifier) +- [The year month ("Y", "y") format specifier](#the-year-month-y-y-format-specifier) + + + +### The month ("M", "m") format specifier + +The "M" or "m" standard format specifier represents a custom date and time format string that is defined by the specific culture. For example, the custom format string for the invariant culture is "MMMM dd". + +The following example uses the "m" format specifier to display a date and time value. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "m", Culture = ""]), + // Displays April 10 + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "m", Culture = "en-US"]), + // Displays April 10 + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "m", Culture = "ms-MY"]) + // Displays 10 April + } +in + Source +``` + +[Back to table](#table) + + + +### The year month ("Y", "y") format specifier + +The "Y" or "y" standard format specifier represents a custom date format string that is defined by a specific culture. For example, the custom format string for the invariant culture is "yyyy MMMM". + +The following example uses the "y" format specifier to display a date and time value. + +```powerquery-m +let + Source = + { + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "Y", Culture = ""]), + // Displays 2024 April + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "Y", Culture = "en-US"]), + // Displays April 2024 + + DateTime.ToText(#datetime(2024, 4, 10, 6, 30, 0), [Format = "y", Culture = "af-ZA"]) + // Displays April 2024 + } +in + Source +``` + +[Back to table](#table) + +## Related content + +- [How culture affects text formatting](how-culture-affects-text-formatting.md) +- [Date, Time, DateTime, and DateTimeZone type conversion](type-conversion.md#date-time-datetime-and-datetimezone) +- [Date functions](date-functions.md) +- [DateTime functions](datetime-functions.md) +- [DateTimeZone functions](datetimezone-functions.md) +- [Time functions](time-functions.md) +- [Custom Date and Time Format Strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/standard-numeric-format-strings.md b/query-languages/m/standard-numeric-format-strings.md new file mode 100644 index 000000000..e815da65d --- /dev/null +++ b/query-languages/m/standard-numeric-format-strings.md @@ -0,0 +1,412 @@ +--- +description: "Learn more about: Standard numeric format strings" +title: Standard numeric format strings +ms.date: 9/30/2024 +ms.custom: "nonautomated-date" +ms.subservice: m-background +--- + +# Standard numeric format strings + +Standard numeric format strings are used to format common numeric types. A standard numeric format string takes the form *`[format specifier][precision specifier]`*, where: + +- *Format specifier* is a single alphabetic character that specifies the type of number format, for example, currency or percent. Any numeric format string that contains more than one alphabetic character, including white space, is interpreted as a custom numeric format string. For more information, go to [Custom numeric format strings](custom-numeric-format-strings.md). + +- *Precision specifier* is an optional integer that affects the number of digits in the resulting string. The precision specifier controls the number of digits in the string representation of a number. + + When the precision specifier controls the number of fractional digits in the result string, the result string reflects a number that is rounded to a representable result nearest to the infinitely precise result. + + > [!NOTE] + > The precision specifier determines the number of digits in the result string. To pad a result string with leading or trailing spaces or other characters (such a 0), use the [Text.PadStart](text-padstart.md) and [Text.PadEnd](text-padend.md) functions and use the overall length `count` in these functions to pad the result string. + +Standard numeric format strings are supported by the [Number.ToText](number-totext.md) function. + +## Standard format specifiers + +The following table describes the standard numeric format specifiers and displays sample output produced by each format specifier. Go to the [Notes](#notes) section for additional information about using standard numeric format strings, and the [Code example](#code-example) section for a comprehensive illustration of their use. + +> [!NOTE] +> The result of a formatted string for a specific culture might differ from the following examples. Operating system settings, user settings, environment variables, and other settings on the system you use can all affect the format. + +| Format specifier | Name | Description | Examples | +|--|--|--|--| +| "C" or "c" | Currency | Result: A currency value.

Supported by: All numeric types.

Precision specifier: Number of decimal digits.

Default precision specifier: Defined by the culture.

More information: [The Currency ("C") Format Specifier](#CFormatString). | 123.456 ("C", en-US)
-> \$123.46

123.456 ("C", fr-FR)
-> 123,46 €

123.456 ("C", ja-JP)
-> ¥123

-123.456 ("C3", en-US)
-> (\$123.456)

-123.456 ("C3", fr-FR)
-> -123,456 €

-123.456 ("C3", ja-JP)
-> -¥123.456 | +| "D" or "d" | Decimal | Result: Integer digits with optional negative sign.

Supported by: Integral types only.

Precision specifier: Minimum number of digits.

Default precision specifier: Minimum number of digits required.

More information: [The Decimal("D") Format Specifier](#DFormatString). | 1234 ("D")
-> 1234

-1234 ("D6")
-> -001234 | +| "E" or "e" | Exponential (scientific) | Result: Exponential notation.

Supported by: All numeric types.

Precision specifier: Number of decimal digits.

Default precision specifier: 6.

More information: [The Exponential ("E") Format Specifier](#EFormatString). | 1052.0329112756 ("E", en-US)
-> 1.052033E+003

1052.0329112756 ("e", fr-FR)
-> 1,052033e+003

-1052.0329112756 ("e2", en-US)
-> -1.05e+003

-1052.0329112756 ("E2", fr-FR)
-> -1,05E+003 | +| "F" or "f" | Fixed-point | Result: Integral and decimal digits with optional negative sign.

Supported by: All numeric types.

Precision specifier: Number of decimal digits.

Default precision specifier: Defined by the culture.

More information: [The Fixed-Point ("F") Format Specifier](#FFormatString). | 1234.567 ("F", en-US)
-> 1234.57

1234.567 ("F", de-DE)
-> 1234,57

1234 ("F1", en-US)
-> 1234.0

1234 ("F1", de-DE)
-> 1234,0

-1234.56 ("F4", en-US)
-> -1234.5600

-1234.56 ("F4", de-DE)
-> -1234,5600 | +| "G" or "g" | General | Result: The more compact of either fixed-point or scientific notation.

Supported by: All numeric types.

Precision specifier: Number of significant digits.

Default precision specifier: Depends on numeric type.

More information: [The General ("G") Format Specifier](#GFormatString). | -123.456 ("G", en-US)
-> -123.456

-123.456 ("G", sv-SE)
-> -123,456

123.4546 ("G4", en-US)
-> 123.5

123.4546 ("G4", sv-SE)
-> 123,5

-1.234567890e-25 ("G", en-US)
-> -1.23456789E-25

-1.234567890e-25 ("G", sv-SE)
-> -1,23456789E-25 | +| "N" or "n" | Number | Result: Integral and decimal digits, group separators, and a decimal separator with optional negative sign.

Supported by: All numeric types.

Precision specifier: Desired number of decimal places.

Default precision specifier: Defined by the culture.

More information: [The Numeric ("N") Format Specifier](#NFormatString). | 1234.567 ("N", en-US)
-> 1,234.57

1234.567 ("N", ru-RU)
-> 1 234,57

1234 ("N1", en-US)
-> 1,234.0

1234 ("N1", ru-RU)
-> 1 234,0

-1234.56 ("N3", en-US)
-> -1,234.560

-1234.56 ("N3", ru-RU)
-> -1 234,560 | +| "P" or "p" | Percent | Result: Number multiplied by 100 and displayed with a percent symbol.

Supported by: All numeric types.

Precision specifier: Desired number of decimal places.

Default precision specifier: Defined by the culture.

More information: [The Percent ("P") Format Specifier](#PFormatString). | 1 ("P", en-US)
-> 100.00 %

1 ("P", fr-FR)
-> 100,00 %

-0.39678 ("P1", en-US)
-> -39.7 %

-0.39678 ("P1", fr-FR)
-> -39,7 % | +| "X" or "x" | Hexadecimal | Result: A hexadecimal string.

Supported by: Integral types only.

Precision specifier: Number of digits in the result string.

More information: [The Hexadecimal ("X") Format Specifier](#XFormatString). | 255 ("X")
-> FF

-1 ("x")
-> ff

255 ("x4")
-> 00ff

-1 ("X4")
-> 00FF | +| Any other single character | Unknown specifier | Result: Throws an Expression error at run time. | | + +## Use standard numeric format strings + +A standard numeric format string can be used to define the formatting of a numeric value. It can be passed to the [Number.ToText](number-totext.md) `format` parameter. The following example formats a numeric value as a currency string in the current culture (in this case, the en-US culture). + +```powerquery-m +Number.ToText(123.456, "C2") +// Displays $123.46 +``` + +Optionally, you can supply a `count` argument in the [Text.PadStart](text-padstart.md) and [Text.PadEnd](text-padend.md) functions to specify the width of the numeric field and whether its value is right- or left-aligned. For example, the following sample left-aligns a currency value in a 28-character field, and it right-aligns a currency value in a 14-character field (when using a monospaced font). + +```powerquery-m +let + amounts = {16305.32, 18794.16}, + result = Text.Format(" Beginning Balance Ending Balance#(cr,lf) #{0}#{1}", + { + Text.PadEnd(Number.ToText(amounts{0}, "C2"), 28), + Text.PadStart(Number.ToText(amounts{1}, "C2"), 14) + }) +in + result + +// Displays: +// Beginning Balance Ending Balance +// $16,305.32 $18,794.16 + +``` + +The following sections provide detailed information about each of the standard numeric format strings. + + + +## Currency format specifier (C) + +The "C" (or currency) format specifier converts a number to a string that represents a currency amount. The precision specifier indicates the desired number of decimal places in the result string. If the precision specifier is omitted, the default number of decimal places to use in currency values is 2. + +If the value to be formatted has more than the specified or default number of decimal places, the fractional value is rounded in the result string. If the value to the right of the number of specified decimal places is 5 or greater, the last digit in the result string is rounded away from zero. + +The result string is affected by the formatting information of the current culture. + +The following example formats a value with the currency format specifier: + +```powerquery-m +let + Source = + { + Number.ToText(12345.6789, "C"), + Number.ToText(12345.6789, "C3"), + Number.ToText(12345.6789, "C3", "da-DK") + } +in + Source + +// The example displays the following list on a system whose +// current culture is English (United States): +// $12,345.68 +// $12,345.679 +// 12.345,679 kr. +``` + + + +## Decimal format specifier (D) + +The "D" (or decimal) format specifier converts a number to a string of decimal digits (0-9), prefixed by a minus sign if the number is negative. This format is supported only for integral types. + +The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. If no precision specifier is specified, the default is the minimum value required to represent the integer without leading zeros. + +The result string is affected by the formatting information of the current culture. + +The following example formats a value with the decimal format specifier. + +```powerquery-m +let + Source = + { + Number.ToText(12345, "D"), + // Displays 12345 + + Number.ToText(12345, "D8"), + // Displays 00012345 + + Number.ToText(-12345, "D"), + // Displays -12345 + + Number.ToText(-12345, "D8") + // Displays -00012345 + } +in + Source +``` + + + +## Exponential format specifier (E) + +The exponential ("E") format specifier converts a number to a string of the form "-d.ddd…E+ddd" or "-d.ddd…e+ddd", where each "d" indicates a digit (0-9). The string starts with a minus sign if the number is negative. Exactly one digit always precedes the decimal point. + +The precision specifier indicates the desired number of digits after the decimal point. If the precision specifier is omitted, a default of six digits after the decimal point is used. + +The case of the format specifier indicates whether to prefix the exponent with an "E" or an "e". The exponent always consists of a plus or minus sign and a minimum of three digits. The exponent is padded with zeros to meet this minimum, if required. + +The result string is affected by the formatting information of the current culture. + +The following example formats a value with the exponential format specifier: + +```powerquery-m +let + Source = + { + Number.ToText(12345.6789, "E", ""), + // Displays 1.234568E+004 + + Number.ToText(12345.6789, "E10", ""), + // Displays 1.2345678900E+004 + + Number.ToText(12345.6789, "e4", ""), + // 1.2346e+004 + + Number.ToText(12345.6789, "E", "fr-FR") + // Displays 1,234568E+004 + } +in + Source +``` + +> [!NOTE] +> The blank text value ("") in the last parameter of [Number.ToText](number-totext.md) in the previous sample refers to the invariant culture. + + + +## Fixed-point format specifier (F) + +The fixed-point ("F") format specifier converts a number to a string of the form "-ddd.ddd…" where each "d" indicates a digit (0-9). The string starts with a minus sign if the number is negative. + +The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default number of decimal places to use in numeric values is 2. + +The result string is affected by the formatting information of the current culture. + +The following example formats a double and an integer value with the fixed-point format specifier: + +```powerquery-m +let + Source = + { + Number.ToText(17843, "F", ""), + // Displays 17843.00 + + Number.ToText(-29541, "F3", ""), + // Displays -29541.000 + + Number.ToText(18934.1879, "F", ""), + // Displays 18934.19 + + Number.ToText(18934.1879, "F0", ""), + // Displays 18934 + + Number.ToText(-1898300.1987, "F1", ""), + // Displays -1898300.2 + + Number.ToText(-1898300.1987, "F3", "es-ES") + // Displays -1898300,199 + } +in + Source +``` + + + +## General format specifier (G) + +The general ("G") format specifier converts a number to the more compact of either fixed-point or scientific notation, depending on the type of the number and whether a precision specifier is present. The precision specifier defines the maximum number of significant digits that can appear in the result string. If the precision specifier is omitted or zero, the type of the number determines the default precision, as indicated in the following table. + +|Numeric type | Default precision | +|----------------------------|-------------------| +|`Byte.Type` or `Int8.Type` |3 digits| +|`Int16.Type` |5 digits| +|`Int32.Type` |10 digits| +|`Int64.Type` |19 digits| +|`Single.Type` |9 digits| +|`Double.Type` |17 digits| +|`Decimal.Type` |15 digits| + +Fixed-point notation is used if the exponent that would result from expressing the number in scientific notation is greater than -5 and less than the precision specifier; otherwise, scientific notation is used. The result contains a decimal point if required, and trailing zeros after the decimal point are omitted. If the precision specifier is present and the number of significant digits in the result exceeds the specified precision, the excess trailing digits are removed by rounding. + +However, if the number is a `Decimal.Type` and the precision specifier is omitted, fixed-point notation is always used and trailing zeros are preserved. + +If scientific notation is used, the exponent in the result is prefixed with "E" if the format specifier is "G", or "e" if the format specifier is "g". The exponent contains a minimum of two digits. This differs from the format for scientific notation that is produced by the exponential format specifier, which includes a minimum of three digits in the exponent. + +The result string is affected by the formatting information of the current culture. + +The following example formats assorted floating-point values with the general format specifier: + +```powerquery-m +let + Source = + { + Number.ToText(12345.6789, "G", ""), + // Displays 12345.6789 + + Number.ToText(12345.6789, "G", "fr-FR"), + // Displays 12345,6789 + + Number.ToText(12345.6789, "G7", ""), + // Displays 12345.68 + + Number.ToText(.0000023, "G", ""), + // Displays 2.3E-06 + + Number.ToText(.0000023, "G", "fr-FR"), + // Displays 2,3E-06 + + Number.ToText(.0023, "G", ""), + // Displays 0.0023 + + Number.ToText(1234, "G2", ""), + // Displays 1.2E+03 + + Number.ToText(Number.PI, "G5", "") + // Displays 3.1416 + } +in + Source +``` + + + +## Numeric format specifier (N) + +The numeric ("N") format specifier converts a number to a string of the form "-d,ddd,ddd.ddd…", where "-" indicates a negative number symbol if required, "d" indicates a digit (0-9), "," indicates a group separator, and "." indicates a decimal point symbol. The precision specifier indicates the desired number of digits after the decimal point. If the precision specifier is omitted, the number of decimal places is defined by the current culture. + +The result string is affected by the formatting information of the current culture. + +The following example formats assorted floating-point values with the number format specifier: + +```powerquery-m +let + Source = + { + Number.ToText(-12445.6789, "N", ""), + // Displays -12,445.68 + + Number.ToText(-12445.6789, "N1", "sv-SE"), + // Displays -12 445,7 + + Number.ToText(123456789, "N1", "") + // Displays 123,456,789.0 + } +in + Source +``` + + + +## Percent format specifier (P) + +The percent ("P") format specifier multiplies a number by 100 and converts it to a string that represents a percentage. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default numeric precision supplied by the current culture is used. + +The following example formats floating-point values with the percent format specifier: + +```powerquery-m +let + Source = + { + Number.ToText(.2468013, "P", ""), + // Displays 24.68 % + + Number.ToText(.2468013, "P", "hr-HR"), + // Displays 24,68 % + + Number.ToText(.2468013, "P1", "en-US") + // Displays 24.7% + } +in + Source +``` + + + +## Hexadecimal format specifier (X) + +The hexadecimal ("X") format specifier converts a number to a string of hexadecimal digits. The case of the format specifier indicates whether to use uppercase or lowercase characters for hexadecimal digits that are greater than 9. For example, use "X" to produce "ABCDEF", and "x" to produce "abcdef". This format is supported only for integral types. + +The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. + +The result string isn't affected by the formatting information of the current culture. + +The following example formats values with the hexadecimal format specifier. + +```powerquery-m +let + Source = + { + Number.ToText(0x2045e, "x"), + // Displays 2045e + + Number.ToText(0x2045e, "X"), + // Displays 2045E + + Number.ToText(0x2045e, "X8"), + // Displays 0002045E + + Number.ToText(123456789, "X"), + // Displays 75BCD15 + + Number.ToText(123456789, "X2") + // Displays 75BCD15 + } +in + Source +``` + +## Notes + +This section contains additional information about using standard numeric format strings. + +### Integral and floating-point numeric types + +Some descriptions of standard numeric format specifiers refer to integral or floating-point numeric types. The integral numeric types are `Byte.Type`, `Int8.Type`, `Int16.Type`, `Int32.Type`, and`Int64.Type`. The floating-point numeric types are `Decimal.Type`, `Single.Type`, and `Double.Type`. + +### Floating-point infinities and NaN + +Regardless of the format string, if the value of a `Decimal.Type`, `Single.Type` or `Double.Type` floating-point type is positive infinity, negative infinity, or not a number (NaN), the formatted string is the value of the respective [Number.PositiveInfinity](number-positiveinfinity.md), [Number.NegativeInfinity](number-negativeinfinity.md), or [Number.NaN](number-nan.md) constants specified by the currently applicable culture. + +## Code example + +The following example formats a floating point and an integral numeric value using the en-US culture and all the standard numeric format specifiers. This example uses two particular numeric types (`Double.Type` and `Int32.Type`), but would yield similar results for any of the other numeric base types (`Byte.Type`, `Decimal.Type`, `Int8.Type`, `Int16.Type`, `Int64.Type`, and `Single.Type`). + +```powerquery-m +let + // Display text representations of numbers for en-US culture + culture = "en-US", + + // Output floating point values + floating = Double.From(10761.937554), + #"Floating results" = + { + Text.Format("C: #{0}", {Number.ToText(floating, "C", culture)}), // Displays "C: $10,761.94" + Text.Format("E: #{0}", {Number.ToText(floating, "E03", culture)}), // Displays "E: 1.076E+004" + Text.Format("F: #{0}", {Number.ToText(floating, "F04", culture)}), // Displays "F: 10761.9376" + Text.Format("G: #{0}", {Number.ToText(floating, "G", culture)}), // Displays "G: 10761.937554" + Text.Format("N: #{0}", {Number.ToText(floating, "N03", culture)}), // Displays "N: 10,761.938" + Text.Format("P: #{0}", {Number.ToText(floating/10000, "P02", culture)}) // Displays "P: 107.62%" + }, + + // Output integral values + integral = Int32.From(8395), + #"Integral results" = + { + Text.Format("C: #{0}", {Number.ToText(integral, "C", culture)}), // Displays "C: $8,395.00" + Text.Format("D: #{0}", {Number.ToText(integral, "D6", culture)}), // Displays "D: 008395" + Text.Format("E: #{0}", {Number.ToText(integral, "E03", culture)}), // Displays "E: 8.395E+003" + Text.Format("F: #{0}", {Number.ToText(integral, "F01", culture)}), // Displays "F: 8395.0" + Text.Format("G: #{0}", {Number.ToText(integral, "G", culture)}), // Displays "G: 8395" + Text.Format("N: #{0}", {Number.ToText(integral, "N01", culture)}), // Displays "N: 8,395.0" + Text.Format("P: #{0}", {Number.ToText(integral/10000, "P02", culture)}), // Displays "P: 83.95%" + Text.Format("X: 0x#{0}", {Number.ToText(integral, "X", culture)}) // Displays "X: 0x20CB" + }, + results = #"Floating results" & #"Integral results" + +in + results +``` + +## Related content + +- [How culture affects text formatting](how-culture-affects-text-formatting.md) +- [Number type conversion](type-conversion.md#number) +- [Data Types in Power Query](/power-query/data-types) +- [Custom Numeric Format Strings](custom-numeric-format-strings.md) diff --git a/query-languages/m/sybase-database.md b/query-languages/m/sybase-database.md index 9f4d071f0..05c2c7aaa 100644 --- a/query-languages/m/sybase-database.md +++ b/query-languages/m/sybase-database.md @@ -1,32 +1,29 @@ --- description: "Learn more about: Sybase.Database" -title: "Sybase.Database | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Sybase.Database" +ms.subservice: m-source --- # Sybase.Database ## Syntax
-Sybase.Database(server as text, database as text, optional options as nullable record) as table
+Sybase.Database(
+    server as text,
+    database as text,
+    optional options as nullable record
+) as table
 
## About -Returns a table of SQL tables and views available in a Sybase database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: +Returns a table of SQL tables and views available in a Sybase database on server `server` in the database instance named `database`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: -* `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). -* `NavigationPropertyNameGenerator` : A function that is used for the creation of names for navigation properties. -* `Query` : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. -* `CommandTimeout` : A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. -* `ConnectionTimeout` : 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. -* `HierarchicalNavigation` : A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). +* `NavigationPropertyNameGenerator`: A function that is used for the creation of names for navigation properties. +* `Query`: A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. +* `CommandTimeout`: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. +* `ConnectionTimeout`: 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. +* `HierarchicalNavigation`: A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). - The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. - +The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. diff --git a/query-languages/m/table-addcolumn.md b/query-languages/m/table-addcolumn.md index 80a6b2e21..02fb7d5db 100644 --- a/query-languages/m/table-addcolumn.md +++ b/query-languages/m/table-addcolumn.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.AddColumn" -title: "Table.AddColumn | Microsoft Docs" -ms.date: 3/9/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.AddColumn" +ms.subservice: m-source --- # Table.AddColumn ## Syntax
-Table.AddColumn(table as table, newColumnName as text, columnGenerator as function, optional columnType as nullable type) as table
+Table.AddColumn(
+    table as table,
+    newColumnName as text,
+    columnGenerator as function,
+    optional columnType as nullable type
+) as table
 
## About @@ -24,7 +22,7 @@ Adds a column named `newColumnName` to the table `table`. The values for the col ## Example 1 -Add a column named "TotalPrice" to the table with each value being the sum of column [Price] and column [Shipping]. +Add a number column named "TotalPrice" to the table, with each value being the sum of the [Price] and [Shipping] columns. **Usage** @@ -36,7 +34,8 @@ Table.AddColumn( [OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0, Shipping = 10.00] }), "TotalPrice", - each [Price] + [Shipping] + each [Price] + [Shipping], + type number ) ``` @@ -49,3 +48,7 @@ Table.FromRecords({ [OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25, Shipping = 10, TotalPrice = 35] }) ``` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/table-addfuzzyclustercolumn.md b/query-languages/m/table-addfuzzyclustercolumn.md index 12f544565..1d97cfb54 100644 --- a/query-languages/m/table-addfuzzyclustercolumn.md +++ b/query-languages/m/table-addfuzzyclustercolumn.md @@ -1,24 +1,22 @@ --- description: "Learn more about: Table.AddFuzzyClusterColumn" -title: "Table.AddFuzzyClusterColumn | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.AddFuzzyClusterColumn" +ms.subservice: m-source --- # Table.AddFuzzyClusterColumn ## Syntax
-Table.AddFuzzyClusterColumn(table as table, columnName as text, newColumnName as text, optional options as nullable record) as table
+Table.AddFuzzyClusterColumn(
+    table as table,
+    columnName as text,
+    newColumnName as text,
+    optional options as nullable record
+) as table
 
- -## About + +## About Adds a new column `newColumnName` to `table` with representative values of `columnName`. The representatives are obtained by fuzzily matching values in `columnName`, for each row. @@ -28,7 +26,7 @@ An optional set of `options` may be included to specify how to compare the key c * `IgnoreCase`: A logical (true/false) value that allows case-insensitive key grouping. For example, when true, "Grapes" is grouped with "grapes". The default value is true. * `IgnoreSpace`: A logical (true/false) value that allows combining of text parts in order to find groups. For example, when true, "Gra pes" is grouped with "Grapes". The default value is true. * `SimilarityColumnName`: A name for the column that shows the similarity between an input value and the representative value for that input. The default value is null, in which case a new column for similarities will not be added. -* `Threshold`: A number between 0.00 and 1.00 that specifies the similarity score at which two values will be grouped. For example, "Grapes" and "Graes" (missing "p") are grouped together only if this option is set to less than 0.90. A threshold of 1.00 is the same as specifying an exact match criteria while grouping. The default value is 0.80. +* `Threshold`: A number between 0.00 and 1.00 that specifies the similarity score at which two values will be grouped. For example, "Grapes" and "Graes" (missing the "p") are grouped together only if this option is set to less than 0.90. A threshold of 1.00 only allows exact matches. (Note that a fuzzy "exact match" might ignore differences like casing, word order, and punctuation.) The default value is 0.80. * `TransformationTable`: A table that allows grouping records based on custom value mappings. It should contain "From" and "To" columns. For example, "Grapes" is grouped with "Raisins" if a transformation table is provided with the "From" column containing "Grapes" and the "To" column containing "Raisins". Note that the transformation will be applied to all occurrences of the text in the transformation table. With the above transformation table, "Grapes are sweet" will also be grouped with "Raisins are sweet". ### Example 1 @@ -73,3 +71,7 @@ Table.FromRecords( type table [EmployeeID = nullable number, Location = nullable text, Location_Cleaned = nullable text] ) ``` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/table-addindexcolumn.md b/query-languages/m/table-addindexcolumn.md index fdb95e7db..d1598959d 100644 --- a/query-languages/m/table-addindexcolumn.md +++ b/query-languages/m/table-addindexcolumn.md @@ -1,21 +1,20 @@ --- description: "Learn more about: Table.AddIndexColumn" -title: "Table.AddIndexColumn | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.AddIndexColumn" +ms.subservice: m-source --- # Table.AddIndexColumn ## Syntax
-Table.AddIndexColumn(table as table, newColumnName as text, optional initialValue as nullable number, optional increment as nullable number, optional columnType as nullable type) as table
+Table.AddIndexColumn(
+    table as table,
+    newColumnName as text,
+    optional initialValue as nullable number,
+    optional increment as nullable number,
+    optional columnType as nullable type
+) as table
 
## About @@ -81,3 +80,7 @@ Table.FromRecords({ [CustomerID = 4, Name = "Ringo", Phone = "232-1550", Index = 25] }) ``` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/table-addjoincolumn.md b/query-languages/m/table-addjoincolumn.md index 2cdd871c2..930ac842b 100644 --- a/query-languages/m/table-addjoincolumn.md +++ b/query-languages/m/table-addjoincolumn.md @@ -1,24 +1,23 @@ --- description: "Learn more about: Table.AddJoinColumn" -title: "Table.AddJoinColumn | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.AddJoinColumn" +ms.subservice: m-source --- # Table.AddJoinColumn ## Syntax
-Table.AddJoinColumn(table1 as table, key1 as any, table2 as function, key2 as any, newColumnName as text) as table  
+Table.AddJoinColumn(
+    table1 as table,
+    key1 as any,
+    table2 as function,
+    key2 as any,
+    newColumnName as text
+) as table
 
- -## About + +## About Joins the rows of `table1` with the rows of `table2` based on the equality of the values of the key columns selected by `key1` (for `table1`) and `key2` (for `table2`). The results are entered into the column named `newColumnName`. This function behaves similarly to [Table.Join](/powerquery-m/table-join) with a JoinKind of LeftOuter except that the join results are presented in a nested rather than flattened fashion. diff --git a/query-languages/m/table-addkey.md b/query-languages/m/table-addkey.md index a7bc164c0..2efda1c44 100644 --- a/query-languages/m/table-addkey.md +++ b/query-languages/m/table-addkey.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.AddKey" -title: "Table.AddKey | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.AddKey" +ms.subservice: m-source --- # Table.AddKey ## Syntax
-Table.AddKey(table as table, columns as list, isPrimary as logical) as table
+Table.AddKey(
+    table as table,
+    columns as list,
+    isPrimary as logical
+) as table
 
## About diff --git a/query-languages/m/table-addrankcolumn.md b/query-languages/m/table-addrankcolumn.md index 88ecb2f6a..eee5c1bae 100644 --- a/query-languages/m/table-addrankcolumn.md +++ b/query-languages/m/table-addrankcolumn.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.AddRankColumn" -title: "Table.AddRankColumn | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.AddRankColumn" +ms.subservice: m-source --- # Table.AddRankColumn ## Syntax
-Table.AddRankColumn(table as table, newColumnName as text, comparisonCriteria as any, optional options as nullable record) as table
+Table.AddRankColumn(
+    table as table,
+    newColumnName as text,
+    comparisonCriteria as any,
+    optional options as nullable record
+) as table
 
## About @@ -52,3 +50,7 @@ Table.FromRecords({ [CustomerID = 4, Name = "Ringo", Revenue = 50, RevenueRank = 4] }) ``` + +## Related content + +[Comparison criteria](table-functions.md#comparison-criteria) diff --git a/query-languages/m/table-aggregatetablecolumn.md b/query-languages/m/table-aggregatetablecolumn.md index 4dc0156d7..53116303c 100644 --- a/query-languages/m/table-aggregatetablecolumn.md +++ b/query-languages/m/table-aggregatetablecolumn.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.AggregateTableColumn" -title: "Table.AggregateTableColumn | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.AggregateTableColumn" +ms.subservice: m-source --- # Table.AggregateTableColumn ## Syntax
-Table.AggregateTableColumn(table as table, column as text, aggregations as list) as table
+Table.AggregateTableColumn(
+    table as table,
+    column as text,
+    aggregations as list
+) as table
 
## About diff --git a/query-languages/m/table-alternaterows.md b/query-languages/m/table-alternaterows.md index 0beabe7e5..75a33ec5a 100644 --- a/query-languages/m/table-alternaterows.md +++ b/query-languages/m/table-alternaterows.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.AlternateRows" -title: "Table.AlternateRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.AlternateRows" +ms.subservice: m-source --- # Table.AlternateRows ## Syntax
-Table.AlternateRows(table as table, offset as number, skip as number, take as number) as table
+Table.AlternateRows(
+    table as table,
+    offset as number,
+    skip as number,
+    take as number
+) as table
 
## About diff --git a/query-languages/m/table-approximaterowcount.md b/query-languages/m/table-approximaterowcount.md index a9ccae258..0a434e1f7 100644 --- a/query-languages/m/table-approximaterowcount.md +++ b/query-languages/m/table-approximaterowcount.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ApproximateRowCount" -title: "Table.ApproximateRowCount | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ApproximateRowCount" +ms.subservice: m-source --- # Table.ApproximateRowCount diff --git a/query-languages/m/table-buffer.md b/query-languages/m/table-buffer.md index 23fd2e2ce..aa08f5e3e 100644 --- a/query-languages/m/table-buffer.md +++ b/query-languages/m/table-buffer.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Buffer" -title: "Table.Buffer | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Buffer" +ms.subservice: m-source --- # Table.Buffer @@ -22,11 +15,15 @@ Table.Buffer(table as table, optional options as nullable record) Buffers a table in memory, isolating it from external changes during evaluation. Buffering is shallow. It forces the evaluation of any scalar cell values, but leaves non-scalar values (records, lists, tables, and so on) as-is. -Note that using this function might or might not make your queries run faster. In some cases, it can make your queries run more slowly due to the added cost of reading all the data and storing it in memory, as well as the fact that buffering prevents downstream folding. If the data doesn't need to be buffered but you just want to prevent downstream folding, use [Table.StopFolding](/powerquery-m/table-stopfolding) instead. +* `table`: The table to buffer in memory. +* `options`: [Optional] The following options record values can be used: + * `BufferMode`: The buffer mode that describes the type of buffering to be performed. This option can be either [BufferMode.Eager](buffermode-type.md) or [BufferMode.Delayed](buffermode-type.md). + +Using this function might or might not make your queries run faster. In some cases, it can make your queries run more slowly due to the added cost of reading all the data and storing it in memory, as well as the fact that buffering prevents downstream folding. If the data doesn't need to be buffered but you just want to prevent downstream folding, use [Table.StopFolding](/powerquery-m/table-stopfolding) instead. ## Example 1 -Load all the rows of a SQL table into memory, so that any downstream operations will no longer be able to query the SQL server. +Load all the rows of a SQL table into memory, so that any downstream operations are no longer able to query the SQL server. **Usage** @@ -34,7 +31,7 @@ Load all the rows of a SQL table into memory, so that any downstream operations let Source = Sql.Database("SomeSQLServer", "MyDb"), MyTable = Source{[Item="MyTable"]}[Data], - BufferMyTable = Table.Buffer(dbo_MyTable) + BufferMyTable = Table.Buffer(MyTable) in BufferMyTable ``` diff --git a/query-languages/m/table-column.md b/query-languages/m/table-column.md index 5d8b22de7..29f22c33a 100644 --- a/query-languages/m/table-column.md +++ b/query-languages/m/table-column.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Column" -title: "Table.Column | Microsoft Docs" -ms.date: 3/10/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Column" +ms.subservice: m-source --- # Table.Column diff --git a/query-languages/m/table-columncount.md b/query-languages/m/table-columncount.md index a67f3598c..e0ffd77ec 100644 --- a/query-languages/m/table-columncount.md +++ b/query-languages/m/table-columncount.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ColumnCount" -title: "Table.ColumnCount | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ColumnCount" +ms.subservice: m-source --- # Table.ColumnCount diff --git a/query-languages/m/table-columnnames.md b/query-languages/m/table-columnnames.md index c2aee7f2c..6f3844045 100644 --- a/query-languages/m/table-columnnames.md +++ b/query-languages/m/table-columnnames.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ColumnNames" -title: "Table.ColumnNames | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ColumnNames" +ms.subservice: m-source --- # Table.ColumnNames diff --git a/query-languages/m/table-columnsoftype.md b/query-languages/m/table-columnsoftype.md index 002628532..03f439d87 100644 --- a/query-languages/m/table-columnsoftype.md +++ b/query-languages/m/table-columnsoftype.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ColumnsOfType" -title: "Table.ColumnsOfType | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ColumnsOfType" +ms.subservice: m-source --- # Table.ColumnsOfType @@ -41,3 +34,7 @@ Table.ColumnsOfType( **Output** `{"a"}` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/table-combine.md b/query-languages/m/table-combine.md index 386304647..65f06f7d3 100644 --- a/query-languages/m/table-combine.md +++ b/query-languages/m/table-combine.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Combine" -title: "Table.Combine | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Combine" +ms.subservice: m-source --- # Table.Combine diff --git a/query-languages/m/table-combinecolumns.md b/query-languages/m/table-combinecolumns.md index bbfa26477..516a9da14 100644 --- a/query-languages/m/table-combinecolumns.md +++ b/query-languages/m/table-combinecolumns.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.CombineColumns" -title: "Table.CombineColumns | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.CombineColumns" +ms.subservice: m-source --- # Table.CombineColumns ## Syntax
-Table.CombineColumns(table as table, sourceColumns as list, combiner as function, column as text) as table
+Table.CombineColumns(
+    table as table,
+    sourceColumns as list,
+    combiner as function,
+    column as text
+) as table
 
## About diff --git a/query-languages/m/table-combinecolumnstorecord.md b/query-languages/m/table-combinecolumnstorecord.md index 7a7e714ae..9378169d5 100644 --- a/query-languages/m/table-combinecolumnstorecord.md +++ b/query-languages/m/table-combinecolumnstorecord.md @@ -1,25 +1,28 @@ --- description: "Learn more about: Table.CombineColumnsToRecord" -title: "Table.CombineColumnsToRecord | Microsoft Docs" -ms.date: 09/14/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.CombineColumnsToRecord" +ms.subservice: m-source --- # Table.CombineColumnsToRecord ## Syntax
-Table.CombineColumnsToRecord(table as table, newColumnName as text, sourceColumns as list, optional options as nullable record) as table
+Table.CombineColumnsToRecord(
+    table as table,
+    newColumnName as text,
+    sourceColumns as list,
+    optional options as nullable record
+) as table
 
- -## About + +## About + Combines the specified columns of `table` into a new record-valued column named `newColumnName` where each record has field names and values corresponding to the column names and values of the columns that were combined. If a record is specified for `options`, the following options may be provided: * `DisplayNameColumn`: When specified as text, indicates that the given column name should be treated as the display name of the record. This need not be one of the columns in the record itself. * `TypeName`: When specified as text, supplies a logical type name for the resulting record which can be used during data load to drive behavior by the loading environment. + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/table-conformtopagereader.md b/query-languages/m/table-conformtopagereader.md index df002c573..9e9e17fce 100644 --- a/query-languages/m/table-conformtopagereader.md +++ b/query-languages/m/table-conformtopagereader.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ConformToPageReader" -title: "Table.ConformToPageReader | Microsoft Docs" -ms.date: 8/21/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ConformToPageReader" +ms.subservice: m-source --- # Table.ConformToPageReader @@ -17,6 +10,7 @@ ms.author: dougklo
 Table.ConformToPageReader(table as table, shapingFunction as function) as table
 
- -## About + +## About + This function is intended for internal use only. diff --git a/query-languages/m/table-contains.md b/query-languages/m/table-contains.md index 2d1f94151..9303b50db 100644 --- a/query-languages/m/table-contains.md +++ b/query-languages/m/table-contains.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.Contains" -title: "Table.Contains | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Contains" +ms.subservice: m-source --- # Table.Contains ## Syntax
-Table.Contains(table as table, row as record, optional equationCriteria as any) as logical
+Table.Contains(
+    table as table,
+    row as record,
+    optional equationCriteria as any
+) as logical
 
## About @@ -88,3 +85,7 @@ Table.Contains( **Output** `true` + +## Related content + +[Equation criteria](table-functions.md#equation-criteria) diff --git a/query-languages/m/table-containsall.md b/query-languages/m/table-containsall.md index ddfdfb3a8..6becc1a8b 100644 --- a/query-languages/m/table-containsall.md +++ b/query-languages/m/table-containsall.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.ContainsAll" -title: "Table.ContainsAll | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ContainsAll" +ms.subservice: m-source --- # Table.ContainsAll ## Syntax
-Table.ContainsAll(table as table, rows as list, optional equationCriteria as any) as logical
+Table.ContainsAll(
+    table as table,
+    rows as list,
+    optional equationCriteria as any
+) as logical
 
## About @@ -72,3 +69,7 @@ Table.ContainsAll( **Output** `false` + +## Related content + +[Equation criteria](table-functions.md#equation-criteria) diff --git a/query-languages/m/table-containsany.md b/query-languages/m/table-containsany.md index 5bad42dfb..5ddcefc34 100644 --- a/query-languages/m/table-containsany.md +++ b/query-languages/m/table-containsany.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.ContainsAny" -title: "Table.ContainsAny | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ContainsAny" +ms.subservice: m-source --- # Table.ContainsAny ## Syntax
-Table.ContainsAny(table as table, rows as list, optional equationCriteria as any) as logical
+Table.ContainsAny(
+    table as table,
+    rows as list,
+    optional equationCriteria as any
+) as logical
 
## About @@ -91,3 +88,7 @@ Table.ContainsAny( **Output** `true` + +## Related content + +[Equation criteria](table-functions.md#equation-criteria) diff --git a/query-languages/m/table-demoteheaders.md b/query-languages/m/table-demoteheaders.md index 0735b0240..c4181e637 100644 --- a/query-languages/m/table-demoteheaders.md +++ b/query-languages/m/table-demoteheaders.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.DemoteHeaders" -title: "Table.DemoteHeaders | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.DemoteHeaders" +ms.subservice: m-source --- # Table.DemoteHeaders diff --git a/query-languages/m/table-distinct.md b/query-languages/m/table-distinct.md index 8f2adbf9f..a73b486b9 100644 --- a/query-languages/m/table-distinct.md +++ b/query-languages/m/table-distinct.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Table.Distinct" -title: "Table.Distinct | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Distinct" +ms.subservice: m-source --- # Table.Distinct @@ -19,7 +13,9 @@ Table.Distinct(table as table, optional equationCriteria as any) a ## About -Removes duplicate rows from the table `table`. An optional parameter, `equationCriteria`, specifies which columns of the table are tested for duplication. If `equationCriteria` is not specified, all columns are tested. +Removes duplicate rows from the table. An optional parameter, `equationCriteria`, specifies which columns of the table are tested for duplication. If `equationCriteria` is not specified, all columns are tested. + +Because Power Query sometimes offloads certain operations to backend data sources (known as *folding*), and also sometimes optimizes queries by skipping operations that aren't strictly necessary, in general there's no guarantee which specific duplicate will be preserved. For example, you can't assume that the first row with a unique set of column values will remain, and rows further down in the table will be removed. If you want the duplicate removal to behave predictably, first buffer the table using [Table.Buffer](table-buffer.md). ## Example 1 @@ -71,3 +67,7 @@ Table.FromRecords({ [a = "A", b = "b"] }) ``` + +## Related content + +[Equation criteria](table-functions.md#equation-criteria) diff --git a/query-languages/m/table-duplicatecolumn.md b/query-languages/m/table-duplicatecolumn.md index 4de82ec66..003eee895 100644 --- a/query-languages/m/table-duplicatecolumn.md +++ b/query-languages/m/table-duplicatecolumn.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.DuplicateColumn" -title: "Table.DuplicateColumn | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.DuplicateColumn" +ms.subservice: m-source --- # Table.DuplicateColumn ## Syntax
-Table.DuplicateColumn(table as table, columnName as text, newColumnName as text, optional columnType as nullable type) as table
+Table.DuplicateColumn(
+    table as table,
+    columnName as text,
+    newColumnName as text,
+    optional columnType as nullable type
+) as table
 
## About @@ -47,3 +45,7 @@ Table.FromRecords({ [a = 3, b = 4, #"copied column" = 3] }) ``` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/table-expandlistcolumn.md b/query-languages/m/table-expandlistcolumn.md index c7cda4f30..b4a411d9a 100644 --- a/query-languages/m/table-expandlistcolumn.md +++ b/query-languages/m/table-expandlistcolumn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ExpandListColumn" -title: "Table.ExpandListColumn | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ExpandListColumn" +ms.subservice: m-source --- # Table.ExpandListColumn @@ -20,11 +13,11 @@ Table.ExpandListColumn(table as table, column as text) as table ## About -Given a `table`, where a `column` is a list of values, splits the list into a row for each value. Values in the other columns are duplicated in each new row created. +Given a `table` where `column` contains a list of values, splits the list into a row for each value. Values in the other columns are duplicated in each new row created. This function can also expand nested tables by treating them as lists of records. ## Example 1 -Split the list column [Name] in the table. +Split the list column [Name]. **Usage** @@ -44,3 +37,30 @@ Table.FromRecords({ [Name = "Paul", Discount = 0.15] }) ``` + +## Example 2 + +Split the nested table column [Components]. + +**Usage** + +```powerquery-m +Table.ExpandListColumn( + #table( + {"Part", "Components"}, + { + {"Tool", #table({"Name", "Quantity"}, {{"Thingamajig", 2}, {"Widget", 3}})} + } + ), + "Components" +) +``` + +**Output** + +```powerquery-m +Table.FromRecords({ + [Part = "Tool", Components = [Name = "Thingamajig", Quantity = 2]], + [Part = "Tool", Components = [Name = "Widget", Quantity = 3]] +}) +``` diff --git a/query-languages/m/table-expandrecordcolumn.md b/query-languages/m/table-expandrecordcolumn.md index 89fa06e44..289f3c3b9 100644 --- a/query-languages/m/table-expandrecordcolumn.md +++ b/query-languages/m/table-expandrecordcolumn.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.ExpandRecordColumn" -title: "Table.ExpandRecordColumn | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ExpandRecordColumn" +ms.subservice: m-source --- # Table.ExpandRecordColumn ## Syntax
-Table.ExpandRecordColumn(table as table, column as text, fieldNames as list, optional newColumnNames as nullable list) as table
+Table.ExpandRecordColumn(
+    table as table,
+    column as text,
+    fieldNames as list,
+    optional newColumnNames as nullable list
+) as table
 
## About diff --git a/query-languages/m/table-expandtablecolumn.md b/query-languages/m/table-expandtablecolumn.md index f51195e6f..8167c914a 100644 --- a/query-languages/m/table-expandtablecolumn.md +++ b/query-languages/m/table-expandtablecolumn.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.ExpandTableColumn" -title: "Table.ExpandTableColumn | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ExpandTableColumn" +ms.subservice: m-source --- # Table.ExpandTableColumn ## Syntax
-Table.ExpandTableColumn(table as table, column as text, columnNames as list, optional newColumnNames as nullable list) as table
+Table.ExpandTableColumn(
+    table as table,
+    column as text,
+    columnNames as list,
+    optional newColumnNames as nullable list
+) as table
 
## About diff --git a/query-languages/m/table-filldown.md b/query-languages/m/table-filldown.md index d9f08bfb5..9a25d3fd5 100644 --- a/query-languages/m/table-filldown.md +++ b/query-languages/m/table-filldown.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.FillDown" -title: "Table.FillDown | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FillDown" +ms.subservice: m-source --- # Table.FillDown diff --git a/query-languages/m/table-fillup.md b/query-languages/m/table-fillup.md index 40b56a284..6982f6477 100644 --- a/query-languages/m/table-fillup.md +++ b/query-languages/m/table-fillup.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.FillUp" -title: "Table.FillUp | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FillUp" +ms.subservice: m-source --- # Table.FillUp diff --git a/query-languages/m/table-filterwithdatatable.md b/query-languages/m/table-filterwithdatatable.md index 9133afe63..efb12c334 100644 --- a/query-languages/m/table-filterwithdatatable.md +++ b/query-languages/m/table-filterwithdatatable.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.FilterWithDataTable" -title: "Table.FilterWithDataTable | Microsoft Docs" -ms.date: 5/3/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FilterWithDataTable" +ms.subservice: m-source --- # Table.FilterWithDataTable diff --git a/query-languages/m/table-findtext.md b/query-languages/m/table-findtext.md index a4f95719a..876e4cad1 100644 --- a/query-languages/m/table-findtext.md +++ b/query-languages/m/table-findtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.FindText" -title: "Table.FindText | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FindText" +ms.subservice: m-source --- # Table.FindText diff --git a/query-languages/m/table-first.md b/query-languages/m/table-first.md index e128a22bc..4de7aa672 100644 --- a/query-languages/m/table-first.md +++ b/query-languages/m/table-first.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.First" -title: "Table.First | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.First" +ms.subservice: m-source --- # Table.First diff --git a/query-languages/m/table-firstn.md b/query-languages/m/table-firstn.md index c30dadc51..c43914b8f 100644 --- a/query-languages/m/table-firstn.md +++ b/query-languages/m/table-firstn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.FirstN" -title: "Table.FirstN | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FirstN" +ms.subservice: m-source --- # Table.FirstN diff --git a/query-languages/m/table-firstvalue.md b/query-languages/m/table-firstvalue.md index 0c2402f0c..8fbc2e700 100644 --- a/query-languages/m/table-firstvalue.md +++ b/query-languages/m/table-firstvalue.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.FirstValue" -title: "Table.FirstValue | Microsoft Docs" -ms.date: 8/1/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FirstValue" +ms.subservice: m-source --- # Table.FirstValue @@ -19,5 +12,5 @@ Table.FirstValue(table as table, optional default as any) as any ## About -Returns the first column of the first row of the table `table` or a specified default value. +Returns the first column of the first row of the table `table` or a specified default value. diff --git a/query-languages/m/table-fromcolumns.md b/query-languages/m/table-fromcolumns.md index a8f065bd2..48e5955e5 100644 --- a/query-languages/m/table-fromcolumns.md +++ b/query-languages/m/table-fromcolumns.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.FromColumns" -title: "Table.FromColumns | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FromColumns" +ms.subservice: m-source --- # Table.FromColumns diff --git a/query-languages/m/table-fromlist.md b/query-languages/m/table-fromlist.md index 307c49adc..a427d14c2 100644 --- a/query-languages/m/table-fromlist.md +++ b/query-languages/m/table-fromlist.md @@ -1,51 +1,79 @@ --- description: "Learn more about: Table.FromList" -title: "Table.FromList | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FromList" +ms.subservice: m-source --- # Table.FromList ## Syntax
-Table.FromList(list as list, optional splitter as nullable function, optional columns as any, optional default as any, optional extraValues as nullable number) as table
+Table.FromList(
+    list as list,
+    optional splitter as nullable function,
+    optional columns as any,
+    optional default as any,
+    optional extraValues as nullable number
+) as table
 
## About -Converts a list, `list` into a table by applying the optional splitting function, `splitter`, to each item in the list. By default, the list is assumed to be a list of text values that is split by commas. Optional `columns` may be the number of columns, a list of columns or a TableType. Optional `default` and `extraValues` may also be specified. +Converts a list, `list` into a table by applying the optional [splitting function](splitter-functions.md), `splitter`, to each item in the list. By default, the list is assumed to be a list of text values that is split by commas. Optional `columns` may be the number of columns, a list of columns or a TableType. Optional `default` and `extraValues` may also be specified. ## Example 1 -Create a table from the list with the column named "Letters" using the default splitter. +Create a table from a list using the default splitter. **Usage** ```powerquery-m -Table.FromList({"a", "b", "c", "d"}, null, {"Letters"}) +Table.FromList( + {"a,apple", "b,ball", "c,cookie", "d,door"}, + null, + {"Letter", "Example Word"} +) ``` **Output** ```powerquery-m Table.FromRecords({ - [Letters = "a"], - [Letters = "b"], - [Letters = "c"], - [Letters = "d"] + [Letter = "a", #"Example Word" = "apple"], + [Letter = "b", #"Example Word" = "ball"], + [Letter = "c", #"Example Word" = "cookie"], + [Letter = "d", #"Example Word" = "door"] }) ``` ## Example 2 -Create a table from the list using the [Record.FieldValues](record-fieldvalues.md) splitter with the resulting table having "CustomerID" and "Name" as column names. +Create a table from a list using a custom splitter. + +**Usage** + +```powerquery-m +Table.FromList( + {"a,apple", "b,ball", "c,cookie", "d,door"}, + Splitter.SplitByNothing(), + {"Letter and Example Word"} +) +``` + +**Output** + +```powerquery-m +Table.FromRecords({ + [#"Letter and Example Word" = "a,apple"], + [#"Letter and Example Word" = "b,ball"], + [#"Letter and Example Word" = "c,cookie"], + [#"Letter and Example Word" = "d,door"] +}) +``` + +## Example 3 + +Create a table from the list using the [Record.FieldValues](record-fieldvalues.md) splitter. **Usage** diff --git a/query-languages/m/table-frompartitions.md b/query-languages/m/table-frompartitions.md index 7ecc52720..8270b27f9 100644 --- a/query-languages/m/table-frompartitions.md +++ b/query-languages/m/table-frompartitions.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.FromPartitions" -title: "Table.FromPartitions | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FromPartitions" +ms.subservice: m-source --- # Table.FromPartitions ## Syntax
-Table.FromPartitions(partitionColumn as text, partitions as list, optional partitionColumnType as nullable type) as table
+Table.FromPartitions(
+    partitionColumn as text,
+    partitions as list,
+    optional partitionColumnType as nullable type
+) as table
 
## About @@ -94,3 +91,7 @@ Table.FromRecords({ ] }) ``` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/table-fromrecords.md b/query-languages/m/table-fromrecords.md index 7cbb91492..52034a823 100644 --- a/query-languages/m/table-fromrecords.md +++ b/query-languages/m/table-fromrecords.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.FromRecords" -title: "Table.FromRecords | Microsoft Docs" -ms.date: 3/10/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FromRecords" +ms.subservice: m-source --- # Table.FromRecords ## Syntax
-Table.FromRecords(records as list, optional columns as any, optional missingField as nullable number) as table
+Table.FromRecords(
+    records as list,
+    optional columns as any,
+    optional missingField as nullable number
+) as table
 
## About @@ -65,3 +62,7 @@ Table.ColumnsOfType( **Output** `{"CustomerID"}` + +## Related content + +[Missing field](missingfield-type.md) diff --git a/query-languages/m/table-fromrows.md b/query-languages/m/table-fromrows.md index e91500608..ef52924e3 100644 --- a/query-languages/m/table-fromrows.md +++ b/query-languages/m/table-fromrows.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.FromRows" -title: "Table.FromRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FromRows" +ms.subservice: m-source --- # Table.FromRows @@ -35,7 +28,7 @@ Table.FromRows( {2, "Jim", "987-6543"} }, {"CustomerID", "Name", "Phone"} - +) ``` **Output** diff --git a/query-languages/m/table-fromvalue.md b/query-languages/m/table-fromvalue.md index e3ba9e16d..0e5804133 100644 --- a/query-languages/m/table-fromvalue.md +++ b/query-languages/m/table-fromvalue.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.FromValue" -title: "Table.FromValue | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FromValue" +ms.subservice: m-source --- # Table.FromValue diff --git a/query-languages/m/table-functions.md b/query-languages/m/table-functions.md index d1a246e11..56f331bbb 100644 --- a/query-languages/m/table-functions.md +++ b/query-languages/m/table-functions.md @@ -1,13 +1,9 @@ --- description: "Learn more about: Table functions" -title: "Table functions | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table functions" +ms.date: 8/29/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-source --- # Table functions @@ -17,167 +13,170 @@ These functions create and manipulate table values. |Name|Description| |------------|---------------| +[#table](sharptable.md) | Creates a table value from columns and rows.| |[ItemExpression.From](itemexpression-from.md) | Returns the abstract syntax tree (AST) for the body of a function.| -|[ItemExpression.Item](itemexpression-item.md) | An abstract syntax tree (AST) node representing the item in an item expression.| |[RowExpression.Column](rowexpression-column.md)|Returns an abstract syntax tree (AST) that represents access to a column within a row expression.| |[RowExpression.From](rowexpression-from.md)|Returns the abstract syntax tree (AST) for the body of a function.| -|[RowExpression.Row](rowexpression-row.md)|An abstract syntax tree (AST) node representing the row in a row expression.| -|[Table.FromColumns](table-fromcolumns.md)|Returns a table from a list containing nested lists with the column names and values.| +|[Table.FromColumns](table-fromcolumns.md)|Creates a table from a list of columns and specified values.| |[Table.FromList](table-fromlist.md)|Converts a list into a table by applying the specified splitting function to each item in the list.| -|[Table.FromRecords](table-fromrecords.md)|Returns a table from a list of records.| -|[Table.FromRows](table-fromrows.md)|Creates a table from the list where each element of the list is a list that contains the column values for a single row.| -|[Table.FromValue](table-fromvalue.md)|Returns a table with a column containing the provided value or list of values.| -|[Table.FuzzyGroup](table-fuzzygroup.md)|Groups the rows of a table by fuzzily matching values in the specified column for each row.| -|[Table.FuzzyJoin](table-fuzzyjoin.md)|Joins the rows from the two tables that fuzzy match based on the given keys.| -|[Table.FuzzyNestedJoin](table-fuzzynestedjoin.md)|Performs a fuzzy join between tables on supplied columns and produces the join result in a new column.| -|[Table.Split](table-split.md)|Splits the specified table into a list of tables using the specified page size.| +|[Table.FromRecords](table-fromrecords.md)|Converts a list of records into a table.| +|[Table.FromRows](table-fromrows.md)|Creates a table from a list of row values and optional columns.| +|[Table.FromValue](table-fromvalue.md)|Creates a table with a column from the provided value or values.| +|[Table.WithErrorContext](table-witherrorcontext.md) | This function is intended for internal use only.| |[Table.View](table-view.md)|Creates or extends a table with user-defined handlers for query and action operations.| +|[Table.ViewError](table-viewerror.md) | Creates a modified error record that won't trigger a fallback when thrown by a handler defined on a view (via [Table.View](table-view.md)).| |[Table.ViewFunction](table-viewfunction.md) | Creates a function that can be intercepted by a handler defined on a view (via [Table.View](table-view.md)).| -|[Table.ViewError](table-viewerror.md) | Creates a modified error record which won't trigger a fallback when thrown by a handler defined on a view (via **Table.View**)| ## Conversions |Name|Description| |------------|---------------| -|[Table.ToColumns](table-tocolumns.md)|Returns a list of nested lists each representing a column of values in the input table.| -|[Table.ToList](table-tolist.md)|Returns a table into a list by applying the specified combining function to each row of values in a table.| -|[Table.ToRecords](table-torecords.md)|Returns a list of records from an input table.| -|[Table.ToRows](table-torows.md)|Returns a nested list of row values from an input table.| +|[Table.ToColumns](table-tocolumns.md)|Creates a list of nested lists of column values from a table.| +|[Table.ToList](table-tolist.md)|Converts a table into a list by applying the specified combining function to each row of values in the table.| +|[Table.ToRecords](table-torecords.md)|Converts a table to a list of records.| +|[Table.ToRows](table-torows.md)|Creates a list of nested lists of row values from a table.| ## Information |Name|Description| |------------|---------------| |[Table.ApproximateRowCount](table-approximaterowcount.md)|Returns the approximate number of rows in the table.| -|[Table.ColumnCount](table-columncount.md)|Returns the number of columns in a table.| -|[Table.IsEmpty](table-isempty.md)|Returns true if the table does not contain any rows.| +|[Table.ColumnCount](table-columncount.md)|Returns the number of columns in the table.| +|[Table.IsEmpty](table-isempty.md)|Indicates whether the table contains any rows.| +|[Table.PartitionValues](table-partitionvalues.md)|Returns information about how a table is partitioned.| |[Table.Profile](table-profile.md)|Returns a profile of the columns of a table.| -|[Table.RowCount](table-rowcount.md)|Returns the number of rows in a table.| -|[Table.Schema](table-schema.md)|Returns a table containing a description of the columns (i.e. the schema) of the specified table.| -|[Tables.GetRelationships](tables-getrelationships.md)|Returns the relationships among a set of tables. | +|[Table.RowCount](table-rowcount.md)|Returns the number of rows in the table.| +|[Table.Schema](table-schema.md)|Returns a table containing a description of the columns (that is, the schema) of the specified table.| +|[Tables.GetRelationships](tables-getrelationships.md)|Gets the relationships among a set of tables.| ## Row operations |Name|Description| |------------|---------------| -|[Table.AlternateRows](table-alternaterows.md)|Returns a table containing an alternating pattern of the rows from a table.| -|[Table.Combine](table-combine.md)|Returns a table that is the result of merging a list of tables. The tables must all have the same row type structure.| -|[Table.FindText](table-findtext.md)|Returns a table containing only the rows that have the specified text within one of their cells or any part thereof.| -|[Table.First](table-first.md)|Returns the first row from a table.| -|[Table.FirstN](table-firstn.md)|Returns the first row(s) of a table, depending on the countOrCondition parameter.| +|[Table.AlternateRows](table-alternaterows.md)|Keeps the initial offset then alternates taking and skipping the following rows.| +|[Table.Combine](table-combine.md)|Returns a table that is the result of merging a list of tables.| +|[Table.FindText](table-findtext.md)|Returns all the rows that contain the given text in the table.| +|[Table.First](table-first.md)|Returns the first row or a specified default value.| +|[Table.FirstN](table-firstn.md)|Returns the first count rows specified.| |[Table.FirstValue](table-firstvalue.md)|Returns the first column of the first row of the table or a specified default value.| -|[Table.FromPartitions](table-frompartitions.md)|Returns a table that is the result of combining a set of partitioned tables into new columns. The type of the column can optionally be specified, the default is any.| -|[Table.InsertRows](table-insertrows.md)|Returns a table with the list of rows inserted into the table at an index. Each row to insert must match the row type of the table..| -|[Table.Last](table-last.md)|Returns the last row of a table.| -|[Table.LastN](table-lastn.md)|Returns the last row(s) from a table, depending on the countOrCondition parameter.| -|[Table.MatchesAllRows](table-matchesallrows.md)|Returns true if all of the rows in a table meet a condition.| -|[Table.MatchesAnyRows](table-matchesanyrows.md)|Returns true if any of the rows in a table meet a condition.| -|[Table.Partition](table-partition.md)|Partitions the table into a list of groups number of tables, based on the value of the column of each row and a hash function. The hash function is applied to the value of the column of a row to obtain a hash value for the row. The hash value modulo groups determines in which of the returned tables the row will be placed.| -|[Table.PartitionValues](table-partitionvalues.md)|Returns information about how a table is partitioned.| -|[Table.Range](table-range.md)|Returns the specified number of rows from a table starting at an offset.| -|[Table.RemoveFirstN](table-removefirstn.md)|Returns a table with the specified number of rows removed from the table starting at the first row. The number of rows removed depends on the optional countOrCondition parameter.| -|[Table.RemoveLastN](table-removelastn.md)|Returns a table with the specified number of rows removed from the table starting at the last row. The number of rows removed depends on the optional countOrCondition parameter.| -|[Table.RemoveRows](table-removerows.md)|Returns a table with the specified number of rows removed from the table starting at an offset.| -|[Table.RemoveRowsWithErrors](table-removerowswitherrors.md)|Returns a table with all rows removed from the table that contain an error in at least one of the cells in a row.| -|[Table.Repeat](table-repeat.md)|Returns a table containing the rows of the table repeated the count number of times.| -|[Table.ReplaceRows](table-replacerows.md)|Returns a table where the rows beginning at an offset and continuing for count are replaced with the provided rows.| +|[Table.FromPartitions](table-frompartitions.md)|Returns a table that is the result of combining a set of partitioned tables.| +|[Table.InsertRows](table-insertrows.md)|Inserts a list of rows into the table at the specified position.| +|[Table.Last](table-last.md)|Returns the last row or a specified default value.| +|[Table.LastN](table-lastn.md)|Returns the last specified number of rows.| +|[Table.MatchesAllRows](table-matchesallrows.md)|Indicates whether all the rows in the table meet the given condition.| +|[Table.MatchesAnyRows](table-matchesanyrows.md)|Indicates whether any the rows in the table meet the given condition.| +|[Table.Partition](table-partition.md)|Partitions the table into a list of tables based on the number of groups and column specified.| +|[Table.Range](table-range.md)|Returns the rows beginning at the specified offset.| +|[Table.RemoveFirstN](table-removefirstn.md)|Returns a table with the specified number of rows removed from the table starting at the first row.| +|[Table.RemoveLastN](table-removelastn.md)|Returns a table with the specified number of rows removed from the table starting at the last row.| +|[Table.RemoveRows](table-removerows.md)|Removes the specified number of rows.| +|[Table.RemoveRowsWithErrors](table-removerowswitherrors.md)|Returns a table with the rows removed from the input table that contain an error in at least one of the cells. If a columns list is specified, then only the cells in the specified columns are inspected for errors.| +|[Table.Repeat](table-repeat.md)|Repeats the rows of the tables a specified number of times.| +|[Table.ReplaceRows](table-replacerows.md)|Replaces the specified range of rows with the provided row or rows.| |[Table.ReverseRows](table-reverserows.md)|Returns a table with the rows in reverse order.| -|[Table.SelectRows](table-selectrows.md)|Returns a table containing only the rows that match a condition.| -|[Table.SelectRowsWithErrors](table-selectrowswitherrors.md)|Returns a table with only the rows from table that contain an error in at least one of the cells in a row.| -|[Table.SingleRow](table-singlerow.md)|Returns a single row from a table.| -|[Table.Skip](table-skip.md)|Returns a table that does not contain the first row or rows of the table.| +|[Table.SelectRows](table-selectrows.md)|Selects the rows that meet the condition function.| +|[Table.SelectRowsWithErrors](table-selectrowswitherrors.md)|Returns a table with only those rows of the input table that contain an error in at least one of the cells. If a columns list is specified, then only the cells in the specified columns are inspected for errors.| +|[Table.SingleRow](table-singlerow.md)|Returns a single row in the table.| +|[Table.Skip](table-skip.md)|Returns a table with the first specified number of rows skipped.| |[Table.SplitAt](table-splitat.md)|Returns a list containing the first count rows specified and the remaining rows.| ## Column operations |Name|Description| |------------|---------------| -|[Table.Column](table-column.md)|Returns the values from a column in a table.| -|[Table.ColumnNames](table-columnnames.md)|Returns the names of columns from a table.| +|[Table.Column](table-column.md)|Returns a specified column of data from the table as a list.| +|[Table.ColumnNames](table-columnnames.md)|Returns the column names as a list.| |[Table.ColumnsOfType](table-columnsoftype.md)|Returns a list with the names of the columns that match the specified types.| -|[Table.DemoteHeaders](table-demoteheaders.md)|Demotes the header row down into the first row of a table.| +|[Table.DemoteHeaders](table-demoteheaders.md)|Demotes the column headers to the first row of values.| |[Table.DuplicateColumn](table-duplicatecolumn.md) | Duplicates a column with the specified name. Values and type are copied from the source column.| -|[Table.HasColumns](table-hascolumns.md)|Returns true if a table has the specified column or columns.| -|[Table.Pivot](table-pivot.md)|Given a table and attribute column containing pivotValues, creates new columns for each of the pivot values and assigns them values from the valueColumn. An optional aggregationFunction can be provided to handle multiple occurrence of the same key value in the attribute column.| -|[Table.PrefixColumns](table-prefixcolumns.md)|Returns a table where the columns have all been prefixed with a text value.| -|[Table.PromoteHeaders](table-promoteheaders.md)|Promotes the first row of the table into its header or column names.| -|[Table.RemoveColumns](table-removecolumns.md)|Returns a table without a specific column or columns.| -|[Table.ReorderColumns](table-reordercolumns.md)|Returns a table with specific columns in an order relative to one another.| +|[Table.HasColumns](table-hascolumns.md)|Indicates whether the table contains the specified column or columns.| +|[Table.Pivot](table-pivot.md)|Given a pair of columns representing attribute-value pairs, rotates the data in the attribute column into a column headings.| +|[Table.PrefixColumns](table-prefixcolumns.md)|Returns a table where the columns have all been prefixed with the given text.| +|[Table.PromoteHeaders](table-promoteheaders.md)|Promotes the first row of values as the new column headers (that is, as column names).| +|[Table.RemoveColumns](table-removecolumns.md)|Removes the specified columns.| +|[Table.ReorderColumns](table-reordercolumns.md)|Returns a table with the columns in the specified order.| |[Table.RenameColumns](table-renamecolumns.md)|Returns a table with the columns renamed as specified.| -|[Table.SelectColumns](table-selectcolumns.md)|Returns a table that contains only specific columns.| +|[Table.SelectColumns](table-selectcolumns.md)|Returns a table with only the specified columns.| |[Table.TransformColumnNames](table-transformcolumnnames.md)|Transforms column names by using the given function.| -|[Table.Unpivot](table-unpivot.md)|Given a list of table columns, transforms those columns into attribute-value pairs.| -|[Table.UnpivotOtherColumns](table-unpivotothercolumns.md)|Translates all columns other than a specified set into attribute-value pairs, combined with the rest of the values in each row.| +|[Table.Unpivot](table-unpivot.md)|Translates a set of columns in a table into attribute-value pairs.| +|[Table.UnpivotOtherColumns](table-unpivotothercolumns.md)|Translates all columns other than a specified set into attribute-value pairs.| ## Transformation |Name|Description| |------------|---------------| -|[Table.AddColumn](table-addcolumn.md)|Adds a column named newColumnName to a table.| +|[Table.AddColumn](table-addcolumn.md)|Adds a column with the specified name. The value is computed using the specified selection function with each row taken as an input.| |[Table.AddFuzzyClusterColumn](table-addfuzzyclustercolumn.md)| Adds a new column with representative values obtained by fuzzy grouping values of the specified column in the table.| -|[Table.AddIndexColumn](table-addindexcolumn.md)|Returns a table with a new column with a specific name that, for each row, contains an index of the row in the table.| -|[Table.AddJoinColumn](table-addjoincolumn.md)|Performs a nested join between table1 and table2 from specific columns and produces the join result as a newColumnName column for each row of table1.| -|[Table.AddKey](table-addkey.md)|Adds a key to table.| -|[Table.AggregateTableColumn](table-aggregatetablecolumn.md)|Aggregates tables nested in a specific column into multiple columns containing aggregate values for those tables.| -|[Table.CombineColumns](table-combinecolumns.md)|Table.CombineColumns merges columns using a combiner function to produce a new column. Table.CombineColumns is the inverse of Table.SplitColumns.| +|[Table.AddIndexColumn](table-addindexcolumn.md)|Appends a column with explicit position values.| +|[Table.AddJoinColumn](table-addjoincolumn.md)|Performs a join between tables on supplied columns and produces the join result in a new column.| +|[Table.AddKey](table-addkey.md)|Adds a key to a table.| +|[Table.AggregateTableColumn](table-aggregatetablecolumn.md)|Aggregates a column of tables into multiple columns in the containing table.| +|[Table.CombineColumns](table-combinecolumns.md)|Combines the specified columns into a new column using the specified combiner function.| |[Table.CombineColumnsToRecord](table-combinecolumnstorecord.md)|Combines the specified columns into a new record-valued column where each record has field names and values corresponding to the column names and values of the columns that were combined.| |[Table.ConformToPageReader](table-conformtopagereader.md)|This function is intended for internal use only.| |[Table.ExpandListColumn](table-expandlistcolumn.md)|Given a column of lists in a table, create a copy of a row for each value in its list.| |[Table.ExpandRecordColumn](table-expandrecordcolumn.md)|Expands a column of records into columns with each of the values.| |[Table.ExpandTableColumn](table-expandtablecolumn.md)|Expands a column of records or a column of tables into multiple columns in the containing table.| -|[Table.FillDown](table-filldown.md)|Replaces null values in the specified column or columns of the table with the most recent non-null value in the column.| -|[Table.FillUp](table-fillup.md)|Returns a table from the table specified where the value of the next cell is propagated to the null values cells above in the column specified.| +|[Table.FillDown](table-filldown.md)|Propagates the value of a previous cell to the null-valued cells below in the column.| +|[Table.FillUp](table-fillup.md)|Propagates the value of a cell to the null-valued cells above in the column.| |[Table.FilterWithDataTable](table-filterwithdatatable.md)|This function is intended for internal use only.| -|[Table.Group](table-group.md)|Groups table rows by the values of key columns for each row.| -|[Table.Join](table-join.md)|Joins the rows of table1 with the rows of table2 based on the equality of the values of the key columns selected by table1, key1 and table2, key2.| +|[Table.FuzzyGroup](table-fuzzygroup.md)|Groups rows in the table based on fuzzy matching of keys.| +|[Table.FuzzyJoin](table-fuzzyjoin.md)|Joins the rows from the two tables that fuzzy match based on the given keys.| +|[Table.FuzzyNestedJoin](table-fuzzynestedjoin.md)|Performs a fuzzy join between tables on supplied columns and produces the join result in a new column.| +|[Table.Group](table-group.md)|Groups rows in the table that have the same key.| +|[Table.Join](table-join.md)|Joins the rows from the two tables that match based on the given keys.| |[Table.Keys](table-keys.md)|Returns the keys of the specified table.| -|[Table.NestedJoin](table-nestedjoin.md)|Joins the rows of the tables based on the equality of the keys. The results are entered into a new column.| +|[Table.NestedJoin](table-nestedjoin.md)|Performs a join between tables on supplied columns and produces the join result in a new column.| +|[Table.PartitionKey](table-partitionkey.md) | Returns the partition key of the specified table.| |[Table.ReplaceErrorValues](table-replaceerrorvalues.md)|Replaces the error values in the specified columns with the corresponding specified value.| |[Table.ReplaceKeys](table-replacekeys.md)|Replaces the keys of the specified table.| +|[Table.ReplacePartitionKey](table-replacepartitionkey.md) | Replaces the partition key of the specified table.| |[Table.ReplaceRelationshipIdentity](table-replacerelationshipidentity.md)|This function is intended for internal use only.| -|[Table.ReplaceValue](table-replacevalue.md)|Replaces oldValue with newValue in specific columns of a table, using the provided replacer function, such as text.Replace or Value.Replace.| -|[Table.SplitColumn](table-splitcolumn.md)|Returns a new set of columns from a single column applying a splitter function to each value.| +|[Table.ReplaceValue](table-replacevalue.md)|Replaces one value with another in the specified columns.| +|[Table.Split](table-split.md)|Splits the specified table into a list of tables using the specified page size.| +|[Table.SplitColumn](table-splitcolumn.md)|Splits the specified column into a set of additional columns using the specified splitter function.| |[Table.TransformColumns](table-transformcolumns.md)|Transforms the values of one or more columns.| -|[Table.TransformColumnTypes](table-transformcolumntypes.md)|Transforms the column types from a table using a type.| -|[Table.TransformRows](table-transformrows.md)|Transforms the rows from a table using a transform function.| -|[Table.Transpose](table-transpose.md)|Returns a table with columns converted to rows and rows converted to columns from the input table.| +|[Table.TransformColumnTypes](table-transformcolumntypes.md)|Applies type transformation(s) of the form { column, type } using a specific culture.| +|[Table.TransformRows](table-transformrows.md)|Transforms the rows of the table using the specified transform function.| +|[Table.Transpose](table-transpose.md)|Makes columns into rows and rows into columns.| ## Membership |Name|Description| |------------|---------------| -|[Table.Contains](table-contains.md)|Determines whether the a record appears as a row in the table.| -|[Table.ContainsAll](table-containsall.md)|Determines whether all of the specified records appear as rows in the table.| -|[Table.ContainsAny](table-containsany.md)|Determines whether any of the specified records appear as rows in the table.| -|[Table.Distinct](table-distinct.md)|Removes duplicate rows from a table, ensuring that all remaining rows are distinct.| -|[Table.IsDistinct](table-isdistinct.md)|Determines whether a table contains only distinct rows.| -|[Table.PositionOf](table-positionof.md)|Determines the position or positions of a row within a table.| -|[Table.PositionOfAny](table-positionofany.md)|Determines the position or positions of any of the specified rows within the table.| -|[Table.RemoveMatchingRows](table-removematchingrows.md)|Removes all occurrences of rows from a table.| -|[Table.ReplaceMatchingRows](table-replacematchingrows.md)|Replaces specific rows from a table with the new rows.| +|[Table.Contains](table-contains.md)|Indicates whether the specified record appears as a row in the table.| +|[Table.ContainsAll](table-containsall.md)|Indicates whether all of the specified records appear as rows in the table.| +|[Table.ContainsAny](table-containsany.md)|Indicates whether any of the specified records appear as rows in the table.| +|[Table.Distinct](table-distinct.md)|Removes duplicate rows from the table.| +|[Table.IsDistinct](table-isdistinct.md)|Indicates whether the table contains only distinct rows (no duplicates).| +|[Table.PositionOf](table-positionof.md)|Returns the position or positions of the row within the table.| +|[Table.PositionOfAny](table-positionofany.md)|Returns the position or positions of any of the specified rows within the table.| +|[Table.RemoveMatchingRows](table-removematchingrows.md)|Removes all occurrences of the specified rows from the table.| +|[Table.ReplaceMatchingRows](table-replacematchingrows.md)|Replaces all the specified rows with the provided row or rows.| ## Ordering |Name|Description| |------------|---------------| -|[Table.Max](table-max.md)|Returns the largest row or rows from a table using a comparisonCriteria.| -|[Table.MaxN](table-maxn.md)|Returns the largest N rows from a table. After the rows are sorted, the countOrCondition parameter must be specified to further filter the result.| -|[Table.Min](table-min.md)|Returns the smallest row or rows from a table using a comparisonCriteria.| -|[Table.MinN](table-minn.md)|Returns the smallest N rows in the given table. After the rows are sorted, the countOrCondition parameter must be specified to further filter the result.| |[Table.AddRankColumn](table-addrankcolumn.md)|Appends a column with the ranking of one or more other columns.| -|[Table.Sort](table-sort.md)|Sorts the rows in a table using a comparisonCriteria or a default ordering if one is not specified.| +|[Table.Max](table-max.md)|Returns the largest row or default value using the given criteria.| +|[Table.MaxN](table-maxn.md)|Returns the largest row or rows using the given criteria.| +|[Table.Min](table-min.md)|Returns the smallest row or a default value using the given criteria.| +|[Table.MinN](table-minn.md)|Returns the smallest row or rows using the given criteria.| +|[Table.Sort](table-sort.md)|Sorts the table using one or more column names and comparison criteria.| ## Other |Name|Description| |------------|---------------| -|[Table.Buffer](table-buffer.md)|Buffers a table into memory, isolating it from external changes during evaluation.| +|[Table.Buffer](table-buffer.md)|Buffers a table in memory, isolating it from external changes during evaluation.| +|[Table.StopFolding](table-stopfolding.md) | Prevents any downstream operations from being run against the original source of the data.| ## Parameter Values ### Naming output columns -This parameter is a list of text values specifying the column names of the resulting table. This parameter is generally used in the Table construction functions, such as [Table.FromRows](table-fromrows.md) and [Table.FromList](table-fromlist.md). +This parameter is a list of text values specifying the column names of the resulting table. This parameter is generally used in the [Table construction functions](#table-construction), such as [Table.FromRows](table-fromrows.md) and [Table.FromList](table-fromlist.md). ### Comparison criteria @@ -207,8 +206,8 @@ More information: [Table.FirstN](table-firstn.md), [Table.MaxN](table-maxn.md) Extra values are used to indicate how the function should handle extra values in a row. This parameter is specified as a number, which maps to the following options: -`ExtraValues.List = 0` -`ExtraValues.Error = 1` +`ExtraValues.List = 0`
+`ExtraValues.Error = 1`
`ExtraValues.Ignore = 2` More information: [Table.FromList](table-fromlist.md), [ExtraValues.Type](extravalues-type.md) @@ -217,8 +216,8 @@ More information: [Table.FromList](table-fromlist.md), [ExtraValues.Type](extrav This parameter is used to indicate how the function should handle missing columns. This parameter is specified as a number, which maps to the following options: -`MissingField.Error = 0` -`MissingField.Ignore = 1` +`MissingField.Error = 0`
+`MissingField.Ignore = 1`
`MissingField.UseNull = 2;` This parameter is used in column or transformation operations, for examples, in [Table.TransformColumns](table-transformcolumns.md). More information: [MissingField.Type](missingfield-type.md) @@ -227,7 +226,7 @@ This parameter is used in column or transformation operations, for examples, in Sort ordering is used to indicate how the results should be sorted. This parameter is specified as a number, which maps to the following options: -`Order.Ascending = 0` +`Order.Ascending = 0`
`Order.Descending = 1` More information: [Order.Type](order-type.md) diff --git a/query-languages/m/table-fuzzygroup.md b/query-languages/m/table-fuzzygroup.md index ae796d35f..259561768 100644 --- a/query-languages/m/table-fuzzygroup.md +++ b/query-languages/m/table-fuzzygroup.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.FuzzyGroup" -title: "Table.FuzzyGroup | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FuzzyGroup" +ms.subservice: m-source --- # Table.FuzzyGroup ## Syntax
-Table.FuzzyGroup(table as table, key as any, aggregatedColumns as list, optional options as nullable record) as table
+Table.FuzzyGroup(
+    table as table,
+    key as any,
+    aggregatedColumns as list,
+    optional options as nullable record
+) as table
 
## About @@ -28,7 +26,7 @@ An optional set of `options` may be included to specify how to compare the key c * `IgnoreCase`: A logical (true/false) value that allows case-insensitive key grouping. For example, when true, "Grapes" is grouped with "grapes". The default value is true. * `IgnoreSpace`: A logical (true/false) value that allows combining of text parts in order to find groups. For example, when true, "Gra pes" is grouped with "Grapes". The default value is true. * `SimilarityColumnName`: A name for the column that shows the similarity between an input value and the representative value for that input. The default value is null, in which case a new column for similarities will not be added. -* `Threshold`: A number between 0.00 and 1.00 that specifies the similarity score at which two values will be grouped. For example, "Grapes" and "Graes" (missing "p") are grouped together only if this option is set to less than 0.90. A threshold of 1.00 is the same as specifying an exact match criteria while grouping. The default value is 0.80. +* `Threshold`: A number between 0.00 and 1.00 that specifies the similarity score at which two values will be grouped. For example, "Grapes" and "Graes" (missing the "p") are grouped together only if this option is set to less than 0.90. A threshold of 1.00 only allows exact matches. (Note that a fuzzy "exact match" might ignore differences like casing, word order, and punctuation.) The default value is 0.80. * `TransformationTable`: A table that allows grouping records based on custom value mappings. It should contain "From" and "To" columns. For example, "Grapes" is grouped with "Raisins" if a transformation table is provided with the "From" column containing "Grapes" and the "To" column containing "Raisins". Note that the transformation will be applied to all occurrences of the text in the transformation table. With the above transformation table, "Grapes are sweet" will also be grouped with "Raisins are sweet". ## Example 1 @@ -65,3 +63,7 @@ Table.FromRecords({ [Location = "Vancouver", Count = 3] }) ``` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/table-fuzzyjoin.md b/query-languages/m/table-fuzzyjoin.md index 4edb73770..97b77ac0b 100644 --- a/query-languages/m/table-fuzzyjoin.md +++ b/query-languages/m/table-fuzzyjoin.md @@ -1,21 +1,21 @@ --- description: "Learn more about: Table.FuzzyJoin" -title: "Table.FuzzyJoin | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FuzzyJoin" +ms.subservice: m-source --- # Table.FuzzyJoin ## Syntax
-Table.FuzzyJoin(table1 as table, key1 as any, table2 as table, key2 as any, optional joinKind as nullable number, optional joinOptions as nullable record) as table
+Table.FuzzyJoin(
+    table1 as table,
+    key1 as any,
+    table2 as table,
+    key2 as any,
+    optional joinKind as nullable number,
+    optional joinOptions as nullable record
+) as table
 
## About @@ -26,12 +26,14 @@ Fuzzy matching is a comparison based on similarity of text rather than equality By default, an inner join is performed, however an optional `joinKind` may be included to specify the type of join. Options include: -* `JoinKind.Inner` -* `JoinKind.LeftOuter` -* `JoinKind.RightOuter` -* `JoinKind.FullOuter` -* `JoinKind.LeftAnti` -* `JoinKind.RightAnti` +* [JoinKind.Inner](joinkind-type.md) +* [JoinKind.LeftOuter](joinkind-type.md) +* [JoinKind.RightOuter](joinkind-type.md) +* [JoinKind.FullOuter](joinkind-type.md) +* [JoinKind.LeftAnti](joinkind-type.md) +* [JoinKind.RightAnti](joinkind-type.md) +* [JoinKind.LeftSemi](joinkind-type.md) +* [JoinKind.RightSemi](joinkind-type.md) An optional set of `joinOptions` may be included to specify how to compare the key columns. Options include: @@ -41,7 +43,7 @@ An optional set of `joinOptions` may be included to specify how to compare the k * `IgnoreSpace`: A logical (true/false) value that allows combining of text parts in order to find matches. For example, when true, "Gra pes" is matched with "Grapes". The default value is true. * `NumberOfMatches`: A whole number that specifies the maximum number of matching rows that can be returned for every input row. For example, a value of 1 will return at most one matching row for each input row. If this option is not provided, all matching rows are returned. * `SimilarityColumnName`: A name for the column that shows the similarity between an input value and the representative value for that input. The default value is null, in which case a new column for similarities will not be added. -* `Threshold`: A number between 0.00 and 1.00 that specifies the similarity score at which two values will be matched. For example, "Grapes" and "Graes" (missing "p") are matched only if this option is set to less than 0.90. A threshold of 1.00 is the same as specifying an exact match criteria. The default value is 0.80. +* `Threshold`: A number between 0.00 and 1.00 that specifies the similarity score at which two values will be matched. For example, "Grapes" and "Graes" (missing the "p") are matched only if this option is set to less than 0.90. A threshold of 1.00 only allows exact matches. (Note that a fuzzy "exact match" might ignore differences like casing, word order, and punctuation.) The default value is 0.80. * `TransformationTable`: A table that allows matching records based on custom value mappings. It should contain "From" and "To" columns. For example, "Grapes" is matched with "Raisins" if a transformation table is provided with the "From" column containing "Grapes" and the "To" column containing "Raisins". Note that the transformation will be applied to all occurrences of the text in the transformation table. With the above transformation table, "Grapes are sweet" will also be matched with "Raisins are sweet". ## Example 1 @@ -103,3 +105,7 @@ Table.FromRecords({ ] }) ``` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/table-fuzzynestedjoin.md b/query-languages/m/table-fuzzynestedjoin.md index 9607cd878..3ae9277c7 100644 --- a/query-languages/m/table-fuzzynestedjoin.md +++ b/query-languages/m/table-fuzzynestedjoin.md @@ -1,21 +1,22 @@ --- description: "Learn more about: Table.FuzzyNestedJoin" -title: "Table.FuzzyNestedJoin | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.FuzzyNestedJoin" +ms.subservice: m-source --- # Table.FuzzyNestedJoin ## Syntax
-Table.FuzzyNestedJoin(table1 as table, key1 as any, table2 as table, key2 as any, newColumnName as text, optional joinKind as nullable number, optional joinOptions as nullable record) as table
+Table.FuzzyNestedJoin(
+    table1 as table,
+    key1 as any,
+    table2 as table,
+    key2 as any,
+    newColumnName as text,
+    optional joinKind as nullable number,
+    optional joinOptions as nullable record
+) as table
 
## About @@ -26,12 +27,14 @@ Fuzzy matching is a comparison based on similarity of text rather than equality The optional `joinKind` specifies the kind of join to perform. By default, a left outer join is performed if a `joinKind` is not specified. Options include: -* `JoinKind.Inner` -* `JoinKind.LeftOuter` -* `JoinKind.RightOuter` -* `JoinKind.FullOuter` -* `JoinKind.LeftAnti` -* `JoinKind.RightAnti` +* [JoinKind.Inner](joinkind-type.md) +* [JoinKind.LeftOuter](joinkind-type.md) +* [JoinKind.RightOuter](joinkind-type.md) +* [JoinKind.FullOuter](joinkind-type.md) +* [JoinKind.LeftAnti](joinkind-type.md) +* [JoinKind.RightAnti](joinkind-type.md) +* [JoinKind.LeftSemi](joinkind-type.md) +* [JoinKind.RightSemi](joinkind-type.md) An optional set of `joinOptions` may be included to specify how to compare the key columns. Options include: @@ -41,7 +44,7 @@ An optional set of `joinOptions` may be included to specify how to compare the k * `IgnoreSpace`: A logical (true/false) value that allows combining of text parts in order to find matches. For example, when true, "Gra pes" is matched with "Grapes". The default value is true. * `NumberOfMatches`: A whole number that specifies the maximum number of matching rows that can be returned for every input row. For example, a value of 1 will return at most one matching row for each input row. If this option is not provided, all matching rows are returned. * `SimilarityColumnName`: A name for the column that shows the similarity between an input value and the representative value for that input. The default value is null, in which case a new column for similarities will not be added. -* `Threshold`: A number between 0.00 and 1.00 that specifies the similarity score at which two values will be matched. For example, "Grapes" and "Graes" (missing "p") are matched only if this option is set to less than 0.90. A threshold of 1.00 is the same as specifying an exact match criteria. The default value is 0.80. +* `Threshold`: A number between 0.00 and 1.00 that specifies the similarity score at which two values will be matched. For example, "Grapes" and "Graes" (missing the "p") are matched only if this option is set to less than 0.90. A threshold of 1.00 only allows exact matches. (Note that a fuzzy "exact match" might ignore differences like casing, word order, and punctuation.) The default value is 0.80. * `TransformationTable`: A table that allows matching records based on custom value mappings. It should contain "From" and "To" columns. For example, "Grapes" is matched with "Raisins" if a transformation table is provided with the "From" column containing "Grapes" and the "To" column containing "Raisins". Note that the transformation will be applied to all occurrences of the text in the transformation table. With the above transformation table, "Grapes are sweet" will also be matched with "Raisins are sweet". ## Example 1 @@ -103,3 +106,7 @@ Table.FromRecords({ ] }) ``` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/table-group.md b/query-languages/m/table-group.md index 879ffc121..c551dea9b 100644 --- a/query-languages/m/table-group.md +++ b/query-languages/m/table-group.md @@ -1,28 +1,27 @@ --- description: "Learn more about: Table.Group" -title: "Table.Group | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Group" +ms.subservice: m-source --- # Table.Group ## Syntax
-Table.Group(table as table, key as any, aggregatedColumns as list, optional groupKind as nullable number, optional comparer as nullable function) as table
+Table.Group(
+    table as table,
+    key as any,
+    aggregatedColumns as list,
+    optional groupKind as nullable number,
+    optional comparer as nullable function
+) as table
 
## About Groups the rows of `table` by the key columns defined by `key`. The `key` can either be a single column name, or a list of column names. For each group, a record is constructed containing the key columns (and their values), along with any aggregated columns specified by `aggregatedColumns`. Optionally, `groupKind` and `comparer` may also be specified. -If the data is already sorted by the key columns, then a `groupKind` of GroupKind.Local can be provided. This may improve the performance of grouping in certain cases, since all the rows with a given set of key values are assumed to be contiguous. +If the data is already sorted by the key columns, then a `groupKind` of [GroupKind.Local](groupkind-type.md) can be provided. This may improve the performance of grouping in certain cases, since all the rows with a given set of key values are assumed to be contiguous. When passing a `comparer`, note that if it treats differing keys as equal, a row may be placed in a group whose keys differ from its own. @@ -61,3 +60,7 @@ Table.FromRecords( {"CustomerID", "total"} ) ``` + +## Related content + +[Comparer functions](comparer-functions.md) \ No newline at end of file diff --git a/query-languages/m/table-hascolumns.md b/query-languages/m/table-hascolumns.md index f13b10b52..e04070cf9 100644 --- a/query-languages/m/table-hascolumns.md +++ b/query-languages/m/table-hascolumns.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.HasColumns" -title: "Table.HasColumns | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.HasColumns" +ms.subservice: m-source --- # Table.HasColumns @@ -20,7 +13,7 @@ Table.HasColumns(table as table, columns as any) as logical ## About -indicates whether the `table` contains the specified column(s), `columns`. Returns `true` if the table contains the column(s), `false` otherwise. +Indicates whether the `table` contains the specified column(s), `columns`. Returns `true` if the table contains the column(s), `false` otherwise. ## Example 1 @@ -29,7 +22,7 @@ Determine if the table has the column [Name]. **Usage** ```powerquery-m -TTable.HasColumns( +Table.HasColumns( Table.FromRecords({ [CustomerID = 1, Name = "Bob", Phone = "123-4567"], [CustomerID = 2, Name = "Jim", Phone = "987-6543"], diff --git a/query-languages/m/table-insertrows.md b/query-languages/m/table-insertrows.md index 550696a17..05ed7c583 100644 --- a/query-languages/m/table-insertrows.md +++ b/query-languages/m/table-insertrows.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Table.InsertRows" -title: "Table.InsertRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.InsertRows" +ms.subservice: m-source --- # Table.InsertRows ## Syntax
-Table.InsertRows(table as table, offset as number, rows as list) as table
+Table.InsertRows(
+    table as table,
+    offset as number,
+    rows as list
+) as table
 
## About -Returns a table with the list of rows, `rows`, inserted into the `table` at the given position, `offset`. Each column in the row to insert much match the column types of the table. +Returns a table with the list of rows, `rows`, inserted into the `table` at the given position, `offset`. Each column in the row to insert must match the column types of the table. ## Example 1 diff --git a/query-languages/m/table-isdistinct.md b/query-languages/m/table-isdistinct.md index 1bce7fcd3..2667d3dae 100644 --- a/query-languages/m/table-isdistinct.md +++ b/query-languages/m/table-isdistinct.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.IsDistinct" -title: "Table.IsDistinct | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.IsDistinct" +ms.subservice: m-source --- # Table.IsDistinct @@ -64,3 +57,7 @@ Table.IsDistinct( **Output** `false` + +## Related content + +[Comparison criteria](table-functions.md#comparison-criteria) diff --git a/query-languages/m/table-isempty.md b/query-languages/m/table-isempty.md index 74790265f..a7d69f464 100644 --- a/query-languages/m/table-isempty.md +++ b/query-languages/m/table-isempty.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.IsEmpty" -title: "Table.IsEmpty | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.IsEmpty" +ms.subservice: m-source --- # Table.IsEmpty diff --git a/query-languages/m/table-join.md b/query-languages/m/table-join.md index dd303cf39..b9b1b625b 100644 --- a/query-languages/m/table-join.md +++ b/query-languages/m/table-join.md @@ -1,21 +1,22 @@ --- description: "Learn more about: Table.Join" -title: "Table.Join | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Join" +ms.subservice: m-source --- # Table.Join ## Syntax
-Table.Join(table1 as table, key1 as any, table2 as table, key2 as any, optional joinKind as nullable number, optional joinAlgorithm as nullable number, optional keyEqualityComparers as nullable list) as table
+Table.Join(
+    table1 as table,
+    key1 as any,
+    table2 as table,
+    key2 as any,
+    optional joinKind as nullable number,
+    optional joinAlgorithm as nullable number,
+    optional keyEqualityComparers as nullable list
+) as table
 
## About @@ -24,14 +25,16 @@ Joins the rows of `table1` with the rows of `table2` based on the equality of th By default, an inner join is performed, however an optional `joinKind` may be included to specify the type of join. Options include: -* `JoinKind.Inner` -* `JoinKind.LeftOuter` -* `JoinKind.RightOuter` -* `JoinKind.FullOuter` -* `JoinKind.LeftAnti` -* `JoinKind.RightAnti` +* [JoinKind.Inner](joinkind-type.md) +* [JoinKind.LeftOuter](joinkind-type.md) +* [JoinKind.RightOuter](joinkind-type.md) +* [JoinKind.FullOuter](joinkind-type.md) +* [JoinKind.LeftAnti](joinkind-type.md) +* [JoinKind.RightAnti](joinkind-type.md) +* [JoinKind.LeftSemi](joinkind-type.md) +* [JoinKind.RightSemi](joinkind-type.md) -An optional set of `keyEqualityComparers` may be included to specify how to compare the key columns. This feature is currently intended for internal use only. +An optional set of `keyEqualityComparers` may be included to specify how to compare the key columns. This parameter is currently intended for internal use only. ## Example 1 @@ -73,3 +76,37 @@ Table.FromRecords({ [CustomerID = 1, Name = "Bob", Phone = "123-4567", OrderID = 6, Item = "Tackle box", Price = 20] }) ``` + +## Example 2 + +Join two tables that have conflicting column names, using multiple key columns. + +**Usage** + +```powerquery-m +let + customers = Table.FromRecords({ + [TenantID = 1, CustomerID = 1, Name = "Bob", Phone = "123-4567"], + [TenantID = 1, CustomerID = 2, Name = "Jim", Phone = "987-6543"] + }), + orders = Table.FromRecords({ + [TenantID = 1, OrderID = 1, CustomerID = 1, Name = "Fishing rod", Price = 100.0], + [TenantID = 1, OrderID = 2, CustomerID = 1, Name = "1 lb. worms", Price = 5.0], + [TenantID = 1, OrderID = 3, CustomerID = 2, Name = "Fishing net", Price = 25.0] + }) +in + Table.Join( + customers, + {"TenantID", "CustomerID"}, + Table.PrefixColumns(orders, "Order"), + {"Order.TenantID", "Order.CustomerID"} + ) +``` + +```powerquery-m +Table.FromRecords({ + [TenantID = 1, CustomerID = 1, Name = "Bob", Phone = "123-4567", Order.TenantID = 1, Order.OrderID = 1, Order.CustomerID = 1, Order.Name = "Fishing rod", Order.Price = 100], + [TenantID = 1, CustomerID = 1, Name = "Bob", Phone = "123-4567", Order.TenantID = 1, Order.OrderID = 2, Order.CustomerID = 1, Order.Name = "1 lb. worms", Order.Price = 5], + [TenantID = 1, CustomerID = 2, Name = "Jim", Phone = "987-6543", Order.TenantID = 1, Order.OrderID = 3, Order.CustomerID = 2, Order.Name = "Fishing net", Order.Price = 25] +}) +``` diff --git a/query-languages/m/table-keys.md b/query-languages/m/table-keys.md index cee9fb0fd..af63a94c2 100644 --- a/query-languages/m/table-keys.md +++ b/query-languages/m/table-keys.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Keys" -title: "Table.Keys | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Keys" +ms.subservice: m-source --- # Table.Keys diff --git a/query-languages/m/table-last.md b/query-languages/m/table-last.md index fc7d59ae6..32dc32b5e 100644 --- a/query-languages/m/table-last.md +++ b/query-languages/m/table-last.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Last" -title: "Table.Last | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Last" +ms.subservice: m-source --- # Table.Last diff --git a/query-languages/m/table-lastn.md b/query-languages/m/table-lastn.md index 55d66df5f..c747415d0 100644 --- a/query-languages/m/table-lastn.md +++ b/query-languages/m/table-lastn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.LastN" -title: "Table.LastN | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.LastN" +ms.subservice: m-source --- # Table.LastN diff --git a/query-languages/m/table-matchesallrows.md b/query-languages/m/table-matchesallrows.md index 6ebb329d4..c568e3447 100644 --- a/query-languages/m/table-matchesallrows.md +++ b/query-languages/m/table-matchesallrows.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.MatchesAllRows" -title: "Table.MatchesAllRows | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.MatchesAllRows" +ms.subservice: m-source --- # Table.MatchesAllRows diff --git a/query-languages/m/table-matchesanyrows.md b/query-languages/m/table-matchesanyrows.md index b8f91abf3..2b5b30fc6 100644 --- a/query-languages/m/table-matchesanyrows.md +++ b/query-languages/m/table-matchesanyrows.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.MatchesAnyRows" -title: "Table.MatchesAnyRows | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.MatchesAnyRows" +ms.subservice: m-source --- # Table.MatchesAnyRows diff --git a/query-languages/m/table-max.md b/query-languages/m/table-max.md index 1ffd38a6b..4e9955a1f 100644 --- a/query-languages/m/table-max.md +++ b/query-languages/m/table-max.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.Max" -title: "Table.Max | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Max" +ms.subservice: m-source --- # Table.Max ## Syntax
 
-Table.Max(table as table, comparisonCriteria as any, optional default as any) as any
+Table.Max(
+    table as table,
+    comparisonCriteria as any,
+    optional default as any
+) as any
 
## About @@ -55,3 +52,7 @@ Table.Max(#table({"a"}, {}), "a", -1) **Output** `-1` + +## Related content + +[Comparison criteria](table-functions.md#comparison-criteria) diff --git a/query-languages/m/table-maxn.md b/query-languages/m/table-maxn.md index 3bdfec2de..fa2d41236 100644 --- a/query-languages/m/table-maxn.md +++ b/query-languages/m/table-maxn.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.MaxN" -title: "Table.MaxN | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.MaxN" +ms.subservice: m-source --- # Table.MaxN ## Syntax
-Table.MaxN(table as table, comparisonCriteria as any, countOrCondition as any) as table
+Table.MaxN(
+    table as table,
+    comparisonCriteria as any,
+    countOrCondition as any
+) as table
 
## About @@ -73,3 +70,7 @@ Table.MaxN( **Output** `Table.FromRecords({})` + +## Related content + +[Comparison criteria](table-functions.md#comparison-criteria) diff --git a/query-languages/m/table-min.md b/query-languages/m/table-min.md index 89d41c1c6..5175d62c4 100644 --- a/query-languages/m/table-min.md +++ b/query-languages/m/table-min.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.Min" -title: "Table.Min | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Min" +ms.subservice: m-source --- # Table.Min ## Syntax
-Table.Min(table as table, comparisonCriteria as any, optional default as any) as any
+Table.Min(
+    table as table,
+    comparisonCriteria as any,
+    optional default as any
+) as any
 
## About @@ -55,3 +52,7 @@ Table.Min(#table({"a"}, {}), "a", -1) **Output** `-1` + +## Related content + +[Comparison criteria](table-functions.md#comparison-criteria) diff --git a/query-languages/m/table-minn.md b/query-languages/m/table-minn.md index 145435dd3..49c6323e9 100644 --- a/query-languages/m/table-minn.md +++ b/query-languages/m/table-minn.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.MinN" -title: "Table.MinN | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.MinN" +ms.subservice: m-source --- # Table.MinN ## Syntax
-Table.MinN(table as table, comparisonCriteria as any, countOrCondition as any) as table
+Table.MinN(
+    table as table,
+    comparisonCriteria as any,
+    countOrCondition as any
+) as table
 
## About @@ -72,3 +69,7 @@ Table.MinN( **Output** `Table.FromRecords({})` + +## Related content + +[Comparison criteria](table-functions.md#comparison-criteria) diff --git a/query-languages/m/table-nestedjoin.md b/query-languages/m/table-nestedjoin.md index 55c4c6a25..d94d58000 100644 --- a/query-languages/m/table-nestedjoin.md +++ b/query-languages/m/table-nestedjoin.md @@ -1,21 +1,22 @@ --- description: "Learn more about: Table.NestedJoin" -title: "Table.NestedJoin | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.NestedJoin" +ms.subservice: m-source --- # Table.NestedJoin ## Syntax
-Table.NestedJoin(table1 as table, key1 as any, table2 as any, key2 as any, newColumnName as text, optional joinKind as nullable number, optional keyEqualityComparers as nullable list) as table
+Table.NestedJoin(
+    table1 as table,
+    key1 as any,
+    table2 as any,
+    key2 as any,
+    newColumnName as text,
+    optional joinKind as nullable number,
+    optional keyEqualityComparers as nullable list
+) as table
 
## About @@ -58,3 +59,7 @@ Table.FromRecords({ [CustomerToCall = 3, CustomerDetails = Table.FromRecords({[CustomerID = 3, Name = "Paul", Phone = "543-7890"]})] }) ``` + +## Related content + +[Join kind](joinkind-type.md) diff --git a/query-languages/m/table-partition.md b/query-languages/m/table-partition.md index 5b2b1b6c6..32c9b2d0e 100644 --- a/query-languages/m/table-partition.md +++ b/query-languages/m/table-partition.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.Partition" -title: "Table.Partition | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Partition" +ms.subservice: m-source --- # Table.Partition ## Syntax
  
-Table.Partition(table as table, column as text, groups as number, hash as function) as list
+Table.Partition(
+    table as table,
+    column as text,
+    groups as number,
+    hash as function
+) as list
 
## About @@ -29,7 +27,7 @@ Partitions the `table` into a list of `groups` number of tables, based on the va ## Example 1 -Partition the table ({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]}) into 2 tables on column [a], using the value of the columns as the hash function. +Partition the table `({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]})` into 2 tables on column [a], using the value of the columns as the hash function. **Usage** diff --git a/query-languages/m/table-partitionkey.md b/query-languages/m/table-partitionkey.md new file mode 100644 index 000000000..b97227fd6 --- /dev/null +++ b/query-languages/m/table-partitionkey.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Table.PartitionKey" +title: "Table.PartitionKey" +ms.subservice: m-source +--- +# Table.PartitionKey + +## Syntax + +
+Table.PartitionKey(table as table) as nullable list
+
+ +## About + +Returns the partition key of the specified table. diff --git a/query-languages/m/table-partitionvalues.md b/query-languages/m/table-partitionvalues.md index 3ece5b406..e5ee7bd8c 100644 --- a/query-languages/m/table-partitionvalues.md +++ b/query-languages/m/table-partitionvalues.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.PartitionValues" -title: "Table.PartitionValues | Microsoft Docs" -ms.date: 9/13/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.PartitionValues" +ms.subservice: m-source --- # Table.PartitionValues diff --git a/query-languages/m/table-pivot.md b/query-languages/m/table-pivot.md index cd0198139..9823451e2 100644 --- a/query-languages/m/table-pivot.md +++ b/query-languages/m/table-pivot.md @@ -1,23 +1,22 @@ --- description: "Learn more about: Table.Pivot" -title: "Table.Pivot | Microsoft Docs" -ms.date: 3/10/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Pivot" +ms.subservice: m-source --- # Table.Pivot ## Syntax
-Table.Pivot(table as table, pivotValues as list, attributeColumn as text, valueColumn as text, optional aggregationFunction as nullable function) as table
+Table.Pivot(
+    table as table,
+    pivotValues as list,
+    attributeColumn as text,
+    valueColumn as text,
+    optional aggregationFunction as nullable function
+) as table
 
- + ## About Given a pair of columns representing attribute-value pairs, rotates the data in the attribute column into a column headings. diff --git a/query-languages/m/table-positionof.md b/query-languages/m/table-positionof.md index 00f08d663..b42f5c58e 100644 --- a/query-languages/m/table-positionof.md +++ b/query-languages/m/table-positionof.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.PositionOf" -title: "Table.PositionOf | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.PositionOf" +ms.subservice: m-source --- # Table.PositionOf ## Syntax
-Table.PositionOf(table as table, row as record, optional occurrence as any, optional equationCriteria as any) as any
+Table.PositionOf(
+    table as table,
+    row as record,
+    optional occurrence as any,
+    optional equationCriteria as any
+) as any
 
## About @@ -94,3 +92,7 @@ Table.PositionOf( **Output** `{0, 2}` + +## Related content + +[Equation criteria](table-functions.md#equation-criteria) diff --git a/query-languages/m/table-positionofany.md b/query-languages/m/table-positionofany.md index e1eb2b5ff..79a90fe5e 100644 --- a/query-languages/m/table-positionofany.md +++ b/query-languages/m/table-positionofany.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.PositionOfAny" -title: "Table.PositionOfAny | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.PositionOfAny" +ms.subservice: m-source --- # Table.PositionOfAny ## Syntax
 
-Table.PositionOfAny(table as table, rows as list, optional occurrence as nullable number, optional equationCriteria as any) as any
+Table.PositionOfAny(
+    table as table,
+    rows as list,
+    optional occurrence as nullable number,
+    optional equationCriteria as any
+) as any
 
## About @@ -77,3 +75,7 @@ Table.PositionOfAny( **Output** `{0, 1, 2}` + +## Related content + +[Equation criteria](table-functions.md#equation-criteria) diff --git a/query-languages/m/table-prefixcolumns.md b/query-languages/m/table-prefixcolumns.md index f101f9242..b185b6e9b 100644 --- a/query-languages/m/table-prefixcolumns.md +++ b/query-languages/m/table-prefixcolumns.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.PrefixColumns" -title: "Table.PrefixColumns | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.PrefixColumns" +ms.subservice: m-source --- # Table.PrefixColumns diff --git a/query-languages/m/table-profile.md b/query-languages/m/table-profile.md index a99f56d1b..1874647a4 100644 --- a/query-languages/m/table-profile.md +++ b/query-languages/m/table-profile.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Profile" -title: "Table.Profile | Microsoft Docs" -ms.date: 8/1/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Profile" +ms.subservice: m-source --- # Table.Profile @@ -18,5 +11,16 @@ ms.author: dougklo Table.Profile(table as table, optional additionalAggregates as nullable list) as table -## About -

Returns a profile for the columns in table.

The following information is returned for each column (when applicable):

  • minimum
  • maximum
  • average
  • standard deviation
  • count
  • null count
  • distinct count

+## About + +Returns a profile for the columns in `table`. + +The following information is returned for each column (when applicable): + +* minimum +* maximum +* average +* standard deviation +* count +* null count +* distinct count diff --git a/query-languages/m/table-promoteheaders.md b/query-languages/m/table-promoteheaders.md index 68937daf3..b63d5bc12 100644 --- a/query-languages/m/table-promoteheaders.md +++ b/query-languages/m/table-promoteheaders.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.PromoteHeaders" -title: "Table.PromoteHeaders | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.PromoteHeaders" +ms.subservice: m-source --- # Table.PromoteHeaders @@ -63,3 +56,7 @@ Table.PromoteHeaders( **Output** `Table.FromRecords({[1 = 1, Name = "Bob", #"1/1/1980" = #date(1980, 1, 1)]})` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/table-range.md b/query-languages/m/table-range.md index 081de1bf8..08f203b2d 100644 --- a/query-languages/m/table-range.md +++ b/query-languages/m/table-range.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.Range" -title: "Table.Range | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Range" +ms.subservice: m-source --- # Table.Range ## Syntax
-Table.Range(table as table, offset as number, optional count as nullable number) as table
+Table.Range(
+    table as table,
+    offset as number,
+    optional count as nullable number
+) as table
 
## About diff --git a/query-languages/m/table-removecolumns.md b/query-languages/m/table-removecolumns.md index 0f42d10ab..86ece1ad4 100644 --- a/query-languages/m/table-removecolumns.md +++ b/query-languages/m/table-removecolumns.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Table.RemoveColumns" -title: "Table.RemoveColumns | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.RemoveColumns" +ms.subservice: m-source --- # Table.RemoveColumns ## Syntax
-Table.RemoveColumns(table as table, columns as any, optional missingField as nullable number) as table
+Table.RemoveColumns(
+    table as table,
+    columns as any,
+    optional missingField as nullable number
+) as table
 
## About -Removes the specified `columns` from the `table` provided. If the column doesn't exist, an exception is thrown unless the optional parameter `missingField` specifies an alternative (eg. `MissingField.UseNull` or `MissingField.Ignore`). +Removes the specified `columns` from the `table` provided. If the specified column doesn't exist, an error is raised unless the optional parameter `missingField` specifies an alternative behavior (for example, [MissingField.UseNull](missingfield-type.md) or [MissingField.Ignore](missingfield-type.md)). ## Example 1 @@ -32,7 +29,7 @@ Remove column [Phone] from the table. Table.RemoveColumns( Table.FromRecords({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}), "Phone" - +) ``` **Output** @@ -41,7 +38,7 @@ Table.RemoveColumns( ### Example 2 -Remove column [Address] from the table. Throws an error if it doesn't exist. +Try to remove a non-existent column from the table. **Usage** @@ -54,4 +51,4 @@ Table.RemoveColumns( **Output** -`[Expression.Error] The field 'Address' of the record was not found.` +`[Expression.Error] The column 'Address' of the table wasn't found.` diff --git a/query-languages/m/table-removefirstn.md b/query-languages/m/table-removefirstn.md index 99ba60d0e..8788b6d75 100644 --- a/query-languages/m/table-removefirstn.md +++ b/query-languages/m/table-removefirstn.md @@ -1,12 +1,7 @@ --- description: "Learn more about: Table.RemoveFirstN" -title: "Table.RemoveFirstN | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Table.RemoveFirstN" +ms.subservice: m-source --- # Table.RemoveFirstN diff --git a/query-languages/m/table-removelastn.md b/query-languages/m/table-removelastn.md index 7f107a78e..c201953e7 100644 --- a/query-languages/m/table-removelastn.md +++ b/query-languages/m/table-removelastn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.RemoveLastN" -title: "Table.RemoveLastN | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.RemoveLastN" +ms.subservice: m-source --- # Table.RemoveLastN diff --git a/query-languages/m/table-removematchingrows.md b/query-languages/m/table-removematchingrows.md index 8a8cee464..3c2b61262 100644 --- a/query-languages/m/table-removematchingrows.md +++ b/query-languages/m/table-removematchingrows.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.RemoveMatchingRows" -title: "Table.RemoveMatchingRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.RemoveMatchingRows" +ms.subservice: m-source --- # Table.RemoveMatchingRows ## Syntax
-Table.RemoveMatchingRows(table as table, rows as list, optional equationCriteria as any) as table
+Table.RemoveMatchingRows(
+    table as table,
+    rows as list,
+    optional equationCriteria as any
+) as table
 
## About @@ -43,3 +40,7 @@ Table.RemoveMatchingRows( **Output** `Table.FromRecords({[a = 3, b = 4]})` + +## Related content + +[Equation criteria](table-functions.md#equation-criteria) diff --git a/query-languages/m/table-removerows.md b/query-languages/m/table-removerows.md index c6883f47a..20f726788 100644 --- a/query-languages/m/table-removerows.md +++ b/query-languages/m/table-removerows.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.RemoveRows" -title: "Table.RemoveRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.RemoveRows" +ms.subservice: m-source --- # Table.RemoveRows ## Syntax
-Table.RemoveRows(table as table, offset as number, optional count as nullable number) as table
+Table.RemoveRows(
+    table as table,
+    offset as number,
+    optional count as nullable number
+) as table
 
## About diff --git a/query-languages/m/table-removerowswitherrors.md b/query-languages/m/table-removerowswitherrors.md index 790dae9dd..4f657a7bc 100644 --- a/query-languages/m/table-removerowswitherrors.md +++ b/query-languages/m/table-removerowswitherrors.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.RemoveRowsWithErrors" -title: "Table.RemoveRowsWithErrors | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.RemoveRowsWithErrors" +ms.subservice: m-source --- # Table.RemoveRowsWithErrors diff --git a/query-languages/m/table-renamecolumns.md b/query-languages/m/table-renamecolumns.md index d737dcd38..99c02169d 100644 --- a/query-languages/m/table-renamecolumns.md +++ b/query-languages/m/table-renamecolumns.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Table.RenameColumns" -title: "Table.RenameColumns | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.RenameColumns" +ms.subservice: m-source --- # Table.RenameColumns ## Syntax
-Table.RenameColumns(table as table, renames as list, optional missingField as nullable number) as table
+Table.RenameColumns(
+    table as table,
+    renames as list,
+    optional missingField as nullable number
+) as table
 
## About -Performs the given renames to the columns in table `table`. A replacement operation `renames` consists of a list of two values, the old column name and new column name, provided in a list. If the column doesn't exist, an exception is thrown unless the optional parameter `missingField` specifies an alternative (eg. `MissingField.UseNull` or `MissingField.Ignore`). +Performs the given renames to the columns in table `table`. A replacement operation `renames` consists of a list of two values, the old column name and new column name, provided in a list. If the column doesn't exist, an exception is thrown unless the optional parameter `missingField` specifies an alternative (eg. [MissingField.UseNull](missingfield-type.md) or [MissingField.Ignore](missingfield-type.md)). ## Example 1 diff --git a/query-languages/m/table-reordercolumns.md b/query-languages/m/table-reordercolumns.md index e10a92c3a..7d15be822 100644 --- a/query-languages/m/table-reordercolumns.md +++ b/query-languages/m/table-reordercolumns.md @@ -1,26 +1,23 @@ --- description: "Learn more about: Table.ReorderColumns" -title: "Table.ReorderColumns | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ReorderColumns" +ms.subservice: m-source --- # Table.ReorderColumns ## Syntax
-Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as table
+Table.ReorderColumns(
+    table as table,
+    columnOrder as list,
+    optional missingField as nullable number
+) as table
 
## About -Returns a table from the input `table`, with the columns in the order specified by `columnOrder`. Columns that are not specified in the list will not be reordered. If the column doesn't exist, an exception is thrown unless the optional parameter `missingField` specifies an alternative (eg. `MissingField.UseNull` or `MissingField.Ignore`). +Returns a table from the input `table`, with the columns in the order specified by `columnOrder`. Columns that are not specified in the list will not be reordered. If the column doesn't exist, an exception is thrown unless the optional parameter `missingField` specifies an alternative (eg. [MissingField.UseNull](missingfield-type.md) or [MissingField.Ignore](missingfield-type.md)). ## Example 1 diff --git a/query-languages/m/table-repeat.md b/query-languages/m/table-repeat.md index 06d0c1fb9..f8bff6cb9 100644 --- a/query-languages/m/table-repeat.md +++ b/query-languages/m/table-repeat.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Repeat" -title: "Table.Repeat | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Repeat" +ms.subservice: m-source --- # Table.Repeat @@ -35,6 +28,7 @@ Table.Repeat( [a = 3, b = "world"] }), 2 +) ``` diff --git a/query-languages/m/table-replaceerrorvalues.md b/query-languages/m/table-replaceerrorvalues.md index 44da38df5..9a5ee6a67 100644 --- a/query-languages/m/table-replaceerrorvalues.md +++ b/query-languages/m/table-replaceerrorvalues.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ReplaceErrorValues" -title: "Table.ReplaceErrorValues | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ReplaceErrorValues" +ms.subservice: m-source --- # Table.ReplaceErrorValues diff --git a/query-languages/m/table-replacekeys.md b/query-languages/m/table-replacekeys.md index d6143290b..ff478642c 100644 --- a/query-languages/m/table-replacekeys.md +++ b/query-languages/m/table-replacekeys.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ReplaceKeys" -title: "Table.ReplaceKeys | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ReplaceKeys" +ms.subservice: m-source --- # Table.ReplaceKeys diff --git a/query-languages/m/table-replacematchingrows.md b/query-languages/m/table-replacematchingrows.md index e87132763..3e441f39e 100644 --- a/query-languages/m/table-replacematchingrows.md +++ b/query-languages/m/table-replacematchingrows.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.ReplaceMatchingRows" -title: "Table.ReplaceMatchingRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ReplaceMatchingRows" +ms.subservice: m-source --- # Table.ReplaceMatchingRows ## Syntax
-Table.ReplaceMatchingRows(table as table, replacements as list, optional equationCriteria as any) as table
+Table.ReplaceMatchingRows(
+    table as table,
+    replacements as list,
+    optional equationCriteria as any
+) as table
 
## About @@ -53,3 +50,7 @@ Table.FromRecords({ [a = -1, b = -2] }) ``` + +## Related content + +[Equation criteria](table-functions.md#equation-criteria) diff --git a/query-languages/m/table-replacepartitionkey.md b/query-languages/m/table-replacepartitionkey.md new file mode 100644 index 000000000..df50b25be --- /dev/null +++ b/query-languages/m/table-replacepartitionkey.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Table.ReplacePartitionKey" +title: "Table.ReplacePartitionKey" +ms.subservice: m-source +--- +# Table.ReplacePartitionKey + +## Syntax + +
+Table.ReplacePartitionKey(table as table, partitionKey as nullable list) as table
+
+ +## About + +Replaces the partition key of the specified table. diff --git a/query-languages/m/table-replacerelationshipidentity.md b/query-languages/m/table-replacerelationshipidentity.md index 4038dbb62..de5475799 100644 --- a/query-languages/m/table-replacerelationshipidentity.md +++ b/query-languages/m/table-replacerelationshipidentity.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ReplaceRelationshipIdentity" -title: "Table.ReplaceRelationshipIdentity | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ReplaceRelationshipIdentity" +ms.subservice: m-source --- # Table.ReplaceRelationshipIdentity diff --git a/query-languages/m/table-replacerows.md b/query-languages/m/table-replacerows.md index 8aa55e284..7c46d3f23 100644 --- a/query-languages/m/table-replacerows.md +++ b/query-languages/m/table-replacerows.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.ReplaceRows" -title: "Table.ReplaceRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ReplaceRows" +ms.subservice: m-source --- # Table.ReplaceRows ## Syntax
-Table.ReplaceRows(table as table, offset as number, count as number, rows as list) as table
+Table.ReplaceRows(
+    table as table,
+    offset as number,
+    count as number,
+    rows as list
+) as table
 
## About diff --git a/query-languages/m/table-replacevalue.md b/query-languages/m/table-replacevalue.md index c15eda38a..abe5b4e44 100644 --- a/query-languages/m/table-replacevalue.md +++ b/query-languages/m/table-replacevalue.md @@ -1,21 +1,20 @@ --- description: "Learn more about: Table.ReplaceValue" -title: "Table.ReplaceValue | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ReplaceValue" +ms.subservice: m-source --- # Table.ReplaceValue ## Syntax
-Table.ReplaceValue(table as table, oldValue as any, newValue as any, replacer as function, columnsToSearch as list) as table
+Table.ReplaceValue(
+    table as table,
+    oldValue as any,
+    newValue as any,
+    replacer as function,
+    columnsToSearch as list
+) as table
 
## About @@ -24,20 +23,21 @@ Replaces `oldValue` with `newValue` in the specified columns of the `table`. ## Example 1 -Replace the text "goodbye" with the text "world" in the table. +Replace the text "goodbye" with "world" in column B, matching only the entire value. **Usage** ```powerquery-m Table.ReplaceValue( Table.FromRecords({ - [a = 1, b = "hello"], - [a = 3, b = "goodbye"] + [A = 1, B = "hello"], + [A = 2, B = "goodbye"], + [A = 3, B = "goodbyes"] }), "goodbye", "world", - Replacer.ReplaceText, - {"b"} + Replacer.ReplaceValue, + {"B"} ) ``` @@ -45,27 +45,56 @@ Table.ReplaceValue( ```powerquery-m Table.FromRecords({ - [a = 1, b = "hello"], - [a = 3, b = "world"] + [A = 1, B = "hello"], + [A = 2, B = "world"], + [A = 3, B = "goodbyes"] }) ``` ## Example 2 -Replace the text "ur" with the text "or" in the table. +Replace the text "ur" with "or" in column B, matching any part of the value. **Usage** ```powerquery-m Table.ReplaceValue( Table.FromRecords({ - [a = 1, b = "hello"], - [a = 3, b = "wurld"] + [A = 1, B = "hello"], + [A = 2, B = "wurld"] }), "ur", "or", Replacer.ReplaceText, - {"b"} + {"B"} +) +``` + +**Output** + +```powerquery-m +Table.FromRecords({ + [A = 1, B = "hello"], + [A = 2, B = "world"] +}) +``` + +## Example 3 + +Anonymize the names of US employees. + +**Usage** + +```powerquery-m +Table.ReplaceValue( + Table.FromRecords({ + [Name = "Cindy", Country = "US"], + [Name = "Bob", Country = "CA"] + }), + each if [Country] = "US" then [Name] else false, + each Text.Repeat("*", Text.Length([Name])), + Replacer.ReplaceValue, + {"Name"} ) ``` @@ -73,7 +102,43 @@ Table.ReplaceValue( ```powerquery-m Table.FromRecords({ - [a = 1, b = "hello"], - [a = 3, b = "world"] + [Name = "*****", Country = "US"], + [Name = "Bob", Country = "CA"] }) ``` + +## Example 4 + +Anonymize all columns of US employees. + +**Usage** + +```powerquery-m +Table.ReplaceValue( + Table.FromRecords({ + [Name = "Cindy", Country = "US"], + [Name = "Bob", Country = "CA"] + }), + each [Country] = "US", + "?", + (currentValue, isUS, replacementValue) => + if isUS then + Text.Repeat(replacementValue, Text.Length(currentValue)) + else + currentValue, + {"Name", "Country"} +) +``` + +**Output** + +```powerquery-m +Table.FromRecords({ + [Name = "?????", Country = "??"], + [Name = "Bob", Country = "CA"] +}) +``` + +## Related content + +[Replacer functions](replacer-functions.md) diff --git a/query-languages/m/table-reverserows.md b/query-languages/m/table-reverserows.md index fe1e4d122..1464ee301 100644 --- a/query-languages/m/table-reverserows.md +++ b/query-languages/m/table-reverserows.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ReverseRows" -title: "Table.ReverseRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ReverseRows" +ms.subservice: m-source --- # Table.ReverseRows diff --git a/query-languages/m/table-rowcount.md b/query-languages/m/table-rowcount.md index 6222223d2..5fd93e075 100644 --- a/query-languages/m/table-rowcount.md +++ b/query-languages/m/table-rowcount.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.RowCount" -title: "Table.RowCount | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.RowCount" +ms.subservice: m-source --- # Table.RowCount diff --git a/query-languages/m/table-schema.md b/query-languages/m/table-schema.md index 9769dfa97..2ba47acdb 100644 --- a/query-languages/m/table-schema.md +++ b/query-languages/m/table-schema.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Schema" -title: "Table.Schema | Microsoft Docs" -ms.date: 11/17/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Schema" +ms.subservice: m-source --- # Table.Schema @@ -27,10 +20,10 @@ Each row in the table describes the properties of a column of `table`: | Column Name | Description | | --- | --- | | `Name` | The name of the column. | -| `Position` | The 0-based position of the column in `table`. +| `Position` | The 0-based position of the column in `table`. | | `TypeName` | The name of the type of the column. | | `Kind` | The kind of the type of the column. | -| `IsNullable` | Whether the column can contain `null` values. +| `IsNullable` | Whether the column can contain `null` values. | | `NumericPrecisionBase` | The numeric base (for example, base-2 or base-10) of the `NumericPrecision` and `NumericScale` fields. | | `NumericPrecision` | The precision of a numeric column in the base specified by `NumericPrecisionBase`. This is the maximum number of digits that can be represented by a value of this type (including fractional digits). | | `NumericScale` | The scale of a numeric column in the base specified by `NumericPrecisionBase`. This is the number of digits in the fractional part of a value of this type. A value of `0` indicates a fixed scale with no fractional digits. A value of `null` indicates the scale is not known (either because it is floating or not defined). | @@ -42,4 +35,3 @@ Each row in the table describes the properties of a column of `table`: | `NativeDefaultExpression` | The default expression for a value of this column in the native expression language of the source (for example, `42` or `newid()` for SQL Server). | |   |   | | `Description` | The description of the column. | -| | | diff --git a/query-languages/m/table-selectcolumns.md b/query-languages/m/table-selectcolumns.md index af0274e99..5ebf05995 100644 --- a/query-languages/m/table-selectcolumns.md +++ b/query-languages/m/table-selectcolumns.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.SelectColumns" -title: "Table.SelectColumns | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.SelectColumns" +ms.subservice: m-source --- # Table.SelectColumns ## Syntax
-Table.SelectColumns(table as table, columns as any, optional missingField as nullable number) as table
+Table.SelectColumns(
+    table as table,
+    columns as any,
+    optional missingField as nullable number
+) as table
 
## About @@ -24,7 +21,7 @@ Returns the `table` with only the specified `columns`. * `table`: The provided table. * `columns`: The list of columns from the table `table` to return. Columns in the returned table are in the order listed in `columns`. -* `missingField`: *(Optional)* What to do if the column does not exist. Example: `MissingField.UseNull` or `MissingField.Ignore`. +* `missingField`: *(Optional)* What to do if the column does not exist. Example: [MissingField.UseNull](missingfield-type.md) or [MissingField.Ignore](missingfield-type.md). ## Example 1 diff --git a/query-languages/m/table-selectrows.md b/query-languages/m/table-selectrows.md index b2322ab50..5c4d98072 100644 --- a/query-languages/m/table-selectrows.md +++ b/query-languages/m/table-selectrows.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.SelectRows" -title: "Table.SelectRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.SelectRows" +ms.subservice: m-source --- # Table.SelectRows diff --git a/query-languages/m/table-selectrowswitherrors.md b/query-languages/m/table-selectrowswitherrors.md index 7fba1e4d8..331560c2c 100644 --- a/query-languages/m/table-selectrowswitherrors.md +++ b/query-languages/m/table-selectrowswitherrors.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.SelectRowsWithErrors" -title: "Table.SelectRowsWithErrors | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.SelectRowsWithErrors" +ms.subservice: m-source --- # Table.SelectRowsWithErrors diff --git a/query-languages/m/table-singlerow.md b/query-languages/m/table-singlerow.md index 6dc17a08d..c2fe43a64 100644 --- a/query-languages/m/table-singlerow.md +++ b/query-languages/m/table-singlerow.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.SingleRow" -title: "Table.SingleRow | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.SingleRow" +ms.subservice: m-source --- # Table.SingleRow @@ -20,7 +13,7 @@ Table.SingleRow(table as table) as record ## About -Returns the single row in the one row `table`. If the `table` has more than one row, an exception is thrown. +Returns the single row in the one row `table`. If the `table` does not contain exactly one row, an error is raised. ## Example 1 diff --git a/query-languages/m/table-skip.md b/query-languages/m/table-skip.md index d26cbba70..5a5264730 100644 --- a/query-languages/m/table-skip.md +++ b/query-languages/m/table-skip.md @@ -1,12 +1,7 @@ --- description: "Learn more about: Table.Skip" -title: "Table.Skip | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +title: "Table.Skip" +ms.subservice: m-source --- # Table.Skip diff --git a/query-languages/m/table-sort.md b/query-languages/m/table-sort.md index 13047142a..305b749d7 100644 --- a/query-languages/m/table-sort.md +++ b/query-languages/m/table-sort.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Sort" -title: "Table.Sort | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Sort" +ms.subservice: m-source --- # Table.Sort @@ -141,3 +134,7 @@ Table.FromRecords({ [OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25] }) ``` + +## Related content + +[Comparison criteria](table-functions.md#comparison-criteria) diff --git a/query-languages/m/table-split.md b/query-languages/m/table-split.md index d0d05216d..e24041136 100644 --- a/query-languages/m/table-split.md +++ b/query-languages/m/table-split.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Split" -title: "Table.Split | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Split" +ms.subservice: m-source --- # Table.Split diff --git a/query-languages/m/table-splitat.md b/query-languages/m/table-splitat.md index ecc7ea0cc..1620be374 100644 --- a/query-languages/m/table-splitat.md +++ b/query-languages/m/table-splitat.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.SplitAt" -title: "Table.SplitAt | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.SplitAt" +ms.subservice: m-source --- # Table.SplitAt @@ -27,7 +20,7 @@ Return the first two rows of the table and the remaining rows of the table. **Usage** ```powerquery-m -Table.SplitAt(#table({"a", "b", "c"}, {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}), 2) +Table.SplitAt(#table({"a", "b", "c"}, {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}), 2) ``` **Output** diff --git a/query-languages/m/table-splitcolumn.md b/query-languages/m/table-splitcolumn.md index 5c895cbed..9ccb4faa8 100644 --- a/query-languages/m/table-splitcolumn.md +++ b/query-languages/m/table-splitcolumn.md @@ -1,52 +1,176 @@ --- description: "Learn more about: Table.SplitColumn" -title: "Table.SplitColumn | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.SplitColumn" +ms.subservice: m-source --- # Table.SplitColumn ## Syntax
-Table.SplitColumn(table as table, sourceColumn as text, splitter as function, optional columnNamesOrNumber as any, optional default as any, optional extraColumns as any) as table
+Table.SplitColumn(
+    table as table,
+    sourceColumn as text,
+    splitter as function,
+    optional columnNamesOrNumber as any,
+    optional default as any,
+    optional extraColumns as any
+) as table
 
## About -Splits the specified columns into a set of additional columns using the specified splitter function. +Splits the specified column into a set of additional columns using the specified splitter function. + +* `table`: The table containing the column to split. +* `sourceColumn`: The name of the column to split. +* `splitter`: The [splitter function](splitter-functions.md) used to split the column (for example, [Splitter.SplitTextByDelimiter](splitter-splittextbydelimiter.md) or [Splitter.SplitTextByPositions](splitter-splittextbypositions.md)). +* `columnNamesOrNumber`: Either a list of new column names to create, or the number of new columns. +* `default`: Overrides the value used when there aren't enough split values to fill all of the new columns. The default for this parameter is `null`. +* `extraColumns`: Specifies what to do if there might be more split values than the number of new columns. You can pass an [ExtraValues.Type](extravalues-type.md) enumeration value to this parameter. The default is `ExtraValues.Ignore`. ## Example 1 -Split the [Name] column at position of "i" into two columns +Split the name column into first name and last name. + +**Usage** + +```powerquery-m +let + Source = #table(type table[CustomerID = number, Name = text, Phone = text], + { + {1, "Bob White", "123-4567"}, + {2, "Jim Smith", "987-6543"}, + {3, "Paul", "543-7890"}, + {4, "Cristina Best", "232-1550"} + }), + SplitColumns = Table.SplitColumn( + Source, + "Name", + Splitter.SplitTextByDelimiter(" ")) +in + SplitColumns +``` + +**Output** + +```powerquery-m +#table(type table[CustomerID = number, Name.1 = text, Name.2 = text, Phone = text], +{ + {1, "Bob", "White", "123-4567"}, + {2, "Jim", "Smith", "987-6543"}, + {3, "Paul", null, "543-7890"}, + {4, "Cristina", "Best", "232-1550"} +}) +``` + +## Example 2 + +Split the name column into first name and last name, then rename the new columns. + +**Usage** + +```powerquery-m +let + Source = #table(type table[CustomerID = number, Name = text, Phone = text], + { + {1, "Bob White", "123-4567"}, + {2, "Jim Smith", "987-6543"}, + {3, "Paul", "543-7890"}, + {4, "Cristina Best", "232-1550"} + }), + SplitColumns = Table.SplitColumn( + Source, + "Name", + Splitter.SplitTextByDelimiter(" "), + {"First Name", "Last Name"}) +in + SplitColumns +``` + +**Output** + +```powerquery-m +#table(type table[CustomerID = number, First Name = text, Last Name = text, Phone = text], +{ + {1, "Bob", "White", "123-4567"}, + {2, "Jim", "Smith", "987-6543"}, + {3, "Paul", null, "543-7890"}, + {4, "Cristina", "Best", "232-1550"} +}) +``` + +## Example 3 + +Split the name column into first name and last name, rename the new columns, and fill in any blanks with "-No Entry-". + +**Usage** + +```powerquery-m +let + Source = #table(type table[CustomerID = number, Name = text, Phone = text], + { + {1, "Bob White", "123-4567"}, + {2, "Jim Smith", "987-6543"}, + {3, "Paul", "543-7890"}, + {4, "Cristina Best", "232-1550"} + }), + SplitColumns = Table.SplitColumn( + Source, + "Name", + Splitter.SplitTextByDelimiter(" "), + {"First Name", "Last Name"}, + "-No Entry-") +in + SplitColumns +``` + +**Output** + +```powerquery-m +#table(type table[CustomerID = number, First Name = text, Last Name = text, Phone = text], +{ + {1, "Bob", "White", "123-4567"}, + {2, "Jim", "Smith", "987-6543"}, + {3, "Paul", "-No Entry-", "543-7890"}, + {4, "Cristina", "Best", "232-1550"} +}) +``` + +## Example 4 + +Split the name column into first name and last name, then rename the new columns. Because there might be more values than the number of available columns, make the last name column a list that includes all values after the first name. **Usage** ```powerquery-m let - Customers = 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 = "Cristina", Phone = "232-1550"] - }) + Source = #table(type table[CustomerID = number, Name = text, Phone = text], + { + {1, "Bob White", "123-4567"}, + {2, "Jim Smith", "987-6543"}, + {3, "Paul Green", "543-7890"}, + {4, "Cristina J. Best", "232-1550"} + }), + SplitColumns = Table.SplitColumn( + Source, + "Name", + Splitter.SplitTextByDelimiter(" "), + {"First Name", "Last Name"}, + null, + ExtraValues.List) in - Table.SplitColumn(Customers, "Name", Splitter.SplitTextByDelimiter("i"), 2 + SplitColumns ``` **Output** ```powerquery-m -Table.FromRecords({ - [CustomerID = 1, Name.1 = "Bob", Name.2 = null, Phone = "123-4567"], - [CustomerID = 2, Name.1 = "J", Name.2 = "m", Phone = "987-6543"], - [CustomerID = 3, Name.1 = "Paul", Name.2 = null, Phone = "543-7890"], - [CustomerID = 4, Name.1 = "Cr", Name.2 = "st", Phone = "232-1550"] +#table(type table[CustomerID = number, First Name = text, Last Name = text, Phone = text], +{ + {1, "Bob", {"White"}, "123-4567"}, + {2, "Jim", {"Smith"}, "987-6543"}, + {3, "Paul", {"Green"}, "543-7890"}, + {4, "Cristina", {"J.", "Best"}, "232-1550"} }) ``` diff --git a/query-languages/m/table-stopfolding.md b/query-languages/m/table-stopfolding.md index 4057c60fe..857e94f8a 100644 --- a/query-languages/m/table-stopfolding.md +++ b/query-languages/m/table-stopfolding.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.StopFolding" -title: "Table.StopFolding | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.StopFolding" +ms.subservice: m-source --- # Table.StopFolding @@ -32,7 +25,7 @@ Fetches data from a SQL table in a way that prevents any downstream operations f let Source = Sql.Database("SomeSQLServer", "MyDb"), MyTable = Source{[Item="MyTable"]}[Data], - MyLocalTable = Table.StopFolding(dbo_MyTable) + MyLocalTable = Table.StopFolding(MyTable) in MyLocalTable ``` diff --git a/query-languages/m/table-tocolumns.md b/query-languages/m/table-tocolumns.md index fe98c4399..8c0fc4d1d 100644 --- a/query-languages/m/table-tocolumns.md +++ b/query-languages/m/table-tocolumns.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ToColumns" -title: "Table.ToColumns | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ToColumns" +ms.subservice: m-source --- # Table.ToColumns diff --git a/query-languages/m/table-tolist.md b/query-languages/m/table-tolist.md index 1a02c7dd9..a0e9d1e6b 100644 --- a/query-languages/m/table-tolist.md +++ b/query-languages/m/table-tolist.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ToList" -title: "Table.ToList | Microsoft Docs" -ms.date: 5/3/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ToList" +ms.subservice: m-source --- # Table.ToList @@ -42,3 +35,7 @@ Table.ToList( **Output** `{"1,Bob,123-4567", "2,Jim,987-6543", "3,Paul,543-7890"}` + +## Related content + +[Combiner functions](combiner-functions.md) \ No newline at end of file diff --git a/query-languages/m/table-torecords.md b/query-languages/m/table-torecords.md index 816c5f88e..06edb214f 100644 --- a/query-languages/m/table-torecords.md +++ b/query-languages/m/table-torecords.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ToRecords" -title: "Table.ToRecords | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ToRecords" +ms.subservice: m-source --- # Table.ToRecords diff --git a/query-languages/m/table-torows.md b/query-languages/m/table-torows.md index 7305e0da5..ce65b5ea9 100644 --- a/query-languages/m/table-torows.md +++ b/query-languages/m/table-torows.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ToRows" -title: "Table.ToRows | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ToRows" +ms.subservice: m-source --- # Table.ToRows @@ -20,7 +13,7 @@ Table.ToRows(table as table) as list ## About -Creates a list of nested lists from the table, table. Each list item is an inner list that contains the row values. +Creates a list of nested lists from the table, `table`. Each list item is an inner list that contains the row values. ## Example 1 diff --git a/query-languages/m/table-transformcolumnnames.md b/query-languages/m/table-transformcolumnnames.md index 15c55c0fa..a9b0f3942 100644 --- a/query-languages/m/table-transformcolumnnames.md +++ b/query-languages/m/table-transformcolumnnames.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Table.TransformColumnNames" -title: "Table.TransformColumnNames | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.TransformColumnNames" +ms.subservice: m-source --- # Table.TransformColumnNames ## Syntax
-Table.TransformColumnNames(table as table, nameGenerator as function, optional options as nullable record) as table
+Table.TransformColumnNames(
+    table as table,
+    nameGenerator as function,
+    optional options as nullable record
+) as table
 
## About @@ -63,3 +60,7 @@ Table.TransformColumnNames( **Output** `Table.FromRecords({[Column = 1, cOlum1 = 2, coLum2 = 3]})` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/table-transformcolumns.md b/query-languages/m/table-transformcolumns.md index 03ab4a1e8..3ace16a0d 100644 --- a/query-languages/m/table-transformcolumns.md +++ b/query-languages/m/table-transformcolumns.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.TransformColumns" -title: "Table.TransformColumns | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.TransformColumns" +ms.subservice: m-source --- # Table.TransformColumns ## Syntax
-Table.TransformColumns(table as table, transformOperations as list, optional defaultTransformation as nullable function, optional missingField as nullable number) as table
+Table.TransformColumns(
+    table as table,
+    transformOperations as list,
+    optional defaultTransformation as nullable function,
+    optional missingField as nullable number
+) as table
 
## About diff --git a/query-languages/m/table-transformcolumntypes.md b/query-languages/m/table-transformcolumntypes.md index 6a83e2e96..640d8165f 100644 --- a/query-languages/m/table-transformcolumntypes.md +++ b/query-languages/m/table-transformcolumntypes.md @@ -1,49 +1,139 @@ --- description: "Learn more about: Table.TransformColumnTypes" -title: "Table.TransformColumnTypes | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.TransformColumnTypes" +ms.subservice: m-source --- # Table.TransformColumnTypes ## Syntax
-Table.TransformColumnTypes(table as table, typeTransformations as list, optional culture as nullable text) as table
+Table.TransformColumnTypes(
+    table as table,
+    typeTransformations as list,
+    optional culture as nullable text
+) as table
 
## About -Returns a table from the input `table` by applying the transform operation to the columns specified in the parameter `typeTransformations` (where format is { column name, type name}), using the specified culture in the optional parameter `culture` (for example, "en-US"). If the column doesn't exist, an exception is thrown. +Returns a table by applying the transform operations to the specified columns using an optional culture. + +* `table`: The input table to transform. +* `typeTransformations`: The type transformations to apply. The format for a single transformation is { column name, type value }. A list of transformations can be used to change the types of more than one column at a time. If a column doesn't exist, an error is raised. +* `culture`: (Optional) The culture to use when transforming the column types (for example, "en-US"). If a record is specified for `culture`, it can contain the following fields: + * `Culture`: The culture to use when transforming the column types (for example, "en-US"). + * `MissingField`: If a column doesn't exist, an error is raised unless this field provides an alternative behavior (for example, [MissingField.UseNull](missingfield-type.md) or [MissingField.Ignore](missingfield-type.md)). + +The type value in the `typeTransformations` parameter can be `any`, all of the `number` types, `text`, all of the `date`, `time`, `datetime`, `datetimezone`, and `duration` types, `logical`, or `binary`. The `list`, `record`, `table`, or `function` types aren't valid for this parameter. + +For each column listed in `typeTransformations`, the ".From" method corresponding to the specified type value is normally used to perform the transformation. For example, if a [Currency.Type](type-conversion.md#commonly-used-types) type value is given for a column, the transformation function [Currency.From](currency-from.md) is applied to each value in that column. ## Example 1 -Transform the number values in column [a] to text values from the table `({[a = 1, b = 2], [a = 3, b = 4]})`. +Transform the number values in the first column to text values. **Usage** ```powerquery-m -Table.TransformColumnTypes( - Table.FromRecords({ - [a = 1, b = 2], - [a = 3, b = 4] +let + Source = #table(type table [a = number, b = number], + { + {1, 2}, + {3, 4} }), - {"a", type text}, - "en-US" -) + #"Transform Column" = Table.TransformColumnTypes( + Source, + {"a", type text} + ) +in + #"Transform Column" ``` **Output** ```powerquery-m -Table.FromRecords({ - [a = "1", b = 2], - [a = "3", b = 4] +#table(type table [a = text, b = number], +{ + {"1", 2}, + {"3", 4} }) ``` + +## Example 2 + +Transform the dates in the table to their French text equivalents. + +**Usage** + +```powerquery-m +let + Source = #table(type table [Company ID = text, Country = text, Date = date], + { + {"JS-464", "USA", #date(2024, 3, 24)}, + {"LT-331", "France", #date(2024, 10, 5)}, + {"XE-100", "USA", #date(2024, 5, 21)}, + {"RT-430", "Germany", #date(2024, 1,18)}, + {"LS-005", "France", #date(2023, 12, 31)}, + {"UW-220", "Germany", #date(2024, 2, 25)} + }), + #"Transform Column" = Table.TransformColumnTypes( + Source, + {"Date", type text}, + "fr-FR" + ) +in + #"Transform Column" +``` + +**Output** + +```powerquery-m +#table(type table [Company ID = text, Country = text, Date = text], + { + {"JS-464", "USA", "24/03/2024"}, + {"LT-331", "France", "05/10/2024"}, + {"XE-100", "USA", "21/05/2024"}, + {"RT-430", "Germany", "18/01/2024"}, + {"LS-005", "France", "31/12/2023"}, + {"UW-220", "Germany", "25/02/2024"} + }) +``` + +## Example 3 + +Transform the dates in the table to their German text equivalents, and the values in the table to percentages. + +**Usage** + +```powerquery-m +let + Source = #table(type table [Date = date, Customer ID = text, Value = number], + { + {#date(2024, 3, 12), "134282", .24368}, + {#date(2024, 5, 30), "44343", .03556}, + {#date(2023, 12, 14), "22", .3834} + }), + #"Transform Columns" = Table.TransformColumnTypes( + Source, + {{"Date", type text}, {"Value", Percentage.Type}}, + "de-DE") +in + #"Transform Columns" +``` + +**Output** + +```powerquery-m +#table(type table [Date = text, Customer ID = text, Value = Percentage.Type], +{ + {"12.03.2024", "134282", .24368}, + {"30.05.2024", "44343", .03556}, + {"14.12.2023", "22", .3834} +}) +``` + +## Related content + +* [Types and type conversion](type-conversion.md) +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/table-transformrows.md b/query-languages/m/table-transformrows.md index 854162ebf..92c6e0ee4 100644 --- a/query-languages/m/table-transformrows.md +++ b/query-languages/m/table-transformrows.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.TransformRows" -title: "Table.TransformRows | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.TransformRows" +ms.subservice: m-source --- # Table.TransformRows diff --git a/query-languages/m/table-transpose.md b/query-languages/m/table-transpose.md index ae6ddcfa5..f92c83711 100644 --- a/query-languages/m/table-transpose.md +++ b/query-languages/m/table-transpose.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.Transpose" -title: "Table.Transpose | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Transpose" +ms.subservice: m-source --- # Table.Transpose diff --git a/query-languages/m/table-unpivot.md b/query-languages/m/table-unpivot.md index b1bad678c..ef42c4457 100644 --- a/query-languages/m/table-unpivot.md +++ b/query-languages/m/table-unpivot.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Table.Unpivot" -title: "Table.Unpivot | Microsoft Docs" -ms.date: 3/10/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.Unpivot" +ms.subservice: m-source --- # Table.Unpivot ## Syntax
-Table.Unpivot(table as table, pivotColumns as list, attributeColumn as text, valueColumn as text) as table
+Table.Unpivot(
+    table as table,
+    pivotColumns as list,
+    attributeColumn as text,
+    valueColumn as text
+) as table
 
## About diff --git a/query-languages/m/table-unpivotothercolumns.md b/query-languages/m/table-unpivotothercolumns.md index 1e20fbaa8..0c3a6827b 100644 --- a/query-languages/m/table-unpivotothercolumns.md +++ b/query-languages/m/table-unpivotothercolumns.md @@ -1,21 +1,20 @@ --- description: "Learn more about: Table.UnpivotOtherColumns" -title: "Table.UnpivotOtherColumns | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.UnpivotOtherColumns" +ms.subservice: m-source --- + # Table.UnpivotOtherColumns ## Syntax
-Table.UnpivotOtherColumns(table as table, pivotColumns as list, attributeColumn as text, valueColumn as text) as table
+Table.UnpivotOtherColumns(
+    table as table,
+    pivotColumns as list,
+    attributeColumn as text,
+    valueColumn as text
+) as table
 
## About diff --git a/query-languages/m/table-view.md b/query-languages/m/table-view.md index 1e2256701..c4647c4e0 100644 --- a/query-languages/m/table-view.md +++ b/query-languages/m/table-view.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.View" -title: "Table.View | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.View" +ms.subservice: m-source --- # Table.View diff --git a/query-languages/m/table-viewerror.md b/query-languages/m/table-viewerror.md index 5a8150825..e3ef32b18 100644 --- a/query-languages/m/table-viewerror.md +++ b/query-languages/m/table-viewerror.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ViewError" -title: "Table.ViewError | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ViewError" +ms.subservice: m-source --- # Table.ViewError diff --git a/query-languages/m/table-viewfunction.md b/query-languages/m/table-viewfunction.md index b86543d8d..3cb85553f 100644 --- a/query-languages/m/table-viewfunction.md +++ b/query-languages/m/table-viewfunction.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Table.ViewFunction" -title: "Table.ViewFunction | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Table.ViewFunction" +ms.subservice: m-source --- # Table.ViewFunction @@ -22,7 +15,7 @@ Table.ViewFunction(function as function) as function Creates a view function based on `function` that can be handled in a view created by [Table.View](/powerquery-m/table-view). -The `OnInvoke` handler of **Table.View** can be used to defined a handler for the view function. +The `OnInvoke` handler of [Table.View](table-view.md) can be used to define a handler for the view function. As with the handlers for built-in operations, if no `OnInvoke` handler is specified, or if it does not handle the view function, or if an error is raised by the handler, `function` is applied on top of the view. diff --git a/query-languages/m/table-witherrorcontext.md b/query-languages/m/table-witherrorcontext.md new file mode 100644 index 000000000..f63dca654 --- /dev/null +++ b/query-languages/m/table-witherrorcontext.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Table.WithErrorContext" +title: "Table.WithErrorContext" +ms.subservice: m-source +--- +# Table.WithErrorContext + +## Syntax + +
+Table.WithErrorContext(value as any, context as text) as any
+
+ +## About + +This function is intended for internal use only. diff --git a/query-languages/m/tables-getrelationships.md b/query-languages/m/tables-getrelationships.md index f073027b9..530e320f4 100644 --- a/query-languages/m/tables-getrelationships.md +++ b/query-languages/m/tables-getrelationships.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Tables.GetRelationships" -title: "Tables.GetRelationships | Microsoft Docs" -ms.date: 8/1/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Tables.GetRelationships" +ms.subservice: m-source --- # Tables.GetRelationships @@ -16,7 +9,8 @@ ms.author: dougklo
 Tables.GetRelationships(tables as table, optional dataColumn as nullable text) as table
-
- -## About + + +## About + Gets the relationships among a set of tables. The set `tables` is assumed to have a structure similar to that of a navigation table. The column defined by `dataColumn` contains the actual data tables. diff --git a/query-languages/m/teradata-database.md b/query-languages/m/teradata-database.md index 414b87900..0260f40b9 100644 --- a/query-languages/m/teradata-database.md +++ b/query-languages/m/teradata-database.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Teradata.Database" -title: "Teradata.Database | Microsoft Docs" -ms.date: 02/03/2021 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Teradata.Database" +ms.subservice: m-source --- # Teradata.Database @@ -18,19 +12,19 @@ Teradata.Database(server as text, optional options as nullable rec ## About -Returns a table of SQL tables and views from the Teradata database on server `server`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: -* `CreateNavigationProperties` : A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). +Returns a table of SQL tables and views from the Teradata database on server `server`. The port may be optionally specified with the server, separated by a colon. An optional record parameter, `options`, may be specified to control the following options: + +* `CreateNavigationProperties`: A logical (true/false) that sets whether to generate navigation properties on the returned values (default is true). -* `NavigationPropertyNameGenerator` : A function that is used for the creation of names for navigation properties. +* `NavigationPropertyNameGenerator`: A function that is used for the creation of names for navigation properties. -* `Query` : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. +* `Query`: A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will be returned. -* `CommandTimeout` : A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. +* `CommandTimeout`: A duration that controls how long the server-side query is allowed to run before it is canceled. The default value is ten minutes. -* `ConnectionTimeout` : 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. +* `ConnectionTimeout`: 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. -* `HierarchicalNavigation` : A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). +* `HierarchicalNavigation`: A logical (true/false) that sets whether to view the tables grouped by their schema names (default is false). -The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. - +The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example. diff --git a/query-languages/m/text-afterdelimiter.md b/query-languages/m/text-afterdelimiter.md index 546277b06..c11d528b6 100644 --- a/query-languages/m/text-afterdelimiter.md +++ b/query-languages/m/text-afterdelimiter.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.AfterDelimiter" -title: "Text.AfterDelimiter | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.AfterDelimiter" +ms.subservice: m-source --- # Text.AfterDelimiter ## Syntax
-Text.AfterDelimiter(text as nullable text, delimiter as text, optional index as any) as any
+Text.AfterDelimiter(
+    text as nullable text,
+    delimiter as text,
+    optional index as any
+) as any
 
## About diff --git a/query-languages/m/text-at.md b/query-languages/m/text-at.md index 513c07703..4bae37965 100644 --- a/query-languages/m/text-at.md +++ b/query-languages/m/text-at.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.At" -title: "Text.At | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.At" +ms.subservice: m-source --- # Text.At diff --git a/query-languages/m/text-beforedelimiter.md b/query-languages/m/text-beforedelimiter.md index 866747f63..9811554fc 100644 --- a/query-languages/m/text-beforedelimiter.md +++ b/query-languages/m/text-beforedelimiter.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.BeforeDelimiter" -title: "Text.BeforeDelimiter | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.BeforeDelimiter" +ms.subservice: m-source --- # Text.BeforeDelimiter ## Syntax
-Text.BeforeDelimiter(text as nullable text, delimiter as text, optional index as any) as any
+Text.BeforeDelimiter(
+    text as nullable text,
+    delimiter as text,
+    optional index as any
+) as any
 
## About diff --git a/query-languages/m/text-betweendelimiters.md b/query-languages/m/text-betweendelimiters.md index eab65d4bd..4e6864fc3 100644 --- a/query-languages/m/text-betweendelimiters.md +++ b/query-languages/m/text-betweendelimiters.md @@ -1,21 +1,20 @@ --- description: "Learn more about: Text.BetweenDelimiters" -title: "Text.BetweenDelimiters | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.BetweenDelimiters" +ms.subservice: m-source --- # Text.BetweenDelimiters ## Syntax
-Text.BetweenDelimiters(text as nullable text, startDelimiter as text, endDelimiter as text, optional startIndex as any, optional endIndex as any) as any
+Text.BetweenDelimiters(
+    text as nullable text,
+    startDelimiter as text,
+    endDelimiter as text,
+    optional startIndex as any,
+    optional endIndex as any
+) as any
 
## About diff --git a/query-languages/m/text-clean.md b/query-languages/m/text-clean.md index 374e42e1a..52e4c3a62 100644 --- a/query-languages/m/text-clean.md +++ b/query-languages/m/text-clean.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Text.Clean" -title: "Text.Clean | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Clean" +ms.subservice: m-source --- # Text.Clean diff --git a/query-languages/m/text-combine.md b/query-languages/m/text-combine.md index 076de3c66..0f28e4c4b 100644 --- a/query-languages/m/text-combine.md +++ b/query-languages/m/text-combine.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Combine" -title: "Text.Combine | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Combine" +ms.subservice: m-source --- # Text.Combine @@ -20,7 +13,7 @@ Text.Combine(texts as list, optional separator as nullable text) a ## About -Returns the result of combining the list of text values, `texts`, into a single text value. An optional separator used in the final combined text may be specified, `separator`. +Returns the result of combining the list of text values, `texts`, into a single text value. Any `null` values present in `texts` are ignored. An optional `separator` used in the final combined text can be specified. ## Example 1 @@ -38,7 +31,7 @@ Text.Combine({"Seattle", "WA"}) ## Example 2 -Combine text values "Seattle" and "WA" separated by a comma and a space, ", ". +Combine text values "Seattle" and "WA", separated by a comma and a space. **Usage** @@ -49,3 +42,45 @@ Text.Combine({"Seattle", "WA"}, ", ") **Output** `"Seattle, WA"` + +## Example 3 + +Combine the values "Seattle", `null`, and "WA", separated by a comma and a space. (Note that the `null` is ignored.) + +**Usage** + +```powerquery-m +Text.Combine({"Seattle", null, "WA"}, ", ") +``` + +**Output** + +`"Seattle, WA"` + +## Example 4 + +**Usage** + +Combine the first name, middle initial (if present), and last name into the individual’s full name. + +```powerquery-m +let + Source = Table.FromRecords({ + [First Name = "Doug", Middle Initial = "J", Last Name = "Elis"], + [First Name = "Anna", Middle Initial = "M", Last Name = "Jorayew"], + [First Name = "Rada", Middle Initial = null, Last Name = "Mihaylova"] + }), + FullName = Table.AddColumn(Source, "Full Name", each Text.Combine({[First Name], [Middle Initial], [Last Name]}, " ")) +in + FullName +``` + +**Output** + +```powerquery-m +Table.FromRecords({ + [First Name = "Doug", Middle Initial = "J", Last Name = "Elis", Full Name = "Doug J Elis"], + [First Name = "Anna", Middle Initial = "M", Last Name = "Jorayew", Full Name = "Anna M Jorayew"], + [First Name = "Rada", Middle Initial = null, Last Name = "Mihaylova", Full Name = "Rada Mihaylova"] +}) +``` diff --git a/query-languages/m/text-contains.md b/query-languages/m/text-contains.md index 04c6935a0..24c9cf06f 100644 --- a/query-languages/m/text-contains.md +++ b/query-languages/m/text-contains.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.Contains" -title: "Text.Contains | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Contains" +ms.subservice: m-source --- # Text.Contains ## Syntax
-Text.Contains(text as nullable text, substring as text, optional comparer as nullable function) as nullable logical
+Text.Contains(
+    text as nullable text,
+    substring as text,
+    optional comparer as nullable function
+) as nullable logical
 
## About @@ -28,6 +25,10 @@ The optional argument `comparer` can be used to specify case-insensitive or cult * [Comparer.OrdinalIgnoreCase](/powerquery-m/comparer-ordinalignorecase): Used to perform a case-insensitive ordinal comparison * [Comparer.FromCulture](/powerquery-m/comparer-fromculture): Used to perform a culture-aware comparison +If the first argument is null, this function returns null. + +All characters are treated literally. For example, "DR", " DR", "DR ", and " DR " aren't considered equal to each other. + ## Example 1 Find if the text "Hello World" contains "Hello". @@ -69,3 +70,44 @@ Text.Contains("Hello World", "hello", Comparer.OrdinalIgnoreCase) **Output** `true` + +## Example 4 + +Find the rows in a table that contain either "A-" or "7" in the account code. + +**Usage** + +```powerquery-m +let + Source = #table(type table [Account Code = text, Posted Date = date, Sales = number], + { + {"US-2004", #date(2023,1,20), 580}, + {"CA-8843", #date(2023,7,18), 280}, + {"PA-1274", #date(2022,1,12), 90}, + {"PA-4323", #date(2023,4,14), 187}, + {"US-1200", #date(2022,12,14), 350}, + {"PTY-507", #date(2023,6,4), 110} + }), + #"Filtered rows" = Table.SelectRows( + Source, + each Text.Contains([Account Code], "A-") or + Text.Contains([Account Code], "7")) +in + #"Filtered rows" +``` + +**Output** + +```powerquery-m +#table(type table [Account Code = text, Posted Date = date, Sales = number], +{ + {"CA-8843", #date(2023,7,18), 280}, + {"PA-1274", #date(2022,1,12), 90}, + {"PA-4323", #date(2023,4,14), 187}, + {"PTY-507", #date(2023,6,4), 110} +}) +``` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/text-end.md b/query-languages/m/text-end.md index 67080b5d0..b033372a1 100644 --- a/query-languages/m/text-end.md +++ b/query-languages/m/text-end.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.End" -title: "Text.End | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.End" +ms.subservice: m-source --- # Text.End diff --git a/query-languages/m/text-endswith.md b/query-languages/m/text-endswith.md index 01ed97f2d..18971ab96 100644 --- a/query-languages/m/text-endswith.md +++ b/query-languages/m/text-endswith.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.EndsWith" -title: "Text.EndsWith | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.EndsWith" +ms.subservice: m-source --- # Text.EndsWith ## Syntax
-Text.EndsWith(text as nullable text, substring as text, optional comparer as nullable function) as nullable logical
+Text.EndsWith(
+    text as nullable text,
+    substring as text,
+    optional comparer as nullable function
+) as nullable logical
 
## About @@ -57,3 +54,7 @@ Text.EndsWith("Hello, World", "World") **Output** `true` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/text-format.md b/query-languages/m/text-format.md index 05527a9f9..4d2eadb91 100644 --- a/query-languages/m/text-format.md +++ b/query-languages/m/text-format.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.Format" -title: "Text.Format | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Format" +ms.subservice: m-source --- # Text.Format ## Syntax
-Text.Format(formatString as text, arguments as any, optional culture as nullable text) as text
+Text.Format(
+    formatString as text,
+    arguments as any,
+    optional culture as nullable text
+) as text
 
## About @@ -58,3 +55,7 @@ Text.Format( **Output** `"The time for the 10 km run held in Seattle on 3/10/2015 was 00:54:40."` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/text-from.md b/query-languages/m/text-from.md index ed98d8691..2ea9293e8 100644 --- a/query-languages/m/text-from.md +++ b/query-languages/m/text-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.From" -title: "Text.From | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.From" +ms.subservice: m-source --- # Text.From @@ -20,7 +13,10 @@ Text.From(value as any, optional culture as nullable text) as null ## About -Returns the text representation of `value`. The `value` can be a `number`, `date`, `time`, `datetime`, `datetimezone`, `logical`, `duration` or `binary` value. If the given value is null, `Text.From` returns null. An optional `culture` may also be provided (for example, "en-US"). +Returns the text representation of a specified value. + +* `value`: The value to convert to text. The value can be a `number`, `date`, `time`, `datetime`, `datetimezone`, `logical`, `duration`, or `binary` value. If the given value is `null`, this function returns `null`. +* `culture`: (Optional) The culture to use when converting the value to text (for example, "en-US"). ## Example 1 @@ -35,3 +31,88 @@ Text.From(3) **Output** `"3"` + +## Example 2 + +Get the text equivalent of the specified date and time. + +**Usage** + +```powerquery-m +Text.From(#datetime(2024, 6, 24, 14, 32, 22)) +``` + +**Output** + +`"6/24/2024 2:32:22 PM"` + +## Example 3 + +Get the German text equivalent of the specified date and time. + +**Usage** + +```powerquery-m +Text.From(#datetime(2024, 6, 24, 14, 32, 22), "de-DE") +``` + +**Output** + +`"24.06.2024 14:32:22"` + +## Example 4 + +Get a binary value from text encoded as hexadecimal and change the value back to text. + +**Usage** + +```powerquery-m +Text.From(Binary.FromText("10FF", BinaryEncoding.Hex)) +``` + +**Output** + +`"EP8="` + +## Example 5 + +Get the rows in the table that contain data for France and convert the dates to text using the French culture. + +**Usage** + +```powerquery-m +let + Source = #table(type table [Company ID = text, Country = text, Date = date], + { + {"JS-464", "USA", #date(2024, 3, 24)}, + {"LT-331", "France", #date(2024, 10, 5)}, + {"XE-100", "USA", #date(2024, 5, 21)}, + {"RT-430", "Germany", #date(2024, 1,18)}, + {"LS-005", "France", #date(2023, 12, 31)}, + {"UW-220", "Germany", #date(2024, 2, 25)} + }), + #"Convert Dates" = Table.TransformColumns( + Table.SelectRows(Source, each [Country] = "France"), + {"Date", each Text.From(_, "fr-FR")} + ) +in + #"Convert Dates" +``` + +**Output** + +```powerquery-m +#table(type table [Company ID = text, Country = text, Date = text], +{ + {"LT-331", "France", "05/10/2024"}, + {"LS-005", "France", "31/12/2023"} +}) +``` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard numeric format strings](standard-numeric-format-strings.md) +* [Custom numeric format strings](custom-numeric-format-strings.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/text-frombinary.md b/query-languages/m/text-frombinary.md index 008f6b5b9..ace2fdb63 100644 --- a/query-languages/m/text-frombinary.md +++ b/query-languages/m/text-frombinary.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.FromBinary" -title: "Text.FromBinary | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.FromBinary" +ms.subservice: m-source --- # Text.FromBinary @@ -17,6 +10,7 @@ ms.author: dougklo
 Text.FromBinary(binary as nullable binary, optional encoding as nullable number) as nullable text
 
- -## About + +## About + Decodes data, `binary`, from a binary value in to a text value, using `encoding` type. diff --git a/query-languages/m/text-functions.md b/query-languages/m/text-functions.md index 38d403e56..5571a61ea 100644 --- a/query-languages/m/text-functions.md +++ b/query-languages/m/text-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Text functions" -title: "Text functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text functions" +ms.date: 6/9/2025 +ms.custom: "nonautomated-date" --- # Text functions @@ -18,23 +12,23 @@ These functions create and manipulate text values. |Name|Description| |------------|---------------| -|[Text.InferNumberType](text-infernumbertype.md)|Infers the granular number type (Int64.Type, Double.Type, and so on) of a number encoded in text.| +|[Text.InferNumberType](text-infernumbertype.md)|Infers the granular number type (`Int64.Type`, `Double.Type`, and so on) of a number encoded in text.| |[Text.Length](text-length.md)|Returns the number of characters in a text value.| ## Text Comparisons |Name|Description| |------------|---------------| -|[Character.FromNumber](character-fromnumber.md)|Returns a number to its character value.| -|[Character.ToNumber](character-tonumber.md)|Returns a character to its number value.| -|[Guid.From](guid-from.md) | Returns a `Guid.Type` value from the given `value`.| +|[Character.FromNumber](character-fromnumber.md)|Converts a number to a text character.| +|[Character.ToNumber](character-tonumber.md)|Converts a character to a number value.| +|[Guid.From](guid-from.md) | Returns a GUID value from the given value.| |[Json.FromValue](json-fromvalue.md) | Produces a JSON representation of a given value.| -|[Text.From](text-from.md)|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.| +|[Text.From](text-from.md)|Creates a text value from the given value.| |[Text.FromBinary](text-frombinary.md)|Decodes data from a binary value in to a text value using an encoding.| -|[Text.NewGuid](text-newguid.md)|Returns a Guid value as a text value.| +|[Text.NewGuid](text-newguid.md)|Returns a GUID value as a text value.| |[Text.ToBinary](text-tobinary.md)|Encodes a text value into binary value using an encoding.| |[Text.ToList](text-tolist.md)|Returns a list of characters from a text value.| -|[Value.FromText](value-fromtext.md)|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.| +|[Value.FromText](value-fromtext.md)|Creates a strongly-typed value from a textual representation.| ## Extraction @@ -50,8 +44,8 @@ These functions create and manipulate text values. |Name|Description| |------------|---------------| -|[Text.Insert](text-insert.md)|Returns a text value with newValue inserted into a text value starting at a zero-based offset.| -|[Text.Remove](text-remove.md)|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.| +|[Text.Insert](text-insert.md)|Inserts one text value into another at a given position.| +|[Text.Remove](text-remove.md)|Removes all occurrences of the given character or list of characters from the input text value.| |[Text.RemoveRange](text-removerange.md)|Removes count characters at a zero-based offset from a text value.| |[Text.Replace](text-replace.md)|Replaces all occurrences of a substring with a new text value.| |[Text.ReplaceRange](text-replacerange.md)|Replaces length characters in a text value starting at a zero-based offset with the new text value.| @@ -61,10 +55,10 @@ These functions create and manipulate text values. |Name|Description| |------------|---------------| -|[Text.Contains](text-contains.md)|Returns true if a text value substring was found within a text value string; otherwise, false.| +|[Text.Contains](text-contains.md)|Returns `true` if a text value substring was found within a text value string; otherwise, `false`.| |[Text.EndsWith](text-endswith.md)|Returns a logical value indicating whether a text value substring was found at the end of a string.| -|[Text.PositionOf](text-positionof.md)|Returns the first occurrence of substring in a string and returns its position starting at startOffset.| -|[Text.PositionOfAny](text-positionofany.md)|Returns the first occurrence of a text value in list and returns its position starting at startOffset.| +|[Text.PositionOf](text-positionof.md)|Returns the first position of the value (-1 if not found).| +|[Text.PositionOfAny](text-positionofany.md)|Returns the first position in the text value of any listed character (-1 if not found).| |[Text.StartsWith](text-startswith.md)|Returns a logical value indicating whether a text value substring was found at the beginning of a string.| ## Transformations @@ -73,18 +67,18 @@ These functions create and manipulate text values. |------------|---------------| |[Text.AfterDelimiter](text-afterdelimiter.md)|Returns the portion of text after the specified delimiter.| |[Text.BeforeDelimiter](text-beforedelimiter.md)|Returns the portion of text before the specified delimiter.| -|[Text.BetweenDelimiters](text-betweendelimiters.md)|Returns the portion of text between the specified startDelimiter and endDelimiter.| +|[Text.BetweenDelimiters](text-betweendelimiters.md)|Returns the portion of text between the specified `startDelimiter` and `endDelimiter`.| |[Text.Clean](text-clean.md)|Returns the original text value with non-printable characters removed.| |[Text.Combine](text-combine.md)|Returns a text value that is the result of joining all text values with each value separated by a separator.| |[Text.Lower](text-lower.md)|Returns the lowercase of a text value.| -|[Text.PadEnd](text-padend.md)|Returns a text value padded at the end with pad to make it at least length characters.| -|[Text.PadStart](text-padstart.md)|Returns a text value padded at the beginning with pad to make it at least length characters. If pad is not specified, whitespace is used as pad.| +|[Text.PadEnd](text-padend.md)|Returns text of a specified length by padding the end of the given text.| +|[Text.PadStart](text-padstart.md)|Returns text of a specified length by padding the start of the given text.| |[Text.Proper](text-proper.md)|Returns a text value with first letters of all words converted to uppercase.| |[Text.Repeat](text-repeat.md)|Returns a text value composed of the input text value repeated a number of times.| |[Text.Reverse](text-reverse.md)|Reverses the provided text.| |[Text.Split](text-split.md)|Returns a list containing parts of a text value that are delimited by a separator text value.| |[Text.SplitAny](text-splitany.md)|Returns a list containing parts of a text value that are delimited by any separator text values.| -|[Text.Trim](text-trim.md)|Removes any occurrences of characters in trimChars from text.| -|[Text.TrimEnd](text-trimend.md)|Removes any occurrences of the characters specified in trimChars from the end of the original text value.| -|[Text.TrimStart](text-trimstart.md)|Removes any occurrences of the characters in trimChars from the start of the original text value.| +|[Text.Trim](text-trim.md)|Removes all the specified leading and trailing characters.| +|[Text.TrimEnd](text-trimend.md)|Removes all specified trailing characters.| +|[Text.TrimStart](text-trimstart.md)|Removes all specified leading characters.| |[Text.Upper](text-upper.md)|Returns the uppercase of a text value.| diff --git a/query-languages/m/text-infernumbertype.md b/query-languages/m/text-infernumbertype.md index 1123a45f8..2aa13db53 100644 --- a/query-languages/m/text-infernumbertype.md +++ b/query-languages/m/text-infernumbertype.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.InferNumberType" -title: "Text.InferNumberType | Microsoft Docs" -ms.date: 11/17/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.InferNumberType" +ms.subservice: m-source --- # Text.InferNumberType @@ -17,8 +10,11 @@ ms.author: dougklo
 Text.InferNumberType(text as text, optional culture as nullable text) as type
 
- + ## About -Infers the granular number type (Int64.Type, Double.Type, and so on) of `text`. An error is raised if `text` is not a number. An optional `culture` may also be provided (for example, "en-US"). - +Infers the granular number type (`Int64.Type`, `Double.Type`, and so on) of `text`. An error is raised if `text` is not a number. An optional `culture` may also be provided (for example, "en-US"). + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/text-insert.md b/query-languages/m/text-insert.md index cd5670bdb..a3d420325 100644 --- a/query-languages/m/text-insert.md +++ b/query-languages/m/text-insert.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.Insert" -title: "Text.Insert | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Insert" +ms.subservice: m-source --- # Text.Insert ## Syntax
-Text.Insert(text as nullable text, offset as number, newText as text) as nullable text
+Text.Insert(
+    text as nullable text,
+    offset as number,
+    newText as text
+) as nullable text
 
## About diff --git a/query-languages/m/text-length.md b/query-languages/m/text-length.md index 1cf072e62..4854a71c6 100644 --- a/query-languages/m/text-length.md +++ b/query-languages/m/text-length.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Length" -title: "Text.Length | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Length" +ms.subservice: m-source --- # Text.Length diff --git a/query-languages/m/text-lower.md b/query-languages/m/text-lower.md index 63da99f0b..383ff37cb 100644 --- a/query-languages/m/text-lower.md +++ b/query-languages/m/text-lower.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Lower" -title: "Text.Lower | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Lower" +ms.subservice: m-source --- # Text.Lower @@ -35,3 +28,7 @@ Text.Lower("AbCd") **Output** `"abcd"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/text-middle.md b/query-languages/m/text-middle.md index bd148e379..440a2de80 100644 --- a/query-languages/m/text-middle.md +++ b/query-languages/m/text-middle.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.Middle" -title: "Text.Middle | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Middle" +ms.subservice: m-source --- # Text.Middle ## Syntax
-Text.Middle(text as nullable text, start as number, optional count as nullable number) as nullable text
+Text.Middle(
+    text as nullable text,
+    start as number,
+    optional count as nullable number
+) as nullable text
 
## About @@ -49,3 +46,17 @@ Text.Middle("Hello World", 6, 20) **Output** `"World"` + +## Example 3 + +Find the substring from the text "Hello World" starting at index 0 spanning 2 characters. + +**Usage** + +```powerquery-m +Text.Middle("Hello World", 0, 2) +``` + +**Output** + +`"He"` diff --git a/query-languages/m/text-newguid.md b/query-languages/m/text-newguid.md index 6ea313f56..cf2201c09 100644 --- a/query-languages/m/text-newguid.md +++ b/query-languages/m/text-newguid.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Text.NewGuid" -title: "Text.NewGuid | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.NewGuid" +ms.subservice: m-source --- # Text.NewGuid ## Syntax
-Text.NewGuid() as text 
+Text.NewGuid() as text
 
- -## About + +## About + Returns a new, random globally unique identifier (GUID). diff --git a/query-languages/m/text-padend.md b/query-languages/m/text-padend.md index 2fe8f097c..28b722ebc 100644 --- a/query-languages/m/text-padend.md +++ b/query-languages/m/text-padend.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.PadEnd" -title: "Text.PadEnd | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.PadEnd" +ms.subservice: m-source --- # Text.PadEnd ## Syntax
-Text.PadEnd(text as nullable text, count as number, optional character as nullable text) as nullable text
+Text.PadEnd(
+    text as nullable text,
+    count as number,
+    optional character as nullable text
+) as nullable text
 
## About diff --git a/query-languages/m/text-padstart.md b/query-languages/m/text-padstart.md index 1cf6e0d3a..bd70a456f 100644 --- a/query-languages/m/text-padstart.md +++ b/query-languages/m/text-padstart.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.PadStart" -title: "Text.PadStart | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.PadStart" +ms.subservice: m-source --- # Text.PadStart ## Syntax
-Text.PadStart(text as nullable text, count as number, optional character as nullable text) as nullable text
+Text.PadStart(
+    text as nullable text,
+    count as number,
+    optional character as nullable text
+) as nullable text
 
## About diff --git a/query-languages/m/text-positionof.md b/query-languages/m/text-positionof.md index 2310e7543..ffc8049a1 100644 --- a/query-languages/m/text-positionof.md +++ b/query-languages/m/text-positionof.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Text.PositionOf" -title: "Text.PositionOf | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.PositionOf" +ms.subservice: m-source --- # Text.PositionOf ## Syntax
-Text.PositionOf(text as text, substring as text, optional occurrence as nullable number, optional comparer as nullable function) as any
+Text.PositionOf(
+    text as text,
+    substring as text,
+    optional occurrence as nullable number,
+    optional comparer as nullable function
+) as any
 
## About @@ -57,3 +55,7 @@ Text.PositionOf("Hello, World! Hello, World!", "World", Occurrence.Last) **Output** `21` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/text-positionofany.md b/query-languages/m/text-positionofany.md index 3672461ae..974065335 100644 --- a/query-languages/m/text-positionofany.md +++ b/query-languages/m/text-positionofany.md @@ -1,51 +1,48 @@ --- description: "Learn more about: Text.PositionOfAny" -title: "Text.PositionOfAny | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.PositionOfAny" +ms.subservice: m-source --- # Text.PositionOfAny ## Syntax
-Text.PositionOfAny(text as text, characters as list, optional occurrence as nullable number) as any
+Text.PositionOfAny(
+    text as text,
+    characters as list,
+    optional occurrence as nullable number
+) as any
 
## About -Returns the position of the first occurrence of any of the characters in the character list `text` found in the text value `characters`. An optional parameter `occurrence` may be used to specify which occurrence position to return. +Returns the first position of any character in the list `characters` that is found in `text`. An optional parameter `occurrence` may be used to specify which occurrence position to return. ## Example 1 -Find the position of "W" in text "Hello, World!". +Find the first position of "W" or "H" in text "Hello, World!". **Usage** ```powerquery-m -Text.PositionOfAny("Hello, World!", {"W"}) +Text.PositionOfAny("Hello, World!", {"H", "W"}) ``` **Output** -`7` +`0` ## Example 2 -Find the position of "W" or "H" in text "Hello, World!". +Find all the positions of "W" or "H" in text "Hello, World!". **Usage** ```powerquery-m -Text.PositionOfAny("Hello, World!", {"H", "W"}) +Text.PositionOfAny("Hello, World!", {"H", "W"}, Occurrence.All) ``` **Output** -`0` +{0, 7} diff --git a/query-languages/m/text-proper.md b/query-languages/m/text-proper.md index 1afe20a3b..5a4dd9c93 100644 --- a/query-languages/m/text-proper.md +++ b/query-languages/m/text-proper.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Proper" -title: "Text.Proper | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Proper" +ms.subservice: m-source --- # Text.Proper @@ -35,3 +28,7 @@ Text.Proper("the QUICK BrOWn fOx jUmPs oVER tHe LAzy DoG") **Output** `"The Quick Brown Fox Jumps Over The Lazy Dog"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/text-range.md b/query-languages/m/text-range.md index 915c392c2..9c4057281 100644 --- a/query-languages/m/text-range.md +++ b/query-languages/m/text-range.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.Range" -title: "Text.Range | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Range" +ms.subservice: m-source --- # Text.Range ## Syntax
-Text.Range(text as nullable text, offset as number, optional count as nullable number) as nullable text
+Text.Range(
+    text as nullable text,
+    offset as number,
+    optional count as nullable number
+) as nullable text
 
## About diff --git a/query-languages/m/text-remove.md b/query-languages/m/text-remove.md index 4699b651f..fb09ef848 100644 --- a/query-languages/m/text-remove.md +++ b/query-languages/m/text-remove.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Remove" -title: "Text.Remove | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Remove" +ms.subservice: m-source --- # Text.Remove diff --git a/query-languages/m/text-removerange.md b/query-languages/m/text-removerange.md index a333eb536..c23ed0801 100644 --- a/query-languages/m/text-removerange.md +++ b/query-languages/m/text-removerange.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.RemoveRange" -title: "Text.RemoveRange | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.RemoveRange" +ms.subservice: m-source --- # Text.RemoveRange ## Syntax
-Text.RemoveRange(text as nullable text, offset as number, optional count as nullable number) as nullable text
+Text.RemoveRange(
+    text as nullable text,
+    offset as number,
+    optional count as nullable number
+) as nullable text
 
## About diff --git a/query-languages/m/text-repeat.md b/query-languages/m/text-repeat.md index 979dfa278..fc9d76356 100644 --- a/query-languages/m/text-repeat.md +++ b/query-languages/m/text-repeat.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Repeat" -title: "Text.Repeat | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Repeat" +ms.subservice: m-source --- # Text.Repeat diff --git a/query-languages/m/text-replace.md b/query-languages/m/text-replace.md index c9d00dd76..1a7fbddc1 100644 --- a/query-languages/m/text-replace.md +++ b/query-languages/m/text-replace.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Text.Replace" -title: "Text.Replace | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Replace" +ms.subservice: m-source --- # Text.Replace ## Syntax
-Text.Replace(text as nullable text, old as text, new as text) as nullable text
+Text.Replace(
+    text as nullable text,
+    old as text,
+    new as text
+) as nullable text
 
## About diff --git a/query-languages/m/text-replacerange.md b/query-languages/m/text-replacerange.md index 1d1c0aba8..e82c9423c 100644 --- a/query-languages/m/text-replacerange.md +++ b/query-languages/m/text-replacerange.md @@ -1,21 +1,19 @@ --- description: "Learn more about: Text.ReplaceRange" -title: "Text.ReplaceRange | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.ReplaceRange" +ms.subservice: m-source --- # Text.ReplaceRange ## Syntax
-Text.ReplaceRange(text as nullable text, offset as number, count as number, newText as text) as nullable text
+Text.ReplaceRange(
+    text as nullable text,
+    offset as number,
+    count as number,
+    newText as text
+) as nullable text
 
## About diff --git a/query-languages/m/text-reverse.md b/query-languages/m/text-reverse.md index 187bb5399..742f5eb89 100644 --- a/query-languages/m/text-reverse.md +++ b/query-languages/m/text-reverse.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Reverse" -title: "Text.Reverse| Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Reverse" +ms.subservice: m-source --- # Text.Reverse diff --git a/query-languages/m/text-select.md b/query-languages/m/text-select.md index f59bb7f0b..03042471d 100644 --- a/query-languages/m/text-select.md +++ b/query-languages/m/text-select.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Select" -title: "Text.Select | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Select" +ms.subservice: m-source --- # Text.Select diff --git a/query-languages/m/text-split.md b/query-languages/m/text-split.md index f64a640c0..9bc5cf5b3 100644 --- a/query-languages/m/text-split.md +++ b/query-languages/m/text-split.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Split" -title: "Text.Split | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Split" +ms.subservice: m-source --- # Text.Split @@ -20,7 +13,10 @@ Text.Split(text as text, separator as text) as list ## About -Returns a list of text values resulting from the splitting a text value `text` based on the specified delimiter, `separator`. +Returns a list of text values resulting from the splitting of a text value based on the specified delimiter. + +* `text`: The text value to split. +* `separator`: The delimiter used to split the text. The delimiter can be either a single character or a sequence of characters. If a sequence of characters is used, the text is split only at instances where the exact sequence occurs. ## Example 1 @@ -41,3 +37,23 @@ Text.Split("Name|Address|PhoneNumber", "|") "PhoneNumber" } ``` + +## Example 2 + +Create a list from the text value using a sequence of characters. + +**Usage** + +```powerquery-m +Text.Split("Name, the Customer, the Purchase Date", ", the ") +``` + +**Output** + +```powerquery-m +{ + Name, + Customer, + Purchase Date +} +``` diff --git a/query-languages/m/text-splitany.md b/query-languages/m/text-splitany.md index ee1b23764..75cdc2559 100644 --- a/query-languages/m/text-splitany.md +++ b/query-languages/m/text-splitany.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.SplitAny" -title: "Text.SplitAny | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.SplitAny" +ms.subservice: m-source --- # Text.SplitAny @@ -20,26 +13,30 @@ Text.SplitAny(text as text, separators as text) as list ## About -Returns a list of text values resulting from the splitting a text value `text` based on any character in the specified delimiter, `separators`. +Returns a list of text values resulting from the splitting of a text value based on any character specified in the delimiter. + +* `text`: The text value to split. +* `separator`: The delimiter characters used to split the text. ## Example 1 -Create a list from the text value "Jamie|Campbell|Admin|Adventure Works|www.adventure-works.com". +Create a list from the given text using the specified delimiter characters. **Usage** ```powerquery-m -Text.SplitAny("Jamie|Campbell|Admin|Adventure Works|www.adventure-works.com", "|") +Text.SplitAny("Name|Customer ID|Purchase|Month-Day-Year", "|-") ``` **Output** ```powerquery-m { - "Jamie", - "Campbell", - "Admin", - "Adventure Works", - "www.adventure-works.com" + "Name", + "Customer ID", + "Purchase", + "Month", + "Day", + "Year" } ``` diff --git a/query-languages/m/text-start.md b/query-languages/m/text-start.md index 46d52a30c..656321605 100644 --- a/query-languages/m/text-start.md +++ b/query-languages/m/text-start.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Start" -title: "Text.Start | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Start" +ms.subservice: m-source --- # Text.Start @@ -35,3 +28,41 @@ Text.Start("Hello, World", 5) **Output** `"Hello"` + +## Example 2 + +Use the first four characters of the first name and the first three characters of the last name to create an individual's email address. + +**Usage** + +```powerquery-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 +``` + +**Output** + +```powerquery-m +#table(type table [First Name = text, Last Name = text, Email Address = text], +{ + {"Douglas", "Elis", "DougEli@contoso.com"}, + {"Ana", "Jorayew", "AnaJor@contoso.com"}, + {"Rada", "Mihaylova", "RadaMih@contoso.com"} +}) +``` diff --git a/query-languages/m/text-startswith.md b/query-languages/m/text-startswith.md index 1b76e8b01..3382be9ea 100644 --- a/query-languages/m/text-startswith.md +++ b/query-languages/m/text-startswith.md @@ -1,38 +1,35 @@ --- description: "Learn more about: Text.StartsWith" -title: "Text.StartsWith | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.StartsWith" +ms.subservice: m-source --- # Text.StartsWith ## Syntax
-Text.StartsWith(text as nullable text, substring as text, optional comparer as nullable function) as nullable logical
+Text.StartsWith(
+    text as nullable text,
+    substring as text,
+    optional comparer as nullable function
+) as nullable logical
 
## About Returns true if text value `text` starts with text value `substring`. -* `text`: A `text` value which is to be searched -* `substring`: A `text` value which is the substring to be searched for in `substring` -* `comparer`: *[Optional]* A `Comparer` used for controlling the comparison. For example, `Comparer.OrdinalIgnoreCase` may be used to perform case-insensitive searches +* `text`: A `text` value which is to be searched. +* `substring`: A `text` value which is the substring to be searched for in `text`. +* `comparer`: *[Optional]* A `Comparer` used for controlling the comparison. For example, [Comparer.OrdinalIgnoreCase](comparer-ordinalignorecase.md) may be used to perform case-insensitive searches. `comparer` is a `Comparer` which is used to control the comparison. Comparers can be used to provide case-insensitive or culture and locale-aware comparisons. The following built-in comparers are available in the formula language: -* `Comparer.Ordinal`: Used to perform an exact ordinal comparison -* `Comparer.OrdinalIgnoreCase`: Used to perform an exact ordinal case-insensitive comparison -* `Comparer.FromCulture`: Used to perform a culture-aware comparison +* [Comparer.Ordinal](comparer-ordinal.md): Used to perform an exact ordinal comparison. +* `Comparer.OrdinalIgnoreCase`: Used to perform an exact ordinal case-insensitive comparison. +* [Comparer.FromCulture](comparer-fromculture.md): Used to perform a culture-aware comparison. ## Example 1 @@ -61,3 +58,21 @@ Text.StartsWith("Hello, World", "Hello") **Output** `true` + +## Example 3 + +Ignoring case, check if the text "Hello, World" starts with the text "hello". + +**Usage** + +```powerquery-m +Text.StartsWith("Hello, World", "hello", Comparer.OrdinalIgnoreCase) +``` + +**Output** + +`true` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/text-tobinary.md b/query-languages/m/text-tobinary.md index 3459313e9..3c1fe6561 100644 --- a/query-languages/m/text-tobinary.md +++ b/query-languages/m/text-tobinary.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Text.ToBinary" -title: "Text.ToBinary | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.ToBinary" +ms.subservice: m-source --- # Text.ToBinary ## Syntax
-Text.ToBinary(text as nullable text, optional encoding as nullable number, optional includeByteOrderMark as nullable logical) as nullable binary
+Text.ToBinary(
+    text as nullable text,
+    optional encoding as nullable number,
+    optional includeByteOrderMark as nullable logical
+) as nullable binary
 
- -## About + +## About + Encodes the given text value, `text`, into a binary value using the specified `encoding`. diff --git a/query-languages/m/text-tolist.md b/query-languages/m/text-tolist.md index 0fc83e4f6..d74882c39 100644 --- a/query-languages/m/text-tolist.md +++ b/query-languages/m/text-tolist.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.ToList" -title: "Text.ToList | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.ToList" +ms.subservice: m-source --- # Text.ToList diff --git a/query-languages/m/text-trim.md b/query-languages/m/text-trim.md index e875168b3..e1f6623ac 100644 --- a/query-languages/m/text-trim.md +++ b/query-languages/m/text-trim.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.Trim" -title: "Text.Trim | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Trim" +ms.subservice: m-source --- # Text.Trim @@ -20,7 +13,10 @@ Text.Trim(text as nullable text, optional trim as any) as nullable ## About -Returns the result of removing all leading and trailing whitespace from text value `text`. +Returns the result of removing all leading and trailing characters from the specified `text`. By default, all the leading and trailing whitespace characters are removed. + +* `text`: The text from which the leading and trailing 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 and trailing trim operation stops when a non-trimmed character is encountered. ## Example 1 @@ -35,3 +31,61 @@ Text.Trim(" a b c d ") **Output** `"a b c d"` + +## Example 2 + +Remove leading and trailing zeroes from the text representation of a number. + +**Usage** + +```powerquery-m +Text.Trim("0000056.4200", "0") +``` + +**Output** + +`"56.42"` + +## Example 3 + +Remove the leading and trailing brackets from an HTML tag. + +**Usage** + +```powerquery-m +Text.Trim("
", {"<", ">", "/"}) +``` + +**Output** + +`"div"` + +## Example 4 + +Remove the special characters used around the pending sales status. + +**Usage** + +```powerquery-m +let + Source = #table(type table [Home Sale = text, Sales Date = date, Sales Status = text], + { + {"1620 Ferris Way", #date(2024, 8, 22), "##@@Pending@@##"}, + {"757 1st Ave. S.", #date(2024, 3, 15), "Sold"}, + {"22303 Fillmore", #date(2024, 10, 2), "##@@Pending@@##"} + }), + #"Trimmed Status" = Table.TransformColumns(Source, {"Sales Status", each Text.Trim(_, {"#", "@"})}) +in + #"Trimmed Status" +``` + +**Output** + +```powerquery-m +#table(type table [Home Sale = text, Sales Date = date, Sales Status = text], + { + {"1620 Ferris Way", #date(2024, 8, 22), "Pending"}, + {"757 1st Ave. S.", #date(2024, 3, 15), "Sold"}, + {"22303 Fillmore", #date(2024, 10, 2), "Pending"} + }) +``` diff --git a/query-languages/m/text-trimend.md b/query-languages/m/text-trimend.md index 63ac311ac..a2b66be15 100644 --- a/query-languages/m/text-trimend.md +++ b/query-languages/m/text-trimend.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.TrimEnd" -title: "Text.TrimEnd | Microsoft Docs" -ms.date: 4/22/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.TrimEnd" +ms.subservice: m-source --- # Text.TrimEnd @@ -20,11 +13,14 @@ Text.TrimEnd(text as nullable text, optional trim as any) as nulla ## About -Returns the result of removing all trailing whitespace from text value `text`. +Returns the result of removing all trailing characters from the specified `text`. By default, all the trailing whitespace characters are removed. + +* `text`: The text from which the trailing 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 trailing trim operation stops when a non-trimmed character is encountered. ## Example 1 -Remove trailing whitespace from " a b c d ". +Remove trailing whitespace from " a b c d ". **Usage** @@ -37,3 +33,48 @@ Text.TrimEnd(" a b c d ")
 "     a b c d"
 
+ +## Example 2 + +Remove trailing zeroes from a text representation of a padded floating point number. + +**Usage** + +```powerquery-m +Text.TrimEnd("03.487700000", "0") +``` + +**Output** + +`"03.4877"` + +## Example 3 + +Remove the trailing padding characters from a fixed-width account name. + +**Usage** + +```powerquery-m +let + Source = #table(type table [Name = text, Account Name= text, Interest = number], + { + {"Bob", "US-847263****@", 2.8410}, + {"Leslie", "FR-4648****@**", 3.8392}, + {"Ringo", "DE-2046790@***", 12.6600} + }), + #"Trimmed Account" = Table.TransformColumns(Source, {"Account Name", each Text.TrimEnd(_, {"*", "@"})}) +in + #"Trimmed Account" +``` + +**Output** + +```powerquery-m +#table(type table [Name = text, Account Name = text, Interest = number], + { + {"Bob", "US-847263", 2.841}, + {"Leslie", "FR-4648", 3.8392}, + {"Ringo", "DE-2046790", 12.66} + }), + +``` diff --git a/query-languages/m/text-trimstart.md b/query-languages/m/text-trimstart.md index 46e4dbead..6d6d2fa26 100644 --- a/query-languages/m/text-trimstart.md +++ b/query-languages/m/text-trimstart.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Text.TrimStart" -title: "Text.TrimStart | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.TrimStart" +ms.subservice: m-source --- # Text.TrimStart @@ -20,7 +13,10 @@ Text.TrimStart(text as nullable text, optional trim as any) as nul ## About -Returns the result of removing all leading whitespace from text value `text`. +Returns the result of removing all leadling characters from the specified `text`. By default, all the leading whitespace characters are removed. + +* `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. ## Example 1 @@ -37,3 +33,47 @@ Text.TrimStart(" a b c d ")
 "a b c d    "
 
+ +## Example 2 + +Remove leading zeroes from the text representation of a number. + +**Usage** + +```powerquery-m +Text.TrimStart("0000056.420", "0") +``` + +**Output** + +`"56.420"` + +## Example 3 + +Remove the leading padding characters from a fixed width account name. + +**Usage** + +```powerquery-m +let + Source = #table(type table [Name = text, Account Name= text, Interest = number], + { + {"Bob", "@****847263-US", 2.8410}, + {"Leslie", "@******4648-FR", 3.8392}, + {"Ringo", "@*****24679-DE", 12.6600} + }), + #"Trimmed Account" = Table.TransformColumns(Source, {"Account Name", each Text.TrimStart(_, {"*", "@"})}) +in + #"Trimmed Account" +``` + +**Output** + +```powerquery-m +#table(type table [Name = text, Account Name = text, Interest = number], + { + {"Bob", "847263-US", 2.841}, + {"Leslie", "4648-FR", 3.8392}, + {"Ringo", "2046790-DE", 12.66} + }), +``` diff --git a/query-languages/m/text-upper.md b/query-languages/m/text-upper.md index 0193d5281..1630de19f 100644 --- a/query-languages/m/text-upper.md +++ b/query-languages/m/text-upper.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Text.Upper" -title: "Text.Upper | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Text.Upper" +ms.subservice: m-source --- # Text.Upper @@ -34,3 +28,7 @@ Text.Upper("aBcD") **Output** `"ABCD"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/textencoding-type.md b/query-languages/m/textencoding-type.md index 10e11befb..0f0e317d7 100644 --- a/query-languages/m/textencoding-type.md +++ b/query-languages/m/textencoding-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: TextEncoding.Type" -title: "TextEncoding.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "TextEncoding.Type" +ms.subservice: m-source --- # TextEncoding.Type diff --git a/query-languages/m/time-endofhour.md b/query-languages/m/time-endofhour.md index 381898041..c51bde619 100644 --- a/query-languages/m/time-endofhour.md +++ b/query-languages/m/time-endofhour.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Time.EndOfHour" -title: "Time.EndOfHour | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time.EndOfHour" +ms.subservice: m-source --- # Time.EndOfHour @@ -20,7 +13,7 @@ Time.EndOfHour(dateTime as any) as any ## About -Returns a `time`, `datetime`, or `datetimezone` value representing the end of the hour in `dateTime`, including fractional seconds. Time zone information is preserved. +Returns the end of the hour represented by `dateTime`, including fractional seconds. Time zone information is preserved. * `dateTime`: A `time`, `datetime`, or `datetimezone` value from which the end of the hour is calculated. diff --git a/query-languages/m/time-from.md b/query-languages/m/time-from.md index 8797bb56e..3f19e34ec 100644 --- a/query-languages/m/time-from.md +++ b/query-languages/m/time-from.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Time.From" -title: "Time.From | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time.From" +ms.subservice: m-source --- # Time.From @@ -56,3 +49,9 @@ Time.From(#datetime(1899, 12, 30, 06, 45, 12)) **Output** `#time(06, 45, 12)` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) \ No newline at end of file diff --git a/query-languages/m/time-fromtext.md b/query-languages/m/time-fromtext.md index 6b806dbe7..21e22b6fa 100644 --- a/query-languages/m/time-fromtext.md +++ b/query-languages/m/time-fromtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Time.FromText" -title: "Time.FromText | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time.FromText" +ms.subservice: m-source --- # Time.FromText @@ -22,7 +15,7 @@ Time.FromText(text as nullable text, optional options as any) as n Creates a `time` value from a textual representation, `text`. An optional `record` parameter, `options`, may be provided to specify additional properties. The `record` can contain the following fields: -* `Format`: A `text` value indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providing `null` will result in parsing the time using a best effort. +* `Format`: A `text` value indicating the format to use. For more details, go to [Standard date and time format strings](standard-date-and-time-format-strings.md) and [Custom date and time format strings](custom-date-and-time-format-strings.md). Omitting this field or providing `null` will result in parsing the time using a best effort. * `Culture`: When `Format` is not null, `Culture` controls some format specifiers. For example, in `"en-US"` `"tt"` is `"AM" or "PM"`, while in `"ar-EG"` `"tt"` is `"ص" or "م"`. When `Format` is `null`, `Culture` controls the default format to use. When `Culture` is `null` or omitted, [Culture.Current](culture-current.md) is used. @@ -69,3 +62,9 @@ Time.FromText("10") **Output** `#time(10, 00, 00)` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/time-functions.md b/query-languages/m/time-functions.md index b1e81da00..083e39128 100644 --- a/query-languages/m/time-functions.md +++ b/query-languages/m/time-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Time functions" -title: "Time functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time functions" +ms.date: 11/14/2022 +ms.custom: "nonautomated-date" --- # Time functions @@ -16,13 +10,13 @@ These functions create and manipulate time values. |Name|Description| |------------|---------------| -|[Time.EndOfHour](time-endofhour.md)|Returns a DateTime value from the end of the hour.| +|[Time.EndOfHour](time-endofhour.md)|Returns the end of the hour.| |[Time.From](time-from.md)|Returns a time value from a value.| |[Time.FromText](time-fromtext.md)|Creates a Time from local, universal, and custom Time formats.| |[Time.Hour](time-hour.md)|Returns an hour value from a DateTime value.| |[Time.Minute](time-minute.md)|Returns a minute value from a DateTime value.| |[Time.Second](time-second.md)|Returns a second value from a DateTime value| -|[Time.StartOfHour](time-startofhour.md)|Returns the first value of the hour from a time value.| +|[Time.StartOfHour](time-startofhour.md)|Returns the start of the hour.| |[Time.ToRecord](time-torecord.md)|Returns a record containing parts of a Date value.| |[Time.ToText](time-totext.md)|Returns a text value from a Time value.| |[#time](sharptime.md)|Creates a time value from hour, minute, and second.| diff --git a/query-languages/m/time-hour.md b/query-languages/m/time-hour.md index 0156f3579..460827ad8 100644 --- a/query-languages/m/time-hour.md +++ b/query-languages/m/time-hour.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Time.Hour" -title: "Time.Hour | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time.Hour" +ms.subservice: m-source --- # Time.Hour diff --git a/query-languages/m/time-minute.md b/query-languages/m/time-minute.md index 3561931ca..f5703d7e0 100644 --- a/query-languages/m/time-minute.md +++ b/query-languages/m/time-minute.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Time.Minute" -title: "Time.Minute | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time.Minute" +ms.subservice: m-source --- # Time.Minute diff --git a/query-languages/m/time-second.md b/query-languages/m/time-second.md index 4659f1092..246071240 100644 --- a/query-languages/m/time-second.md +++ b/query-languages/m/time-second.md @@ -1,21 +1,14 @@ --- description: "Learn more about: Time.Second" -title: "Time.Second | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time.Second" +ms.subservice: m-source --- # Time.Second ## Syntax
-Time.Second(dateTime as any) as nullable number`
+Time.Second(dateTime as any) as nullable number
 
## About diff --git a/query-languages/m/time-startofhour.md b/query-languages/m/time-startofhour.md index d7f7b0190..06ebf6239 100644 --- a/query-languages/m/time-startofhour.md +++ b/query-languages/m/time-startofhour.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Time.StartOfHour" -title: "Time.StartOfHour | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time.StartOfHour" +ms.subservice: m-source --- # Time.StartOfHour @@ -20,11 +13,11 @@ Time.StartOfHour(dateTime as any) as any ## About -Returns the first value of the hour given a `time`, `datetime` or `datetimezone` type. +Returns the start of the hour represented by `dateTime`. `dateTime` must be a `time`, `datetime` or `datetimezone` value. ## Example 1 -Find the start of the hour for October 10th, 2011, 8:10:32AM (`#datetime(2011, 10, 10, 8, 10, 32)`). +Find the start of the hour for October 10th, 2011, 8:10:32AM. **Usage** diff --git a/query-languages/m/time-torecord.md b/query-languages/m/time-torecord.md index 74ed30532..93d0c71c9 100644 --- a/query-languages/m/time-torecord.md +++ b/query-languages/m/time-torecord.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Time.ToRecord" -title: "Time.ToRecord | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time.ToRecord" +ms.subservice: m-source --- # Time.ToRecord diff --git a/query-languages/m/time-totext.md b/query-languages/m/time-totext.md index 91d5c9604..ab108033c 100644 --- a/query-languages/m/time-totext.md +++ b/query-languages/m/time-totext.md @@ -1,28 +1,25 @@ --- description: "Learn more about: Time.ToText" -title: "Time.ToText | Microsoft Docs" -ms.date: 6/24/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Time.ToText" +ms.subservice: m-source --- # Time.ToText ## Syntax
-Time.ToText(time as nullable time, optional options as any, optional culture as nullable text) as nullable text
+Time.ToText(
+    time as nullable time,
+    optional options as any,
+    optional culture as nullable text
+) as nullable text
 
## About Returns a textual representation of `time`. An optional `record` parameter, `options`, may be provided to specify additional properties. `culture` is only used for legacy workflows. The `record` can contain the following fields: -* `Format`: A `text` value indicating the format to use. For more details, go to https://go.microsoft.com/fwlink/?linkid=2180104 and https://go.microsoft.com/fwlink/?linkid=2180105. Omitting this field or providing `null` will result in formatting the date using the default defined by `Culture`. +* `Format`: A `text` value indicating the format to use. For more details, go to [Standard date and time format strings](standard-date-and-time-format-strings.md) and [Custom date and time format strings](custom-date-and-time-format-strings.md). Omitting this field or providing `null` will result in formatting the date using the default defined by `Culture`. * `Culture`: When `Format` is not null, `Culture` controls some format specifiers. For example, in `"en-US"` `"tt"` is `"AM" or "PM"`, while in `"ar-EG"` `"tt"` is `"ص" or "م"`. When `Format` is `null`, `Culture` controls the default format to use. When `Culture` is `null` or omitted, [Culture.Current](culture-current.md) is used. @@ -69,3 +66,9 @@ Time.ToText(#time(11, 56, 2), [Format="T", Culture="de-DE"]) **Output** `"11:56:02"` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) +* [Standard date and time format strings](standard-date-and-time-format-strings.md) +* [Custom date and time format strings](custom-date-and-time-format-strings.md) diff --git a/query-languages/m/timezone-current.md b/query-languages/m/timezone-current.md index d502fe018..6396b9ec1 100644 --- a/query-languages/m/timezone-current.md +++ b/query-languages/m/timezone-current.md @@ -1,14 +1,7 @@ --- description: "Learn more about: TimeZone.Current" -title: "TimeZone.Current | Microsoft Docs" -ms.date: 9/13/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "TimeZone.Current" +ms.subservice: m-source --- # TimeZone.Current diff --git a/query-languages/m/toc.yml b/query-languages/m/toc.yml index 70117f79a..2dbd6bbf4 100644 --- a/query-languages/m/toc.yml +++ b/query-languages/m/toc.yml @@ -42,12 +42,32 @@ items: href: evaluation-model.md - name: Operators href: operators.md - - name: Type conversion + - name: Types and type conversion href: type-conversion.md - name: Metadata href: metadata.md - name: Errors href: errors.md + - name: Date and time + items: + - name: Local, fixed, and UTC variants + href: m-local-fixed-utc-variants.md + - name: Durations in Power Query M + href: durations.md + - name: Text formatting + items: + - name: Standard numeric format strings + href: standard-numeric-format-strings.md + - name: Custom numeric format strings + href: custom-numeric-format-strings.md + - name: Standard date and time format strings + href: standard-date-and-time-format-strings.md + - name: Custom date and time format strings + href: custom-date-and-time-format-strings.md + - name: How culture affects text formatting + href: how-culture-affects-text-formatting.md + - name: Capitalization in Power Query M + href: m-working-with-case.md - name: Functions items: - name: Functions overview @@ -122,6 +142,10 @@ items: href: cube-transform.md - name: DB2.Database href: db2-database.md + - name: DeltaLake.Metadata + href: deltalake-metadata.md + - name: DeltaLake.Table + href: deltalake-table.md - name: Essbase.Cubes href: essbase-cubes.md - name: Excel.CurrentWorkbook @@ -252,6 +276,12 @@ items: href: binary-tolist.md - name: Binary.ToText href: binary-totext.md + - name: Binary.View + href: binary-view.md + - name: Binary.ViewError + href: binary-viewerror.md + - name: Binary.ViewFunction + href: binary-viewfunction.md - name: BinaryFormat.7BitEncodedSignedInteger href: binaryformat-7bitencodedsignedinteger.md - name: BinaryFormat.7BitEncodedUnsignedInteger @@ -572,6 +602,8 @@ items: href: error-handling.md - name: Diagnostics.ActivityId href: diagnostics-activityid.md + - name: Diagnostics.CorrelationId + href: diagnostics-correlationid.md - name: Diagnostics.Trace href: diagnostics-trace.md - name: Error.Record @@ -596,6 +628,8 @@ items: href: function-invoke.md - name: Function.InvokeAfter href: function-invokeafter.md + - name: Function.InvokeWithErrorContext + href: function-invokewitherrorcontext.md - name: Function.IsDataSource href: function-isdatasource.md - name: Function.ScalarVector @@ -964,14 +998,10 @@ items: href: table-functions.md - name: ItemExpression.From href: itemexpression-from.md - - name: ItemExpression.Item - href: itemexpression-item.md - name: RowExpression.Column href: rowexpression-column.md - name: RowExpression.From href: rowexpression-from.md - - name: RowExpression.Row - href: rowexpression-row.md - name: Table.AddColumn href: table-addcolumn.md - name: Table.AddFuzzyClusterColumn @@ -1092,6 +1122,8 @@ items: href: table-nestedjoin.md - name: Table.Partition href: table-partition.md + - name: Table.PartionKey + href: table-partitionkey.md - name: Table.PartitionValues href: table-partitionvalues.md - name: Table.Pivot @@ -1132,6 +1164,8 @@ items: href: table-replacekeys.md - name: Table.ReplaceMatchingRows href: table-replacematchingrows.md + - name: Table.ReplacePartitionKey + href: table-replacepartitionkey.md - name: Table.ReplaceRelationshipIdentity href: table-replacerelationshipidentity.md - name: Table.ReplaceRows @@ -1192,6 +1226,8 @@ items: href: table-viewerror.md - name: Table.ViewFunction href: table-viewfunction.md + - name: Table.WithErrorContext + href: table-witherrorcontext.md - name: Tables.GetRelationships href: tables-getrelationships.md - name: '#table' @@ -1352,10 +1388,14 @@ items: href: type-replacefacets.md - name: Type.ReplaceTableKeys href: type-replacetablekeys.md + - name: Type.ReplaceTablePartitionKey + href: type-replacetablepartitionkey.md - name: Type.TableColumn href: type-tablecolumn.md - name: Type.TableKeys href: type-tablekeys.md + - name: Type.TablePartitionKey + href: type-tablepartitionkey.md - name: Type.TableRow href: type-tablerow.md - name: Type.TableSchema @@ -1378,6 +1418,8 @@ items: items: - name: Value functions overview href: value-functions.md + - name: Action.WithErrorContext + href: action-witherrorcontext.md - name: DirectQueryCapabilities.From href: directquerycapabilities-from.md - name: Embedded.Value @@ -1386,6 +1428,10 @@ items: href: excel-shapetable.md - name: Graph.Nodes href: graph-nodes.md + - name: Module.Versions + href: module-versions.md + - name: Progress.DataSourceProgress + href: progress-datasourceprogress.md - name: SqlExpression.SchemaFrom href: sqlexpression-schemafrom.md - name: SqlExpression.ToExpression @@ -1438,8 +1484,14 @@ items: href: value-versionidentity.md - name: Value.Versions href: value-versions.md + - name: Value.ViewError + href: value-viewerror.md + - name: Value.ViewFunction + href: value-viewfunction.md - name: Variable.Value href: variable-value.md + - name: Variable.ValueOrDefault + href: variable-valueordefault.md - name: Enumerations items: - name: Enumerations @@ -1508,6 +1560,8 @@ items: items: - name: Constants href: constants.md + - name: ItemExpression.Item + href: itemexpression-item.md - name: Number.E href: number-e.md - name: Number.Epsilon @@ -1520,6 +1574,8 @@ items: href: number-pi.md - name: Number.PositiveInfinity href: number-positiveinfinity.md + - name: RowExpression.Row + href: rowexpression-row.md - name: Dynamic values items: - name: Dynamic values diff --git a/query-languages/m/tracelevel-type.md b/query-languages/m/tracelevel-type.md index e0a96cfd0..00098be04 100644 --- a/query-languages/m/tracelevel-type.md +++ b/query-languages/m/tracelevel-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: TraceLevel.Type" -title: "TraceLevel.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "TraceLevel.Type" +ms.subservice: m-source --- # TraceLevel.Type diff --git a/query-languages/m/type-addtablekey.md b/query-languages/m/type-addtablekey.md index d86003172..74f3f0888 100644 --- a/query-languages/m/type-addtablekey.md +++ b/query-languages/m/type-addtablekey.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Type.AddTableKey" -title: "Type.AddTableKey | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.AddTableKey" +ms.subservice: m-source --- # Type.AddTableKey ## Syntax
-Type.AddTableKey(table as type, columns as list, isPrimary as logical) as type
+Type.AddTableKey(
+    table as type,
+    columns as list,
+    isPrimary as logical
+) as type
 
- -## About + +## About + Adds a key to the given table type. diff --git a/query-languages/m/type-closedrecord.md b/query-languages/m/type-closedrecord.md index 52e880a33..d0db669ed 100644 --- a/query-languages/m/type-closedrecord.md +++ b/query-languages/m/type-closedrecord.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.ClosedRecord" -title: "Type.ClosedRecord | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.ClosedRecord" +ms.subservice: m-source --- # Type.ClosedRecord @@ -35,3 +28,7 @@ Type.ClosedRecord(type [A = number, ...]) **Output** `type [A = number]` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/type-conversion.md b/query-languages/m/type-conversion.md index 00599c655..3b1c67af8 100644 --- a/query-languages/m/type-conversion.md +++ b/query-languages/m/type-conversion.md @@ -1,39 +1,125 @@ --- -description: "Learn more about: Type conversion" -title: "Type conversion | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery +description: "Learn more about: Types and type conversion" +title: "Types and type conversion" +ms.topic: conceptual +ms.date: 12/20/2024 +ms.custom: "nonautomated-date" +ms.subservice: m-background +--- -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo +# Types and type conversion ---- -# Type conversion -The Power Query M formula language has formulas to convert between types. The following is a summary of conversion formulas in M. +Power Query M uses types to classify values to have a more structured data set. This article describes the most commonly-used M types and how to convert one type to another type. + +## Commonly-used types + +Data types refers to any type that's used to clarify the structure of specific data. The most commonly used data types are primitive types. These types include: + +* `type any`, which classifies any value. +* `type null`, which classifies the null value. +* `type logical`, which classifies the values true and false. +* `type number`, which classifies number values. +* `type time`, which classifies time values. +* `type date`, which classifies date values. +* `type datetime`, which classifies datetime values. +* `type datetimezone`, which classifies datetimezone values. +* `type duration`, which classifies duration values. +* `type text`, which classifies text values. +* `type binary`, which classifies binary values. +* `type type`, which classifies type values. +* `type list`, which classifies list values. +* `type record`, which classifies record values. +* `type table`, which classifies table values. +* `type function`, which classifies function values. +* `type anynonnull`, which classifies all values excluding null. +* `type none`, which classifies no values. + +For more information about these types, go to [Types](m-spec-types.md). + +In addition to these common data types, there is also a set of data types using the format `*.Type`. The most commonly used data types of this format are: + +* `Byte.Type`, which classifies an 8-bit number value. +* `Int8.Type`, which classifies an 8-bit number value. +* `Int16.Type`, which classifies a 16-bit number value. +* `Int32.Type`, which classifies a 32-bit number value. +* `Int64.Type`, which classifies a 64-bit number value. +* `Single.Type`, which classifies a 9-digit floating number value. +* `Double.Type`, which classifies a 17-digit floating number value. +* `Decimal.Type`, which classifies a 15-digit floating number value. +* `Currency.Type`, which classifies a 19-digit number value with four digits to the right of the "." separator. +* `Percentage.Type`, which classifies a 15-digit number value with a mask to format the value as a percentage. +* `Guid.Type`, which classifies a GUID text value. + +The primitive types can also be written in the `*.Type` format as well. Therefore, you can write `number` as `Number.Type`, `record` as `Record.Type`, and so on. + +When you use any of these types, be aware that, like all M code, these types are case-sensitive. + +The following table contains more information about each of these types. + +|Data type | Description| +|----------|------------| +|`any`|The `any` data type is the status given when a value doesn't have an explicit data type definition. The `any` type is the data type that classifies all values.| +|`binary`|The `binary` data type can be used to represent any other data with a binary format.| +|`type`| A value that classifies other values. For more information, go to [Types](m-spec-types.md). | +|`null`| Represents the absence of a value, or a value of indeterminate or unknown state. | +|`anynonnull`| Represents any type that is nonnullable.| +|`date` | Represents just a date (no time portion).| +|`time`|Represents just time (no date portion).| +|`datetime` |Represents both a date and time value. The time portion of a date is stored as a fraction to whole multiples of 1/300 seconds (3.33 ms). Dates between the years 1900 and 9999 are supported.| +|`datetimezone` |Represents a UTC date and time with a time-zone offset.| +|`duration`| Represents a length of time. This type can be added or subtracted from a `datetime` field with correct results. For more information, go to [Duration](m-spec-values.md#duration).| +|`text`|A Unicode character data string. Can be strings, numbers, or dates represented in a text format. Maximum string length is 268,435,456 Unicode characters (where each Unicode character is two bytes) or 536,870,912 bytes.| +|`logical`|A Boolean value of either `true` or `false`.| +|`list`| A value which produces a sequence of values when enumerated. For more information, go to [List types](m-spec-types.md#list-types) and [List values](m-spec-values.md#list).| +|`record`| An ordered sequence of fields. Each field contains a field name and field value. For more information, go to [Record types](m-spec-types.md#record-types) and [Record values](m-spec-values.md#record).| +|`table`| An ordered sequence of rows divided into columns. For more information, go to [Table types](m-spec-types.md#table-types) and [Table values](m-spec-values.md#table).| +|`function`| A value that maps a set of arguments to a single value. For more information, go to [Functions](m-spec-functions.md) and [Function types](m-spec-types.md#function-types).| +|`number`| Represents any number used for numeric and arithmetic operations. For more information, go to [Number](m-spec-values.md#number).| +|`Decimal.Type`|Represents a 64-bit (eight-byte) floating-point number. It's the most common number type, and corresponds to numbers as you usually think of them. Although designed to handle numbers with fractional values, it also handles whole numbers. The `Decimal.Type` can handle negative values from –1.79E +308 through –2.23E –308, 0, and positive values from 2.23E –308 through 1.79E + 308. For example, numbers like 34, 34.01, and 34.000367063 are valid decimal numbers. The largest precision that can be represented in a `Decimal.Type` is 15 digits long. The decimal separator can occur anywhere in the number. The `Decimal.Type` corresponds to how Excel stores its numbers. Note that a binary floating-point number can't represent all numbers within its supported range with 100% accuracy. Thus, minor differences in precision might occur when representing certain decimal numbers.| +| `Currency.Type` | This data type has a fixed location for the decimal separator. The decimal separator always has four digits to its right and allows for 19 digits of significance. The largest value it can represent is 922,337,203,685,477.5807 (positive or negative). Unlike `Decimal.Type`, the `Currency.Type` is always precise and is thus useful in cases where the imprecision of floating-point notation might introduce errors.| +|`Percentage.Type` | Fundamentally the same as a `Decimal.Type`, but it has a mask to format the values as a percentage value.| +|`Int8.Type`| Represents an 8-bit (one-byte) signed integer value. Because it's an integer, it has no digits to the right of the decimal place. It allows for 3 digits; a positive or negative whole number between –128 and 127. As with the `Currency.Type`, the `Int8.Type` can be useful in cases where you need to control rounding.| +|`Int16.Type`| Represents a 16-bit (two-byte) signed integer value. Because it's an integer, it has no digits to the right of the decimal place. It allows for 6 digits; a positive or negative whole number between –32,768 (–2^15) and 32,767 (2^15-1). As with the `Currency.Type`, the `Int16.Type` can be useful in cases where you need to control rounding.| +|`Int32.Type`| Represents a 32-bit (four-byte) signed integer value. Because it's an integer, it has no digits to the right of the decimal place. It allows for 10 digits; a positive or negative whole number between –2,147,483,648 (–2^31) and 2,147,483,647 (2^31–1). As with the `Currency.Type`, the `Int32.Type` can be useful in cases where you need to control rounding.| +|`Int64.Type` | Represents a 64-bit (eight-byte) signed integer value. Because it's an integer, it has no digits to the right of the decimal place. It allows for 19 digits; a positive or negative whole number between –9,223,372,036,854,775,808 (–2^63) and 9,223,372,036,854,775,807 (2^63–1). It can represent the largest possible precision of the various numeric data types. As with the `Currency.Type`, the `Int64.Type` can be useful in cases where you need to control rounding. | +|`Byte.Type`| Represents an 8-bit (one-byte) unsigned integer value. Because it's an unsigned integer, it has no digits to the right of the decimal place and can only contain positive values. It allows for 3 digits; a positive number between 0 and 255.| +|`Single.Type`| Represents a single-precision floating-point number. It has an approximate range of –3.99 X 1038 to 3.99 X 1038 and supports approximately 9 digits of precision. It can also represent positive and negative infinity, and NaN (Not a Number).| +|`Double.Type`| Represents a double-precision floating-point number. It has an approximate range of –1.7976931348623158 X 10307 to 1.7976931348623158 X 10307 and supports approximately 17 digits of precision. It can also represent positive and negative infinity, and NaN (Not a Number).| +|`Guid.Type`| Represents a 128-bit text value consisting of 32 hexadecimal values using the form factor of \<8 hex values>-\<4 hex values>-\<4 hex values>-\<4 hex values>-\<12 hex values>, which make up the GUID value.| +|`none`|The data type that classifies no values. | + +The only other commonly used `*.Type` values are enumerations. For more information, go to [Enumerations](enumerations.md). + +## Type conversion + +The Power Query M formula language has formulas to convert between types. The following is a summary of conversion formulas in M. -## Number +### Number |Type conversion|Description| |-------------------|---------------| |Number.FromText(text as text) as number|Returns a number value from a text value.| |Number.ToText(number as number) as text|Returns a text value from a number value.| |Number.From(value as any) as number|Returns a number value from a value.| +|Byte.From(value as any) as number|Returns an 8-bit integer number value from the given value.| +|Int8.From(value as any) as number|Returns an 8-bit integer number value from the given value.| +|Int16.From(value as any) as number|Returns a 16-bit integer number value from the given value.| |Int32.From(value as any) as number|Returns a 32-bit integer number value from the given value.| |Int64.From(value as any) as number|Returns a 64-bit integer number value from the given value.| |Single.From(value as any) as number|Returns a Single number value from the given value.| |Double.From(value as any) as number|Returns a Double number value from the given value.| |Decimal.From(value as any) as number|Returns a Decimal number value from the given value.| |Currency.From(value as any) as number|Returns a Currency number value from the given value.| +|Percentage.From(value as any) as number|Returns a Percentage number value from the given value.| -## Text +### Text |Type conversion|Description| |-------------------|---------------| |Text.From(value as any) as text|Returns the text representation of a number, date, time, datetime, datetimezone, logical, duration or binary value.| +|Guid.From(value as text) as text|Returns the GUID representation of the specified text.| -## Logical +### Logical |Type conversion|Description| |-------------------|---------------| @@ -41,12 +127,16 @@ The Power Query M formula language has formulas to convert between types. The fo |Logical.ToText(logical as logical) as text|Returns a text value from a logical value.| |Logical.From(value as any) as logical|Returns a logical value from a value.| -## Date, Time, DateTime, and DateTimeZone +### Date, Time, DateTime, and DateTimeZone |Type conversion|Description| |-------------------|---------------| |.FromText(text as text) as date, time, datetime, or datetimezone|Returns a date, time, datetime, or datetimezone value from a set of date formats and culture value.| -|.ToText(date, time, dateTime, or dateTimeZone as
date, time, datetime, or datetimezone) as text|Returns a text value from a date, time, datetime, or datetimezone value.| +|.ToText(date, time, dateTime, or dateTimeZone as date, time, datetime, or datetimezone) as text|Returns a text value from a date, time, datetime, or datetimezone value.| |.From(value as any)|Returns a date, time, datetime, or datetimezone value from a value.| |.ToRecord(date, time, dateTime, or dateTimeZone as date, time, datetime, or datetimezone)|Returns a record containing parts of a date, time, datetime, or datetimezone value.| - + +## Related content + +* [Types](m-spec-types.md) +* [Power Query M type system](power-query-m-type-system.md) diff --git a/query-languages/m/type-facets.md b/query-languages/m/type-facets.md index 93a9b8919..e982e8378 100644 --- a/query-languages/m/type-facets.md +++ b/query-languages/m/type-facets.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.Facets" -title: "Type.Facets | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.Facets" +ms.subservice: m-source --- # Type.Facets @@ -17,7 +10,7 @@ ms.author: dougklo
 Type.Facets(type as type) as record
 
- -## About -Returns a record containing the facets of `type` - + +## About + +Returns a record containing the facets of `type`. diff --git a/query-languages/m/type-forfunction.md b/query-languages/m/type-forfunction.md index c288c07ce..4cd9ff3ee 100644 --- a/query-languages/m/type-forfunction.md +++ b/query-languages/m/type-forfunction.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.ForFunction" -title: "Type.ForFunction | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.ForFunction" +ms.subservice: m-source --- # Type.ForFunction diff --git a/query-languages/m/type-forrecord.md b/query-languages/m/type-forrecord.md index d0a7b7606..fb14bc86c 100644 --- a/query-languages/m/type-forrecord.md +++ b/query-languages/m/type-forrecord.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.ForRecord" -title: "Type.ForRecord | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.ForRecord" +ms.subservice: m-source --- # Type.ForRecord @@ -17,6 +10,32 @@ ms.author: dougklo
 Type.ForRecord(fields as record, open as logical) as type
 
- -## About + +## About + Returns a type that represents records with specific type constraints on fields. + +## Example 1 + +Dynamically generate a table type. + +**Usage** + +```powerquery-m +let + columnNames = {"Name", "Score"}, + columnTypes = {type text, type number}, + rowColumnTypes = List.Transform(columnTypes, (t) => [Type = t, Optional = false]), + rowType = Type.ForRecord(Record.FromList(rowColumnTypes, columnNames), false) +in + #table(type table rowType, {{"Betty", 90.3}, {"Carl", 89.5}}) +``` + +**Output** + +```powerquery-m +#table( + type table [Name = text, Score = number], + {{"Betty", 90.3}, {"Carl", 89.5}} +) +``` diff --git a/query-languages/m/type-functionparameters.md b/query-languages/m/type-functionparameters.md index be7e5b1d2..60cf3698e 100644 --- a/query-languages/m/type-functionparameters.md +++ b/query-languages/m/type-functionparameters.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.FunctionParameters" -title: "Type.FunctionParameters | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.FunctionParameters" +ms.subservice: m-source --- # Type.FunctionParameters diff --git a/query-languages/m/type-functionrequiredparameters.md b/query-languages/m/type-functionrequiredparameters.md index 3cac7a3be..15a050848 100644 --- a/query-languages/m/type-functionrequiredparameters.md +++ b/query-languages/m/type-functionrequiredparameters.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.FunctionRequiredParameters" -title: "Type.FunctionRequiredParameters | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.FunctionRequiredParameters" +ms.subservice: m-source --- # Type.FunctionRequiredParameters diff --git a/query-languages/m/type-functionreturn.md b/query-languages/m/type-functionreturn.md index e26b66367..62706583e 100644 --- a/query-languages/m/type-functionreturn.md +++ b/query-languages/m/type-functionreturn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.FunctionReturn" -title: "Type.FunctionReturn | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.FunctionReturn" +ms.subservice: m-source --- # Type.FunctionReturn diff --git a/query-languages/m/type-functions.md b/query-languages/m/type-functions.md index 95176f42c..1ea6fa24c 100644 --- a/query-languages/m/type-functions.md +++ b/query-languages/m/type-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Type functions" -title: "Type functions | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type functions" +ms.date: 7/16/2025 +ms.custom: "nonautomated-date" --- # Type functions @@ -19,7 +13,7 @@ These functions create and manipulate type values. |[Type.AddTableKey](type-addtablekey.md)|Add a key to a table type.| |[Type.ClosedRecord](type-closedrecord.md)|The given type must be a record type returns a closed version of the given record type (or the same type, if it is already closed)| |[Type.Facets](type-facets.md) | Returns the facets of a type.| -|[Type.ForFunction](type-forfunction.md)|Creates a function type from the given .| +|[Type.ForFunction](type-forfunction.md)|Returns a type that represents functions with specific parameter and return type constraints.| |[Type.ForRecord](type-forrecord.md)|Returns a Record type from a fields record.| |[Type.FunctionParameters](type-functionparameters.md)|Returns a record with field values set to the name of the parameters of a function type, and their values set to their corresponding types.| |[Type.FunctionRequiredParameters](type-functionrequiredparameters.md)|Returns a number indicating the minimum number of parameters required to invoke the a type of function.| @@ -33,8 +27,10 @@ These functions create and manipulate type values. |[Type.RecordFields](type-recordfields.md)|Returns a record describing the fields of a record type with each field of the returned record type having a corresponding name and a value that is a record of the form `[ Type = type, Optional = logical ]`.| |[Type.ReplaceFacets](type-replacefacets.md) | Replaces the facets of a type.| |[Type.ReplaceTableKeys](type-replacetablekeys.md)|Replaces the keys in a table type.| +|[Type.ReplaceTablePartitionKey](type-replacetablepartitionkey.md) | Returns a new table type with the partition key replaced by the specified partition key.| |[Type.TableColumn](type-tablecolumn.md) | Returns the type of a column in a table.| |[Type.TableKeys](type-tablekeys.md)|Returns keys from a table type.| +|[Type.TablePartitionKey](type-tablepartitionkey.md) | Returns the partition key for the given table type if it has one.| |[Type.TableRow](type-tablerow.md)|Returns a row type from a table type.| |[Type.TableSchema](type-tableschema.md) | Returns a table containing a description of the columns (i.e. the schema) of the specified table type.| |[Type.Union](type-union.md) | Returns the union of a list of types.| diff --git a/query-languages/m/type-is.md b/query-languages/m/type-is.md index 347a11151..f6c552479 100644 --- a/query-languages/m/type-is.md +++ b/query-languages/m/type-is.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.Is" -title: "Type.Is | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.Is" +ms.subservice: m-source --- # Type.Is @@ -20,7 +13,7 @@ Type.Is(type1 as type, type2 as type) as logical ## About -Determines if a value of `type1` is always compatible with `type2`. +Determines if a value of `type1` is always compatible with `type2`. Parameter `type2` should be a primitive (or nullable primitive) type value. Otherwise, this function's behavior is undefined and shouldn't be relied on. ## Example 1 @@ -49,3 +42,7 @@ Type.Is(type any, type number) **Output** `false` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/type-isnullable.md b/query-languages/m/type-isnullable.md index 896af3940..ea2309bff 100644 --- a/query-languages/m/type-isnullable.md +++ b/query-languages/m/type-isnullable.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.IsNullable" -title: "Type.IsNullable | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.IsNullable" +ms.subservice: m-source --- # Type.IsNullable @@ -49,3 +42,7 @@ Type.IsNullable(type nullable number) **Output** `true` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/type-isopenrecord.md b/query-languages/m/type-isopenrecord.md index a19692ea2..292e3882c 100644 --- a/query-languages/m/type-isopenrecord.md +++ b/query-languages/m/type-isopenrecord.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.IsOpenRecord" -title: "Type.IsOpenRecord | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.IsOpenRecord" +ms.subservice: m-source --- # Type.IsOpenRecord diff --git a/query-languages/m/type-listitem.md b/query-languages/m/type-listitem.md index 6d1494b52..3545679db 100644 --- a/query-languages/m/type-listitem.md +++ b/query-languages/m/type-listitem.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.ListItem" -title: "Type.ListItem | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.ListItem" +ms.subservice: m-source --- # Type.ListItem @@ -35,3 +28,7 @@ Type.ListItem(type {number}) **Output** `type number` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/type-nonnullable.md b/query-languages/m/type-nonnullable.md index c9f73dbb8..943b07c77 100644 --- a/query-languages/m/type-nonnullable.md +++ b/query-languages/m/type-nonnullable.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.NonNullable" -title: "Type.NonNullable | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.NonNullable" +ms.subservice: m-source --- # Type.NonNullable @@ -35,3 +28,7 @@ Type.NonNullable(type nullable number) **Output** `type number` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/type-openrecord.md b/query-languages/m/type-openrecord.md index 1d9c4b575..951216d3d 100644 --- a/query-languages/m/type-openrecord.md +++ b/query-languages/m/type-openrecord.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.OpenRecord" -title: "Type.OpenRecord | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.OpenRecord" +ms.subservice: m-source --- # Type.OpenRecord @@ -35,3 +28,7 @@ Type.OpenRecord(type [A = number]) **Output** `type [A = number, ...]` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/type-recordfields.md b/query-languages/m/type-recordfields.md index 514c5d60c..f77b20f8e 100644 --- a/query-languages/m/type-recordfields.md +++ b/query-languages/m/type-recordfields.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.RecordFields" -title: "Type.RecordFields | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.RecordFields" +ms.subservice: m-source --- # Type.RecordFields @@ -40,3 +33,7 @@ Type.RecordFields(type [A = number, optional B = any]) B = [Type = type any, Optional = true] ] ``` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/type-replacefacets.md b/query-languages/m/type-replacefacets.md index 786568e6c..5af1e60a1 100644 --- a/query-languages/m/type-replacefacets.md +++ b/query-languages/m/type-replacefacets.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.ReplaceFacets" -title: "Type.ReplaceFacets | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.ReplaceFacets" +ms.subservice: m-source --- # Type.ReplaceFacets @@ -17,7 +10,7 @@ ms.author: dougklo
 Type.ReplaceFacets(type as type, facets as record) as type
 
- -## About + +## About + Replaces the facets of `type` with the facets contained in the record `facets`. - diff --git a/query-languages/m/type-replacetablekeys.md b/query-languages/m/type-replacetablekeys.md index 93c53cd70..dbf463bc3 100644 --- a/query-languages/m/type-replacetablekeys.md +++ b/query-languages/m/type-replacetablekeys.md @@ -1,22 +1,74 @@ --- description: "Learn more about: Type.ReplaceTableKeys" -title: "Type.ReplaceTableKeys | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.ReplaceTableKeys" +ms.subservice: m-source --- # Type.ReplaceTableKeys ## Syntax -
  
+
 Type.ReplaceTableKeys(tableType as type, keys as list) as type
 
- -## About + +## About + Returns a new table type with all keys replaced by the specified list of keys. + +Each key is defined using a record in the following form: + +* `Columns`: a list of the column names that define the key +* `Primary`: `true` if the key is the table's primary key; otherwise, `false` + +The specified list of keys is validated to ensure that no more than one primary key is defined and that all key column names exist on the table type. + +## Example 1 + +Replace the key information on a table type. + +**Usage** + +```powerquery-m +let + BaseType = type table [ID = number, FirstName = text, LastName = text], + KeysAdded = Type.ReplaceTableKeys( + BaseType, + { + [Columns = {"ID"}, Primary = true], + [Columns = {"FirstName", "LastName"}, Primary = false] + } + ), + DetailsOfKeys = Type.TableKeys(KeysAdded) +in + DetailsOfKeys +``` + +**Output** + +```powerquery-m +{ + [Columns = {"ID"}, Primary = true], + [Columns = {"FirstName", "LastName"}, Primary = false] +} +``` + +## Example 2 + +Clear the key information previously defined on a table type. + +**Usage** + +```powerquery-m +let + TypeWithKey = Type.AddTableKey(type table [ID = number, Name = text], {"ID"}, true), + KeyRemoved = Type.ReplaceTableKeys(TypeWithKey, {}), + DetailsOfKeys = Type.TableKeys(KeyRemoved) +in + DetailsOfKeys +``` + +**Output** + +```powerquery-m +{} +``` diff --git a/query-languages/m/type-replacetablepartitionkey.md b/query-languages/m/type-replacetablepartitionkey.md new file mode 100644 index 000000000..4b0014e02 --- /dev/null +++ b/query-languages/m/type-replacetablepartitionkey.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Type.ReplaceTablePartitionKey" +title: "Type.ReplaceTablePartitionKey" +ms.subservice: m-source +--- +# Type.ReplaceTablePartitionKey + +## Syntax + +
+Type.ReplaceTablePartitionKey(tableType as type, partitionKey as nullable list) as type
+
+ +## About + +Returns a new table type with the partition key replaced by the specified partition key. diff --git a/query-languages/m/type-tablecolumn.md b/query-languages/m/type-tablecolumn.md index 1c6e6deec..71c066a4b 100644 --- a/query-languages/m/type-tablecolumn.md +++ b/query-languages/m/type-tablecolumn.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.TableColumn" -title: "Type.TableColumn | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.TableColumn" +ms.subservice: m-source --- # Type.TableColumn @@ -19,4 +12,5 @@ Type.TableColumn(tableType as type, column as text) as type
## About + Returns the type of the column `column` in the table type `tableType`. diff --git a/query-languages/m/type-tablekeys.md b/query-languages/m/type-tablekeys.md index 461bec113..c8dc456ab 100644 --- a/query-languages/m/type-tablekeys.md +++ b/query-languages/m/type-tablekeys.md @@ -1,22 +1,42 @@ --- description: "Learn more about: Type.TableKeys" -title: "Type.TableKeys | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.TableKeys" +ms.subservice: m-source --- # Type.TableKeys ## Syntax
-Type.TableKeys(tableType as type) as list 
+Type.TableKeys(tableType as type) as list
 
- -## About + +## About + Returns the possibly empty list of keys for the given table type. + +Each key is described by a record in the following form: + +* `Columns`: a list of the column names that define the key +* `Primary`: `true` if the key is the table's primary key; otherwise, `false` + +## Example 1 + +Return the key information for a table type. + +**Usage** + +```powerquery-m +let + BaseType = type table [ID = number, Name = text], + AddKey = Type.AddTableKey(BaseType, {"ID"}, true), + DetailsOfKeys = Type.TableKeys(AddKey) +in + DetailsOfKeys +``` + +**Output** + +```powerquery-m +{[Columns = {"ID"}, Primary = true]} +``` diff --git a/query-languages/m/type-tablepartitionkey.md b/query-languages/m/type-tablepartitionkey.md new file mode 100644 index 000000000..0f23d4d36 --- /dev/null +++ b/query-languages/m/type-tablepartitionkey.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Type.TablePartitionKey" +title: "Type.TablePartitionKey" +ms.subservice: m-source +--- +# Type.TablePartitionKey + +## Syntax + +
+Type.TablePartitionKey(tableType as type) as nullable list
+
+ +## About + +Returns the partition key for the given table type if it has one. diff --git a/query-languages/m/type-tablerow.md b/query-languages/m/type-tablerow.md index f5a7838b2..21e7f21ad 100644 --- a/query-languages/m/type-tablerow.md +++ b/query-languages/m/type-tablerow.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.TableRow" -title: "Type.TableRow | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.TableRow" +ms.subservice: m-source --- # Type.TableRow @@ -38,3 +31,7 @@ in **Output** `[Column1 = [Type = type any, Optional = false]]` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/type-tableschema.md b/query-languages/m/type-tableschema.md index b81a673dc..c9228cfdf 100644 --- a/query-languages/m/type-tableschema.md +++ b/query-languages/m/type-tableschema.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.TableSchema" -title: "Type.TableSchema | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.TableSchema" +ms.subservice: m-source --- # Type.TableSchema @@ -23,3 +16,7 @@ Type.TableSchema(tableType as type) as table Returns a table describing the columns of `tableType`. Refer to the documentation for [Table.Schema](/powerquery-m/table-schema) for a description of the resulting table. + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/type-union.md b/query-languages/m/type-union.md index 331963c50..a83c2709e 100644 --- a/query-languages/m/type-union.md +++ b/query-languages/m/type-union.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Type.Union" -title: "Type.Union | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Type.Union" +ms.subservice: m-source --- # Type.Union @@ -19,5 +12,5 @@ Type.Union(types as list) as type ## About -Returns the union of the types in `types`. +Returns the union of the types in `types`. diff --git a/query-languages/m/understanding-power-query-m-functions.md b/query-languages/m/understanding-power-query-m-functions.md index c1d58e3b2..392e048ff 100644 --- a/query-languages/m/understanding-power-query-m-functions.md +++ b/query-languages/m/understanding-power-query-m-functions.md @@ -1,32 +1,31 @@ --- description: "Learn more about: Understanding Power Query M functions" -title: "Understanding Power Query M functions | Microsoft Docs" -ms.date: 4/16/2018 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Understanding Power Query M functions" +ms.topic: conceptual +ms.date: 2/14/2025 +ms.custom: "nonautomated-date" +ms.subservice: m-background --- + # Understanding Power Query M functions -In the Power Query M formula language, a **function** is a mapping from a set of input values to a single output value. A function is written by first naming the function parameters, and then providing an expression to compute the result of the function. The body of the function follows the goes-to (=>) symbol. Optionally, type information can be included on parameters and the function return value. A function is defined and invoked in the body of a **let** statement. Parameters and/or return value can be implicit or explicit. Implicit parameters and/or return value are of type **any**. Type **any** is similar to an object type in other languages. All types in M derive from type **any**. - -A **function** is a value just like a number or a text value, and can be included in-line just like any other expression. The following example shows a function which is the value of an Add variable which is then invoked, or executed, from several other variables. When a function is invoked, a set of values are specified which are logically substituted for the required set of input values within the function body expression. - -**Example – Explicit parameters and return value** - -```powerquery-m + +In the Power Query M formula language, a *function* is a mapping from a set of input values to a single output value. A function is written by first naming the function parameters, and then providing an expression to compute the result of the function. The body of the function follows the goes-to (=>) symbol. Optionally, type information can be included on parameters and the function return value. A function is defined and invoked in the body of a **let** statement. Parameters and/or return value can be implicit or explicit. Implicit parameters and/or return value are of type **any**. Type **any** is similar to an object type in other languages. All types in M derive from type **any**. + +A function is a value just like a number or a text value, and can be included in-line just like any other expression. The following example shows a function that is the value of an **Add** variable, which is then invoked, or executed, from several other variables. When a function is invoked, a set of values are specified that logically substitute for the required set of input values within the function body expression. + +**Example - Explicit parameters and return value** + +```powerquery-m let AddOne = (x as number) as number => x + 1, //additional expression steps CalcAddOne = AddOne(5) in CalcAddOne -``` -**Example – Implicit parameters and return value** - +``` + +**Example - Implicit parameters and return value** + ```powerquery-m let Add = (x, y) => x + y, @@ -37,9 +36,10 @@ let ] in AddResults -``` -**Find the first element of a list greater than 5, or null otherwise** - +``` + +**Find the first element of a list greater than 5, or null otherwise** + ```powerquery-m let FirstGreaterThan5 = (list) => @@ -55,24 +55,26 @@ let ] in Results -``` +``` + Functions can be used recursively. In order to recursively reference the function, prefix the identifier with @. - + ```powerquery-m let fact = (num) => if num = 0 then 1 else num * @fact (num-1) in fact(5) // equals 120 -``` -**Each keyword** - -The **each** keyword is used to easily create simple functions. “each ...” is syntactic sugar for a function signature that takes the _ parameter “(\_) => ...” - -Each is useful when combined with the lookup operator, which is applied by default to _ -For example, each [CustomerID] is the same as each \_[CustomerID], which is the same as (\_) => \_[CustomerID] - -**Example – Using each in table row filter** - +``` + +**Each keyword** + +The **each** keyword is used to easily create simple functions. `each ...` is syntactic sugar for a function signature that takes the `_` parameter `(_) => ...`. + +The **each** keyword is useful when combined with the lookup operator, which is applied by default to `_`. +For example, `each [CustomerID]` is the same as `each _[CustomerID]`, which is the same as `(_) => _[CustomerID]`. + +**Example - Using each in table row filter** + ```powerquery-m Table.SelectRows( Table.FromRecords({ @@ -83,6 +85,6 @@ Table.SelectRows( }), each [CustomerID] = 2 )[Name] - + // equals "Jim" ``` diff --git a/query-languages/m/uri-buildquerystring.md b/query-languages/m/uri-buildquerystring.md index 0d50ab453..553fd953c 100644 --- a/query-languages/m/uri-buildquerystring.md +++ b/query-languages/m/uri-buildquerystring.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Uri.BuildQueryString" -title: "Uri.BuildQueryString | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Uri.BuildQueryString" +ms.subservice: m-source --- # Uri.BuildQueryString diff --git a/query-languages/m/uri-combine.md b/query-languages/m/uri-combine.md index 0ea377d76..d1d77c74f 100644 --- a/query-languages/m/uri-combine.md +++ b/query-languages/m/uri-combine.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Uri.Combine" -title: "Uri.Combine | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Uri.Combine" +ms.subservice: m-source --- # Uri.Combine @@ -17,6 +10,7 @@ ms.author: dougklo
 Uri.Combine(baseUri as text, relativeUri as text) as text
 
- -## About + +## About + Returns an absolute URI that is the combination of the input `baseUri` and `relativeUri`. diff --git a/query-languages/m/uri-escapedatastring.md b/query-languages/m/uri-escapedatastring.md index 60fecc7da..ff98dcbd3 100644 --- a/query-languages/m/uri-escapedatastring.md +++ b/query-languages/m/uri-escapedatastring.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Uri.EscapeDataString" -title: "Uri.EscapeDataString | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Uri.EscapeDataString" +ms.subservice: m-source --- # Uri.EscapeDataString diff --git a/query-languages/m/uri-functions.md b/query-languages/m/uri-functions.md index 627583029..991244e0a 100644 --- a/query-languages/m/uri-functions.md +++ b/query-languages/m/uri-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Uri functions" -title: "Uri functions | Microsoft Docs" +title: "Uri functions" ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +ms.custom: "nonautomated-date" --- # Uri functions diff --git a/query-languages/m/uri-parts.md b/query-languages/m/uri-parts.md index 1076c7320..fc5e3a754 100644 --- a/query-languages/m/uri-parts.md +++ b/query-languages/m/uri-parts.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Uri.Parts" -title: "Uri.Parts | Microsoft Docs" -ms.date: 3/11/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Uri.Parts" +ms.subservice: m-source --- # Uri.Parts diff --git a/query-languages/m/value-add.md b/query-languages/m/value-add.md index 1b63d924d..8a6dd8709 100644 --- a/query-languages/m/value-add.md +++ b/query-languages/m/value-add.md @@ -1,24 +1,20 @@ --- description: "Learn more about: Value.Add" -title: "Value.Add | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Add" +ms.subservice: m-source --- # Value.Add - + ## Syntax
-Value.Add(value1 as any, value2 as any, optional precision as nullable number) as any
+Value.Add(
+    value1 as any,
+    value2 as any,
+    optional precision as nullable number
+) as any
 
- -## About - Returns the sum of `value1` and `value2`. An optional `precision` parameter may be specified, by default `Precision.Double` is used. +## About +Returns the sum of `value1` and `value2`. An optional `precision` parameter may be specified, by default `Precision.Double` is used. diff --git a/query-languages/m/value-alternates.md b/query-languages/m/value-alternates.md index b68e6a73b..7dc5dc93b 100644 --- a/query-languages/m/value-alternates.md +++ b/query-languages/m/value-alternates.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.Alternates" -title: "Value.Alternates | Microsoft Docs" -ms.date: 5/12/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Alternates" +ms.subservice: m-source --- # Value.Alternates diff --git a/query-languages/m/value-as.md b/query-languages/m/value-as.md index 047a53823..93c75e0f8 100644 --- a/query-languages/m/value-as.md +++ b/query-languages/m/value-as.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.As" -title: "Value.As | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.As" +ms.subservice: m-source --- # Value.As diff --git a/query-languages/m/value-compare.md b/query-languages/m/value-compare.md index bb1b9bc67..4a76e0d32 100644 --- a/query-languages/m/value-compare.md +++ b/query-languages/m/value-compare.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Value.Compare" -title: "Value.Compare | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Compare" +ms.subservice: m-source --- # Value.Compare ## Syntax
-Value.Compare(value1 as any, value2 as any, optional precision as nullable number) as number 
+Value.Compare(
+    value1 as any,
+    value2 as any,
+    optional precision as nullable number
+) as number
 
- -## About -Returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second one. + +## About + +Returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second. diff --git a/query-languages/m/value-divide.md b/query-languages/m/value-divide.md index bed83070f..23579f868 100644 --- a/query-languages/m/value-divide.md +++ b/query-languages/m/value-divide.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Value.Divide" -title: "Value.Divide | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Divide" +ms.subservice: m-source --- # Value.Divide ## Syntax
-Value.Divide(value1 as any, value2 as any, optional precision as nullable number) as any
-
+Value.Divide( + value1 as any, + value2 as any, + optional precision as nullable number +) as any + -## About +## About + Returns the result of dividing `value1` by `value2`. An optional `precision` parameter may be specified, by default `Precision.Double` is used. diff --git a/query-languages/m/value-equals.md b/query-languages/m/value-equals.md index 5d945c874..eebb9dc0a 100644 --- a/query-languages/m/value-equals.md +++ b/query-languages/m/value-equals.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Value.Equals" -title: "Value.Equals | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Equals" +ms.subservice: m-source --- # Value.Equals ## Syntax
-Value.Equals(value1 as any, value2 as any, optional precision as nullable number) as logical
+Value.Equals(
+    value1 as any,
+    value2 as any,
+    optional precision as nullable number
+) as logical
 
- -## About + +## About + Returns true if value `value1` is equal to value `value2`, false otherwise. diff --git a/query-languages/m/value-expression.md b/query-languages/m/value-expression.md index 4b057eec3..4ffd63147 100644 --- a/query-languages/m/value-expression.md +++ b/query-languages/m/value-expression.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.Expression" -title: "Value.Expression | Microsoft Docs" -ms.date: 3/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Expression" +ms.subservice: m-source --- # Value.Expression diff --git a/query-languages/m/value-firewall.md b/query-languages/m/value-firewall.md index 3bfe3c9c6..dccdb3fb6 100644 --- a/query-languages/m/value-firewall.md +++ b/query-languages/m/value-firewall.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.Firewall" -title: "Value.Firewall | Microsoft Docs" -ms.date: 10/18/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Firewall" +ms.subservice: m-source --- # Value.Firewall diff --git a/query-languages/m/value-fromtext.md b/query-languages/m/value-fromtext.md index 8788efc97..cd10da7ea 100644 --- a/query-languages/m/value-fromtext.md +++ b/query-languages/m/value-fromtext.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.FromText" -title: "Value.FromText | Microsoft Docs" -ms.date: 4/1/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.FromText" +ms.subservice: m-source --- # Value.FromText @@ -16,7 +9,74 @@ ms.author: dougklo
 Value.FromText(text as any, optional culture as nullable text) as any
-
- -## About -Decodes a value from a textual representation, `text`, 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. An optional `culture` may also be provided (for example, "en-US"). + + +## About + +Decodes a value from a textual representation and interprets it as a value with an appropriate type. + +* `text`: The text to interpret. +* `culture` (Optional) A specific culture used to interpret the text (for example, "en-US"). + +This function takes a text value and returns a value of type `number`, `logical`, `null`, `datetime`, `duration`, or `text`. An empty text value is interpreted as a `null` value. + +## Example 1 + +Convert text representing a number to its corresponding number value. + +**Usage** + +```powerquery-m +Value.FromText("12345.6789") +``` + +**Output** + +`12345.6789` + +## Example 2 + +Convert text representing a percentage to its corresponding number value. + +**Usage** + +```powerquery-m +Value.FromText("25.4%") +``` + +**Output** + +`0.254` + + +## Example 3 + +Convert text representing a French Euro value to its corresponding number value. + +**Usage** + +```powerquery-m +Value.FromText("€1,190", "fr-FR") +``` + +**Output** + +`1.19` + +## Example 4 + +Convert text representing a German date and time to its corresponding date and time value. + +**Usage** + +```powerquery-m +Value.FromText("24 Dez 2024 14:33:20", "de-DE") +``` + +**Output** + +`#datetime(2024, 12, 24, 14, 33, 20)` + +## Related content + +* [How culture affects text formatting](how-culture-affects-text-formatting.md) diff --git a/query-languages/m/value-functions.md b/query-languages/m/value-functions.md index 73732d550..fae13f9d9 100644 --- a/query-languages/m/value-functions.md +++ b/query-languages/m/value-functions.md @@ -1,14 +1,8 @@ --- description: "Learn more about: Value functions" -title: "Value functions | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value functions" +ms.date: 9/3/2025 +ms.custom: "nonautomated-date" --- # Value functions @@ -17,14 +11,14 @@ These functions evaluate and perform operations on values. |Name|Description| |------------|---------------| |[Value.Alternates](value-alternates.md)|Expresses alternate query plans.| -|[Value.Compare](value-compare.md)|Returns 1, 0, or -1 based on value1 being greater than, equal to, or less than the value2. An optional comparer function can be provided.| +|[Value.Compare](value-compare.md)|Returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second.| |[Value.Equals](value-equals.md)|Returns whether two values are equal.| |[Value.Expression](value-expression.md)|Returns an abstract syntax tree (AST) that represents the value's expression.| |[Value.VersionIdentity](value-versionidentity.md)|Returns the version identity of a value.| |[Value.Versions](value-versions.md)|Returns a navigation table containing the available versions of a value.| |[Value.NativeQuery](value-nativequery.md) | Evaluates a query against a target.| -|[Value.NullableEquals](value-nullableequals.md)|Returns a logical value or null based on two values .| -|[Value.Optimize](value-optimize.md)|If value represents a query that can be optimized, returns the optimized query. Otherwise returns value. +|[Value.NullableEquals](value-nullableequals.md)|Returns a logical value or null based on two values.| +|[Value.Optimize](value-optimize.md)|If value represents a query that can be optimized, returns the optimized query. Otherwise returns value.| |[Value.Type](value-type.md) | Returns the type of the given value.| ## Arithmetic operations @@ -44,15 +38,21 @@ These functions evaluate and perform operations on values. |[Value.Is](value-is.md)|Determines whether a value is compatible with the specified type.| |[Value.ReplaceType](value-replacetype.md)|Replaces the value's type.| -|Implementation | Description -|-------------- | ----------- +|Implementation | Description | +|-------------- | ----------- | +|[Action.WithErrorContext](action-witherrorcontext.md) | This function is intended for internal use only.| |[DirectQueryCapabilities.From](directquerycapabilities-from.md) | This function is intended for internal use only.| |[Embedded.Value](embedded-value.md) | Accesses a value by name in an embedded mashup.| |[Excel.ShapeTable](excel-shapetable.md) | This function is intended for internal use only.| -|[Value.Firewall](value-firewall.md) | This function is intended for internal use only.| -|[Variable.Value](variable-value.md) | This function is intended for internal use only.| +|[Module.Versions](module-versions.md) | Returns a record of module versions for the current module and its dependencies.| +|[Progress.DataSourceProgress](progress-datasourceprogress.md) | This function is intended for internal use only. | |[SqlExpression.SchemaFrom](sqlexpression-schemafrom.md) | This function is intended for internal use only.| |[SqlExpression.ToExpression](sqlexpression-toexpression.md) | This function is intended for internal use only.| +|[Value.Firewall](value-firewall.md) | This function is intended for internal use only.| +|[Value.ViewError](value-viewerror.md) | This function is intended for internal use only.| +|[Value.ViewFunction](value-viewfunction.md) | This function is intended for internal use only.| +|[Variable.Value](variable-value.md) | Returns the value of the specified variable.| +|[Variable.ValueOrDefault](variable-valueordefault.md) | Returns the value of the specified variable or the default value if the variable is not defined.| ## Metadata diff --git a/query-languages/m/value-is.md b/query-languages/m/value-is.md index 9713f7edf..c9e523dc9 100644 --- a/query-languages/m/value-is.md +++ b/query-languages/m/value-is.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.Is" -title: "Value.Is | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Is" +ms.subservice: m-source --- # Value.Is diff --git a/query-languages/m/value-lineage.md b/query-languages/m/value-lineage.md index 9d8b78caf..61724a1ac 100644 --- a/query-languages/m/value-lineage.md +++ b/query-languages/m/value-lineage.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Value.Lineage" -title: "Value.Lineage | Microsoft Docs" -ms.date: 9/22/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Lineage" +ms.subservice: m-source --- # Value.Lineage ## Syntax -
 
+
 Value.Lineage(value as any) as any
 
## About + This function is intended for internal use only. diff --git a/query-languages/m/value-metadata.md b/query-languages/m/value-metadata.md index 6f8363173..6d40e19d1 100644 --- a/query-languages/m/value-metadata.md +++ b/query-languages/m/value-metadata.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Value.Metadata" -title: "Value.Metadata | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Metadata" +ms.subservice: m-source --- # Value.Metadata ## Syntax
-Value.Metadata(value as any) as any 
+Value.Metadata(value as any) as any
 
- -## About + +## About + Returns a record containing the input's metadata. diff --git a/query-languages/m/value-multiply.md b/query-languages/m/value-multiply.md index 6ad49d14f..7c2819246 100644 --- a/query-languages/m/value-multiply.md +++ b/query-languages/m/value-multiply.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Value.Multiply" -title: "Value.Multiply | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Multiply" +ms.subservice: m-source --- # Value.Multiply ## Syntax
-Value.Multiply(value1 as any, value2 as any, optional precision as nullable number) as any
+Value.Multiply(
+    value1 as any,
+    value2 as any,
+    optional precision as nullable number
+) as any
 
- -## About -Returns the product of multiplying `value1` by `value2`. An optional `precision` parameter may be specified, by default `Precision.Double` is used. + +## About + +Returns the product of multiplying `value1` by `value2`. An optional `precision` parameter may be specified, by default [Precision.Double](precision-type.md) is used. diff --git a/query-languages/m/value-nativequery.md b/query-languages/m/value-nativequery.md index 9daaf108a..5217f1866 100644 --- a/query-languages/m/value-nativequery.md +++ b/query-languages/m/value-nativequery.md @@ -1,20 +1,18 @@ --- description: "Learn more about: Value.NativeQuery" -title: "Value.NativeQuery | Microsoft Docs" -ms.date: 11/17/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.NativeQuery" +ms.subservice: m-source --- # Value.NativeQuery ## Syntax -
Value.NativeQuery(target as any, query as text, optional parameters as any, optional options as nullable record) as any
+
Value.NativeQuery(
+    target as any,
+    query as text,
+    optional parameters as any,
+    optional options as nullable record
+) as any
 
## About diff --git a/query-languages/m/value-nullableequals.md b/query-languages/m/value-nullableequals.md index d0a134357..78d94c871 100644 --- a/query-languages/m/value-nullableequals.md +++ b/query-languages/m/value-nullableequals.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Value.NullableEquals" -title: "Value.NullableEquals | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.NullableEquals" +ms.subservice: m-source --- # Value.NullableEquals ## Syntax -
  
-Value.NullableEquals(value1 as any, value2 as any, optional precision as nullable number) as nullable logical
+
+Value.NullableEquals(
+    value1 as any,
+    value2 as any,
+    optional precision as nullable number
+) as nullable logical
 
- -## About -Returns null if either argument `value1`, `value2` is null, otherwise equivalent to Value.Equals. + +## About + +Returns null if either argument `value1`, `value2` is null, otherwise equivalent to [Value.Equals](value-equals.md). diff --git a/query-languages/m/value-optimize.md b/query-languages/m/value-optimize.md index 8e6b3ac6c..72d0874e0 100644 --- a/query-languages/m/value-optimize.md +++ b/query-languages/m/value-optimize.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.Optimize" -title: "Value.Optimize | Microsoft Docs" -ms.date: 06/16/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Optimize" +ms.subservice: m-source --- # Value.Optimize @@ -17,6 +10,7 @@ ms.author: dougklo
 Value.Optimize(value as any) as any
 
- -## About + +## About + When used within Value.Expression, if `value` represents a query that can be optimized, this function indicates that the optimized expression should be returned. Otherwise, `value` will be passed through with no effect. diff --git a/query-languages/m/value-removemetadata.md b/query-languages/m/value-removemetadata.md index 83868489c..ecffdb5af 100644 --- a/query-languages/m/value-removemetadata.md +++ b/query-languages/m/value-removemetadata.md @@ -1,22 +1,48 @@ --- description: "Learn more about: Value.RemoveMetadata" -title: "Value.RemoveMetadata | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.RemoveMetadata" +ms.subservice: m-source --- # Value.RemoveMetadata ## Syntax
-Value.RemoveMetadata(value as any, optional metaValue as any) as any 
-
- -## About +Value.RemoveMetadata(value as any, optional metaValue as any) as any +
+ +## About + Strips the input of metadata. + +## Example 1 + +Remove all metadata from a text value. + +**Usage** + +```powerquery-m +Value.Metadata( + Value.RemoveMetadata("abc" meta [a = 1, b = 2]) +) +``` + +**Output** + +`[]` + +## Example 2 + +Remove only one field of metadata from a text value. + +**Usage** + +```powerquery-m +Value.Metadata( + Value.RemoveMetadata("abc" meta [a = 1, b = 2], {"a"}) +) +``` + +**Output** + +`[b = 2]` diff --git a/query-languages/m/value-replacemetadata.md b/query-languages/m/value-replacemetadata.md index e99e3ba7a..78069b786 100644 --- a/query-languages/m/value-replacemetadata.md +++ b/query-languages/m/value-replacemetadata.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.ReplaceMetadata" -title: "Value.ReplaceMetadata | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.ReplaceMetadata" +ms.subservice: m-source --- # Value.ReplaceMetadata @@ -17,6 +10,7 @@ ms.author: dougklo
 Value.ReplaceMetadata(value as any, metaValue as any) as any
 
- -## About + +## About + Replaces the input's metadata information. diff --git a/query-languages/m/value-replacetype.md b/query-languages/m/value-replacetype.md index c49eb3c8b..3579605b3 100644 --- a/query-languages/m/value-replacetype.md +++ b/query-languages/m/value-replacetype.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.ReplaceType" -title: "Value.ReplaceType | Microsoft Docs" -ms.date: 4/13/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.ReplaceType" +ms.subservice: m-source --- # Value.ReplaceType diff --git a/query-languages/m/value-subtract.md b/query-languages/m/value-subtract.md index 64ececc09..358bacbec 100644 --- a/query-languages/m/value-subtract.md +++ b/query-languages/m/value-subtract.md @@ -1,22 +1,20 @@ --- description: "Learn more about: Value.Subtract" -title: "Value.Subtract | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Subtract" +ms.subservice: m-source --- # Value.Subtract ## Syntax
-Value.Subtract(value1 as any, value2 as any, optional precision as nullable number) as any
+Value.Subtract(
+    value1 as any,
+    value2 as any,
+    optional precision as nullable number
+) as any
 
- -## About + +## About + Returns the difference of `value1` and `value2`. An optional `precision` parameter may be specified, by default `Precision.Double` is used. diff --git a/query-languages/m/value-traits.md b/query-languages/m/value-traits.md index 1f86acb21..daf58739e 100644 --- a/query-languages/m/value-traits.md +++ b/query-languages/m/value-traits.md @@ -1,22 +1,16 @@ --- description: "Learn more about: Value.Traits" -title: "Value.Traits | Microsoft Docs" -ms.date: 9/22/2020 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Traits" +ms.subservice: m-source --- # Value.Traits ## Syntax -
 
+
 Value.Traits(value as any) as table
 
## About + This function is intended for internal use only. diff --git a/query-languages/m/value-type.md b/query-languages/m/value-type.md index f15cb2d0a..1bdd4eba9 100644 --- a/query-languages/m/value-type.md +++ b/query-languages/m/value-type.md @@ -1,22 +1,64 @@ --- description: "Learn more about: Value.Type" -title: "Value.Type | Microsoft Docs" -ms.date: 8/2/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Type" +ms.subservice: m-source --- # Value.Type - ## Syntax +
 Value.Type(value as any) as type
 
## About + Returns the type of the given value. + +* `value`: The value whose type is returned. + +## Example 1 + +Return the type of the specified number. + +**Usage** + +```powerquery-m +Value.Type(243.448) +``` + +**Output** + +`type number` + +## Example 2 + +Return the type of the specified date. + +**Usage** + +```powerquery-m +Value.Type(#datetime(2010, 12, 31)) +``` + +**Output** + +`type date` + +## Example 3 + +Return the type of the specified record. + +**Usage** + +```powerquery-m +Value.Type([a = 1, b = 2]) +``` + +**Output** + +`type record` + +## Related content + +* [Types and type conversion](type-conversion.md) diff --git a/query-languages/m/value-versionidentity.md b/query-languages/m/value-versionidentity.md index acfd5dd8c..f88601b26 100644 --- a/query-languages/m/value-versionidentity.md +++ b/query-languages/m/value-versionidentity.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.VersionIdentity" -title: "Value.VersionIdentity | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.VersionIdentity" +ms.subservice: m-source --- # Value.VersionIdentity diff --git a/query-languages/m/value-versions.md b/query-languages/m/value-versions.md index f13842d42..e1566fbb0 100644 --- a/query-languages/m/value-versions.md +++ b/query-languages/m/value-versions.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Value.Versions" -title: "Value.Versions | Microsoft Docs" -ms.date: 5/19/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Value.Versions" +ms.subservice: m-source --- # Value.Versions diff --git a/query-languages/m/value-viewerror.md b/query-languages/m/value-viewerror.md new file mode 100644 index 000000000..c75912a47 --- /dev/null +++ b/query-languages/m/value-viewerror.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Value.ViewError" +title: "Value.ViewError" +ms.subservice: m-source +--- +# Value.ViewError + +## Syntax + +
+Value.ViewError(errorRecord as record) as record
+
+ +## About + +This function is intended for internal use only. diff --git a/query-languages/m/value-viewfunction.md b/query-languages/m/value-viewfunction.md new file mode 100644 index 000000000..7c851f108 --- /dev/null +++ b/query-languages/m/value-viewfunction.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Value.ViewFunction" +title: "Value.ViewFunction" +ms.subservice: m-source +--- +# Value.ViewFunction + +## Syntax + +
+Value.ViewFunction(function as function) as function
+
+ +## About + +This function is intended for internal use only. diff --git a/query-languages/m/variable-value.md b/query-languages/m/variable-value.md index 49136ea63..a0be370ae 100644 --- a/query-languages/m/variable-value.md +++ b/query-languages/m/variable-value.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Variable.Value" -title: "Variable.Value | Microsoft Docs" -ms.date: 10/18/2021 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Variable.Value" +ms.subservice: m-source --- # Variable.Value @@ -20,4 +13,4 @@ Variable.Value(identifier as text) as any ## About -This function is intended for internal use only. +Returns the value of the specified variable `identifier` defined by the current evaluation environment. If the variable is not defined, an error is raised. diff --git a/query-languages/m/variable-valueordefault.md b/query-languages/m/variable-valueordefault.md new file mode 100644 index 000000000..80293b44f --- /dev/null +++ b/query-languages/m/variable-valueordefault.md @@ -0,0 +1,16 @@ +--- +description: "Learn more about: Variable.ValueOrDefault" +title: "Variable.ValueOrDefault" +ms.subservice: m-source +--- +# Variable.ValueOrDefault + +## Syntax + +
+Variable.ValueOrDefault(identifier as text, optional defaultValue as any) as any
+
+ +## About + +Returns the value of the specified variable `identifier` defined by the current evaluation environment. If the variable is not defined, the optional `defaultValue` is returned. diff --git a/query-languages/m/web-browsercontents.md b/query-languages/m/web-browsercontents.md index 25d651261..aa69499ee 100644 --- a/query-languages/m/web-browsercontents.md +++ b/query-languages/m/web-browsercontents.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Web.BrowserContents" -title: "Web.BrowserContents | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Web.BrowserContents" +ms.subservice: m-source --- # Web.BrowserContents @@ -16,11 +10,12 @@ ms.author: dougklo
 Web.BrowserContents(url as text, optional options as nullable record) as text
 
- -## About + +## About Returns the HTML for the specified `url`, as viewed by a web browser. An optional record parameter, `options`, may be provided to specify additional properties. The record can contain the following fields: +* `ApiKeyName`: If the target site has a notion of an API key, this parameter can be used to specify the name (not the value) of the key parameter that must be used in the URL. The actual key value is provided in the credential. * `WaitFor`: Specifies a condition to wait for before downloading the HTML, in addition to waiting for the page to load (which is always done). Can be a record containing Timeout and/or Selector fields. If only a Timeout is specified, the function will wait the amount of time specified before downloading the HTML. If both a Selector and Timeout are specified, and the Timeout elapses before the Selector exists on the page, an error will be thrown. If a Selector is specified with no Timeout, a default Timeout of 30 seconds is applied. ## Example 1 diff --git a/query-languages/m/web-contents.md b/query-languages/m/web-contents.md index e7b734d6f..47a215dd0 100644 --- a/query-languages/m/web-contents.md +++ b/query-languages/m/web-contents.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Web.Contents" -title: "Web.Contents | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Web.Contents" +ms.subservice: m-source --- # Web.Contents @@ -99,3 +92,7 @@ Web.Contents("https://contoso.com/api/customers/get", [ApiKeyName="api_key"]) **Output** `binary` + +## More information + +[Status code handling with Web.Contents in custom connectors](/power-query/handling-status-codes) diff --git a/query-languages/m/web-headers.md b/query-languages/m/web-headers.md index dec0b58e1..4a62b25f3 100644 --- a/query-languages/m/web-headers.md +++ b/query-languages/m/web-headers.md @@ -1,14 +1,7 @@ --- description: "Learn more about: Web.Headers" -title: "Web.Headers | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Web.Headers" +ms.subservice: m-source --- # Web.Headers diff --git a/query-languages/m/web-page.md b/query-languages/m/web-page.md index f540d6b9a..d7abbf56d 100644 --- a/query-languages/m/web-page.md +++ b/query-languages/m/web-page.md @@ -1,13 +1,7 @@ --- description: "Learn more about: Web.Page" -title: "Web.Page | Microsoft Docs" -ms.date: 10/17/2019 -ms.service: powerquery -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Web.Page" +ms.subservice: m-source --- # Web.Page @@ -15,8 +9,8 @@ ms.author: dougklo
 Web.Page(html as any) as table
-
- -## About -Returns the contents of the HTML document broken into its constituent structures, as well as a representation of the full document and its text after removing tags. +
+ +## About +Returns the contents of the HTML document broken into its constituent structures, as well as a representation of the full document and its text after removing tags. diff --git a/query-languages/m/webaction-request.md b/query-languages/m/webaction-request.md index d87ad8373..d926c3e4d 100644 --- a/query-languages/m/webaction-request.md +++ b/query-languages/m/webaction-request.md @@ -1,21 +1,18 @@ --- description: "Learn more about: WebAction.Request" -title: "WebAction.Request | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "WebAction.Request" +ms.subservice: m-source --- # WebAction.Request ## Syntax
-WebAction.Request(method as text, url as text, optional options as nullable record) as action
+WebAction.Request(
+    method as text,
+    url as text,
+    optional options as nullable record
+) as action
 
## About diff --git a/query-languages/m/webmethod-type.md b/query-languages/m/webmethod-type.md index c86cadad6..ba3b458fe 100644 --- a/query-languages/m/webmethod-type.md +++ b/query-languages/m/webmethod-type.md @@ -1,14 +1,7 @@ --- description: "Learn more about: WebMethod.Type" -title: "WebMethod.Type | Microsoft Docs" -ms.date: 5/16/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "WebMethod.Type" +ms.subservice: m-source --- # WebMethod.Type diff --git a/query-languages/m/xml-document.md b/query-languages/m/xml-document.md index 2888ec27a..0373d2efb 100644 --- a/query-languages/m/xml-document.md +++ b/query-languages/m/xml-document.md @@ -1,23 +1,16 @@ --- description: "Learn more about: Xml.Document" -title: "Xml.Document | Microsoft Docs" -ms.date: 7/29/2019 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Xml.Document" +ms.subservice: m-source --- # Xml.Document - ## Syntax
 Xml.Document(contents as any, optional encoding as nullable number) as table
 
- -## About + +## About + Returns the contents of the XML document as a hierarchical table. diff --git a/query-languages/m/xml-tables.md b/query-languages/m/xml-tables.md index c8a7a1209..9c571aac7 100644 --- a/query-languages/m/xml-tables.md +++ b/query-languages/m/xml-tables.md @@ -1,21 +1,18 @@ --- description: "Learn more about: Xml.Tables" -title: "Xml.Tables | Microsoft Docs" -ms.date: 3/14/2022 -ms.service: powerquery - -ms.reviewer: ehvonleh -ms.topic: reference -author: dougklopfenstein -ms.author: dougklo - +title: "Xml.Tables" +ms.subservice: m-source --- # Xml.Tables ## Syntax
-Xml.Tables(contents as any, optional options as nullable record, optional encoding as nullable number) as table
+Xml.Tables(
+    contents as any,
+    optional options as nullable record,
+    optional encoding as nullable number
+) as table
 
## About
Type assertion x as yIs compatible nullable-primitive type or errorIs compatible primitive/nullable primitive type or error
Type conformance x is yTest if compatible nullable-primitive typeTest if type is compatible with primitive type or nullable primitive type
Logical AND