CURRENCY
A value as a fixed decimal number (Currency), rounded to four decimals.
Group: Math. Compatible with DAX.
Syntax
CURRENCY ( <value> )
| Parameter | Type | Description |
|---|---|---|
value | Value | A number, or a text, date or TRUE/FALSE that can be read as one. |
Returns
Currency. The value as a fixed decimal number with four decimals.
Remarks
- Currency is the type Power BI calls Fixed decimal number: whole ten-thousandths, so money adds up without floating-point surprises.
- The fifth decimal decides the fourth, a half going away from zero: 2.71828 becomes 2.7183, 1.00005 becomes 1.0001 and -2.00005 becomes -2.0001.
- Arithmetic keeps the four decimals. A Currency multiplied or divided by a number is a Currency again, rounded to four decimals:
CURRENCY ( 1 ) / 3is 0.3333, and that times 3 is 0.9999. - In
SUMXand the other iterators that rounding happens on every row: three rows of 1 times 0.00007 add up to 0.0003, while their total of 3 times 0.00007 is 0.0002. Multiply the total, orCONVERTtoDOUBLEfirst, when the small digits matter. - Adding a number with more decimals, or multiplying two Currency values, gives an ordinary number instead.
- TRUE is 1 and FALSE 0; a date becomes its day number. Text that is not a number is an error, and so is a value beyond about 922 trillion, either way.
- A blank gives BLANK.
Compared with DAX
Power BI Desktop answers the same when its formula engine does the multiplication. When its storage engine multiplies a Currency column inside a scan, it can round differently, depending on the query. OpenBI applies the rule above, row by row, in every query.
Examples
Four decimals
EVALUATE
ROW (
"2.71828", CURRENCY ( 2.71828 ),
"1.00005", CURRENCY ( 1.00005 ),
"42", CURRENCY ( 42 ),
"TRUE", CURRENCY ( TRUE () )
)
| 2.71828 | 1.00005 | 42 | TRUE |
|---|---|---|---|
| 2.7183 | 1.0001 | 42 | 1 |
Rounded at each step
EVALUATE
ROW (
"A third", CURRENCY ( 1 ) / 3,
"Times three", CURRENCY ( 1 ) / 3 * 3,
"As a number", 1 / 3 * 3
)
| A third | Times three | As a number |
|---|---|---|
| 0.3333 | 0.9999 | 1 |
Row by row in SUMX
Each row's 0.00007 is rounded to 0.0001 before the rows are added.
EVALUATE
VAR Items =
DATATABLE ( "Item", STRING, "Price", CURRENCY, { { "a", 1 }, { "b", 1 }, { "c", 1 } } )
RETURN
ROW (
"Row by row", SUMX ( Items, [Price] * 0.00007 ),
"Total first", SUMX ( Items, [Price] ) * 0.00007
)
| Row by row | Total first |
|---|---|
| 0.0003 | 0.0002 |