Search code examples
group-bypowerbiaggregatedaxmeasure

Dax measure to calculate minimum value with in a group of a complete table


The ask is to create a measure (not a calculated column using Earlier), to fetch minimum unit price of a product group by year and "UnitofMeasure" and show them as "UnitPriceMin" against complete list of data in separate column as shown below-

enter image description here


Solution

  • You can try with this below measure.

    I have considered column "Year", "description" and "unitmeasure" for the grouping. You can add/remove columns as per your necessity.

    Considered your table name - "product_details". change it as per your table name.

    group_wise_min = 
    
    VAR current_row_year = MIN(product_details[year])
    VAR current_row_product = MIN(product_details[description])
    VAR current_row_unit_measure = MIN(product_details[unitmeasure])
    
    RETURN
    CALCULATE(
        MIN(product_details[unitprice]),
        FILTER(
            ALL(product_details),
            product_details[year] = current_row_year
                && product_details[description] = current_row_product
                && product_details[unitmeasure] = current_row_unit_measure
        )
    )
    

    Output will be as below-

    enter image description here