What is the CURRENCY Function in DAX?
The CURRENCY function in DAX is used to format a numeric value as a currency. This function takes two arguments: the value to be formatted and the currency symbol to use. The syntax of the CURRENCY function is as follows:
The value argument can be a column reference, a measure, or a numeric value. The currency_symbol argument is a string that represents the currency symbol to use. For example, to format a value as US dollars, you would use the string "USD".
Using the CURRENCY Function in Power BI
To use the CURRENCY function in Power BI, you first need to create a measure or a calculated column that contains the value you want to format. Once you have the measure or calculated column, you can use the CURRENCY function to format the value as a currency.
For example, suppose you have a sales table with a column named "SalesAmount". To format the sales amount as US dollars, you can create a measure using the following DAX expression:
SalesAmount_formatted = CURRENCY(SalesAmount, “USD”)
This measure will format the sales amount as US dollars and can be used in your reports and visualizations.
The CURRENCY function in DAX provides several formatting options that allow you to customize the appearance of the formatted value. These options are specified using optional arguments in the CURRENCY function.
The following table lists the available formatting options:
| Argument | Description |
| --- | --- |
| DecimalPlaces | Specifies the number of decimal places to display. |
| IncludeThousandsSeparator | Specifies whether to include a thousands separator. |
| NegativeNumberFormat | Specifies how to format negative numbers. |
| ZeroValueFormat | Specifies how to format zero values. |
To use these formatting options, you need to include them as optional arguments in the CURRENCY function. For example, to format a value with two decimal places and include a thousands separator, you can use the following expression:
CURRENCY(SalesAmount, “USD”, 2, TRUE)
This expression will format the SalesAmount column as US dollars with two decimal places and a thousands separator.
The CURRENCY function in Power BI's DAX language provides a powerful tool for formatting numeric values as currencies. By using this function, you can create custom calculations and formulas that are tailored to your needs. With the formatting options available in the CURRENCY function, you can customize the appearance of the formatted value to meet your requirements.