TRUNC DAX Function (Math and Trig)

Truncates a number to an integer by removing the decimal, or fractional, part of the number.

Syntax

TRUNC ( <Number> [, <NumberOfDigits>] )
Parameter Attributes Description
Number

The number you want to truncate.

NumberOfDigits Optional

A number specifying the precision of the truncation; if omitted, 0 (zero).

Return values

Scalar A single decimal value.

The truncated number.

Remarks

If NumberOfDigits is greater than 0 (zero), then number is truncated to the specified number of decimal places.

If NumberOfDigits is 0, the number is truncated to the integer part.

If NumberOfDigits is less than 0, the number is truncated to the left of the decimal point.

» 3 related articles
» 1 related function

Examples

--  Example with positive numbers
--
--  Argument for rounding functions:
--    positive: at a given number of decimal places
--    zero:     to the nearest integer
--    negative: rounds digits to the left of the decimal point
--
--  ROUND rounds to the nearest value
--  ROUNDDOWN always rounds down
--  ROUNDUP always rounds up
--  TRUNC truncates the decimal part, returning an integer
DEFINE 
    VAR Vals = GENERATESERIES ( 14.90, 16.01, 0.03 )
EVALUATE    
    ADDCOLUMNS (
        Vals,
        "ROUND 0",      ROUND     ( [Value],  0 ),
        "ROUND +1",     ROUND     ( [Value],  1 ),
        "ROUND -1",     ROUND     ( [Value], -1 ),
        "ROUNDDOWN  0", ROUNDDOWN ( [Value],  0 ),
        "ROUNDDOWN +1", ROUNDDOWN ( [Value],  1 ),
        "ROUNDDOWN -1", ROUNDDOWN ( [Value], -1 ),
        "ROUNDUP  0",   ROUNDUP   ( [Value],  0 ),
        "ROUNDUP +1",   ROUNDUP   ( [Value],  1 ),
        "ROUNDUP -1",   ROUNDUP   ( [Value], -1 ),
        "TRUNC",        TRUNC     ( [Value]     )   
    )
ORDER BY [Value] ASC
Value ROUND 0 ROUND +1 ROUND -1 ROUNDDOWN 0 ROUNDDOWN +1 ROUNDDOWN -1 ROUNDUP 0 ROUNDUP +1 ROUNDUP -1 TRUNC
14.90 15 14.90 10 14 14.90 10 15 14.90 20 14
14.93 15 14.90 10 14 14.90 10 15 15.00 20 14
14.96 15 15.00 10 14 14.90 10 15 15.00 20 14
14.99 15 15.00 10 14 14.90 10 15 15.00 20 14
15.02 15 15.00 20 15 15.00 10 16 15.10 20 15
15.05 15 15.10 20 15 15.00 10 16 15.10 20 15
15.08 15 15.10 20 15 15.00 10 16 15.10 20 15
15.11 15 15.10 20 15 15.10 10 16 15.20 20 15
15.14 15 15.10 20 15 15.10 10 16 15.20 20 15
15.17 15 15.20 20 15 15.10 10 16 15.20 20 15
15.20 15 15.20 20 15 15.20 10 16 15.20 20 15
15.23 15 15.20 20 15 15.20 10 16 15.30 20 15
15.26 15 15.30 20 15 15.20 10 16 15.30 20 15
15.29 15 15.30 20 15 15.20 10 16 15.30 20 15
15.32 15 15.30 20 15 15.30 10 16 15.40 20 15
15.35 15 15.40 20 15 15.30 10 16 15.40 20 15
15.38 15 15.40 20 15 15.30 10 16 15.40 20 15
15.41 15 15.40 20 15 15.40 10 16 15.50 20 15
15.44 15 15.40 20 15 15.40 10 16 15.50 20 15
15.47 15 15.50 20 15 15.40 10 16 15.50 20 15
15.50 16 15.50 20 15 15.50 10 16 15.50 20 15
15.53 16 15.50 20 15 15.50 10 16 15.60 20 15
15.56 16 15.60 20 15 15.50 10 16 15.60 20 15
15.59 16 15.60 20 15 15.50 10 16 15.60 20 15
15.62 16 15.60 20 15 15.60 10 16 15.70 20 15
15.65 16 15.70 20 15 15.60 10 16 15.70 20 15
15.68 16 15.70 20 15 15.60 10 16 15.70 20 15
15.71 16 15.70 20 15 15.70 10 16 15.80 20 15
15.74 16 15.70 20 15 15.70 10 16 15.80 20 15
15.77 16 15.80 20 15 15.70 10 16 15.80 20 15
15.80 16 15.80 20 15 15.80 10 16 15.80 20 15
15.83 16 15.80 20 15 15.80 10 16 15.90 20 15
15.86 16 15.90 20 15 15.80 10 16 15.90 20 15
15.89 16 15.90 20 15 15.80 10 16 15.90 20 15
15.92 16 15.90 20 15 15.90 10 16 16.00 20 15
15.95 16 16.00 20 15 15.90 10 16 16.00 20 15
15.98 16 16.00 20 15 15.90 10 16 16.00 20 15
16.01 16 16.00 20 16 16.00 10 17 16.10 20 16
--  Example with negative numbers
--
--  Argument for rounding functions:
--    positive: at a given number of decimal places
--    zero:     to the nearest integer
--    negative: rounds digits to the left of the decimal point
--
--  ROUND rounds to the nearest value
--  ROUNDDOWN always rounds down
--  ROUNDUP always rounds up
--  TRUNC truncates the decimal part, returning an integer
DEFINE 
    VAR Vals = GENERATESERIES ( -16.01, -14.90, 0.03 )
