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:
- Simplify numerical data by converting values to their nearest even integer.
- Standardize values for scenarios requiring even numbers (e.g., inventory counts, packaging, or binning).
- 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
- Inventory Management: Adjust product counts to even numbers for pairing or packaging purposes.
- Bin Ranges: Create ranges or intervals with even boundaries for data grouping.
- Custom Rounding: Standardize calculations that must adhere to even-numbered constraints.
EVEN(<number>)</number>
| Parameter | Type | Description |
|---|---|---|
<number> | Scalar | A numeric value (or column) that will be rounded up to the nearest even integer. |
How Does EVEN Dax Function Works?
- The EVEN function evaluates the input number.
- 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]) > 10, "Sufficient Stock", "Restock Required")
Output: Evaluates stock levels based on rounded even values.
Tips and Tricks
- Handles Negative Numbers: EVEN rounds negative numbers down to ensure the result is still even.
- Pair with INT: For non-rounded integers, use
INTorROUNDto customize further. - 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.
The EVEN function rounds a numeric value up (or down) to the nearest even integer.
For negative numbers, EVEN rounds down to the nearest even integer.
Yes, if the input is an odd whole number, it will round it up or down to the nearest even integer.
Yes, use the ODD function to round to the nearest odd integer.
Yes, you can combine EVEN with functions like IF, ROUND, or INT for complex calculations.