Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
victormarconis
Frequent Visitor

Problem getting minomo value by group

Hello, I have a table (table1) created by DAX, it returns the products and their last input value. I tried to create a calculated column to find the lowest value per group (presentation). So, in theory, this column (column 1) is returning me correctly, but there are some products that it returns the lowest value of a product that has no presentation, the big problem is just that.
Below is the table and column used.

PS: I already tried using measures or a new calculated table.

Table 1:

UltimasEntradas =
    SUMMARIZE(
        FILTER(Entradas, entradas[data_hora] >= TODAY() - 180 && entradas[data_hora] <= TODAY()),
        Entradas[produto_id],
        "NomeProduto", MAX(entradas[produtoid]),
        "UltimaData", MAX(entradas[data_hora]),
        "UltimoValor", LASTNONBLANK(entradas[Valorsemimposto], 1)
    )


Column 1:

Min_Produto =
VAR MinValue =
    CALCULATE(
        MINX(UltimasEntradas, UltimasEntradas[UltimoValor]),
        ALLEXCEPT(UltimasEntradas, 'apresentaçao'[apresentacao])
    )

RETURN
    MINX(
        FILTER(UltimasEntradas, UltimasEntradas[UltimoValor] = MinValue),
        UltimasEntradas[NomeProduto]
    )


Subtitle:

apresentacao = group
ultimovalor = lastvalue
nomeproduto = nameproduct

1 REPLY 1
technolog
Super User
Super User

You have a table, UltimasEntradas, which is a summary of another table, Entradas, and it's filtered for entries within the last 180 days. This table gives you the product ID, product name, the last date of entry, and the last value without tax for each product.

You're trying to get the minimum value (ultimovalor) for each group (apresentacao). The problem you're facing is that for some products, the minimum value returned is from a product that doesn't belong to any presentation group.

The DAX for Column 1 you provided is trying to get the minimum value for each group and then return the product name (nomeproduto) that has this minimum value.

From what I understand, the issue is that the minimum value is sometimes taken from a product that doesn't belong to any presentation group. To fix this, you should filter out those products without a presentation before calculating the minimum value.

Here's a suggestion to modify your Column 1:

Min_Produto =
VAR MinValue =
CALCULATE(
MINX(UltimasEntradas, UltimasEntradas[UltimoValor]),
ALLEXCEPT(UltimasEntradas, 'apresentaçao'[apresentacao]),
NOT(ISBLANK(UltimasEntradas['apresentaçao'[apresentacao]])) -- This line ensures we only consider products with a presentation
)

RETURN
MINX(
FILTER(UltimasEntradas, UltimasEntradas[UltimoValor] = MinValue),
UltimasEntradas[NomeProduto]
)
The added line ensures that when calculating the minimum value, it only considers products that have a presentation. This should prevent the issue where the minimum value is taken from a product without a presentation.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.