EVALUATE    
    ADDCOLUMNS (
        Vals,
        "ROUND 0",      ROUND     ( [Value],  0 ),
        "ROUND +1",     ROUND     ( [Value],  1 ),
        "ROUND -1",     ROUND     ( [Value], -1 ),
        "ROUNDDOWN  0", ROUNDDOWN ( [Value],  0 ),
        "ROUNDDOWN +1", ROUNDDOWN ( [Value],  1 ),
        "ROUNDDOWN -1", ROUNDDOWN ( [Value], -1 ),
        "ROUNDUP  0",   ROUNDUP   ( [Value],  0 ),
        "ROUNDUP +1",   ROUNDUP   ( [Value],  1 ),
        "ROUNDUP -1",   ROUNDUP   ( [Value], -1 ),
        "TRUNC",        TRUNC     ( [Value]     )   
    )
ORDER BY [Value] ASC
Value ROUND 0 ROUND +1 ROUND -1 ROUNDDOWN 0 ROUNDDOWN +1 ROUNDDOWN -1 ROUNDUP 0 ROUNDUP +1 ROUNDUP -1 TRUNC
-16.01 -16 -16.00 -20 -16 -16.00 -10 -17 -16.10 -20 -16
-15.98 -16 -16.00 -20 -15 -15.90 -10 -16 -16.00 -20 -15
-15.95 -16 -16.00 -20 -15 -15.90 -10 -16 -16.00 -20 -15
-15.92 -16 -15.90 -20 -15 -15.90 -10 -16 -16.00 -20 -15
-15.89 -16 -15.90 -20 -15 -15.80 -10 -16 -15.90 -20 -15
-15.86 -16 -15.90 -20 -15 -15.80 -10 -16 -15.90 -20 -15
-15.83 -16 -15.80 -20 -15 -15.80 -10 -16 -15.90 -20 -15
-15.80 -16 -15.80 -20 -15 -15.80 -10 -16 -15.80 -20 -15
-15.77 -16 -15.80 -20 -15 -15.70 -10 -16 -15.80 -20 -15
-15.74 -16 -15.70 -20 -15 -15.70 -10 -16 -15.80 -20 -15
-15.71 -16 -15.70 -20 -15 -15.70 -10 -16 -15.80 -20 -15
-15.68 -16 -15.70 -20 -15 -15.60 -10 -16 -15.70 -20 -15
-15.65 -16 -15.70 -20 -15 -15.60 -10 -16 -15.70 -20 -15
-15.62 -16 -15.60 -20 -15 -15.60 -10 -16 -15.70 -20 -15
-15.59 -16 -15.60 -20 -15 -15.50 -10 -16 -15.60 -20 -15
-15.56 -16 -15.60 -20 -15 -15.50 -10 -16 -15.60 -20 -15
-15.53 -16 -15.50 -20 -15 -15.50 -10 -16 -15.60 -20 -15
-15.50 -16 -15.50 -20 -15 -15.50 -10 -16 -15.50 -20 -15
-15.47 -15 -15.50 -20 -15 -15.40 -10 -16 -15.50 -20 -15
-15.44 -15 -15.40 -20 -15 -15.40 -10 -16 -15.50 -20 -15
-15.41 -15 -15.40 -20 -15 -15.40 -10 -16 -15.50 -20 -15
-15.38 -15 -15.40 -20 -15 -15.30 -10 -16 -15.40 -20 -15
-15.35 -15 -15.40 -20 -15 -15.30 -10 -16 -15.40 -20 -15
-15.32 -15 -15.30 -20 -15 -15.30 -10 -16 -15.40 -20 -15
-15.29 -15 -15.30 -20 -15 -15.20 -10 -16 -15.30 -20 -15
-15.26 -15 -15.30 -20 -15 -15.20 -10 -16 -15.30 -20 -15
-15.23 -15 -15.20 -20 -15 -15.20 -10 -16 -15.30 -20 -15
-15.20 -15 -15.20 -20 -15 -15.20 -10 -16 -15.20 -20 -15
-15.17 -15 -15.20 -20 -15 -15.10 -10 -16 -15.20 -20 -15
-15.14 -15 -15.10 -20 -15 -15.10 -10 -16 -15.20 -20 -15
-15.11 -15 -15.10 -20 -15 -15.10 -10 -16 -15.20 -20 -15
-15.08 -15 -15.10 -20 -15 -15.00 -10 -16 -15.10 -20 -15
-15.05 -15 -15.10 -20 -15 -15.00 -10 -16 -15.10 -20 -15
-15.02 -15 -15.00 -20 -15 -15.00 -10 -16 -15.10 -20 -15
-14.99 -15 -15.00 -10 -14 -14.90 -10 -15 -15.00 -20 -14
-14.96 -15 -15.00 -10 -14 -14.90 -10 -15 -15.00 -20 -14
-14.93 -15 -14.90 -10 -14 -14.90 -10 -15 -15.00 -20 -14
-14.90 -15 -14.90 -10 -14 -14.90 -10 -15 -14.90 -20 -14

Related articles

Learn more about TRUNC in the following articles:

Related functions

Other related functions are:

Last update: Mar 13, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber,

Microsoft documentation: https://docs.microsoft.com/en-us/dax/trunc-function-dax

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of TRUNC? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.