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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.