Dax Function: MINX
Category: Aggregation functions
The MINX function in Power BI is a DAX (Data Analysis Expressions) function that evaluates an expression for each row of a table and returns the smallest value resulting from those evaluations.
Purpose:
- To compute the minimum value from an expression calculated over rows in a table.
Type of Calculations:
- Row-by-row evaluations within a table.
- Custom calculations using measures, columns, or arithmetic expressions.
Practical Use Cases:
- Custom Aggregations: Calculate the minimum value from a calculated column.
- Dynamic Analysis: Perform conditional evaluations and retrieve the smallest resulting value.
- Derived Metrics: Use in scenarios requiring minimum values based on complex logic.
MINX(<table>, <expression>)
Parameter | Type | Description |
---|---|---|
table | Table | A table to iterate over. Can be a physical table, filtered table, or virtual table. |
expression | Scalar | A DAX expression evaluated for each row of the table, producing a scalar value. |
How Does MINX Dax Function Works?
- Row Context: MINX creates a row context for the specified table.
- Expression Evaluation: It evaluates the given expression for each row in the table.
- Aggregation: The smallest value from the evaluated results is returned.
What Does It Return?
The function returns a scalar value that is the minimum of all the results from evaluating the expression for each row in the table.
When Should We Use It?
- Complex Row Calculations: When the minimum value needs to be calculated from a derived or computed column.
- Conditional Logic: For scenarios requiring row-specific evaluations, such as
IF
conditions or other logical operations. - Dynamic Data Models: For tables filtered dynamically by slicers, filters, or relationships.
Examples
Basic Usage
Find the minimum of a calculated column for a table:
MinValue = MINX(Sales, Sales[Revenue] - Sales[Cost])
Explanation: Calculates the profit (Revenue - Cost
) for each row and returns the smallest profit.
Column Usage
Evaluate the minimum value of a derived metric in a filtered table:
MinDiscountedSales = MINX(FILTER(Sales, Sales[Discount] > 0), Sales[Revenue] * (1 - Sales[Discount]))
Explanation: Applies a filter for rows with discounts and calculates the smallest discounted revenue.
Advanced Usage
Combine with RELATED to calculate minimum values using data from related tables:
MinCategorySales = MINX(RELATEDTABLE(Products), Products[Price] * Products[Quantity])
Explanation: Calculates the smallest total sales value for each product category using data from a related table.
Tips and Tricks
- Use with Filters: Combine with functions like FILTER or ALL to evaluate specific subsets of data.
- Understand Row Context: Ensure you know how row context affects the evaluation of the expression.
- Optimize Expressions: Simplify the expression to improve performance, especially for large datasets.
Performance Impact of MINX DAX Function:
- Filter Context: Ensure unnecessary rows are excluded to optimize calculations.
- Large Datasets: For better performance, pre-aggregate data or use calculated columns where applicable.
Related Functions You Might Need
- MIN: Returns the smallest value in a column without evaluating expressions.
- MAXX: Similar to MINX, but retrieves the largest value.
- SUMX: Sums values from an expression evaluated row by row.
- AVERAGEX: Computes the average of an expression evaluated row by row.
Want to Learn More?
For more information, check out the official Microsoft documentation for MINX. You can also experiment with this function in your Power BI reports to explore its capabilities.
If you’re looking to unlock the full potential of Power BI and take your data insights to the next level, our expert Power BI consulting services are here to help. Whether you need assistance with implementing advanced DAX functions like the ones discussed here, creating interactive dashboards, or optimizing your data models for better performance, our team of seasoned Power BI consultants is ready to provide tailored solutions for your business. Visit our Power BI Consulting Services page to learn more about how we can empower your organization with data-driven decisions.
MIN evaluates the smallest value in a single column, while MINX calculates the minimum result of an expression evaluated for each row in a table.
Yes, you can include logical conditions in the expression, such as IF
statements, to calculate the minimum value based on specific criteria.
Yes, slicers and filters affect the rows in the table being evaluated, altering the results.
Yes, you can use related tables with functions like RELATEDTABLE to include data from other tables in the calculation.
If the table is empty or all rows are filtered out, MINX returns a blank value.
Established in 2020, Lets Viz Technologies provides a full range of high-quality data analysis and data visualization services. We are also an authorized Zoho Partner.
Sitelinks