Dax Function: EVEN

Category: Mathematical and Trigonometric Functions

The EVEN function in Power BI is a DAX (Data Analysis Expressions) function used to round a numeric value up to the nearest even integer. This rounding occurs regardless of whether the input value is positive or negative.

Purpose

The EVEN function is used to:

  1. Simplify numerical data by converting values to their nearest even integer.
  2. Standardize values for scenarios requiring even numbers (e.g., inventory counts, packaging, or binning).
  3. Create custom calculations involving rounding to specific conditions.

Type of Calculations

The EVEN function performs mathematical rounding calculations that ensure the result is an even integer. It rounds positive numbers up and negative numbers down to the nearest even value.

Practical Use Cases

  1. Inventory Management: Adjust product counts to even numbers for pairing or packaging purposes.
  2. Bin Ranges: Create ranges or intervals with even boundaries for data grouping.
  3. Custom Rounding: Standardize calculations that must adhere to even-numbered constraints.

EVEN(<number>)</number>

ParameterTypeDescription
<number>ScalarA numeric value (or column) that will be rounded up to the nearest even integer.


How Does EVEN Dax Function Works?

  1. The EVEN function evaluates the input number.
  2. It rounds the number up (positive) or down (negative) to the nearest even integer:

Example:

EVEN(2.1)=4,EVEN(−2.1)=−4

Mathematical Principle

The function rounds any fractional input to the nearest even whole number. It effectively increases the magnitude of the number to reach the next even integer.


What Does It Return?

The EVEN function returns a whole number (integer) that is:

  • The nearest even integer greater than or equal to the input value if positive.
  • The nearest even integer less than or equal to the input value if negative.

When Should We Use It?

  • When calculations require rounding to even integers (e.g., pairing scenarios).
  • In grouping or binning data by even intervals.
  • To enforce numerical standards where only even integers are acceptable.

Examples

Basic Usage

Round a positive number:


EVEN(3.2)

Output: 4

Column Usage

Apply the EVEN function to a column of numeric values to create even-rounded data:


EVEN([SalesAmount])

Output: A column with each value rounded up to the nearest even integer.

Advanced Usage

Combine EVEN with other DAX functions for conditional calculations:


IF(EVEN([UnitsSold]) &gt; 10, "Sufficient Stock", "Restock Required")

Output: Evaluates stock levels based on rounded even values.

Tips and Tricks

  1. Handles Negative Numbers: EVEN rounds negative numbers down to ensure the result is still even.
  2. Pair with INT: For non-rounded integers, use INT or ROUND to customize further.
  3. Avoid Unnecessary Application: Do not use EVEN for data requiring exact or odd-numbered values.

Potential Pitfalls

  • Unexpected Rounding: Users might mistakenly expect rounding towards zero, which does not occur with EVEN.
  • Performance: Applying EVEN to large datasets in calculated columns can impact performance—use measures where possible.

Performance Impact of EVEN DAX Function:

  • The EVEN function is lightweight and optimized for DAX calculations but should be used cautiously in calculated columns for large datasets.
  • Prefer using it in measures for on-the-fly calculations.

Related Functions You Might Need

  • ODD: Rounds a number to the nearest odd integer.
  • ROUND: Rounds a number to a specified number of digits.
  • INT: Rounds down to the nearest integer.
  • CEILING: Rounds a number up to the nearest multiple of a specified value.

Want to Learn More?
For more information, check out the official Microsoft documentation for EVEN. You can also experiment with this function in your Power BI reports to explore its capabilities.

1. What does the EVEN function do in Power BI?

The EVEN function rounds a numeric value up (or down) to the nearest even integer.

2. How does EVEN handle negative numbers?

For negative numbers, EVEN rounds down to the nearest even integer.

3. Can the EVEN function round whole numbers?

Yes, if the input is an odd whole number, it will round it up or down to the nearest even integer.

4. Is there a way to round to odd numbers in Power BI?

Yes, use the ODD function to round to the nearest odd integer.

5. Can I combine the EVEN function with other DAX functions?

Yes, you can combine EVEN with functions like IF, ROUND, or INT for complex calculations.